From: miod Date: Thu, 17 Apr 2014 18:49:35 +0000 (+0000) Subject: Remove oh-so-important-from-a-security-pov OpenSSL_rtdsc() function. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=7a9318151354b01849fa7b72ca43141cd331f42d;p=openbsd Remove oh-so-important-from-a-security-pov OpenSSL_rtdsc() function. --- diff --git a/lib/libcrypto/alphacpuid.pl b/lib/libcrypto/alphacpuid.pl index f6aea6a7663..0ff4ae22e33 100644 --- a/lib/libcrypto/alphacpuid.pl +++ b/lib/libcrypto/alphacpuid.pl @@ -77,13 +77,4 @@ OPENSSL_atomic_add: addl $0,$17,$0 ret ($26) .end OPENSSL_atomic_add - -.globl OPENSSL_rdtsc -.ent OPENSSL_rdtsc -OPENSSL_rdtsc: - .frame $30,0,$26 - .prologue 0 - rpcc $0 - ret ($26) -.end OPENSSL_rdtsc ___ diff --git a/lib/libcrypto/arm_arch.h b/lib/libcrypto/arm_arch.h index 0ccafb2215a..01797eb4e34 100644 --- a/lib/libcrypto/arm_arch.h +++ b/lib/libcrypto/arm_arch.h @@ -45,7 +45,6 @@ extern unsigned int OPENSSL_armcap_P; #define ARMV7_NEON (1<<0) -#define ARMV7_TICK (1<<1) #endif #endif diff --git a/lib/libcrypto/armcap.c b/lib/libcrypto/armcap.c index 0625587bdd0..f40993c1d55 100644 --- a/lib/libcrypto/armcap.c +++ b/lib/libcrypto/armcap.c @@ -20,16 +20,6 @@ static sigjmp_buf ill_jmp; * ARM compilers support inline assembler... */ void _armv7_neon_probe(void); -unsigned int _armv7_tick(void); - -unsigned int -OPENSSL_rdtsc(void) -{ - if (OPENSSL_armcap_P & ARMV7_TICK) - return _armv7_tick(); - else - return 0; -} #if defined(__GNUC__) && __GNUC__>=2 void OPENSSL_cpuid_setup(void) __attribute__((constructor)); @@ -72,10 +62,6 @@ OPENSSL_cpuid_setup(void) _armv7_neon_probe(); OPENSSL_armcap_P |= ARMV7_NEON; } - if (sigsetjmp(ill_jmp, 1) == 0) { - _armv7_tick(); - OPENSSL_armcap_P |= ARMV7_TICK; - } sigaction (SIGILL, &ill_oact, NULL); sigprocmask(SIG_SETMASK, &oset, NULL); diff --git a/lib/libcrypto/armv4cpuid.S b/lib/libcrypto/armv4cpuid.S index bdfde19c1fc..ba86c9709a2 100644 --- a/lib/libcrypto/armv4cpuid.S +++ b/lib/libcrypto/armv4cpuid.S @@ -11,13 +11,6 @@ _armv7_neon_probe: .word 0xe12fff1e @ bx lr .size _armv7_neon_probe,.-_armv7_neon_probe -.global _armv7_tick -.type _armv7_tick,%function -_armv7_tick: - mrc p15,0,r0,c9,c13,0 - .word 0xe12fff1e @ bx lr -.size _armv7_tick,.-_armv7_tick - .global OPENSSL_atomic_add .type OPENSSL_atomic_add,%function OPENSSL_atomic_add: diff --git a/lib/libcrypto/ia64cpuid.S b/lib/libcrypto/ia64cpuid.S index 517d9388881..39e8093c6cc 100644 --- a/lib/libcrypto/ia64cpuid.S +++ b/lib/libcrypto/ia64cpuid.S @@ -8,13 +8,6 @@ OPENSSL_cpuid_setup: { .mib; br.ret.sptk.many b0 };; .endp OPENSSL_cpuid_setup# -.global OPENSSL_rdtsc# -.proc OPENSSL_rdtsc# -OPENSSL_rdtsc: -{ .mib; mov r8=ar.itc - br.ret.sptk.many b0 };; -.endp OPENSSL_rdtsc# - .global OPENSSL_atomic_add# .proc OPENSSL_atomic_add# .align 32 diff --git a/lib/libcrypto/pariscid.pl b/lib/libcrypto/pariscid.pl index 38985afbacb..cd86b907042 100644 --- a/lib/libcrypto/pariscid.pl +++ b/lib/libcrypto/pariscid.pl @@ -34,18 +34,6 @@ OPENSSL_cpuid_setup nop .PROCEND - .EXPORT OPENSSL_rdtsc,ENTRY - .ALIGN 8 -OPENSSL_rdtsc - .PROC - .CALLINFO NO_CALLS - .ENTRY - mfctl %cr16,$rv - bv ($rp) - .EXIT - nop - .PROCEND - .EXPORT OPENSSL_wipe_cpu,ENTRY .ALIGN 8 OPENSSL_wipe_cpu diff --git a/lib/libcrypto/ppccpuid.pl b/lib/libcrypto/ppccpuid.pl index cf48714e338..37c33c051ab 100755 --- a/lib/libcrypto/ppccpuid.pl +++ b/lib/libcrypto/ppccpuid.pl @@ -84,15 +84,6 @@ Ladd: lwarx r5,0,r3 .long 0 .byte 0,12,0x14,0,0,0,2,0 .long 0 - -.globl .OPENSSL_rdtsc -.align 4 -.OPENSSL_rdtsc: - mftb r3 - mftbu r4 - blr - .long 0 - .byte 0,12,0x14,0,0,0,0,0 ___ $code =~ s/\`([^\`]*)\`/eval $1/gem; diff --git a/lib/libcrypto/s390xcpuid.S b/lib/libcrypto/s390xcpuid.S index 89bf6be82f5..25adb646c4c 100644 --- a/lib/libcrypto/s390xcpuid.S +++ b/lib/libcrypto/s390xcpuid.S @@ -16,15 +16,6 @@ OPENSSL_s390x_facilities: br %r14 .size OPENSSL_s390x_facilities,.-OPENSSL_s390x_facilities -.globl OPENSSL_rdtsc -.type OPENSSL_rdtsc,@function -.align 16 -OPENSSL_rdtsc: - stck 16(%r15) - lg %r2,16(%r15) - br %r14 -.size OPENSSL_rdtsc,.-OPENSSL_rdtsc - .globl OPENSSL_atomic_add .type OPENSSL_atomic_add,@function .align 16 diff --git a/lib/libcrypto/sparccpuid.S b/lib/libcrypto/sparccpuid.S index d8b44af2f0a..b913e3dddbc 100644 --- a/lib/libcrypto/sparccpuid.S +++ b/lib/libcrypto/sparccpuid.S @@ -215,23 +215,6 @@ OPENSSL_atomic_add: sra %o0,%g0,%o0 ! we return signed int, remember? .size OPENSSL_atomic_add,.-OPENSSL_atomic_add -.global _sparcv9_rdtick -.align 32 -_sparcv9_rdtick: - subcc %g0,1,%o0 - .word 0x91408000 !rd %ccr,%o0 - cmp %o0,0x99 - bne .notick - xor %o0,%o0,%o0 - .word 0x91410000 !rd %tick,%o0 - retl - .word 0x93323020 !srlx %o0,32,%o1 -.notick: - retl - xor %o1,%o1,%o1 -.type _sparcv9_rdtick,#function -.size _sparcv9_rdtick,.-_sparcv9_rdtick - .global _sparcv9_vis1_probe .align 8 _sparcv9_vis1_probe: diff --git a/lib/libcrypto/sparcv9cap.c b/lib/libcrypto/sparcv9cap.c index 05c084807a5..f49e71ec936 100644 --- a/lib/libcrypto/sparcv9cap.c +++ b/lib/libcrypto/sparcv9cap.c @@ -6,13 +6,12 @@ #include #include -#define SPARCV9_TICK_PRIVILEGED (1<<0) #define SPARCV9_PREFER_FPU (1<<1) #define SPARCV9_VIS1 (1<<2) #define SPARCV9_VIS2 (1<<3) /* reserved */ #define SPARCV9_FMADD (1<<4) /* reserved for SPARC64 V */ -static int OPENSSL_sparcv9cap_P = SPARCV9_TICK_PRIVILEGED; +static int OPENSSL_sparcv9cap_P = 0; int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, @@ -29,146 +28,11 @@ bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, return bn_mul_mont_int(rp, ap, bp, np, n0, num); } -unsigned long _sparcv9_rdtick(void); void _sparcv9_vis1_probe(void); unsigned long _sparcv9_vis1_instrument(void); void _sparcv9_vis2_probe(void); void _sparcv9_fmadd_probe(void); -unsigned long -OPENSSL_rdtsc(void) -{ - if (OPENSSL_sparcv9cap_P&SPARCV9_TICK_PRIVILEGED) -#if defined(__sun) && defined(__SVR4) - return gethrtime(); -#else - return 0; -#endif - else - return _sparcv9_rdtick(); -} - -#if 0 && defined(__sun) && defined(__SVR4) -/* This code path is disabled, because of incompatibility of - * libdevinfo.so.1 and libmalloc.so.1 (see below for details) - */ -#include -#include -#include -#include - -typedef di_node_t (*di_init_t)(const char *, uint_t); -typedef void (*di_fini_t)(di_node_t); -typedef char * (*di_node_name_t)(di_node_t); -typedef int (*di_walk_node_t)(di_node_t, uint_t, di_node_name_t, int (*)(di_node_t, di_node_name_t)); - -#define DLLINK(h,name) (name=(name##_t)dlsym((h),#name)) - -static int -walk_nodename(di_node_t node, di_node_name_t di_node_name) -{ - char *name = (*di_node_name)(node); - - /* This is expected to catch all UltraSPARC flavors prior T1 */ - if (!strcmp (name, "SUNW,UltraSPARC") || - !strncmp(name,"SUNW,UltraSPARC-I",17)) /* covers II,III,IV */ - { - OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU|SPARCV9_VIS1; - - /* %tick is privileged only on UltraSPARC-I/II, but not IIe */ - if (name[14]!='\0' && name[17]!='\0' && name[18]!='\0') - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; - - return DI_WALK_TERMINATE; - } - /* This is expected to catch remaining UltraSPARCs, such as T1 */ - else if (!strncmp(name, "SUNW,UltraSPARC", 15)) { - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; - - return DI_WALK_TERMINATE; - } - - return DI_WALK_CONTINUE; -} - -void -OPENSSL_cpuid_setup(void) -{ - void *h; - char *e, si[256]; - static int trigger = 0; - - if (trigger) - return; - trigger = 1; - - if ((e = getenv("OPENSSL_sparcv9cap"))) { - OPENSSL_sparcv9cap_P = strtoul(e, NULL, 0); - return; - } - - if (sysinfo(SI_MACHINE, si, sizeof(si)) > 0) { - if (strcmp(si, "sun4v")) - /* FPU is preferred for all CPUs, but US-T1/2 */ - OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU; - } - - if (sysinfo(SI_ISALIST, si, sizeof(si)) > 0) { - if (strstr(si, "+vis")) - OPENSSL_sparcv9cap_P |= SPARCV9_VIS1; - if (strstr(si, "+vis2")) { - OPENSSL_sparcv9cap_P |= SPARCV9_VIS2; - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; - return; - } - } -#ifdef M_KEEP - /* - * Solaris libdevinfo.so.1 is effectively incomatible with - * libmalloc.so.1. Specifically, if application is linked with - * -lmalloc, it crashes upon startup with SIGSEGV in - * free(3LIBMALLOC) called by di_fini. Prior call to - * mallopt(M_KEEP,0) somehow helps... But not always... - */ - if ((h = dlopen(NULL, RTLD_LAZY))) { - union { void *p; - int (*f)(int, int); - } sym; - if ((sym.p = dlsym(h, "mallopt"))) (*sym.f)(M_KEEP, 0); - dlclose(h); - } -#endif - if ((h = dlopen("libdevinfo.so.1", RTLD_LAZY))) - do { - di_init_t di_init; - di_fini_t di_fini; - di_walk_node_t di_walk_node; - di_node_name_t di_node_name; - di_node_t root_node; - - if (!DLLINK(h, di_init)) - break; - if (!DLLINK(h, di_fini)) - break; - if (!DLLINK(h, di_walk_node)) - break; - if (!DLLINK(h, di_node_name)) - break; - - if ((root_node = (*di_init)("/", DINFOSUBTREE)) != - DI_NODE_NIL) { - (*di_walk_node)(root_node, DI_WALK_SIBFIRST, - di_node_name, walk_nodename); - (*di_fini)(root_node); - } - } while (0); - - if (h) - dlclose(h); -} - -#else - static sigjmp_buf common_jmp; static void common_handler(int sig) { @@ -193,7 +57,7 @@ OPENSSL_cpuid_setup(void) } /* Initial value, fits UltraSPARC-I&II... */ - OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU|SPARCV9_TICK_PRIVILEGED; + OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU; sigfillset(&all_masked); sigdelset(&all_masked, SIGILL); @@ -213,11 +77,6 @@ OPENSSL_cpuid_setup(void) sigaction(SIGILL, &common_act, &ill_oact); sigaction(SIGBUS,&common_act,&bus_oact);/* T1 fails 16-bit ldda [on Linux] */ - if (sigsetjmp(common_jmp, 1) == 0) { - _sparcv9_rdtick(); - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; - } - if (sigsetjmp(common_jmp, 1) == 0) { _sparcv9_vis1_probe(); OPENSSL_sparcv9cap_P |= SPARCV9_VIS1; @@ -240,5 +99,3 @@ OPENSSL_cpuid_setup(void) sigprocmask(SIG_SETMASK, &oset, NULL); } - -#endif diff --git a/lib/libcrypto/x86_64cpuid.pl b/lib/libcrypto/x86_64cpuid.pl index 8422e913426..3fe9a2d5667 100644 --- a/lib/libcrypto/x86_64cpuid.pl +++ b/lib/libcrypto/x86_64cpuid.pl @@ -42,16 +42,6 @@ OPENSSL_atomic_add: ret .size OPENSSL_atomic_add,.-OPENSSL_atomic_add -.globl OPENSSL_rdtsc -.type OPENSSL_rdtsc,\@abi-omnipotent -.align 16 -OPENSSL_rdtsc: - rdtsc - shl \$32,%rdx - or %rdx,%rax - ret -.size OPENSSL_rdtsc,.-OPENSSL_rdtsc - .globl OPENSSL_ia32_cpuid .type OPENSSL_ia32_cpuid,\@abi-omnipotent .align 16 diff --git a/lib/libcrypto/x86cpuid.pl b/lib/libcrypto/x86cpuid.pl index 0da613f6971..c7a57a34656 100644 --- a/lib/libcrypto/x86cpuid.pl +++ b/lib/libcrypto/x86cpuid.pl @@ -143,17 +143,6 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); } &external_label("OPENSSL_ia32cap_P"); -&function_begin_B("OPENSSL_rdtsc","EXTRN\t_OPENSSL_ia32cap_P:DWORD"); - &xor ("eax","eax"); - &xor ("edx","edx"); - &picmeup("ecx","OPENSSL_ia32cap_P"); - &bt (&DWP(0,"ecx"),4); - &jnc (&label("notsc")); - &rdtsc (); -&set_label("notsc"); - &ret (); -&function_end_B("OPENSSL_rdtsc"); - # This works in Ring 0 only [read DJGPP+MS-DOS+privileged DPMI host], # but it's safe to call it on any [supported] 32-bit platform... # Just check for [non-]zero return value... diff --git a/lib/libssl/src/crypto/alphacpuid.pl b/lib/libssl/src/crypto/alphacpuid.pl index f6aea6a7663..0ff4ae22e33 100644 --- a/lib/libssl/src/crypto/alphacpuid.pl +++ b/lib/libssl/src/crypto/alphacpuid.pl @@ -77,13 +77,4 @@ OPENSSL_atomic_add: addl $0,$17,$0 ret ($26) .end OPENSSL_atomic_add - -.globl OPENSSL_rdtsc -.ent OPENSSL_rdtsc -OPENSSL_rdtsc: - .frame $30,0,$26 - .prologue 0 - rpcc $0 - ret ($26) -.end OPENSSL_rdtsc ___ diff --git a/lib/libssl/src/crypto/arm_arch.h b/lib/libssl/src/crypto/arm_arch.h index 0ccafb2215a..01797eb4e34 100644 --- a/lib/libssl/src/crypto/arm_arch.h +++ b/lib/libssl/src/crypto/arm_arch.h @@ -45,7 +45,6 @@ extern unsigned int OPENSSL_armcap_P; #define ARMV7_NEON (1<<0) -#define ARMV7_TICK (1<<1) #endif #endif diff --git a/lib/libssl/src/crypto/armcap.c b/lib/libssl/src/crypto/armcap.c index 0625587bdd0..f40993c1d55 100644 --- a/lib/libssl/src/crypto/armcap.c +++ b/lib/libssl/src/crypto/armcap.c @@ -20,16 +20,6 @@ static sigjmp_buf ill_jmp; * ARM compilers support inline assembler... */ void _armv7_neon_probe(void); -unsigned int _armv7_tick(void); - -unsigned int -OPENSSL_rdtsc(void) -{ - if (OPENSSL_armcap_P & ARMV7_TICK) - return _armv7_tick(); - else - return 0; -} #if defined(__GNUC__) && __GNUC__>=2 void OPENSSL_cpuid_setup(void) __attribute__((constructor)); @@ -72,10 +62,6 @@ OPENSSL_cpuid_setup(void) _armv7_neon_probe(); OPENSSL_armcap_P |= ARMV7_NEON; } - if (sigsetjmp(ill_jmp, 1) == 0) { - _armv7_tick(); - OPENSSL_armcap_P |= ARMV7_TICK; - } sigaction (SIGILL, &ill_oact, NULL); sigprocmask(SIG_SETMASK, &oset, NULL); diff --git a/lib/libssl/src/crypto/armv4cpuid.S b/lib/libssl/src/crypto/armv4cpuid.S index bdfde19c1fc..ba86c9709a2 100644 --- a/lib/libssl/src/crypto/armv4cpuid.S +++ b/lib/libssl/src/crypto/armv4cpuid.S @@ -11,13 +11,6 @@ _armv7_neon_probe: .word 0xe12fff1e @ bx lr .size _armv7_neon_probe,.-_armv7_neon_probe -.global _armv7_tick -.type _armv7_tick,%function -_armv7_tick: - mrc p15,0,r0,c9,c13,0 - .word 0xe12fff1e @ bx lr -.size _armv7_tick,.-_armv7_tick - .global OPENSSL_atomic_add .type OPENSSL_atomic_add,%function OPENSSL_atomic_add: diff --git a/lib/libssl/src/crypto/ia64cpuid.S b/lib/libssl/src/crypto/ia64cpuid.S index 517d9388881..39e8093c6cc 100644 --- a/lib/libssl/src/crypto/ia64cpuid.S +++ b/lib/libssl/src/crypto/ia64cpuid.S @@ -8,13 +8,6 @@ OPENSSL_cpuid_setup: { .mib; br.ret.sptk.many b0 };; .endp OPENSSL_cpuid_setup# -.global OPENSSL_rdtsc# -.proc OPENSSL_rdtsc# -OPENSSL_rdtsc: -{ .mib; mov r8=ar.itc - br.ret.sptk.many b0 };; -.endp OPENSSL_rdtsc# - .global OPENSSL_atomic_add# .proc OPENSSL_atomic_add# .align 32 diff --git a/lib/libssl/src/crypto/pariscid.pl b/lib/libssl/src/crypto/pariscid.pl index 38985afbacb..cd86b907042 100644 --- a/lib/libssl/src/crypto/pariscid.pl +++ b/lib/libssl/src/crypto/pariscid.pl @@ -34,18 +34,6 @@ OPENSSL_cpuid_setup nop .PROCEND - .EXPORT OPENSSL_rdtsc,ENTRY - .ALIGN 8 -OPENSSL_rdtsc - .PROC - .CALLINFO NO_CALLS - .ENTRY - mfctl %cr16,$rv - bv ($rp) - .EXIT - nop - .PROCEND - .EXPORT OPENSSL_wipe_cpu,ENTRY .ALIGN 8 OPENSSL_wipe_cpu diff --git a/lib/libssl/src/crypto/ppccpuid.pl b/lib/libssl/src/crypto/ppccpuid.pl index cf48714e338..37c33c051ab 100755 --- a/lib/libssl/src/crypto/ppccpuid.pl +++ b/lib/libssl/src/crypto/ppccpuid.pl @@ -84,15 +84,6 @@ Ladd: lwarx r5,0,r3 .long 0 .byte 0,12,0x14,0,0,0,2,0 .long 0 - -.globl .OPENSSL_rdtsc -.align 4 -.OPENSSL_rdtsc: - mftb r3 - mftbu r4 - blr - .long 0 - .byte 0,12,0x14,0,0,0,0,0 ___ $code =~ s/\`([^\`]*)\`/eval $1/gem; diff --git a/lib/libssl/src/crypto/s390xcpuid.S b/lib/libssl/src/crypto/s390xcpuid.S index 89bf6be82f5..25adb646c4c 100644 --- a/lib/libssl/src/crypto/s390xcpuid.S +++ b/lib/libssl/src/crypto/s390xcpuid.S @@ -16,15 +16,6 @@ OPENSSL_s390x_facilities: br %r14 .size OPENSSL_s390x_facilities,.-OPENSSL_s390x_facilities -.globl OPENSSL_rdtsc -.type OPENSSL_rdtsc,@function -.align 16 -OPENSSL_rdtsc: - stck 16(%r15) - lg %r2,16(%r15) - br %r14 -.size OPENSSL_rdtsc,.-OPENSSL_rdtsc - .globl OPENSSL_atomic_add .type OPENSSL_atomic_add,@function .align 16 diff --git a/lib/libssl/src/crypto/sparccpuid.S b/lib/libssl/src/crypto/sparccpuid.S index d8b44af2f0a..b913e3dddbc 100644 --- a/lib/libssl/src/crypto/sparccpuid.S +++ b/lib/libssl/src/crypto/sparccpuid.S @@ -215,23 +215,6 @@ OPENSSL_atomic_add: sra %o0,%g0,%o0 ! we return signed int, remember? .size OPENSSL_atomic_add,.-OPENSSL_atomic_add -.global _sparcv9_rdtick -.align 32 -_sparcv9_rdtick: - subcc %g0,1,%o0 - .word 0x91408000 !rd %ccr,%o0 - cmp %o0,0x99 - bne .notick - xor %o0,%o0,%o0 - .word 0x91410000 !rd %tick,%o0 - retl - .word 0x93323020 !srlx %o0,32,%o1 -.notick: - retl - xor %o1,%o1,%o1 -.type _sparcv9_rdtick,#function -.size _sparcv9_rdtick,.-_sparcv9_rdtick - .global _sparcv9_vis1_probe .align 8 _sparcv9_vis1_probe: diff --git a/lib/libssl/src/crypto/sparcv9cap.c b/lib/libssl/src/crypto/sparcv9cap.c index 05c084807a5..f49e71ec936 100644 --- a/lib/libssl/src/crypto/sparcv9cap.c +++ b/lib/libssl/src/crypto/sparcv9cap.c @@ -6,13 +6,12 @@ #include #include -#define SPARCV9_TICK_PRIVILEGED (1<<0) #define SPARCV9_PREFER_FPU (1<<1) #define SPARCV9_VIS1 (1<<2) #define SPARCV9_VIS2 (1<<3) /* reserved */ #define SPARCV9_FMADD (1<<4) /* reserved for SPARC64 V */ -static int OPENSSL_sparcv9cap_P = SPARCV9_TICK_PRIVILEGED; +static int OPENSSL_sparcv9cap_P = 0; int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, @@ -29,146 +28,11 @@ bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, return bn_mul_mont_int(rp, ap, bp, np, n0, num); } -unsigned long _sparcv9_rdtick(void); void _sparcv9_vis1_probe(void); unsigned long _sparcv9_vis1_instrument(void); void _sparcv9_vis2_probe(void); void _sparcv9_fmadd_probe(void); -unsigned long -OPENSSL_rdtsc(void) -{ - if (OPENSSL_sparcv9cap_P&SPARCV9_TICK_PRIVILEGED) -#if defined(__sun) && defined(__SVR4) - return gethrtime(); -#else - return 0; -#endif - else - return _sparcv9_rdtick(); -} - -#if 0 && defined(__sun) && defined(__SVR4) -/* This code path is disabled, because of incompatibility of - * libdevinfo.so.1 and libmalloc.so.1 (see below for details) - */ -#include -#include -#include -#include - -typedef di_node_t (*di_init_t)(const char *, uint_t); -typedef void (*di_fini_t)(di_node_t); -typedef char * (*di_node_name_t)(di_node_t); -typedef int (*di_walk_node_t)(di_node_t, uint_t, di_node_name_t, int (*)(di_node_t, di_node_name_t)); - -#define DLLINK(h,name) (name=(name##_t)dlsym((h),#name)) - -static int -walk_nodename(di_node_t node, di_node_name_t di_node_name) -{ - char *name = (*di_node_name)(node); - - /* This is expected to catch all UltraSPARC flavors prior T1 */ - if (!strcmp (name, "SUNW,UltraSPARC") || - !strncmp(name,"SUNW,UltraSPARC-I",17)) /* covers II,III,IV */ - { - OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU|SPARCV9_VIS1; - - /* %tick is privileged only on UltraSPARC-I/II, but not IIe */ - if (name[14]!='\0' && name[17]!='\0' && name[18]!='\0') - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; - - return DI_WALK_TERMINATE; - } - /* This is expected to catch remaining UltraSPARCs, such as T1 */ - else if (!strncmp(name, "SUNW,UltraSPARC", 15)) { - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; - - return DI_WALK_TERMINATE; - } - - return DI_WALK_CONTINUE; -} - -void -OPENSSL_cpuid_setup(void) -{ - void *h; - char *e, si[256]; - static int trigger = 0; - - if (trigger) - return; - trigger = 1; - - if ((e = getenv("OPENSSL_sparcv9cap"))) { - OPENSSL_sparcv9cap_P = strtoul(e, NULL, 0); - return; - } - - if (sysinfo(SI_MACHINE, si, sizeof(si)) > 0) { - if (strcmp(si, "sun4v")) - /* FPU is preferred for all CPUs, but US-T1/2 */ - OPENSSL_sparcv9cap_P |= SPARCV9_PREFER_FPU; - } - - if (sysinfo(SI_ISALIST, si, sizeof(si)) > 0) { - if (strstr(si, "+vis")) - OPENSSL_sparcv9cap_P |= SPARCV9_VIS1; - if (strstr(si, "+vis2")) { - OPENSSL_sparcv9cap_P |= SPARCV9_VIS2; - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; - return; - } - } -#ifdef M_KEEP - /* - * Solaris libdevinfo.so.1 is effectively incomatible with - * libmalloc.so.1. Specifically, if application is linked with - * -lmalloc, it crashes upon startup with SIGSEGV in - * free(3LIBMALLOC) called by di_fini. Prior call to - * mallopt(M_KEEP,0) somehow helps... But not always... - */ - if ((h = dlopen(NULL, RTLD_LAZY))) { - union { void *p; - int (*f)(int, int); - } sym; - if ((sym.p = dlsym(h, "mallopt"))) (*sym.f)(M_KEEP, 0); - dlclose(h); - } -#endif - if ((h = dlopen("libdevinfo.so.1", RTLD_LAZY))) - do { - di_init_t di_init; - di_fini_t di_fini; - di_walk_node_t di_walk_node; - di_node_name_t di_node_name; - di_node_t root_node; - - if (!DLLINK(h, di_init)) - break; - if (!DLLINK(h, di_fini)) - break; - if (!DLLINK(h, di_walk_node)) - break; - if (!DLLINK(h, di_node_name)) - break; - - if ((root_node = (*di_init)("/", DINFOSUBTREE)) != - DI_NODE_NIL) { - (*di_walk_node)(root_node, DI_WALK_SIBFIRST, - di_node_name, walk_nodename); - (*di_fini)(root_node); - } - } while (0); - - if (h) - dlclose(h); -} - -#else - static sigjmp_buf common_jmp; static void common_handler(int sig) { @@ -193,7 +57,7 @@ OPENSSL_cpuid_setup(void) } /* Initial value, fits UltraSPARC-I&II... */ - OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU|SPARCV9_TICK_PRIVILEGED; + OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU; sigfillset(&all_masked); sigdelset(&all_masked, SIGILL); @@ -213,11 +77,6 @@ OPENSSL_cpuid_setup(void) sigaction(SIGILL, &common_act, &ill_oact); sigaction(SIGBUS,&common_act,&bus_oact);/* T1 fails 16-bit ldda [on Linux] */ - if (sigsetjmp(common_jmp, 1) == 0) { - _sparcv9_rdtick(); - OPENSSL_sparcv9cap_P &= ~SPARCV9_TICK_PRIVILEGED; - } - if (sigsetjmp(common_jmp, 1) == 0) { _sparcv9_vis1_probe(); OPENSSL_sparcv9cap_P |= SPARCV9_VIS1; @@ -240,5 +99,3 @@ OPENSSL_cpuid_setup(void) sigprocmask(SIG_SETMASK, &oset, NULL); } - -#endif diff --git a/lib/libssl/src/crypto/x86_64cpuid.pl b/lib/libssl/src/crypto/x86_64cpuid.pl index 8422e913426..3fe9a2d5667 100644 --- a/lib/libssl/src/crypto/x86_64cpuid.pl +++ b/lib/libssl/src/crypto/x86_64cpuid.pl @@ -42,16 +42,6 @@ OPENSSL_atomic_add: ret .size OPENSSL_atomic_add,.-OPENSSL_atomic_add -.globl OPENSSL_rdtsc -.type OPENSSL_rdtsc,\@abi-omnipotent -.align 16 -OPENSSL_rdtsc: - rdtsc - shl \$32,%rdx - or %rdx,%rax - ret -.size OPENSSL_rdtsc,.-OPENSSL_rdtsc - .globl OPENSSL_ia32_cpuid .type OPENSSL_ia32_cpuid,\@abi-omnipotent .align 16 diff --git a/lib/libssl/src/crypto/x86cpuid.pl b/lib/libssl/src/crypto/x86cpuid.pl index 0da613f6971..c7a57a34656 100644 --- a/lib/libssl/src/crypto/x86cpuid.pl +++ b/lib/libssl/src/crypto/x86cpuid.pl @@ -143,17 +143,6 @@ for (@ARGV) { $sse2=1 if (/-DOPENSSL_IA32_SSE2/); } &external_label("OPENSSL_ia32cap_P"); -&function_begin_B("OPENSSL_rdtsc","EXTRN\t_OPENSSL_ia32cap_P:DWORD"); - &xor ("eax","eax"); - &xor ("edx","edx"); - &picmeup("ecx","OPENSSL_ia32cap_P"); - &bt (&DWP(0,"ecx"),4); - &jnc (&label("notsc")); - &rdtsc (); -&set_label("notsc"); - &ret (); -&function_end_B("OPENSSL_rdtsc"); - # This works in Ring 0 only [read DJGPP+MS-DOS+privileged DPMI host], # but it's safe to call it on any [supported] 32-bit platform... # Just check for [non-]zero return value...