]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: selftests: Verify single-stepping a fastpath VM-Exit exits to userspace
authorSean Christopherson <seanjc@google.com>
Fri, 30 Aug 2024 04:44:48 +0000 (21:44 -0700)
committerSean Christopherson <seanjc@google.com>
Tue, 10 Sep 2024 03:12:12 +0000 (20:12 -0700)
In x86's debug_regs test, change the RDMSR(MISC_ENABLES) in the single-step
testcase to a WRMSR(TSC_DEADLINE) in order to verify that KVM honors
KVM_GUESTDBG_SINGLESTEP when handling a fastpath VM-Exit.

Note, the extra coverage is effectively Intel-only, as KVM only handles
TSC_DEADLINE in the fastpath when the timer is emulated via the hypervisor
timer, a.k.a. the VMX preemption timer.

Link: https://lore.kernel.org/r/20240830044448.130449-1-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
tools/testing/selftests/kvm/x86_64/debug_regs.c

index f6b295e0b2d2bb2ef7d8f3f9359df5125c17069d..76cc2df9238a397f6527b18da0387fbc5831cd00 100644 (file)
@@ -47,15 +47,18 @@ static void guest_code(void)
        /*
         * Single step test, covers 2 basic instructions and 2 emulated
         *
-        * Enable interrupts during the single stepping to see that
-        * pending interrupt we raised is not handled due to KVM_GUESTDBG_BLOCKIRQ
+        * Enable interrupts during the single stepping to see that pending
+        * interrupt we raised is not handled due to KVM_GUESTDBG_BLOCKIRQ.
+        *
+        * Write MSR_IA32_TSC_DEADLINE to verify that KVM's fastpath handler
+        * exits to userspace due to single-step being enabled.
         */
        asm volatile("ss_start: "
                     "sti\n\t"
                     "xor %%eax,%%eax\n\t"
                     "cpuid\n\t"
-                    "movl $0x1a0,%%ecx\n\t"
-                    "rdmsr\n\t"
+                    "movl $" __stringify(MSR_IA32_TSC_DEADLINE) ", %%ecx\n\t"
+                    "wrmsr\n\t"
                     "cli\n\t"
                     : : : "eax", "ebx", "ecx", "edx");