components/openssl/openssl-1.0.1-fips-140/patches/38_remove_illegal_instruction_calls.patch
branchs11u3-sru
changeset 7163 ee09edbd5876
parent 7159 59b406bc4a3a
child 7164 b2abbab8e6d5
equal deleted inserted replaced
7159:59b406bc4a3a 7163:ee09edbd5876
     1 #
       
     2 # This patch was developed in house.
       
     3 # This is Solaris-specific: not suitable for upstream.
       
     4 #
       
     5 --- openssl-1.0.1g/crypto/sparcv9cap.c.~1~	Thu May  1 13:07:00 2014
       
     6 +++ openssl-1.0.1g/crypto/sparcv9cap.c	Thu May  1 13:11:33 2014
       
     7 @@ -2,9 +2,9 @@
       
     8  #include <stdlib.h>
       
     9  #include <string.h>
       
    10  #include <setjmp.h>
       
    11 -#include <signal.h>
       
    12  #include <sys/time.h>
       
    13  #include <openssl/bn.h>
       
    14 +#include <sys/auxv.h>
       
    15  
       
    16  #define SPARCV9_TICK_PRIVILEGED (1<<0)
       
    17  #define SPARCV9_PREFER_FPU      (1<<1)
       
    18 @@ -11,6 +11,7 @@
       
    19  #define SPARCV9_VIS1            (1<<2)
       
    20  #define SPARCV9_VIS2            (1<<3) /* reserved */
       
    21  #define SPARCV9_FMADD           (1<<4) /* reserved for SPARC64 V */
       
    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);
       
    34  
       
    35  unsigned long OPENSSL_rdtsc(void)
       
    36  {
       
    37 @@ -170,18 +167,11 @@
       
    38 
       
    39  #else
       
    40 
       
    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      }
       
    60  
       
    61 +    (void) getisax(&ui, 1);
       
    62 +
       
    63      /* Initial value, fits UltraSPARC-I&II... */
       
    64 -    OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU | SPARCV9_TICK_PRIVILEGED;
       
    65 +    OPENSSL_sparcv9cap_P = SPARCV9_BLK;
       
    66  
       
    67 -    sigfillset(&all_masked);
       
    68 -    sigdelset(&all_masked, SIGILL);
       
    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      }
       
   110  
       
   111 -    if (sigsetjmp(common_jmp, 1) == 0) {
       
   112 -        _sparcv9_fmadd_probe();
       
   113 +    if (ui & AV_SPARC_FMAF)
       
   114          OPENSSL_sparcv9cap_P |= SPARCV9_FMADD;
       
   115 -    }
       
   116 -
       
   117 -    sigaction(SIGBUS, &bus_oact, NULL);
       
   118 -    sigaction(SIGILL, &ill_oact, NULL);
       
   119 -
       
   120 -    sigprocmask(SIG_SETMASK, &oset, NULL);
       
   121  }
       
   122  
       
   123  #endif
       
   124 --- openssl-1.0.1g/crypto/sparccpuid.S.~1~      Thu May  1 13:07:00 2014
       
   125 +++ openssl-1.0.1g/crypto/sparccpuid.S  Thu May  1 13:11:33 2014
       
   126 @@ -232,16 +232,6 @@
       
   127  .type	_sparcv9_rdtick,#function
       
   128  .size	_sparcv9_rdtick,.-_sparcv9_rdtick
       
   129  
       
   130 -.global	_sparcv9_vis1_probe
       
   131 -.align	8
       
   132 -_sparcv9_vis1_probe:
       
   133 -	add	%sp,BIAS+2,%o1
       
   134 -	.word	0xc19a5a40	!ldda	[%o1]ASI_FP16_P,%f0
       
   135 -	retl
       
   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
       
   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 -
       
   155 -.global	_sparcv9_fmadd_probe
       
   156 -.align	8
       
   157 -_sparcv9_fmadd_probe:
       
   158 -	.word	0x81b00d80	!fxor	%f0,%f0,%f0
       
   159 -	.word	0x85b08d82	!fxor	%f2,%f2,%f2
       
   160 -	retl
       
   161 -	.word	0x81b80440	!fmaddd	%f0,%f0,%f2,%f0
       
   162 -.type	_sparcv9_fmadd_probe,#function
       
   163 -.size	_sparcv9_fmadd_probe,.-_sparcv9_fmadd_probe
       
   164 -
       
   165  .global	OPENSSL_cleanse
       
   166  .align	32
       
   167  OPENSSL_cleanse: