diff options
author | Peter Xu <peterx@redhat.com> | 2018-08-22 15:19:57 +0800 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-08-22 16:48:37 +0200 |
commit | 4e18bccc2e5544f0be28fc1c4e6be47a469d6c60 (patch) | |
tree | d334c9b09f5e94cb97c85ac487d4da9bf75cf86f /tools/testing/selftests/kvm/lib/kvm_util.c | |
parent | 07a262cc7c586e3f385a61b8870b0913bf31309a (diff) | |
download | talos-obmc-linux-4e18bccc2e5544f0be28fc1c4e6be47a469d6c60.tar.gz talos-obmc-linux-4e18bccc2e5544f0be28fc1c4e6be47a469d6c60.zip |
kvm: selftest: unify the guest port macros
Most of the tests are using the same way to do guest to host sync but
the code is mostly duplicated. Generalize the guest port macros into
the common header file and use it in different tests.
Meanwhile provide "struct guest_args" and a helper "guest_args_read()"
to hide the register details when playing with these port operations on
RDI and RSI.
Signed-off-by: Peter Xu <peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'tools/testing/selftests/kvm/lib/kvm_util.c')
-rw-r--r-- | tools/testing/selftests/kvm/lib/kvm_util.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/tools/testing/selftests/kvm/lib/kvm_util.c b/tools/testing/selftests/kvm/lib/kvm_util.c index 643309d6de74..97d344303c92 100644 --- a/tools/testing/selftests/kvm/lib/kvm_util.c +++ b/tools/testing/selftests/kvm/lib/kvm_util.c @@ -1536,3 +1536,17 @@ void *addr_gva2hva(struct kvm_vm *vm, vm_vaddr_t gva) { return addr_gpa2hva(vm, addr_gva2gpa(vm, gva)); } + +void guest_args_read(struct kvm_vm *vm, uint32_t vcpu_id, + struct guest_args *args) +{ + struct kvm_run *run = vcpu_state(vm, vcpu_id); + struct kvm_regs regs; + + memset(®s, 0, sizeof(regs)); + vcpu_regs_get(vm, vcpu_id, ®s); + + args->port = run->io.port; + args->arg0 = regs.rdi; + args->arg1 = regs.rsi; +} |