From: Jim Mattson Subject: [kvm-unit-tests PATCH v2 3/4] Move vmx_{on,off} into vmx.h Date: Thu, 29 Jun 2017 11:46:46 -0700 Message-ID: <20170629184647.76674-3-jmattson@google.com> References: <20170629175211.66170-1-jmattson@google.com> <20170629184647.76674-1-jmattson@google.com> Cc: Jim Mattson To: Paolo Bonzini , David Hildenbrand , kvm list , David Matlack Return-path: Received: from mail-pg0-f49.google.com ([74.125.83.49]:34414 "EHLO mail-pg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753158AbdF2StY (ORCPT ); Thu, 29 Jun 2017 14:49:24 -0400 Received: by mail-pg0-f49.google.com with SMTP id t186so52267898pgb.1 for ; Thu, 29 Jun 2017 11:49:24 -0700 (PDT) In-Reply-To: <20170629184647.76674-1-jmattson@google.com> Sender: kvm-owner@vger.kernel.org List-ID: Make these functions available to callers outside of vmx.c Signed-off-by: Jim Mattson --- x86/vmx.c | 19 ------------------- x86/vmx.h | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/x86/vmx.c b/x86/vmx.c index f7a34d20ab6a..aff13b430a67 100644 --- a/x86/vmx.c +++ b/x86/vmx.c @@ -424,25 +424,6 @@ static void __attribute__((__used__)) syscall_handler(u64 syscall_no) current->syscall_handler(syscall_no); } -static inline int vmx_on() -{ - bool ret; - u64 rflags = read_rflags() | X86_EFLAGS_CF | X86_EFLAGS_ZF; - asm volatile ("push %1; popf; vmxon %2; setbe %0\n\t" - : "=q" (ret) : "q" (rflags), "m" (vmxon_region) : "cc"); - return ret; -} - -static inline int vmx_off() -{ - bool ret; - u64 rflags = read_rflags() | X86_EFLAGS_CF | X86_EFLAGS_ZF; - - asm volatile("push %1; popf; vmxoff; setbe %0\n\t" - : "=q"(ret) : "q" (rflags) : "cc"); - return ret; -} - static const char * const exit_reason_descriptions[] = { [VMX_EXC_NMI] = "VMX_EXC_NMI", [VMX_EXTINT] = "VMX_EXTINT", diff --git a/x86/vmx.h b/x86/vmx.h index 392979ba8ae8..cbba62e46959 100644 --- a/x86/vmx.h +++ b/x86/vmx.h @@ -585,10 +585,31 @@ extern union vmx_ctrl_msr ctrl_exit_rev; extern union vmx_ctrl_msr ctrl_enter_rev; extern union vmx_ept_vpid ept_vpid; +extern u64 *vmxon_region; + void vmx_set_test_stage(u32 s); u32 vmx_get_test_stage(void); void vmx_inc_test_stage(void); +static int vmx_on(void) +{ + bool ret; + u64 rflags = read_rflags() | X86_EFLAGS_CF | X86_EFLAGS_ZF; + asm volatile ("push %1; popf; vmxon %2; setbe %0\n\t" + : "=q" (ret) : "q" (rflags), "m" (vmxon_region) : "cc"); + return ret; +} + +static int vmx_off(void) +{ + bool ret; + u64 rflags = read_rflags() | X86_EFLAGS_CF | X86_EFLAGS_ZF; + + asm volatile("push %1; popf; vmxoff; setbe %0\n\t" + : "=q"(ret) : "q" (rflags) : "cc"); + return ret; +} + static inline int make_vmcs_current(struct vmcs *vmcs) { bool ret; -- 2.13.2.725.g09c95d1e9-goog