From patchwork Thu Aug 17 16:51:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Ostrovsky X-Patchwork-Id: 9906687 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 77E8C6038C for ; Thu, 17 Aug 2017 16:51:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 69FE128B61 for ; Thu, 17 Aug 2017 16:51:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5E78B28B6B; Thu, 17 Aug 2017 16:51:25 +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=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id DB8CA28B61 for ; Thu, 17 Aug 2017 16:51:24 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1diNyQ-0006x2-2z; Thu, 17 Aug 2017 16:48:46 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1diNyO-0006ww-Mv for xen-devel@lists.xen.org; Thu, 17 Aug 2017 16:48:44 +0000 Received: from [85.158.137.68] by server-17.bemta-3.messagelabs.com id 38/09-01859-BE8C5995; Thu, 17 Aug 2017 16:48:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrILMWRWlGSWpSXmKPExsUyZ7p8oO7rE1M jDa7ekbZY8nExiwOjx9Hdv5kCGKNYM/OS8isSWDM+9H1iLTguVLHyegt7A2MffxcjJ4eQwGQm ie3tPF2MXED2b0aJN/NWs0E4Gxkluu/tYIRwehgler+8YwFpYRMwkjh7dDojiC0iIC1x7fNls CJmgd2MEkcPz2ECSQgLeElM6bsIZrMIqErc+vOSFcTmBYqfmtEIFpcQUJCY8vA9M4RtLNE3q4 9lAiPPAkaGVYwaxalFZalFukYGeklFmekZJbmJmTm6hgbGermpxcWJ6ak5iUnFesn5uZsYgd6 vZ2Bg3MHYfMLvEKMkB5OSKO/vWVMihfiS8lMqMxKLM+KLSnNSiw8xynBwKEnwrj8+NVJIsCg1 PbUiLTMHGIYwaQkOHiUR3uUgad7igsTc4sx0iNQpRl2OVxP+f2MSYsnLz0uVEudtAykSACnKK M2DGwGLiUuMslLCvIwMDAxCPAWpRbmZJajyrxjFORiVhHl3g0zhycwrgdv0CugIJqAjrrRPAj miJBEhJdXA6JrwPFki4Ks7P+/uSW6MhyO1ArxWLl9s9TD+3Xrz+ZdmxvzSy/3+tUu1Qkz4RG9 F9FbZvM9MCRfmSaS0bGxtmLlZ0e39c1OJ/pz/6WoPOewaf2lN3vphzaGJymvWOUv6rhSfbVay vETWc4bl5Oss1S0HdRy7kk+IbLz62fvaDYmLB99edrhupcRSnJFoqMVcVJwIAGVd6waEAgAA X-Env-Sender: boris.ostrovsky@oracle.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1502988521!110474754!1 X-Originating-IP: [156.151.31.81] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTU2LjE1MS4zMS44MSA9PiAyODgzMzk=\n X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 43361 invoked from network); 17 Aug 2017 16:48:43 -0000 Received: from userp1040.oracle.com (HELO userp1040.oracle.com) (156.151.31.81) by server-3.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 17 Aug 2017 16:48:43 -0000 Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by userp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id v7HGmYK8001749 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Aug 2017 16:48:35 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id v7HGmYOB002452 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 17 Aug 2017 16:48:34 GMT Received: from abhmp0004.oracle.com (abhmp0004.oracle.com [141.146.116.10]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id v7HGmXpY003750; Thu, 17 Aug 2017 16:48:33 GMT Received: from ovs104.us.oracle.com (/10.149.76.204) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Thu, 17 Aug 2017 09:48:33 -0700 From: Boris Ostrovsky To: xen-devel@lists.xen.org Date: Thu, 17 Aug 2017 12:51:13 -0400 Message-Id: <1502988673-12744-1-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 1.8.3.1 X-Source-IP: aserv0021.oracle.com [141.146.126.233] Cc: kevin.tian@intel.com, suravee.suthikulpanit@amd.com, andrew.cooper3@citrix.com, jbeulich@suse.com, jun.nakajima@intel.com, Boris Ostrovsky Subject: [Xen-devel] [PATCH v2] hvm: vmx/svm_cpu_up_prepare should be called only once X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP These routines are first called via CPU_UP_PREPARE notifier by the BSP and then by the booting ASP from vmx_cpu_up()/_svm_cpu_up(). Avoid the unnecessary second call. Signed-off-by: Boris Ostrovsky Reported-by: Andrew Cooper --- V2: * Call *cpu_up_prepare() on BSP from start_svm/vmx() xen/arch/x86/hvm/svm/svm.c | 6 +----- xen/arch/x86/hvm/vmx/vmcs.c | 3 --- xen/arch/x86/hvm/vmx/vmx.c | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 0dc9442..2b51e4d 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -1526,7 +1526,6 @@ static int svm_handle_osvw(struct vcpu *v, uint32_t msr, uint64_t *val, bool_t r static int _svm_cpu_up(bool bsp) { uint64_t msr_content; - int rc; unsigned int cpu = smp_processor_id(); const struct cpuinfo_x86 *c = &cpu_data[cpu]; @@ -1538,9 +1537,6 @@ static int _svm_cpu_up(bool bsp) return -EINVAL; } - if ( (rc = svm_cpu_up_prepare(cpu)) != 0 ) - return rc; - write_efer(read_efer() | EFER_SVME); /* Initialize the HSA for this core. */ @@ -1589,7 +1585,7 @@ const struct hvm_function_table * __init start_svm(void) svm_host_osvw_reset(); - if ( _svm_cpu_up(true) ) + if ( svm_cpu_up_prepare(smp_processor_id()) || _svm_cpu_up(true) ) { printk("SVM: failed to initialise.\n"); return NULL; diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index 7854802..73b4731 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -652,9 +652,6 @@ int vmx_cpu_up(void) INIT_LIST_HEAD(&this_cpu(active_vmcs_list)); - if ( (rc = vmx_cpu_up_prepare(cpu)) != 0 ) - return rc; - switch ( __vmxon(this_cpu(vmxon_region)) ) { case -2: /* #UD or #GP */ diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index 67fc85b..f8c2d01 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2433,7 +2433,7 @@ const struct hvm_function_table * __init start_vmx(void) { set_in_cr4(X86_CR4_VMXE); - if ( vmx_cpu_up() ) + if ( vmx_cpu_up_prepare(smp_processor_id()) || vmx_cpu_up() ) { printk("VMX: failed to initialise.\n"); return NULL;