components/openssl/openssl-1.0.1-fips-140/patches/38_remove_illegal_instruction_calls.patch
branchs11u2-sru8-backport
changeset 4020 8e3f49e23eaa
parent 3285 78460de60ed1
equal deleted inserted replaced
3862:0e46f6a07b7f 4020:8e3f49e23eaa
     1 #
     1 #
     2 # This patch was developed in-house.
     2 # This patch was developed in house.
     3 # This is Solaris-specific: not suitable for upstream.
     3 # This is Solaris-specific: not suitable for upstream.
     4 #
     4 #
     5 --- openssl-1.0.1h/crypto/sparcv9cap.c.~1~	Mon Aug  4 15:18:42 2014
     5 --- openssl-1.0.1g/crypto/sparcv9cap.c.~1~	Thu May  1 13:07:00 2014
     6 +++ openssl-1.0.1h/crypto/sparcv9cap.c	Mon Aug  4 15:30:21 2014
     6 +++ openssl-1.0.1g/crypto/sparcv9cap.c	Thu May  1 13:11:33 2014
     7 @@ -5,6 +5,7 @@
     7 @@ -2,9 +2,9 @@
     8  #include <signal.h>
     8  #include <stdlib.h>
       
     9  #include <string.h>
       
    10  #include <setjmp.h>
       
    11 -#include <signal.h>
     9  #include <sys/time.h>
    12  #include <sys/time.h>
    10  #include <openssl/bn.h>
    13  #include <openssl/bn.h>
    11 +#include <sys/auxv.h>
    14 +#include <sys/auxv.h>
    12  
    15  
    13  #define SPARCV9_TICK_PRIVILEGED	(1<<0)
    16  #define SPARCV9_TICK_PRIVILEGED (1<<0)
    14  #define SPARCV9_PREFER_FPU	(1<<1)
    17  #define SPARCV9_PREFER_FPU      (1<<1)
    15 @@ -31,7 +32,6 @@
    18 @@ -11,6 +11,7 @@
    16  void		_sparcv9_vis1_probe(void);
    19  #define SPARCV9_VIS1            (1<<2)
    17  unsigned long	_sparcv9_vis1_instrument(void);
    20  #define SPARCV9_VIS2            (1<<3) /* reserved */
    18  void		_sparcv9_vis2_probe(void);
    21  #define SPARCV9_FMADD           (1<<4) /* reserved for SPARC64 V */
    19 -void		_sparcv9_fmadd_probe(void);
    22 +#define SPARCV9_BLK             (1<<5)
       
    23  
       
    24  static int OPENSSL_sparcv9cap_P = SPARCV9_TICK_PRIVILEGED;
       
    25  
       
    26 @@ -31,10 +31,7 @@
       
    27  }
       
    28 
       
    29  unsigned long _sparcv9_rdtick(void);
       
    30 -void _sparcv9_vis1_probe(void);
       
    31  unsigned long _sparcv9_vis1_instrument(void);
       
    32 -void _sparcv9_vis2_probe(void);
       
    33 -void _sparcv9_fmadd_probe(void);
    20  
    34  
    21  unsigned long OPENSSL_rdtsc(void)
    35  unsigned long OPENSSL_rdtsc(void)
    22  	{
    36  {
    23 @@ -171,6 +171,7 @@
    37 @@ -170,18 +167,11 @@
    24  	struct sigaction	common_act,ill_oact,bus_oact;
    38 
    25  	sigset_t		all_masked,oset;
    39  #else
    26  	static int trigger=0;
    40 
    27 +	uint_t ui = 0;
    41 -static sigjmp_buf common_jmp;
       
    42 -static void common_handler(int sig)
       
    43 -{
       
    44 -    siglongjmp(common_jmp, sig);
       
    45 -}
       
    46 -
       
    47  void OPENSSL_cpuid_setup(void)
       
    48  {
       
    49      char *e;
       
    50 -    struct sigaction common_act, ill_oact, bus_oact;
       
    51 -    sigset_t all_masked, oset;
       
    52      static int trigger = 0;
       
    53 +    uint_t ui = 0;
       
    54 
       
    55      if (trigger)
       
    56          return;
       
    57 @@ -192,54 +182,24 @@
       
    58          return;
       
    59      }
    28  
    60  
    29  	if (trigger) return;
    61 +    (void) getisax(&ui, 1);
    30  	trigger=1;
    62 +
    31 @@ -183,6 +184,7 @@
    63      /* Initial value, fits UltraSPARC-I&II... */
       
    64 -    OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU | SPARCV9_TICK_PRIVILEGED;
       
    65 +    OPENSSL_sparcv9cap_P = SPARCV9_BLK;
    32  
    66  
    33  	/* Initial value, fits UltraSPARC-I&II... */
    67 -    sigfillset(&all_masked);
    34  	OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU|SPARCV9_TICK_PRIVILEGED;
    68 -    sigdelset(&all_masked, SIGILL);
    35 +	(void) getisax(&ui, 1);
    69 -    sigdelset(&all_masked, SIGTRAP);
       
    70 -# ifdef SIGEMT
       
    71 -    sigdelset(&all_masked, SIGEMT);
       
    72 -# endif
       
    73 -    sigdelset(&all_masked, SIGFPE);
       
    74 -    sigdelset(&all_masked, SIGBUS);
       
    75 -    sigdelset(&all_masked, SIGSEGV);
       
    76 -    sigprocmask(SIG_SETMASK, &all_masked, &oset);
       
    77 -
       
    78 -    memset(&common_act, 0, sizeof(common_act));
       
    79 -    common_act.sa_handler = common_handler;
       
    80 -    common_act.sa_mask = all_masked;
       
    81 -
       
    82 -    sigaction(SIGILL, &common_act, &ill_oact);
       
    83 -    sigaction(SIGBUS, &common_act, &bus_oact); /* T1 fails 16-bit ldda [on
       
    84 -                                                * Linux] */
       
    85 -
       
    86 -    if (sigsetjmp(common_jmp, 1) == 0) {
       
    87 -        _sparcv9_rdtick();
       
    88 -        OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED;
       
    89 -    }
       
    90 -
       
    91 -    if (sigsetjmp(common_jmp, 1) == 0) {
       
    92 -        _sparcv9_vis1_probe();
       
    93 -        OPENSSL_sparcv9cap_P |= SPARCV9_VIS1;
       
    94 -        /* detect UltraSPARC-Tx, see sparccpud.S for details... */
       
    95 -        if (_sparcv9_vis1_instrument() >= 12)
       
    96 -            OPENSSL_sparcv9cap_P &= ~(SPARCV9_VIS1 | SPARCV9_PREFER_FPU);
       
    97 -        else {
       
    98 -            _sparcv9_vis2_probe();
       
    99 -            OPENSSL_sparcv9cap_P |= SPARCV9_VIS2;
       
   100 +    if (ui & AV_SPARC_VIS) {
       
   101 +        /* detect UltraSPARC-Tx, see sparccpuid.S for details... */
       
   102 +        if (_sparcv9_vis1_instrument() < 7)
       
   103 +            OPENSSL_sparcv9cap_P |= SPARCV9_TICK_PRIVILEGED;
       
   104 +        if (_sparcv9_vis1_instrument() < 12) {
       
   105 +            OPENSSL_sparcv9cap_P |= SPARCV9_VIS1|SPARCV9_PREFER_FPU;
       
   106 +            if (ui & AV_SPARC_VIS2)
       
   107 +                OPENSSL_sparcv9cap_P |= SPARCV9_VIS2;
       
   108          }
       
   109      }
    36  
   110  
    37  	sigfillset(&all_masked);
   111 -    if (sigsetjmp(common_jmp, 1) == 0) {
    38  	sigdelset(&all_masked,SIGILL);
   112 -        _sparcv9_fmadd_probe();
    39 @@ -222,11 +224,8 @@
   113 +    if (ui & AV_SPARC_FMAF)
    40  			}
   114          OPENSSL_sparcv9cap_P |= SPARCV9_FMADD;
    41  		}
   115 -    }
       
   116 -
       
   117 -    sigaction(SIGBUS, &bus_oact, NULL);
       
   118 -    sigaction(SIGILL, &ill_oact, NULL);
       
   119 -
       
   120 -    sigprocmask(SIG_SETMASK, &oset, NULL);
       
   121  }
    42  
   122  
    43 -	if (sigsetjmp(common_jmp,1) == 0)
   123  #endif
    44 -		{
   124 --- openssl-1.0.1g/crypto/sparccpuid.S.~1~      Thu May  1 13:07:00 2014
    45 -		_sparcv9_fmadd_probe();
   125 +++ openssl-1.0.1g/crypto/sparccpuid.S  Thu May  1 13:11:33 2014
    46 +	if (ui & AV_SPARC_FMAF)
   126 @@ -232,16 +232,6 @@
    47  		OPENSSL_sparcv9cap_P |= SPARCV9_FMADD;
   127  .type	_sparcv9_rdtick,#function
    48 -		}
   128  .size	_sparcv9_rdtick,.-_sparcv9_rdtick
    49  
   129  
    50  	sigaction(SIGBUS,&bus_oact,NULL);
   130 -.global	_sparcv9_vis1_probe
    51  	sigaction(SIGILL,&ill_oact,NULL);
   131 -.align	8
    52 --- openssl-1.0.1h/crypto/sparccpuid.S.~1~	Mon Aug  4 15:18:57 2014
   132 -_sparcv9_vis1_probe:
    53 +++ openssl-1.0.1h/crypto/sparccpuid.S	Mon Aug  4 15:30:34 2014
   133 -	add	%sp,BIAS+2,%o1
    54 @@ -304,16 +304,6 @@
   134 -	.word	0xc19a5a40	!ldda	[%o1]ASI_FP16_P,%f0
    55  .type	_sparcv9_vis2_probe,#function
   135 -	retl
    56  .size	_sparcv9_vis2_probe,.-_sparcv9_vis2_probe
   136 -	.word	0x81b00d80	!fxor	%f0,%f0,%f0
       
   137 -.type	_sparcv9_vis1_probe,#function
       
   138 -.size	_sparcv9_vis1_probe,.-_sparcv9_vis1_probe
       
   139 -
       
   140  ! Probe and instrument VIS1 instruction. Output is number of cycles it
       
   141  ! takes to execute rdtick and pair of VIS1 instructions. US-Tx VIS unit
       
   142  ! is slow (documented to be 6 cycles on T2) and the core is in-order
       
   143 @@ -296,24 +286,6 @@
       
   144  .type	_sparcv9_vis1_instrument,#function
       
   145  .size	_sparcv9_vis1_instrument,.-_sparcv9_vis1_instrument
    57  
   146  
       
   147 -.global	_sparcv9_vis2_probe
       
   148 -.align	8
       
   149 -_sparcv9_vis2_probe:
       
   150 -	retl
       
   151 -	.word	0x81b00980	!bshuffle	%f0,%f0,%f0
       
   152 -.type	_sparcv9_vis2_probe,#function
       
   153 -.size	_sparcv9_vis2_probe,.-_sparcv9_vis2_probe
       
   154 -
    58 -.global	_sparcv9_fmadd_probe
   155 -.global	_sparcv9_fmadd_probe
    59 -.align	8
   156 -.align	8
    60 -_sparcv9_fmadd_probe:
   157 -_sparcv9_fmadd_probe:
    61 -	.word	0x81b00d80	!fxor	%f0,%f0,%f0
   158 -	.word	0x81b00d80	!fxor	%f0,%f0,%f0
    62 -	.word	0x85b08d82	!fxor	%f2,%f2,%f2
   159 -	.word	0x85b08d82	!fxor	%f2,%f2,%f2