KVM: selftests: restore special vmmcall code layout needed by the harness
Paolo Bonzini
maintainerPATCH 1/1 KVM: selftests: restore special vmmcall code layout needed by the harness
Commit 8fda37cf3d41 ("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.
--- .../kvm/x86_64/svm_nested_soft_inject_test.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
tools/testing/selftests/kvm/x86_64/svm_nested_soft_inject_test.c +11 -2
@@ -41,8 +41,17 @@ static void guest_int_handler(struct ex_regs *regs)static void l2_guest_code_int (void ) {GUEST_ASSERT_1 (int_fired ==1 , int_fired); -vmmcall (); -ud2 (); + +/* +* Same as the vmmcall() function, but with a ud2 sneaked after the +* vmmcall. The caller injects an exception with the return address +* increased by 2, so the "pop rbp" must be after the ud2 and we cannot +* use vmmcall() directly. +*/ + __asm__ __volatile__("push %%rbp; vmmcall; ud2; pop %%rbp" + : :"a" (0xdeadbeef ),"c" (0xbeefdead ) + :"rbx" ,"rdx" ,"rsi" ,"rdi" ,"r8" ,"r9" , +"r10" ,"r11" ,"r12" ,"r13" ,"r14" ,"r15" );GUEST_ASSERT_1 (bp_fired ==1 , bp_fired);hlt ();
Signature · 1 line
2.31.1
Quoted 7 lines · Paolo Bonzini
Commit
8fda37cf3d41("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()", 2022-11-21) broke thesvm_nested_soft_inject_testbecause 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.
Quoted 7 lines
Inline a suitably-modified version of
vmmcall()to restore the functionality of the test.Fixes 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()"Cc Vitaly Kuznetsov <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>---
We really, really need to save/restore guest GPRs in L1 when handling exits from L2.
For now,
Vitaly Kuznetsov
Reviewed-byQuoted 11 lines · Sean Christopherson
Quoted 10 lines · Paolo Bonzini
Commit
8fda37cf3d41("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()", 2022-11-21) broke thesvm_nested_soft_inject_testbecause 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.
Quoted 6 lines
Quoted 4 lines
Fixes 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()"Cc Vitaly Kuznetsov <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>---
We really, really need to save/restore guest GPRs in L1 when handling exits from L2.
+1, the amount of stuff we do to workaround the shortcoming (and time we waste debugging) is getting ridiculously high.
Quoted 5 lines
For now,
Reviewed-by Sean Christopherson <[email protected]>
Signature · 1 line
Vitaly
Maxim Levitsky
Reviewed-byQuoted 23 lines · Vitaly Kuznetsov
Quoted 11 lines · Sean Christopherson
Quoted 10 lines · Paolo Bonzini
Commit
8fda37cf3d41("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()", 2022-11-21) broke thesvm_nested_soft_inject_testbecause 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.Quoted 6 lines
Quoted 4 lines
Fixes 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()"Cc Vitaly Kuznetsov <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>---
We really, really need to save/restore guest GPRs in L1 when handling exits from L2.
+1, the amount of stuff we do to workaround the shortcoming (and time we waste debugging) is getting ridiculously high.
Quoted 7 lines
Quoted 4 lines
For now,
Reviewed-by Sean Christopherson <[email protected]>Reviewed-by Vitaly Kuznetsov <[email protected]>
I didn't notice this fix and also found this issue.
Best regards,
Maxim Levitsky
Quoted 32 lines · Maxim Levitsky
Quoted 23 lines · Vitaly Kuznetsov
Quoted 11 lines · Sean Christopherson
Quoted 10 lines · Paolo Bonzini
Commit
8fda37cf3d41("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()", 2022-11-21) broke thesvm_nested_soft_inject_testbecause 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.Quoted 6 lines
Quoted 4 lines
Fixes 8fda37cf3d41 ("KVM: selftests: Stuff RAX/RCX with 'safe' values in vmmcall()/vmcall()"Cc Vitaly Kuznetsov <[email protected]>Signed-off-by Paolo Bonzini <[email protected]>---
We really, really need to save/restore guest GPRs in L1 when handling exits from L2.
+1, the amount of stuff we do to workaround the shortcoming (and time we waste debugging) is getting ridiculously high.
Quoted 7 lines
Quoted 4 lines
For now,
Reviewed-by Sean Christopherson <[email protected]>Reviewed-by Vitaly Kuznetsov <[email protected]>
Quoted 6 lines
I didn't notice this fix and also found this issue.
Reviewed-by Maxim Levitsky <[email protected]>Best regards,
Maxim Levitsky
Seems that this patch got through the cracks,
pinging so someone else won't need to debug this
test too.
Best regards,
Maxim Levitsky