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)
commitfca6d06cd164c6c3029be6323ed06020fca0d933
tree1e36e0d6500b2feacd0e7768b2b910f537a5d88b
parent04f2f60befc9af274c1790e626cc79334b1f4489
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