Skip to contentSkip to conversation

KVM:selftests: Add selftests for CET MSRs

RFC PATCH Superseded Yang Weijiang 1 participant 1 message Jul 20, 2023

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 KVM:selftests: Add selftests for CET MSRs

Test all CET related MSRs with both valid and invalid values in different guest CET support modes. The intent is to test whether any fault/invalid values escape KVM's check or not.

The test doesn't cover all possible valid or invalid msr values but select at least one case of each categories to accelerate tests.

AMD platform support will be added after MSR test framework is fixed.

---
 tools/arch/x86/include/asm/msr-index.h        |   2 +-
 tools/testing/selftests/kvm/Makefile          |   1 +
 .../selftests/kvm/x86_64/cet_msrs_test.c      | 369 ++++++++++++++++++
 3 files changed, 371 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
index ad35355ee43e..d3668f60e59d 100644
@@ -438,7 +438,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
index de10581ea108..10aa8dcad2ee 100644
@@ -117,6 +117,7 @@ TEST_GEN_PROGS_x86_64 += x86_64/sev_migrate_tests
 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/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/x86_64/cet_msrs_test.c new file +369 -0

369 lines not on this page · raw message

Signature · 1 line
2.27.0