diff options
author | Sean Christopherson <sean.j.christopherson@intel.com> | 2020-03-12 16:27:44 -0700 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2020-03-14 11:34:34 +0100 |
commit | 38e505dd94adfedb3e502b9c91e6239ddbcd14da (patch) | |
tree | 4f0150442d18a22cb2a2e3926afc47d392855ee4 | |
parent | e0e2af904058b3dc2ec1dcaa732a734b39d61272 (diff) | |
download | kvm-unit-tests-38e505dd94adfedb3e502b9c91e6239ddbcd14da.tar.gz |
nVMX: Pass exit reason union to is_hypercall()
Pass the exit reason captured in VM-Entry results into __enter_guest()'s
helpers to simplify code and eliminate extra VMREADS.
Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r-- | x86/vmx.c | 19 |
1 files changed, 7 insertions, 12 deletions
@@ -1553,15 +1553,10 @@ static void __attribute__((__used__)) hypercall(u32 hypercall_no) asm volatile("vmcall\n\t"); } -static bool is_hypercall(void) +static bool is_hypercall(union exit_reason exit_reason) { - ulong reason, hyper_bit; - - reason = vmcs_read(EXI_REASON) & 0xff; - hyper_bit = hypercall_field & HYPERCALL_BIT; - if (reason == VMX_VMCALL && hyper_bit) - return true; - return false; + return exit_reason.basic == VMX_VMCALL && + (hypercall_field & HYPERCALL_BIT); } static int handle_hypercall(void) @@ -1624,7 +1619,7 @@ static int exit_handler(union exit_reason exit_reason) current->exits++; regs.rflags = vmcs_read(GUEST_RFLAGS); - if (is_hypercall()) + if (is_hypercall(exit_reason)) ret = handle_hypercall(); else ret = current->exit_handler(exit_reason); @@ -1816,9 +1811,9 @@ void test_set_guest(test_guest_func func) v2_guest_main = func; } -static void check_for_guest_termination(void) +static void check_for_guest_termination(union exit_reason exit_reason) { - if (is_hypercall()) { + if (is_hypercall(exit_reason)) { int ret; ret = handle_hypercall(); @@ -1867,7 +1862,7 @@ void __enter_guest(u8 abort_flag, struct vmentry_result *result) } launched = 1; - check_for_guest_termination(); + check_for_guest_termination(result->exit_reason); return; do_abort: |