From patchwork Mon Apr 10 13:27:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9672737 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 8217A6020C for ; Mon, 10 Apr 2017 14:08:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7083D28450 for ; Mon, 10 Apr 2017 14:08:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 659852846D; Mon, 10 Apr 2017 14:08:46 +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 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 D4BE32846C for ; Mon, 10 Apr 2017 14:08:43 +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 1cxZxK-00034n-83; Mon, 10 Apr 2017 14:06:10 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cxZxJ-00034E-GX for xen-devel@lists.xenproject.org; Mon, 10 Apr 2017 14:06:09 +0000 Received: from [85.158.143.35] by server-4.bemta-6.messagelabs.com id F5/BB-03012-0519BE85; Mon, 10 Apr 2017 14:06:08 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmphkeJIrShJLcpLzFFi42JxWrohUjdg4us Ig1enFCy+b5nM5MDocfjDFZYAxijWzLyk/IoE1oxj706wFmzir3j8kbeBcRp3FyMnh4SAv8SE vxPZQGw2AWWJn529YLaIgJ5E04HnjCA2s0CexNnVi1hBbGEBd4k5vavA4iwCqhIt1w6DxXkFL CTeTmxjhJgpL7Gr7SJYnFPAUmLjvmtgthBQzZUPO9ggbAWJjunHmCB6BSVOznzCArFLQuLgix fMExh5ZyFJzUKSWsDItIpRozi1qCy1SNfQUC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC8 5P3cTIzB0GIBgB+OnZQGHGCU5mJREedMtX0cI8SXlp1RmJBZnxBeV5qQWH2KU4eBQkuDVmACU EyxKTU+tSMvMAQYxTFqCg0dJhPdQP1Cat7ggMbc4Mx0idYpRUUqcVxqkTwAkkVGaB9cGi5xLj LJSwryMQIcI8RSkFuVmlqDKv2IU52BUEuZNApnCk5lXAjf9FdBiJqDFZ3a9BFlckoiQkmpgjD cK9PvCy8IY/tOtV2PpjzfFMvNEfwao59vdeXhC87bd0jtuu46Zpm47UCY1LcPoFHOWHp+5jFB 95JxkjtYn9W2tKuaJ+7vnTQiSWbsrq25OjP/qf4kvJQPmcK5U+pNp1Wpvl3r6Xp9/6S3L31d8 dhy/L+RnlSaRovuIJX9ioeRXLr+tN2yVWIozEg21mIuKEwFakvFBlwIAAA== X-Env-Sender: prvs=266623ab3=wei.liu2@citrix.com X-Msg-Ref: server-5.tower-21.messagelabs.com!1491833165!55079058!2 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.12; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58121 invoked from network); 10 Apr 2017 14:06:08 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-5.tower-21.messagelabs.com with RC4-SHA encrypted SMTP; 10 Apr 2017 14:06:08 -0000 X-IronPort-AV: E=Sophos;i="5.37,182,1488844800"; d="scan'208";a="418326536" From: Wei Liu To: Xen-devel Date: Mon, 10 Apr 2017 14:27:10 +0100 Message-ID: <20170410132716.31610-3-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170410132716.31610-1-wei.liu2@citrix.com> References: <20170410132716.31610-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH for-next 2/8] x86/domain: factor out pv_vcpu_initialise 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP No functional change. Signed-off-by: Wei Liu --- xen/arch/x86/domain.c | 65 ++++++++++++++++++++++++++++----------------------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 90e2b1f82a..96c777c771 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -387,37 +387,10 @@ int switch_compat(struct domain *d) return rc; } -int vcpu_initialise(struct vcpu *v) +static int pv_vcpu_initialise(struct vcpu *v) { struct domain *d = v->domain; - int rc; - - v->arch.flags = TF_kernel_mode; - - rc = mapcache_vcpu_init(v); - if ( rc ) - return rc; - - if ( !is_idle_domain(d) ) - { - paging_vcpu_init(v); - - if ( (rc = vcpu_init_fpu(v)) != 0 ) - return rc; - - vmce_init_vcpu(v); - } - else if ( (rc = xstate_alloc_save_area(v)) != 0 ) - return rc; - - spin_lock_init(&v->arch.vpmu.vpmu_lock); - - if ( is_hvm_domain(d) ) - { - rc = hvm_vcpu_initialise(v); - goto done; - } - + int rc = 0; spin_lock_init(&v->arch.pv_vcpu.shadow_ldt_lock); @@ -458,7 +431,41 @@ int vcpu_initialise(struct vcpu *v) goto done; } } + done: + return rc; +} + +int vcpu_initialise(struct vcpu *v) +{ + struct domain *d = v->domain; + int rc; + + v->arch.flags = TF_kernel_mode; + + rc = mapcache_vcpu_init(v); + if ( rc ) + return rc; + + if ( !is_idle_domain(d) ) + { + paging_vcpu_init(v); + + if ( (rc = vcpu_init_fpu(v)) != 0 ) + return rc; + + vmce_init_vcpu(v); + } + else if ( (rc = xstate_alloc_save_area(v)) != 0 ) + return rc; + + spin_lock_init(&v->arch.vpmu.vpmu_lock); + + if ( is_hvm_domain(d) ) + rc = hvm_vcpu_initialise(v); + else + rc = pv_vcpu_initialise(v); + if ( rc ) { vcpu_destroy_fpu(v);