x86: Add tests for Guest Last Branch Recording (LBR)
PATCH 1/1 x86: Add tests for Guest Last Branch Recording (LBR)
This unit-test is intended to test the KVM's support for the Last Branch Recording (LBR) which is a performance monitor unit (PMU) feature on Intel processors.
If the LBR bit is set to 1 in the DEBUGCTLMSR, the processor will record a running trace of the most recent branches guest taken in the LBR entries for guest to read.
This is a basic check that looks for the MSR LBR (via #GP check), does some branches, and checks that the FROM_IP/TO_IP are good. To run this test, use the QEMU option "-cpu host,migratable=no".
Signed-off-by Like Xu <[email protected]>
--- x86/Makefile.common | 3 +- x86/pmu_lbr.c | 121 ++++++++++++++++++++++++++++++++++++++++++++ x86/unittests.cfg | 6 +++ 3 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 x86/pmu_lbr.c
x86/Makefile.common +2 -1
@@ -62,7 +62,8 @@ tests-common = $(TEST_DIR)/vmexit.flat $(TEST_DIR)/tsc.flat \ $(TEST_DIR)/init.flat $(TEST_DIR)/smap.flat \ $(TEST_DIR)/hyperv_synic.flat $(TEST_DIR)/hyperv_stimer.flat \ $(TEST_DIR)/hyperv_connections.flat \ - $(TEST_DIR)/umip.flat $(TEST_DIR)/tsx-ctrl.flat + $(TEST_DIR)/umip.flat $(TEST_DIR)/tsx-ctrl.flat \ + $(TEST_DIR)/pmu_lbr.flat test_cases: $(tests-common) $(tests)
x86/pmu_lbr.c new file +121 -0
121 lines not on this page · raw message
x86/unittests.cfg +6 -0
@@ -174,6 +174,12 @@ file = pmu.flat extra_params = -cpu max check = /proc/sys/kernel/nmi_watchdog=0 +[pmu_lbr] +file = pmu_lbr.flat +extra_params = -cpu host,migratable=no +check = /sys/module/kvm/parameters/ignore_msrs=N +check = /proc/sys/kernel/nmi_watchdog=0 + [vmware_backdoors] file = vmware_backdoors.flat extra_params = -machine vmport=on -cpu max
Signature · 1 line
2.29.2