From patchwork Thu Jun 29 17:52:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Mattson X-Patchwork-Id: 9817505 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BEA436020A for ; Thu, 29 Jun 2017 17:52:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AFDFA2893D for ; Thu, 29 Jun 2017 17:52:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A3F5B28950; Thu, 29 Jun 2017 17:52:55 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 365532893D for ; Thu, 29 Jun 2017 17:52:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752763AbdF2Rwy (ORCPT ); Thu, 29 Jun 2017 13:52:54 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=gXDioFVwZ2UZtWUnRAJJx5758Fv1Tayg0BAcuXTcH7Q=; b=jhPTXuyDL8q8ZB1kEh4aDT97u4NHwXs2tZMqSb3F3gsOyz6w/HgNtyC+vhKUfP/+JQ HLlwtXCcl+EpYLZ4PhuI/prLOoa4/+I2xtbfVyxP1kvDCgFudUFaAT/TuGN1SOSfzLYj LXHBATHJcrs0ZxcspifcrFx5fSIw3LU2i3796PqNlj0f6xzJgINSNwLvtLYo2MEqnsgW XdDJnZb5gpMP5XcDGFr/DXBlXExLYARY+GVg6BNe1Z9UfmHZNs/VraFVKWg59mzi3XEZ IpUZut2N+L8JlyaQ3y7M1e9Zdua0Oy8A7v8U5RDHB03y3Z8s+kcf5uar83G7moEBUdoY S5Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=gXDioFVwZ2UZtWUnRAJJx5758Fv1Tayg0BAcuXTcH7Q=; b=RqFXL0/7WiC8CFs08hS6dUaWNdUX9I3CsPTVGqPH6ufe54oV0FKzRIQqtO7ehj7H66 V+ugYxTjuSnUyJhTmC9BRCreqxXs/t7ONxIe6IATbcgaQMoMDhXb1aWOlxixbClYhwnb /iYAT79iYU/vxmHeGQhw2cD6AmUoxETHfa1PhO21Oy0x+Z8/ovcBc1MsN2FOEGV5Q8L8 reY8ds6t6ZerDL8Jqtjtj6P/XCLGp0VO3Egx9kvJV34hEVbQAn5bPPTF0UdUHfma3nkl ZCbLW9Jr/6keQzVXnkQtYI73XzyyyZv+CwniX0m3pCtBm02hjnO0+vsbx28E+2K0+ZUt 3zzw== X-Gm-Message-State: AKS2vOzYtPP9XD1w3YI3rHGtfs0GFfI80YGBL0ePfb9qHJnv488giWCo l+EHLFHrRSCVyToVurvjhQ== X-Received: by 10.98.4.131 with SMTP id 125mr17843357pfe.110.1498758771479; Thu, 29 Jun 2017 10:52:51 -0700 (PDT) Received: from turtle.sea.corp.google.com ([172.31.88.24]) by smtp.gmail.com with ESMTPSA id d2sm13942151pfb.49.2017.06.29.10.52.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Jun 2017 10:52:50 -0700 (PDT) From: Jim Mattson To: Paolo Bonzini , David Hildenbrand , kvm list , David Matlack Cc: 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> X-Mailer: git-send-email 2.13.2.725.g09c95d1e9-goog In-Reply-To: <0861dc6b-747e-47c6-8a15-bf0a75aedcf7@redhat.com> References: <0861dc6b-747e-47c6-8a15-bf0a75aedcf7@redhat.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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;