summaryrefslogtreecommitdiff
path: root/src/soc/intel/common/block/cpu/cpulib.c
diff options
context:
space:
mode:
authorPratikkumar Prajapati <pratikkumar.v.prajapati@intel.com>2022-12-19 10:13:09 -0800
committerSridhar Siricilla <sridhar.siricilla@intel.com>2023-01-02 03:55:04 +0000
commite51978f26fde2f400979ad28f35d497ff3b8ad76 (patch)
tree8104ac0b97fa246b165e43a444799eb3cb4e6dc9 /src/soc/intel/common/block/cpu/cpulib.c
parent9693bcb4c4826c6f672f88a6777bc459cb0920da (diff)
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 <pratikkumar.v.prajapati@intel.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/71116 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Subrata Banik <subratabanik@google.com> Reviewed-by: Sridhar Siricilla <sridhar.siricilla@intel.com>
Diffstat (limited to 'src/soc/intel/common/block/cpu/cpulib.c')
-rw-r--r--src/soc/intel/common/block/cpu/cpulib.c10
1 files changed, 10 insertions, 0 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));
+}