With this, the support code for various sparc crypto opcode routines can just test for feature presence via OPENSSL_sparcv9cap_P.
If we were to instead use a scheme that read the %cfr directly, this would instead be a two step process. First we'd need to check SPARCV9_CFR, and if set then we'd read the %cfr, and then if the opcode feature bit we are interested in is set we would proceed to use it. By propagating the %cfr feature bits into OPENSSL_sparcv9cap_P we only need to perform one test. Signed-off-by: David S. Miller <[email protected]> --- crypto/sparc_arch.h | 12 ++++++++++++ crypto/sparcv9cap.c | 42 ++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/crypto/sparc_arch.h b/crypto/sparc_arch.h index 14cec30..3ece96a 100644 --- a/crypto/sparc_arch.h +++ b/crypto/sparc_arch.h @@ -12,5 +12,17 @@ extern int OPENSSL_sparcv9cap_P; #define SPARCV9_FMADD (1<<4) /* reserved for SPARC64 V */ #define SPARCV9_BLK (1<<5) /* VIS1 block copy */ #define SPARCV9_CFR (1<<6) +#define SPARCV9_AES (1<<7) +#define SPARCV9_DES (1<<8) +#define SPARCV9_KASUMI (1<<9) +#define SPARCV9_CAMELLIA (1<<10) +#define SPARCV9_MD5 (1<<11) +#define SPARCV9_SHA1 (1<<12) +#define SPARCV9_SHA256 (1<<13) +#define SPARCV9_SHA512 (1<<14) +#define SPARCV9_MPMUL (1<<15) +#define SPARCV9_MONTMUL (1<<16) +#define SPARCV9_MONTSQR (1<<17) +#define SPARCV9_CRC32C (1<<18) #endif diff --git a/crypto/sparcv9cap.c b/crypto/sparcv9cap.c index 7c4038f..d809c56 100644 --- a/crypto/sparcv9cap.c +++ b/crypto/sparcv9cap.c @@ -28,7 +28,7 @@ void _sparcv9_vis1_probe(void); unsigned long _sparcv9_vis1_instrument(void); void _sparcv9_vis2_probe(void); void _sparcv9_fmadd_probe(void); -void _sparcv9_cfr_probe(void); +unsigned long _sparcv9_cfr_probe(void); size_t _sparcv9_vis1_instrument_bus(unsigned int *,size_t); size_t _sparcv8_vis1_instrument_bus2(unsigned int *,size_t,size_t); @@ -179,6 +179,20 @@ void OPENSSL_cpuid_setup(void) #else +/* Compatability Feature Register (%asr26), SPARC-T4 and later */ +#define CFR_AES 0x00000001 /* Supports AES opcodes */ +#define CFR_DES 0x00000002 /* Supports DES opcodes */ +#define CFR_KASUMI 0x00000004 /* Supports KASUMI opcodes */ +#define CFR_CAMELLIA 0x00000008 /* Supports CAMELLIA opcodes*/ +#define CFR_MD5 0x00000010 /* Supports MD5 opcodes */ +#define CFR_SHA1 0x00000020 /* Supports SHA1 opcodes */ +#define CFR_SHA256 0x00000040 /* Supports SHA256 opcodes */ +#define CFR_SHA512 0x00000080 /* Supports SHA512 opcodes */ +#define CFR_MPMUL 0x00000100 /* Supports MPMUL opcodes */ +#define CFR_MONTMUL 0x00000200 /* Supports MONTMUL opcodes */ +#define CFR_MONTSQR 0x00000400 /* Supports MONTSQR opcodes */ +#define CFR_CRC32C 0x00000800 /* Supports CRC32C opcodes */ + static sigjmp_buf common_jmp; static void common_handler(int sig) { siglongjmp(common_jmp,sig); } @@ -247,8 +261,32 @@ void OPENSSL_cpuid_setup(void) if (sigsetjmp(common_jmp,1) == 0) { - _sparcv9_cfr_probe(); + unsigned long cfr = _sparcv9_cfr_probe(); OPENSSL_sparcv9cap_P |= SPARCV9_CFR; + if (cfr & CFR_AES) + OPENSSL_sparcv9cap_P |= SPARCV9_AES; + if (cfr & CFR_DES) + OPENSSL_sparcv9cap_P |= SPARCV9_DES; + if (cfr & CFR_KASUMI) + OPENSSL_sparcv9cap_P |= SPARCV9_KASUMI; + if (cfr & CFR_CAMELLIA) + OPENSSL_sparcv9cap_P |= SPARCV9_CAMELLIA; + if (cfr & CFR_MD5) + OPENSSL_sparcv9cap_P |= SPARCV9_MD5; + if (cfr & CFR_SHA1) + OPENSSL_sparcv9cap_P |= SPARCV9_SHA1; + if (cfr & CFR_SHA256) + OPENSSL_sparcv9cap_P |= SPARCV9_SHA256; + if (cfr & CFR_SHA512) + OPENSSL_sparcv9cap_P |= SPARCV9_SHA512; + if (cfr & CFR_MPMUL) + OPENSSL_sparcv9cap_P |= SPARCV9_MPMUL; + if (cfr & CFR_MONTMUL) + OPENSSL_sparcv9cap_P |= SPARCV9_MONTMUL; + if (cfr & CFR_MONTSQR) + OPENSSL_sparcv9cap_P |= SPARCV9_MONTSQR; + if (cfr & CFR_CRC32C) + OPENSSL_sparcv9cap_P |= SPARCV9_CRC32C; } sigaction(SIGBUS,&bus_oact,NULL); -- 1.7.10.4 ______________________________________________________________________ OpenSSL Project http://www.openssl.org Development Mailing List [email protected] Automated List Manager [email protected]
