KVM:selftests: Add selftests for CET MSR access
PATCH v2 1/1 KVM:selftests: Add selftests for CET MSR access
Test all CET related MSRs with both valid and invalid values in different guest CET support modes. The intent is to test whether KVM checks are reliable enough for valid and invalid input data.
The test doesn't cover all possible valid or invalid msr values but select one case of each categories to accelerate tests.
AMD platform support will be added after the MSR test framework is fixed.
Signed-off-by Yang Weijiang <[email protected]>
--- tools/arch/x86/include/asm/msr-index.h | 2 +- tools/testing/selftests/kvm/Makefile | 1 + .../selftests/kvm/include/x86_64/processor.h | 5 + .../selftests/kvm/x86_64/cet_msrs_test.c | 384 ++++++++++++++++++ 4 files changed, 391 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/kvm/x86_64/cet_msrs_test.c
tools/arch/x86/include/asm/msr-index.h +1 -1
@@ -440,7 +440,7 @@#define CET_LEG_IW_EN BIT_ULL(3)#define CET_NO_TRACK_EN BIT_ULL(4)#define CET_SUPPRESS_DISABLE BIT_ULL(5) -#define CET_RESERVED (BIT_ULL(6) | BIT_ULL(7) | BIT_ULL(8) | BIT_ULL(9)) +#define CET_INTEL_RESERVED GENMASK_ULL(9, 6)#define CET_SUPPRESS BIT_ULL(10)#define CET_WAIT_ENDBR BIT_ULL(11)
tools/testing/selftests/kvm/Makefile +1 -0
@@ -119,6 +119,7 @@ TEST_GEN_PROGS_x86_64 += x86_64/amx_test TEST_GEN_PROGS_x86_64 += x86_64/max_vcpuid_cap_test TEST_GEN_PROGS_x86_64 += x86_64/triple_fault_event_test TEST_GEN_PROGS_x86_64 += x86_64/recalc_apic_map_test +TEST_GEN_PROGS_x86_64 += x86_64/cet_msrs_test TEST_GEN_PROGS_x86_64 += access_tracking_perf_test TEST_GEN_PROGS_x86_64 += demand_paging_test TEST_GEN_PROGS_x86_64 += dirty_log_test
tools/testing/selftests/kvm/include/x86_64/processor.h +5 -0
@@ -1160,6 +1160,11 @@ static inline uint8_t xsetbv_safe(uint32_t index, uint64_t value)return kvm_asm_safe ("xsetbv" ,"a" (eax),"d" (edx),"c" (index)); } +static inline bool is_canonical_addr (uint64_t la,uint8_t law) +{ +return (((int64_t )la << (64 - law)) >> (64 - law)) == la; +} +bool kvm_is_tdp_enabled (void ); uint64_t *__vm_get_page_table_entry(struct kvm_vm *vm, uint64_t vaddr,
tools/testing/selftests/kvm/x86_64/cet_msrs_test.c new file +384 -0
384 lines not on this page · raw message
Signature · 1 line
2.27.0