diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/lib/libcrypto/arch/sparc64/Makefile.inc | 6 | ||||
| -rw-r--r-- | src/lib/libcrypto/sparccpuid.S | 101 | ||||
| -rw-r--r-- | src/lib/libcrypto/sparcv9cap.c | 98 |
3 files changed, 1 insertions, 204 deletions
diff --git a/src/lib/libcrypto/arch/sparc64/Makefile.inc b/src/lib/libcrypto/arch/sparc64/Makefile.inc index 9101d8a89d..43b4b199cd 100644 --- a/src/lib/libcrypto/arch/sparc64/Makefile.inc +++ b/src/lib/libcrypto/arch/sparc64/Makefile.inc | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | # $OpenBSD: Makefile.inc,v 1.19 2024/08/11 13:02:39 jsing Exp $ | 1 | # $OpenBSD: Makefile.inc,v 1.20 2024/10/19 11:55:32 jsing Exp $ |
| 2 | 2 | ||
| 3 | # sparc64-specific libcrypto build rules | 3 | # sparc64-specific libcrypto build rules |
| 4 | 4 | ||
| @@ -24,7 +24,3 @@ ${dst}.S: ${LCRYPTO_SRC}/${dir}/asm/${src}.pl | |||
| 24 | /usr/bin/env CC=${CC} /usr/bin/perl \ | 24 | /usr/bin/env CC=${CC} /usr/bin/perl \ |
| 25 | ${LCRYPTO_SRC}/${dir}/asm/${src}.pl ${.TARGET} -m64 > ${.TARGET} | 25 | ${LCRYPTO_SRC}/${dir}/asm/${src}.pl ${.TARGET} -m64 > ${.TARGET} |
| 26 | .endfor | 26 | .endfor |
| 27 | |||
| 28 | # not until Montgomery code enabled | ||
| 29 | #CFLAGS+= -DOPENSSL_CPUID_OBJ | ||
| 30 | #SRCS+= sparccpuid.S sparcv9cap.c | ||
diff --git a/src/lib/libcrypto/sparccpuid.S b/src/lib/libcrypto/sparccpuid.S deleted file mode 100644 index 5d314d5d88..0000000000 --- a/src/lib/libcrypto/sparccpuid.S +++ /dev/null | |||
| @@ -1,101 +0,0 @@ | |||
| 1 | #if defined(__SUNPRO_C) && defined(__sparcv9) | ||
| 2 | # define ABI64 /* They've said -xarch=v9 at command line */ | ||
| 3 | #elif defined(__GNUC__) && defined(__arch64__) | ||
| 4 | # define ABI64 /* They've said -m64 at command line */ | ||
| 5 | #endif | ||
| 6 | |||
| 7 | #ifdef ABI64 | ||
| 8 | .register %g2,#scratch | ||
| 9 | .register %g3,#scratch | ||
| 10 | # define FRAME -192 | ||
| 11 | # define BIAS 2047 | ||
| 12 | #else | ||
| 13 | # define FRAME -96 | ||
| 14 | # define BIAS 0 | ||
| 15 | #endif | ||
| 16 | |||
| 17 | .global _sparcv9_vis1_probe | ||
| 18 | .align 8 | ||
| 19 | _sparcv9_vis1_probe: | ||
| 20 | add %sp,BIAS+2,%o1 | ||
| 21 | .word 0xc19a5a40 !ldda [%o1]ASI_FP16_P,%f0 | ||
| 22 | retl | ||
| 23 | .word 0x81b00d80 !fxor %f0,%f0,%f0 | ||
| 24 | .type _sparcv9_vis1_probe,#function | ||
| 25 | .size _sparcv9_vis1_probe,.-_sparcv9_vis1_probe | ||
| 26 | |||
| 27 | ! Probe and instrument VIS1 instruction. Output is number of cycles it | ||
| 28 | ! takes to execute rdtick and pair of VIS1 instructions. US-Tx VIS unit | ||
| 29 | ! is slow (documented to be 6 cycles on T2) and the core is in-order | ||
| 30 | ! single-issue, it should be possible to distinguish Tx reliably... | ||
| 31 | ! Observed return values are: | ||
| 32 | ! | ||
| 33 | ! UltraSPARC IIe 7 | ||
| 34 | ! UltraSPARC III 7 | ||
| 35 | ! UltraSPARC T1 24 | ||
| 36 | ! | ||
| 37 | ! Numbers for T2 and SPARC64 V-VII are more than welcomed. | ||
| 38 | ! | ||
| 39 | ! It would be possible to detect specifically US-T1 by instrumenting | ||
| 40 | ! fmul8ulx16, which is emulated on T1 and as such accounts for quite | ||
| 41 | ! a lot of %tick-s, couple of thousand on Linux... | ||
| 42 | .global _sparcv9_vis1_instrument | ||
| 43 | .align 8 | ||
| 44 | _sparcv9_vis1_instrument: | ||
| 45 | .word 0x91410000 !rd %tick,%o0 | ||
| 46 | .word 0x81b00d80 !fxor %f0,%f0,%f0 | ||
| 47 | .word 0x85b08d82 !fxor %f2,%f2,%f2 | ||
| 48 | .word 0x93410000 !rd %tick,%o1 | ||
| 49 | .word 0x81b00d80 !fxor %f0,%f0,%f0 | ||
| 50 | .word 0x85b08d82 !fxor %f2,%f2,%f2 | ||
| 51 | .word 0x95410000 !rd %tick,%o2 | ||
| 52 | .word 0x81b00d80 !fxor %f0,%f0,%f0 | ||
| 53 | .word 0x85b08d82 !fxor %f2,%f2,%f2 | ||
| 54 | .word 0x97410000 !rd %tick,%o3 | ||
| 55 | .word 0x81b00d80 !fxor %f0,%f0,%f0 | ||
| 56 | .word 0x85b08d82 !fxor %f2,%f2,%f2 | ||
| 57 | .word 0x99410000 !rd %tick,%o4 | ||
| 58 | |||
| 59 | ! calculate intervals | ||
| 60 | sub %o1,%o0,%o0 | ||
| 61 | sub %o2,%o1,%o1 | ||
| 62 | sub %o3,%o2,%o2 | ||
| 63 | sub %o4,%o3,%o3 | ||
| 64 | |||
| 65 | ! find minimum value | ||
| 66 | cmp %o0,%o1 | ||
| 67 | .word 0x38680002 !bgu,a %xcc,.+8 | ||
| 68 | mov %o1,%o0 | ||
| 69 | cmp %o0,%o2 | ||
| 70 | .word 0x38680002 !bgu,a %xcc,.+8 | ||
| 71 | mov %o2,%o0 | ||
| 72 | cmp %o0,%o3 | ||
| 73 | .word 0x38680002 !bgu,a %xcc,.+8 | ||
| 74 | mov %o3,%o0 | ||
| 75 | |||
| 76 | retl | ||
| 77 | nop | ||
| 78 | .type _sparcv9_vis1_instrument,#function | ||
| 79 | .size _sparcv9_vis1_instrument,.-_sparcv9_vis1_instrument | ||
| 80 | |||
| 81 | .global _sparcv9_vis2_probe | ||
| 82 | .align 8 | ||
| 83 | _sparcv9_vis2_probe: | ||
| 84 | retl | ||
| 85 | .word 0x81b00980 !bshuffle %f0,%f0,%f0 | ||
| 86 | .type _sparcv9_vis2_probe,#function | ||
| 87 | .size _sparcv9_vis2_probe,.-_sparcv9_vis2_probe | ||
| 88 | |||
| 89 | .global _sparcv9_fmadd_probe | ||
| 90 | .align 8 | ||
| 91 | _sparcv9_fmadd_probe: | ||
| 92 | .word 0x81b00d80 !fxor %f0,%f0,%f0 | ||
| 93 | .word 0x85b08d82 !fxor %f2,%f2,%f2 | ||
| 94 | retl | ||
| 95 | .word 0x81b80440 !fmaddd %f0,%f0,%f2,%f0 | ||
| 96 | .type _sparcv9_fmadd_probe,#function | ||
| 97 | .size _sparcv9_fmadd_probe,.-_sparcv9_fmadd_probe | ||
| 98 | |||
| 99 | .section ".init",#alloc,#execinstr | ||
| 100 | call OPENSSL_cpuid_setup | ||
| 101 | nop | ||
diff --git a/src/lib/libcrypto/sparcv9cap.c b/src/lib/libcrypto/sparcv9cap.c deleted file mode 100644 index cc39c1bf45..0000000000 --- a/src/lib/libcrypto/sparcv9cap.c +++ /dev/null | |||
| @@ -1,98 +0,0 @@ | |||
| 1 | /* $OpenBSD: sparcv9cap.c,v 1.7 2014/06/20 21:00:46 deraadt Exp $ */ | ||
| 2 | #include <stdio.h> | ||
| 3 | #include <stdlib.h> | ||
| 4 | #include <string.h> | ||
| 5 | #include <setjmp.h> | ||
| 6 | #include <signal.h> | ||
| 7 | #include <sys/time.h> | ||
| 8 | #include <openssl/bn.h> | ||
| 9 | |||
| 10 | #define SPARCV9_PREFER_FPU (1<<1) | ||
| 11 | #define SPARCV9_VIS1 (1<<2) | ||
| 12 | #define SPARCV9_VIS2 (1<<3) /* reserved */ | ||
| 13 | #define SPARCV9_FMADD (1<<4) /* reserved for SPARC64 V */ | ||
| 14 | |||
| 15 | static int OPENSSL_sparcv9cap_P = 0; | ||
| 16 | |||
| 17 | int | ||
| 18 | bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, | ||
| 19 | const BN_ULONG *np, const BN_ULONG *n0, int num) | ||
| 20 | { | ||
| 21 | int bn_mul_mont_fpu(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num); | ||
| 22 | int bn_mul_mont_int(BN_ULONG *rp, const BN_ULONG *ap, const BN_ULONG *bp, const BN_ULONG *np, const BN_ULONG *n0, int num); | ||
| 23 | |||
| 24 | if (num >= 8 && !(num & 1) && | ||
| 25 | (OPENSSL_sparcv9cap_P & (SPARCV9_PREFER_FPU|SPARCV9_VIS1)) == | ||
| 26 | (SPARCV9_PREFER_FPU|SPARCV9_VIS1)) | ||
| 27 | return bn_mul_mont_fpu(rp, ap, bp, np, n0, num); | ||
| 28 | else | ||
| 29 | return bn_mul_mont_int(rp, ap, bp, np, n0, num); | ||
| 30 | } | ||
| 31 | |||
| 32 | void _sparcv9_vis1_probe(void); | ||
| 33 | unsigned long _sparcv9_vis1_instrument(void); | ||
| 34 | void _sparcv9_vis2_probe(void); | ||
| 35 | void _sparcv9_fmadd_probe(void); | ||
| 36 | |||
| 37 | static sigjmp_buf common_jmp; | ||
| 38 | static void | ||
| 39 | common_handler(int sig) | ||
| 40 | { | ||
| 41 | siglongjmp(common_jmp, sig); | ||
| 42 | } | ||
| 43 | |||
| 44 | void | ||
| 45 | OPENSSL_cpuid_setup(void) | ||
| 46 | { | ||
| 47 | char *e; | ||
| 48 | struct sigaction common_act, ill_oact, bus_oact; | ||
| 49 | sigset_t all_masked, oset; | ||
| 50 | static int trigger = 0; | ||
| 51 | |||
| 52 | if (trigger) | ||
| 53 | return; | ||
| 54 | trigger = 1; | ||
| 55 | |||
| 56 | /* Initial value, fits UltraSPARC-I&II... */ | ||
| 57 | OPENSSL_sparcv9cap_P = SPARCV9_PREFER_FPU; | ||
| 58 | |||
| 59 | sigfillset(&all_masked); | ||
| 60 | sigdelset(&all_masked, SIGILL); | ||
| 61 | sigdelset(&all_masked, SIGTRAP); | ||
| 62 | #ifdef SIGEMT | ||
| 63 | sigdelset(&all_masked, SIGEMT); | ||
| 64 | #endif | ||
| 65 | sigdelset(&all_masked, SIGFPE); | ||
| 66 | sigdelset(&all_masked, SIGBUS); | ||
| 67 | sigdelset(&all_masked, SIGSEGV); | ||
| 68 | sigprocmask(SIG_SETMASK, &all_masked, &oset); | ||
| 69 | |||
| 70 | memset(&common_act, 0, sizeof(common_act)); | ||
| 71 | common_act.sa_handler = common_handler; | ||
| 72 | common_act.sa_mask = all_masked; | ||
| 73 | |||
| 74 | sigaction(SIGILL, &common_act, &ill_oact); | ||
| 75 | sigaction(SIGBUS,&common_act,&bus_oact);/* T1 fails 16-bit ldda [on Linux] */ | ||
| 76 | |||
| 77 | if (sigsetjmp(common_jmp, 1) == 0) { | ||
| 78 | _sparcv9_vis1_probe(); | ||
| 79 | OPENSSL_sparcv9cap_P |= SPARCV9_VIS1; | ||
| 80 | /* detect UltraSPARC-Tx, see sparccpud.S for details... */ | ||
| 81 | if (_sparcv9_vis1_instrument() >= 12) | ||
| 82 | OPENSSL_sparcv9cap_P &= ~(SPARCV9_VIS1|SPARCV9_PREFER_FPU); | ||
| 83 | else { | ||
| 84 | _sparcv9_vis2_probe(); | ||
| 85 | OPENSSL_sparcv9cap_P |= SPARCV9_VIS2; | ||
| 86 | } | ||
| 87 | } | ||
| 88 | |||
| 89 | if (sigsetjmp(common_jmp, 1) == 0) { | ||
| 90 | _sparcv9_fmadd_probe(); | ||
| 91 | OPENSSL_sparcv9cap_P |= SPARCV9_FMADD; | ||
| 92 | } | ||
| 93 | |||
| 94 | sigaction(SIGBUS, &bus_oact, NULL); | ||
| 95 | sigaction(SIGILL, &ill_oact, NULL); | ||
| 96 | |||
| 97 | sigprocmask(SIG_SETMASK, &oset, NULL); | ||
| 98 | } | ||
