From: Jim Mattson Subject: [kvm-unit-tests PATCH 1/2] Move vmx_{on,off} into vmx.h Date: Thu, 29 Jun 2017 10:52:10 -0700 Message-ID: <20170629175211.66170-1-jmattson@google.com> References: <0861dc6b-747e-47c6-8a15-bf0a75aedcf7@redhat.com> Cc: Jim Mattson To: Paolo Bonzini , David Hildenbrand , kvm list , David Matlack Return-path: Received: from mail-pg0-f42.google.com ([74.125.83.42]:36205 "EHLO mail-pg0-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751941AbdF2Rww (ORCPT ); Thu, 29 Jun 2017 13:52:52 -0400 Received: by mail-pg0-f42.google.com with SMTP id u62so51346416pgb.3 for ; Thu, 29 Jun 2017 10:52:52 -0700 (PDT) In-Reply-To: <0861dc6b-747e-47c6-8a15-bf0a75aedcf7@redhat.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