Skip to content

Commit 756d396

Browse files
cpuid dummy call with sgx and fix assembly SP + SGX build
1 parent e75f9c7 commit 756d396

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

IDE/LINUX-SGX/sgx_t_static.mk

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,21 +109,20 @@ ifeq ($(HAVE_WOLFSSL_ASSEMBLY), 1)
109109
$(WOLFSSL_ROOT)/wolfcrypt/src/sp_x86_64_asm.S\
110110
$(WOLFSSL_ROOT)/wolfcrypt/src/aes_xts_asm.S\
111111
$(WOLFSSL_ROOT)/wolfcrypt/src/sha3_asm.S\
112-
$(WOLFSSL_ROOT)/wolfcrypt/src/wc_kyber_asm.S\
112+
$(WOLFSSL_ROOT)/wolfcrypt/src/wc_mlkem_asm.S\
113113
$(WOLFSSL_ROOT)/wolfcrypt/src/chacha_asm.S\
114114
$(WOLFSSL_ROOT)/wolfcrypt/src/sha512_asm.S
115115

116116

117117
Wolfssl_C_Extra_Flags += -DWOLFSSL_X86_64_BUILD\
118118
-DWOLFSSL_AESNI\
119-
-maes -masm=intel
120-
121-
#SP assembly needs investigated for use with PIE
122-
#ifeq ($(HAVE_WOLFSSL_SP), 1)
123-
# Wolfssl_C_Extra_Flags += -DWOLFSSL_SP_X86_64_ASM\
124-
# -DWOLFSSL_SP_X86_64\
125-
# -DWOLFSSL_SP_ASM
126-
#endif
119+
-maes -mavx -mavx2 -msse4.2
120+
121+
ifeq ($(HAVE_WOLFSSL_SP), 1)
122+
Wolfssl_C_Extra_Flags += -DWOLFSSL_SP_X86_64_ASM\
123+
-DWOLFSSL_SP_X86_64\
124+
-DWOLFSSL_SP_ASM
125+
endif
127126
endif
128127

129128
Wolfssl_Include_Paths := -I$(WOLFSSL_ROOT)/ \

wolfcrypt/src/cpuid.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,34 @@
2929
static word32 cpuid_flags = 0;
3030
#endif
3131

32-
#ifdef HAVE_CPUID_INTEL
32+
#if defined(HAVE_CPUID_INTEL) && defined(WOLFSSL_SGX)
33+
/* @TODO calling cpuid from a trusted enclave needs additional hardening.
34+
* For initial benchmarking, the cpu support is getting hard set.
35+
* Another thing of note is cpuid calls cause a SIGILL signal, see
36+
* github issue #5 on intel/intel-sgx-ssl */
37+
38+
/* For tying in an actual external call to cpuid this header and function
39+
* call would be used :
40+
* #include <sgx_cpuid.h>
41+
* #define cpuid(reg, leaf, sub) sgx_cpuidex((reg),(leaf),(sub))
42+
*/
43+
void cpuid_set_flags(void)
44+
{
45+
if (!cpuid_check) {
46+
cpuid_flags |= CPUID_AVX1;
47+
cpuid_flags |= CPUID_AVX2;
48+
cpuid_flags |= CPUID_BMI2;
49+
cpuid_flags |= CPUID_RDSEED;
50+
cpuid_flags |= CPUID_AESNI;
51+
cpuid_flags |= CPUID_ADX;
52+
cpuid_flags |= CPUID_MOVBE;
53+
cpuid_flags |= CPUID_BMI1;
54+
55+
cpuid_check = 1;
56+
}
57+
}
58+
59+
#elif defined(HAVE_CPUID_INTEL)
3360
/* Each platform needs to query info type 1 from cpuid to see if aesni is
3461
* supported. Also, let's setup a macro for proper linkage w/o ABI conflicts
3562
*/

0 commit comments

Comments
 (0)