aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/kvm/x86_64/evmcs_test.c
diff options
context:
space:
mode:
authorSean Christopherson <seanjc@google.com>2022-06-02 13:41:33 -0700
committerPaolo Bonzini <pbonzini@redhat.com>2022-06-11 11:47:22 -0400
commit768e9a61856b75de08f5efa5813bb3e7f16ec271 (patch)
tree013104333c2f15ff33996b92a2b5b5dc6fc1853a /tools/testing/selftests/kvm/x86_64/evmcs_test.c
parentKVM: selftests: Require vCPU output array when creating VM with vCPUs (diff)
downloadlinux-dev-768e9a61856b75de08f5efa5813bb3e7f16ec271.tar.xz
linux-dev-768e9a61856b75de08f5efa5813bb3e7f16ec271.zip
KVM: selftests: Purge vm+vcpu_id == vcpu silliness
Take a vCPU directly instead of a VM+vcpu pair in all vCPU-scoped helpers and ioctls. Signed-off-by: Sean Christopherson <seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/x86_64/evmcs_test.c')
-rw-r--r--tools/testing/selftests/kvm/x86_64/evmcs_test.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/tools/testing/selftests/kvm/x86_64/evmcs_test.c b/tools/testing/selftests/kvm/x86_64/evmcs_test.c
index ba39042a5d96..6c4e728d2d85 100644
--- a/tools/testing/selftests/kvm/x86_64/evmcs_test.c
+++ b/tools/testing/selftests/kvm/x86_64/evmcs_test.c
@@ -161,12 +161,12 @@ void inject_nmi(struct kvm_vcpu *vcpu)
{
struct kvm_vcpu_events events;
- vcpu_events_get(vcpu->vm, vcpu->id, &events);
+ vcpu_events_get(vcpu, &events);
events.nmi.pending = 1;
events.flags |= KVM_VCPUEVENT_VALID_NMI_PENDING;
- vcpu_events_set(vcpu->vm, vcpu->id, &events);
+ vcpu_events_set(vcpu, &events);
}
static struct kvm_vcpu *save_restore_vm(struct kvm_vm *vm,
@@ -175,21 +175,21 @@ static struct kvm_vcpu *save_restore_vm(struct kvm_vm *vm,
struct kvm_regs regs1, regs2;
struct kvm_x86_state *state;
- state = vcpu_save_state(vm, vcpu->id);
+ state = vcpu_save_state(vcpu);
memset(&regs1, 0, sizeof(regs1));
- vcpu_regs_get(vm, vcpu->id, &regs1);
+ vcpu_regs_get(vcpu, &regs1);
kvm_vm_release(vm);
/* Restore state in a new VM. */
vcpu = vm_recreate_with_one_vcpu(vm);
- vcpu_set_hv_cpuid(vm, vcpu->id);
- vcpu_enable_evmcs(vm, vcpu->id);
- vcpu_load_state(vm, vcpu->id, state);
+ vcpu_set_hv_cpuid(vcpu);
+ vcpu_enable_evmcs(vcpu);
+ vcpu_load_state(vcpu, state);
kvm_x86_state_cleanup(state);
memset(&regs2, 0, sizeof(regs2));
- vcpu_regs_get(vm, vcpu->id, &regs2);
+ vcpu_regs_get(vcpu, &regs2);
TEST_ASSERT(!memcmp(&regs1, &regs2, sizeof(regs2)),
"Unexpected register values after vcpu_load_state; rdi: %lx rsi: %lx",
(ulong) regs2.rdi, (ulong) regs2.rsi);
@@ -215,14 +215,14 @@ int main(int argc, char *argv[])
exit(KSFT_SKIP);
}
- vcpu_set_hv_cpuid(vm, vcpu->id);
- vcpu_enable_evmcs(vm, vcpu->id);
+ vcpu_set_hv_cpuid(vcpu);
+ vcpu_enable_evmcs(vcpu);
vcpu_alloc_vmx(vm, &vmx_pages_gva);
- vcpu_args_set(vm, vcpu->id, 1, vmx_pages_gva);
+ vcpu_args_set(vcpu, 1, vmx_pages_gva);
vm_init_descriptor_tables(vm);
- vcpu_init_descriptor_tables(vm, vcpu->id);
+ vcpu_init_descriptor_tables(vcpu);
vm_install_exception_handler(vm, UD_VECTOR, guest_ud_handler);
vm_install_exception_handler(vm, NMI_VECTOR, guest_nmi_handler);
@@ -231,13 +231,13 @@ int main(int argc, char *argv[])
for (stage = 1;; stage++) {
run = vcpu->run;
- vcpu_run(vm, vcpu->id);
+ vcpu_run(vcpu);
TEST_ASSERT(run->exit_reason == KVM_EXIT_IO,
"Stage %d: unexpected exit reason: %u (%s),\n",
stage, run->exit_reason,
exit_reason_str(run->exit_reason));
- switch (get_ucall(vm, vcpu->id, &uc)) {
+ switch (get_ucall(vcpu, &uc)) {
case UCALL_ABORT:
TEST_FAIL("%s at %s:%ld", (const char *)uc.args[0],
__FILE__, uc.args[1]);