Skip to content

Commit c32e028

Browse files
committed
KVM: selftests: Verify single-stepping a fastpath VM-Exit exits to userspace
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>
1 parent 9d15171 commit c32e028

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

tools/testing/selftests/kvm/x86_64/debug_regs.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,18 @@ static void guest_code(void)
4747
/*
4848
* Single step test, covers 2 basic instructions and 2 emulated
4949
*
50-
* Enable interrupts during the single stepping to see that
51-
* pending interrupt we raised is not handled due to KVM_GUESTDBG_BLOCKIRQ
50+
* Enable interrupts during the single stepping to see that pending
51+
* interrupt we raised is not handled due to KVM_GUESTDBG_BLOCKIRQ.
52+
*
53+
* Write MSR_IA32_TSC_DEADLINE to verify that KVM's fastpath handler
54+
* exits to userspace due to single-step being enabled.
5255
*/
5356
asm volatile("ss_start: "
5457
"sti\n\t"
5558
"xor %%eax,%%eax\n\t"
5659
"cpuid\n\t"
57-
"movl $0x1a0,%%ecx\n\t"
58-
"rdmsr\n\t"
60+
"movl $" __stringify(MSR_IA32_TSC_DEADLINE) ", %%ecx\n\t"
61+
"wrmsr\n\t"
5962
"cli\n\t"
6063
: : : "eax", "ebx", "ecx", "edx");
6164

0 commit comments

Comments
 (0)