soc/intel/common: Add API to check Key Locker support

Add is_keylocker_supported() API in common cpulib.

This function checks if the CPU supports Key Locker feature.
Returns true if Key Locker feature is supported otherwise false.

Change-Id: Ide9e59a4f11a63df48838eab02c2c584cced12e1
Signed-off-by: Pratikkumar Prajapati <pratikkumar.v.prajapati@intel.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/71117
Reviewed-by: Sridhar Siricilla <sridhar.siricilla@intel.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Pratikkumar Prajapati 2022-12-19 11:21:56 -08:00 committed by Sridhar Siricilla
parent 644b0f5f45
commit 08e8067a58
3 changed files with 20 additions and 2 deletions

View File

@ -533,3 +533,13 @@ bool is_sgx_supported(void)
msr = rdmsr(MTRR_CAP_MSR); /* Bit 12 is PRMRR enablement */
return ((cpuid_regs.ebx & SGX_SUPPORTED) && (msr.lo & MTRR_CAP_PRMRR));
}
bool is_keylocker_supported(void)
{
struct cpuid_result cpuid_regs;
msr_t msr;
cpuid_regs = cpuid_ext(0x7, 0x0); /* ECX[23] is feature capability */
msr = rdmsr(MTRR_CAP_MSR); /* Bit 12 is PRMRR enablement */
return ((cpuid_regs.ecx & KEYLOCKER_SUPPORTED) && (msr.lo & MTRR_CAP_PRMRR));
}

View File

@ -217,4 +217,9 @@ void set_tme_core_activate(void);
*/
bool is_sgx_supported(void);
/*
* This function checks if the CPU supports Key Locker feature.
* Returns true if Key Locker feature is supported otherwise false.
*/
bool is_keylocker_supported(void);
#endif /* SOC_INTEL_COMMON_BLOCK_CPULIB_H */

View File

@ -107,7 +107,10 @@
#define PRMRR_SUPPORTED (1<<12)
#define SMRR_LOCK_SUPPORTED (1<<14)
#define SGX_SUPPORTED (1<<2)
#define TME_SUPPORTED (1<<13)
#define SGX_SUPPORTED (1<<2)
#define TME_SUPPORTED (1<<13)
#define KEYLOCKER_SUPPORTED (1<<23)
#define KEYLOCKER_AESKL (1)
#endif /* SOC_INTEL_COMMON_MSR_H */