summaryrefslogtreecommitdiff
path: root/src/soc/amd/common/block/cpu/noncar
diff options
context:
space:
mode:
Diffstat (limited to 'src/soc/amd/common/block/cpu/noncar')
-rw-r--r--src/soc/amd/common/block/cpu/noncar/cpu.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/soc/amd/common/block/cpu/noncar/cpu.c b/src/soc/amd/common/block/cpu/noncar/cpu.c
index 4afb69a299..891dece7dd 100644
--- a/src/soc/amd/common/block/cpu/noncar/cpu.c
+++ b/src/soc/amd/common/block/cpu/noncar/cpu.c
@@ -1,9 +1,12 @@
/* SPDX-License-Identifier: GPL-2.0-only */
#include <amdblocks/cpu.h>
+#include <arch/cpuid.h>
#include <cpu/cpu.h>
#include <cpu/x86/msr.h>
+#include <cpu/amd/cpuid.h>
#include <cpu/amd/msr.h>
+#include <cpu/amd/mtrr.h>
#include <smbios.h>
#include <soc/iomap.h>
#include <types.h>
@@ -31,3 +34,18 @@ void set_cstate_io_addr(void)
cst_addr.lo = ACPI_CSTATE_CONTROL;
wrmsr(MSR_CSTATE_ADDRESS, cst_addr);
}
+
+static uint32_t get_smee_reserved_address_bits(void)
+{
+ if (rdmsr(SYSCFG_MSR).raw & SYSCFG_MSR_SMEE)
+ return (cpuid_ebx(CPUID_EBX_MEM_ENCRYPT) &
+ CPUID_EBX_MEM_ENCRYPT_ADDR_BITS_MASK) >>
+ CPUID_EBX_MEM_ENCRYPT_ADDR_BITS_SHIFT;
+ else
+ return 0;
+}
+
+uint32_t get_usable_physical_address_bits(void)
+{
+ return cpu_phys_address_size() - get_smee_reserved_address_bits();
+}