summaryrefslogtreecommitdiff
path: root/src/cpu/intel
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpu/intel')
-rw-r--r--src/cpu/intel/common/Makefile.inc2
-rw-r--r--src/cpu/intel/common/common_init.c25
2 files changed, 27 insertions, 0 deletions
diff --git a/src/cpu/intel/common/Makefile.inc b/src/cpu/intel/common/Makefile.inc
index c4ac57ebcf..8b247abe17 100644
--- a/src/cpu/intel/common/Makefile.inc
+++ b/src/cpu/intel/common/Makefile.inc
@@ -1,6 +1,8 @@
## SPDX-License-Identifier: GPL-2.0-only
+bootblock-$(CONFIG_CPU_INTEL_COMMON) += common_init.c
romstage-$(CONFIG_CPU_INTEL_COMMON) += common_init.c
+postcar-$(CONFIG_CPU_INTEL_COMMON) += common_init.c
ramstage-$(CONFIG_CPU_INTEL_COMMON) += common_init.c
ramstage-$(CONFIG_CPU_INTEL_COMMON) += hyperthreading.c
ramstage-$(CONFIG_CPU_INTEL_COMMON_VOLTAGE) += voltage.c
diff --git a/src/cpu/intel/common/common_init.c b/src/cpu/intel/common/common_init.c
index f8608ae029..ff00f0247f 100644
--- a/src/cpu/intel/common/common_init.c
+++ b/src/cpu/intel/common/common_init.c
@@ -238,3 +238,28 @@ bool is_tme_supported(void)
cpuid_regs = cpuid_ext(CPUID_STRUCT_EXTENDED_FEATURE_FLAGS, 0x0);
return (cpuid_regs.ecx & CPUID_EXT_FEATURE_TME_SUPPORTED);
}
+
+/*
+ * Get number of address bits used by Total Memory Encryption (TME)
+ *
+ * Returns TME_ACTIVATE[MK_TME_KEYID_BITS] (MSR 0x982 Bits[32-35]).
+ *
+ * NOTE: This function should be called after MK-TME features has been
+ * configured in the MSRs according to the capabilities and platform
+ * configuration. For instance, after FSP-M.
+ */
+static int get_tme_keyid_bits(void)
+{
+ msr_t msr;
+
+ msr = rdmsr(MSR_TME_ACTIVATE);
+ return msr.hi & TME_ACTIVATE_HI_KEYID_BITS_MASK;
+}
+
+int get_reserved_phys_addr_bits(void)
+{
+ if (!is_tme_supported())
+ return 0;
+
+ return get_tme_keyid_bits();
+}