diff options
author | Sean Christopherson <seanjc@google.com> | 2022-02-15 16:27:47 -0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2022-06-11 11:46:48 -0400 |
commit | 21c602e671755765cde92dd5f07125c6ba8b8d03 (patch) | |
tree | 32ef04c5c79428bd020f66d0bfbd5dcfd0672c58 | |
parent | 706aaa4fedd9b028a3238221a8aba499b74d8f93 (diff) | |
download | linux-stable-21c602e671755765cde92dd5f07125c6ba8b8d03.tar.gz linux-stable-21c602e671755765cde92dd5f07125c6ba8b8d03.tar.bz2 linux-stable-21c602e671755765cde92dd5f07125c6ba8b8d03.zip |
KVM: selftests: Convert vmx_apic_access_test away from VCPU_ID
Convert vmx_apic_access_test to use vm_create_with_one_vcpu() and pass
around a 'struct kvm_vcpu' object instead of using a global VCPU_ID.
Opportunistically make the "vm" variable local, it is unused outside of
main().
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c b/tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c index d438c4d3228a..10f9c86029e6 100644 --- a/tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c +++ b/tools/testing/selftests/kvm/x86_64/vmx_apic_access_test.c @@ -28,11 +28,6 @@ #include "kselftest.h" -#define VCPU_ID 0 - -/* The virtual machine object. */ -static struct kvm_vm *vm; - static void l2_guest_code(void) { /* Exit to L1 */ @@ -84,9 +79,12 @@ int main(int argc, char *argv[]) struct vmx_pages *vmx; bool done = false; + struct kvm_vcpu *vcpu; + struct kvm_vm *vm; + nested_vmx_check_supported(); - vm = vm_create_default(VCPU_ID, 0, (void *) l1_guest_code); + vm = vm_create_with_one_vcpu(&vcpu, l1_guest_code); kvm_get_cpu_address_width(&paddr_width, &vaddr_width); high_gpa = (1ul << paddr_width) - getpagesize(); @@ -97,13 +95,13 @@ int main(int argc, char *argv[]) vmx = vcpu_alloc_vmx(vm, &vmx_pages_gva); prepare_virtualize_apic_accesses(vmx, vm); - vcpu_args_set(vm, VCPU_ID, 2, vmx_pages_gva, high_gpa); + vcpu_args_set(vm, vcpu->id, 2, vmx_pages_gva, high_gpa); while (!done) { - volatile struct kvm_run *run = vcpu_state(vm, VCPU_ID); + volatile struct kvm_run *run = vcpu->run; struct ucall uc; - vcpu_run(vm, VCPU_ID); + vcpu_run(vm, vcpu->id); if (apic_access_addr == high_gpa) { TEST_ASSERT(run->exit_reason == KVM_EXIT_INTERNAL_ERROR, @@ -121,7 +119,7 @@ int main(int argc, char *argv[]) run->exit_reason, exit_reason_str(run->exit_reason)); - switch (get_ucall(vm, VCPU_ID, &uc)) { + switch (get_ucall(vm, vcpu->id, &uc)) { case UCALL_ABORT: TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0], __FILE__, uc.args[1]); |