From: Sean Christopherson Date: Wed, 1 Jun 2022 20:43:40 +0000 (-0700) Subject: KVM: selftests: Convert triple_fault_event_test away from VCPU_ID X-Git-Tag: baikal/mips/sdk6.1~5143^2~6^2~269 X-Git-Url: https://git.baikalelectronics.ru/sdk/?a=commitdiff_plain;h=88ce3028f6ab9fe2baeeef466c2c001a9a7e56ef;p=kernel.git 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: Sean Christopherson Signed-off-by: Paolo Bonzini --- diff --git a/tools/testing/selftests/kvm/x86_64/triple_fault_event_test.c b/tools/testing/selftests/kvm/x86_64/triple_fault_event_test.c index 68e0f1c5ec5a5..2b0f19ddbc8bf 100644 --- a/tools/testing/selftests/kvm/x86_64/triple_fault_event_test.c +++ b/tools/testing/selftests/kvm/x86_64/triple_fault_event_test.c @@ -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: