Add WBINVD and INVD testcase to the VM-Exit performance/latency test so that it's easy to measure latency of VM-Exits that are handled in KVM's fastpath on both Intel and AMD (INVD), and so that a direct comparison can be made to an exit with no meaningful emulation (WBINVD). Don't create entries in x86/unittests.cfg, as running the INVD test on bare metal (or a hypervisor that emulates INVD) would likely corrupt memory (and similarly, WBINVD can have a massively negative impact on the system). Signed-off-by: Sean Christopherson --- x86/vmexit.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/x86/vmexit.c b/x86/vmexit.c index 48a38f60..46cc4c92 100644 --- a/x86/vmexit.c +++ b/x86/vmexit.c @@ -36,6 +36,16 @@ static void vmcall(void) asm volatile ("vmcall" : "+a"(a), "=b"(b), "=c"(c), "=d"(d)); } +static void wbinvd(void) +{ + asm volatile ("wbinvd"); +} + +static void invd(void) +{ + asm volatile ("invd"); +} + #define MSR_EFER 0xc0000080 #define EFER_NX_MASK (1ull << 11) @@ -482,6 +492,8 @@ static void toggle_cr4_pge(void) static struct test tests[] = { { cpuid_test, "cpuid", .parallel = 1, }, { vmcall, "vmcall", .parallel = 1, }, + { wbinvd, "wbinvd", .parallel = 1, }, + { invd, "invd", .parallel = 1, }, #ifdef __x86_64__ { mov_from_cr8, "mov_from_cr8", .parallel = 1, }, { mov_to_cr8, "mov_to_cr8" , .parallel = 1, }, base-commit: af582a4ebaf7828c200dc7150aa0dbccb60b08a7 -- 2.52.0.rc1.455.g30608eb744-goog