From e51978f26fde2f400979ad28f35d497ff3b8ad76 Mon Sep 17 00:00:00 2001 From: Pratikkumar Prajapati Date: Mon, 19 Dec 2022 10:13:09 -0800 Subject: [PATCH] soc/intel/common: Move SGX supported API to cpulib Move is_sgx_supported() API to common cpulib code, so that this function can be used by other code without enabling SOC_INTEL_COMMON_BLOCK_SGX_ENABLE config option. Change-Id: Ib630ac451152ae2471c862fced992dde3b49d05d Signed-off-by: Pratikkumar Prajapati Reviewed-on: https://review.coreboot.org/c/coreboot/+/71116 Tested-by: build bot (Jenkins) Reviewed-by: Subrata Banik Reviewed-by: Sridhar Siricilla --- src/soc/intel/common/block/cpu/cpulib.c | 10 ++++++++++ .../intel/common/block/include/intelblocks/cpulib.h | 6 ++++++ src/soc/intel/common/block/include/intelblocks/sgx.h | 5 ----- src/soc/intel/common/block/sgx/sgx.c | 10 ---------- 4 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/soc/intel/common/block/cpu/cpulib.c b/src/soc/intel/common/block/cpu/cpulib.c index 5332d01565..0e783447cf 100644 --- a/src/soc/intel/common/block/cpu/cpulib.c +++ b/src/soc/intel/common/block/cpu/cpulib.c @@ -523,3 +523,13 @@ unsigned int smbios_cpu_get_max_speed_mhz(void) { return cpu_get_max_turbo_ratio() * CONFIG_CPU_BCLK_MHZ; } + +bool is_sgx_supported(void) +{ + struct cpuid_result cpuid_regs; + msr_t msr; + + cpuid_regs = cpuid_ext(0x7, 0x0); /* EBX[2] is feature capability */ + msr = rdmsr(MTRR_CAP_MSR); /* Bit 12 is PRMRR enablement */ + return ((cpuid_regs.ebx & SGX_SUPPORTED) && (msr.lo & MTRR_CAP_PRMRR)); +} diff --git a/src/soc/intel/common/block/include/intelblocks/cpulib.h b/src/soc/intel/common/block/include/intelblocks/cpulib.h index 7878bf4203..6c3aa56443 100644 --- a/src/soc/intel/common/block/include/intelblocks/cpulib.h +++ b/src/soc/intel/common/block/include/intelblocks/cpulib.h @@ -211,4 +211,10 @@ bool is_tme_supported(void); */ void set_tme_core_activate(void); +/* + * This function checks if the CPU supports SGX feature. + * Returns true if SGX feature is supported otherwise false. + */ +bool is_sgx_supported(void); + #endif /* SOC_INTEL_COMMON_BLOCK_CPULIB_H */ diff --git a/src/soc/intel/common/block/include/intelblocks/sgx.h b/src/soc/intel/common/block/include/intelblocks/sgx.h index 3099faffba..ac056f7f6f 100644 --- a/src/soc/intel/common/block/include/intelblocks/sgx.h +++ b/src/soc/intel/common/block/include/intelblocks/sgx.h @@ -5,11 +5,6 @@ #include -/* - * Check if SGX is supported - */ -int is_sgx_supported(void); - /* * Configure core PRMRR. * PRMRR needs to configured first on all cores and then diff --git a/src/soc/intel/common/block/sgx/sgx.c b/src/soc/intel/common/block/sgx/sgx.c index 88fe174694..31447f9a76 100644 --- a/src/soc/intel/common/block/sgx/sgx.c +++ b/src/soc/intel/common/block/sgx/sgx.c @@ -12,16 +12,6 @@ #include #include -int is_sgx_supported(void) -{ - struct cpuid_result cpuid_regs; - msr_t msr; - - cpuid_regs = cpuid_ext(0x7, 0x0); /* EBX[2] is feature capability */ - msr = rdmsr(MTRR_CAP_MSR); /* Bit 12 is PRMRR enablement */ - return ((cpuid_regs.ebx & SGX_SUPPORTED) && (msr.lo & MTRR_CAP_PRMRR)); -} - void prmrr_core_configure(void) { msr_t prmrr_base, prmrr_mask;