Commit f3443bed authored by Sean Christopherson's avatar Sean Christopherson Committed by Paolo Bonzini

KVM: selftests: Convert triple_fault_event_test away from VCPU_ID

Convert triple_fault_event_test to use vm_create_with_one_vcpu() and pull
the vCPU's ID from 'struct kvm_vcpu'.
Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
parent 08ce0888
......@@ -9,7 +9,6 @@
#include "kselftest.h"
#define VCPU_ID 0
#define ARBITRARY_IO_PORT 0x2000
/* The virtual machine object. */
......@@ -41,6 +40,7 @@ void l1_guest_code(struct vmx_pages *vmx)
int main(void)
{
struct kvm_vcpu *vcpu;
struct kvm_run *run;
struct kvm_vcpu_events events;
vm_vaddr_t vmx_pages_gva;
......@@ -56,13 +56,13 @@ int main(void)
exit(KSFT_SKIP);
}
vm = vm_create_default(VCPU_ID, 0, (void *) l1_guest_code);
vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code);
vm_enable_cap(vm, KVM_CAP_X86_TRIPLE_FAULT_EVENT, 1);
run = vcpu_state(vm, VCPU_ID);
run = vcpu->run;
vcpu_alloc_vmx(vm, &vmx_pages_gva);
vcpu_args_set(vm, VCPU_ID, 1, vmx_pages_gva);
vcpu_run(vm, VCPU_ID);
vcpu_args_set(vm, vcpu->id, 1, vmx_pages_gva);
vcpu_run(vm, vcpu->id);
TEST_ASSERT(run->exit_reason == KVM_EXIT_IO,
"Expected KVM_EXIT_IO, got: %u (%s)\n",
......@@ -70,21 +70,21 @@ int main(void)
TEST_ASSERT(run->io.port == ARBITRARY_IO_PORT,
"Expected IN from port %d from L2, got port %d",
ARBITRARY_IO_PORT, run->io.port);
vcpu_events_get(vm, VCPU_ID, &events);
vcpu_events_get(vm, vcpu->id, &events);
events.flags |= KVM_VCPUEVENT_VALID_TRIPLE_FAULT;
events.triple_fault.pending = true;
vcpu_events_set(vm, VCPU_ID, &events);
vcpu_events_set(vm, vcpu->id, &events);
run->immediate_exit = true;
vcpu_run_complete_io(vm, VCPU_ID);
vcpu_run_complete_io(vm, vcpu->id);
vcpu_events_get(vm, VCPU_ID, &events);
vcpu_events_get(vm, vcpu->id, &events);
TEST_ASSERT(events.flags & KVM_VCPUEVENT_VALID_TRIPLE_FAULT,
"Triple fault event invalid");
TEST_ASSERT(events.triple_fault.pending,
"No triple fault pending");
vcpu_run(vm, VCPU_ID);
vcpu_run(vm, vcpu->id);
switch (get_ucall(vm, VCPU_ID, &uc)) {
switch (get_ucall(vm, vcpu->id, &uc)) {
case UCALL_DONE:
break;
case UCALL_ABORT:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment