Skip to content

Commit 129c48c

Browse files
committed
KVM: selftests: restore special vmmcall code layout needed by the harness
Commit 8fda37c ("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()", 2022-11-21) broke the svm_nested_soft_inject_test because it placed a "pop rbp" instruction after vmmcall. While this is correct and mimics what is done in the VMX case, this particular test expects a ud2 instruction right after the vmmcall, so that it can skip over it in the L1 part of the test. Inline a suitably-modified version of vmmcall() to restore the functionality of the test. Fixes: 8fda37c ("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()" Cc: Vitaly Kuznetsov <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]> Reviewed-by: Sean Christopherson <[email protected]> Reviewed-by: Vitaly Kuznetsov <[email protected]> Reviewed-by: Maxim Levitsky <[email protected]> Message-Id: <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 02d9a04 commit 129c48c

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

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

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,17 @@ static void guest_int_handler(struct ex_regs *regs)
4141
static void l2_guest_code_int(void)
4242
{
4343
GUEST_ASSERT_1(int_fired == 1, int_fired);
44-
vmmcall();
45-
ud2();
44+
45+
/*
46+
* Same as the vmmcall() function, but with a ud2 sneaked after the
47+
* vmmcall. The caller injects an exception with the return address
48+
* increased by 2, so the "pop rbp" must be after the ud2 and we cannot
49+
* use vmmcall() directly.
50+
*/
51+
__asm__ __volatile__("push %%rbp; vmmcall; ud2; pop %%rbp"
52+
: : "a"(0xdeadbeef), "c"(0xbeefdead)
53+
: "rbx", "rdx", "rsi", "rdi", "r8", "r9",
54+
"r10", "r11", "r12", "r13", "r14", "r15");
4655

4756
GUEST_ASSERT_1(bp_fired == 1, bp_fired);
4857
hlt();

0 commit comments

Comments
 (0)