kvm: tests: Test that APICv is effective
PATCH 1/1 kvm: tests: Test that APICv is effective
This test determines whether a read from the local APIC ID register in an L1 guest is significantly faster than a read of the local APIC current count register (implying that APICv is effective).
Signed-off-by Aaron Lewis <[email protected]>
--- tools/testing/selftests/kvm/.gitignore | 1 + tools/testing/selftests/kvm/Makefile | 3 +- .../testing/selftests/kvm/include/kvm_util.h | 2 + tools/testing/selftests/kvm/include/timing.h | 53 +++++++ tools/testing/selftests/kvm/lib/kvm_util.c | 41 +++++ .../testing/selftests/kvm/x86_64/apicv_test.c | 145 ++++++++++++++++++ 6 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/kvm/include/timing.h create mode 100644 tools/testing/selftests/kvm/x86_64/apicv_test.c
tools/testing/selftests/kvm/.gitignore +1 -0
@@ -1,3 +1,4 @@ +/x86_64/apicv_test /x86_64/cr4_cpuid_sync_test /x86_64/evmcs_test /x86_64/hyperv_cpuid
tools/testing/selftests/kvm/Makefile +2 -1
@@ -10,7 +10,8 @@ LIBKVM = lib/assert.c lib/elf.c lib/io.c lib/kvm_util.c lib/ucall.c lib/sparsebi LIBKVM_x86_64 = lib/x86_64/processor.c lib/x86_64/vmx.c LIBKVM_aarch64 = lib/aarch64/processor.c -TEST_GEN_PROGS_x86_64 = x86_64/platform_info_test +TEST_GEN_PROGS_x86_64 = x86_64/apicv_test +TEST_GEN_PROGS_x86_64 += x86_64/platform_info_test TEST_GEN_PROGS_x86_64 += x86_64/set_sregs_test TEST_GEN_PROGS_x86_64 += x86_64/sync_regs_test TEST_GEN_PROGS_x86_64 += x86_64/vmx_tsc_adjust_test
tools/testing/selftests/kvm/include/kvm_util.h +2 -0
@@ -146,6 +146,8 @@ allocate_kvm_dirty_log(struct kvm_userspace_memory_region *region);int vm_create_device (struct kvm_vm *vm,struct kvm_create_device *cd); +bool vm_is_apicv_enabled (struct kvm_vm *vm); +#define sync_global_to_guest (vm, g) ({ \ typeof(g) *_p = addr_gva2hva(vm, (vm_vaddr_t)&(g)); \ memcpy(_p, &(g), sizeof(g)); \
tools/testing/selftests/kvm/include/timing.h new file +53 -0
53 lines not on this page · raw message
tools/testing/selftests/kvm/lib/kvm_util.c +41 -0
44 lines not on this page · raw message
tools/testing/selftests/kvm/x86_64/apicv_test.c new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
2.21.0.1020.gf2820cf01a-goog