From 1a38ec3122af59a802fa68ee3718bca4ba2dfde3 Mon Sep 17 00:00:00 2001 From: haosanzi Date: Tue, 15 Sep 2020 10:08:37 +0800 Subject: [PATCH] rune/libenclave/skeleton: Simplify get_sgx_xfrm_by_cpuid() Signed-off-by: Shirong Hao --- .../internal/runtime/pal/skeleton/sgxutils.c | 40 ++++++------------- 1 file changed, 13 insertions(+), 27 deletions(-) diff --git a/rune/libenclave/internal/runtime/pal/skeleton/sgxutils.c b/rune/libenclave/internal/runtime/pal/skeleton/sgxutils.c index 6dd352a..a0d6423 100644 --- a/rune/libenclave/internal/runtime/pal/skeleton/sgxutils.c +++ b/rune/libenclave/internal/runtime/pal/skeleton/sgxutils.c @@ -49,44 +49,30 @@ static inline uint64_t get_xcr0() return xgetbv(0); } -static bool try_get_xcr0(uint64_t *value) +static uint64_t try_get_xcr0() { int cpu_info[4] = {0, 0, 0, 0}; - *value = SGX_XFRM_LEGACY; - - // check if xgetbv instruction is supported + // Check if xgetbv instruction is supported. __cpuid(cpu_info, 1); - // ecx[27:26] indicate whether support xsave/xrstor, and whether enable xgetbv, xsetbv - if (!(cpu_info[2] & (1<