x86: Add test case for LAM_SUP
PATCH 1/1 x86: Add test case for LAM_SUP
This unit test covers:
1. CR4.LAM_SUP toggle has expected behavior according to LAM status.
2. Memory access (here is strcpy() for test example) with supervisor mode address containing LAM meta data, behave as expected per LAM status.
3. MMIO memory access with supervisor mode address containing LAM meta data, behave as expected per LAM status.
In x86/unittests.cfg, add 2 test cases/guest conf, with and without LAM.
Note:LAM_U57 is covered by running kselftests/x86/lam in guest; and exepecting LAM_U48 test will be complemented there when Kernel supports it.
LAM feature spec: https://cdrdv2.intel.com/v1/dl/getContent/671368, Chap 10 LINEAR ADDRESS MASKING (LAM)
--- lib/x86/processor.h | 3 + x86/Makefile.x86_64 | 1 + x86/lam_sup.c | 170 ++++++++++++++++++++++++++++++++++++++++++++ x86/unittests.cfg | 10 +++ 4 files changed, 184 insertions(+) create mode 100644 x86/lam_sup.c
lib/x86/processor.h +3 -0
@@ -105,6 +105,8 @@#define X86_CR4_CET BIT(X86_CR4_CET_BIT)#define X86_CR4_PKS_BIT (24)#define X86_CR4_PKS BIT(X86_CR4_PKS_BIT) +#define X86_CR4_LAM_SUP_BIT (28) +#define X86_CR4_LAM_SUP BIT(X86_CR4_LAM_SUP_BIT)#define X86_EFLAGS_CF_BIT (0)#define X86_EFLAGS_CF BIT(X86_EFLAGS_CF_BIT)
@@ -248,6 +250,7 @@ static inline bool is_intel(void)#define X86_FEATURE_SPEC_CTRL (CPUID(0x7, 0, EDX, 26))#define X86_FEATURE_ARCH_CAPABILITIES (CPUID(0x7, 0, EDX, 29))#define X86_FEATURE_PKS (CPUID(0x7, 0, ECX, 31)) +#define X86_FEATURE_LAM (CPUID(0x7, 1, EAX, 26))/* * Extended Leafs, a.k.a. AMD defined
x86/Makefile.x86_64 +1 -0
@@ -34,6 +34,7 @@ tests += $(TEST_DIR)/rdpru.$(exe) tests += $(TEST_DIR)/pks.$(exe) tests += $(TEST_DIR)/pmu_lbr.$(exe) tests += $(TEST_DIR)/pmu_pebs.$(exe) +tests += $(TEST_DIR)/lam_sup.$(exe) ifeq ($(CONFIG_EFI),y) tests += $(TEST_DIR)/amd_sev.$(exe)
x86/lam_sup.c new file +170 -0
170 lines not on this page · raw message
x86/unittests.cfg +10 -0
@@ -478,3 +478,13 @@ file = cet.flat arch = x86_64 smp = 2 extra_params = -enable-kvm -m 2048 -cpu host + +[intel-lam] +file = lam_sup.flat +arch = x86_64 +extra_params = -enable-kvm -cpu host + +[intel-no-lam] +file = lam_sup.flat +arch = x86_64 +extra_params = -enable-kvm -cpu host,-lam
base-commit: e3c5c3ef2524c58023073c0fadde2e8ae3c04ec6
Signature · 1 line
2.31.1