]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: selftests: Hardcode VMCALL/VMMCALL opcodes in "fix hypercall" test
authorSean Christopherson <seanjc@google.com>
Wed, 28 Sep 2022 23:36:49 +0000 (23:36 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 30 Sep 2022 10:39:32 +0000 (06:39 -0400)
commit8055ea7e6f61b1d53ea1b3432f77e23a3d432d79
tree1e36e0d6500b2feacd0e7768b2b910f537a5d88b
parent3088195e5a55636d63376b0ca327a66e8793e80b
KVM: selftests: Hardcode VMCALL/VMMCALL opcodes in "fix hypercall" test

Hardcode the VMCALL/VMMCALL opcodes in dedicated arrays instead of
extracting the opcodes from inline asm, and patch in the "other" opcode
so as to preserve the original opcode, i.e. the opcode that the test
executes in the guest.

Preserving the original opcode (by not patching the source), will make
it easier to implement a check that KVM doesn't modify the opcode (the
test currently only verifies that a #UD occurred).

Use INT3 (0xcc) as the placeholder so that the guest will likely die a
horrible death if the test's patching goes awry.

As a bonus, patching from within the test dedups a decent chunk of code.

Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20220928233652.783504-5-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
tools/testing/selftests/kvm/x86_64/fix_hypercall_test.c