Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

KVM: selftests: enlightened VMPTRLD with an incorrect GPA

Check that guest doesn't hang when an invalid eVMCS GPA is specified.
Testing that #UD is injected would probably be better but selftests lack
the infrastructure currently.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Vitaly Kuznetsov and committed by
Paolo Bonzini
6d05a965 41b0552a

+10 -2
+10 -2
tools/testing/selftests/kvm/x86_64/evmcs_test.c
··· 72 72 l1_guest_code(vmx_pages); 73 73 74 74 GUEST_DONE(); 75 + 76 + /* Try enlightened vmptrld with an incorrect GPA */ 77 + evmcs_vmptrld(0xdeadbeef, vmx_pages->enlightened_vmcs); 78 + GUEST_ASSERT(vmlaunch()); 75 79 } 76 80 77 81 int main(int argc, char *argv[]) ··· 124 120 case UCALL_SYNC: 125 121 break; 126 122 case UCALL_DONE: 127 - goto done; 123 + goto part1_done; 128 124 default: 129 125 TEST_FAIL("Unknown ucall %lu", uc.cmd); 130 126 } ··· 156 152 (ulong) regs2.rdi, (ulong) regs2.rsi); 157 153 } 158 154 159 - done: 155 + part1_done: 156 + _vcpu_run(vm, VCPU_ID); 157 + TEST_ASSERT(run->exit_reason == KVM_EXIT_SHUTDOWN, 158 + "Unexpected successful VMEnter with invalid eVMCS pointer!"); 159 + 160 160 kvm_vm_free(vm); 161 161 }