From patchwork Wed Jul 6 15:49:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corneliu ZUZU X-Patchwork-Id: 9216565 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 7C4A860467 for ; Wed, 6 Jul 2016 15:52:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6DC7326E51 for ; Wed, 6 Jul 2016 15:52:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6297026E69; Wed, 6 Jul 2016 15:52:29 +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 EF41126E51 for ; Wed, 6 Jul 2016 15:52:28 +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 1bKp5l-0000za-NA; Wed, 06 Jul 2016 15:50:25 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bKp5j-0000zM-To for xen-devel@lists.xen.org; Wed, 06 Jul 2016 15:50:24 +0000 Received: from [193.109.254.147] by server-2.bemta-14.messagelabs.com id D2/13-29243-FB82D775; Wed, 06 Jul 2016 15:50:23 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrBIsWRWlGSWpSXmKPExsUSfTxjoe4+jdp wg82HNC2WfFzM4sDocXT3b6YAxijWzLyk/IoE1ozPTQUFH7grNky7x9LA2MnZxcjJISTgJrH3 yymWLkYuIHsNo8T5ta3sEImTjBKH3zJC2O4S5/a9YIYoWsUocWbXTLAiNgFtiXOH7jGB2CIC0 hLXPl9mBCliFpjNKPH94FNWkISwgLPE5usvWEBsFgFVifalk4CKODh4BVwlDj8oBjElBOQkFl xIBzE5gQ6687gaYq2rxKKFF5lBbAmBHIk93++xQVRLSfxvVQJZJCHQzSKx8+MXVogaGYlHE2+ yTWAUWsDIsIpRozi1qCy1SNfQRC+pKDM9oyQ3MTNH1xDIzU0tLk5MT81JTCrWS87P3cQIDMF6 BgbGHYzfT3seYpTkYFIS5WX5Vh0uxJeUn1KZkVicEV9UmpNafIhRhoNDSYLXS702XEiwKDU9t SItMwcYDTBpCQ4eJRHeRJA0b3FBYm5xZjpE6hSjopQ4bydIQgAkkVGaB9cGi8BLjLJSwryMDA wMQjwFqUW5mSWo8q8YxTkYlYR5L6kBTeHJzCuBm/4KaDET0OKfLtUgi0sSEVJSDYyb9v0JPX+ pxXH2f59FnYUeL/ovXubykv/yYPLRbzq1gU6r7e5qtoqZb9BN+rVFJ0n+7Q33tXVvHW5p6Wio K29V/SH5Y0pYZ1Ki9gT+TV73ioTtZ+95uXjDs/wtbo5+ju2+tU0TL63j4vqx8MfR1a2X/tgKz ZzwcvNb7o8zm3MD2Nar/4v8+HyWEktxRqKhFnNRcSIAyKUYObsCAAA= X-Env-Sender: czuzu@bitdefender.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1467820221!51951230!1 X-Originating-IP: [91.199.104.161] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 47242 invoked from network); 6 Jul 2016 15:50:22 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-3.tower-27.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 6 Jul 2016 15:50:22 -0000 Received: (qmail 3292 invoked from network); 6 Jul 2016 18:50:21 +0300 Received: from unknown (HELO mx-sr.buh.bitdefender.com) (10.17.80.103) by mx01.bbu.dsd.mx.bitdefender.com with AES256-GCM-SHA384 encrypted SMTP; 6 Jul 2016 18:50:21 +0300 Received: from smtp03.buh.bitdefender.org (unknown [10.17.80.77]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 48F1D7FC02 for ; Wed, 6 Jul 2016 18:50:21 +0300 (EEST) Received: (qmail 22123 invoked from network); 6 Jul 2016 18:50:21 +0300 Received: from unknown (HELO czuzu-dev-vm.clj.bitdefender.biz) (czuzu@bitdefender.com@91.199.104.243) by smtp03.buh.bitdefender.org with SMTP; 6 Jul 2016 18:50:21 +0300 From: Corneliu ZUZU To: xen-devel@lists.xen.org Date: Wed, 6 Jul 2016 18:49:55 +0300 Message-Id: <1467820195-13302-1-git-send-email-czuzu@bitdefender.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1467820154-13256-1-git-send-email-czuzu@bitdefender.com> References: <1467820154-13256-1-git-send-email-czuzu@bitdefender.com> X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp03.buh.bitdefender.org, sigver: 7.66202 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 425550, Stamp: 3], Multi: [Enabled, t: (0.000008, 0.001728)], BW: [Enabled, t: (0.000007,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002176), Flags: BB9BAF5C; NN_NO_CONTENT_TYPE; NN_NO_LINK_NMD; NN_LEGIT_BITDEFENDER; NN_LEGIT_S_SQARE_BRACKETS; NN_LEGIT_MAILING_LIST_TO], SGN: [Enabled, t: (0.006432)], URL: [Enabled, t: (0.000005)], RTDA: [Enabled, t: (0.013626), Hit: No, Details: v2.3.10; Id: 2m1ghmj.1amgkr0nl.n03s], total: 0(775) X-BitDefender-CF-Stamp: none Cc: Andrew Cooper , Kevin Tian , Jan Beulich , Jun Nakajima Subject: [Xen-devel] [PATCH v3 1/8] x86/vmx_update_guest_cr: minor optimization 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 Minor optimization @ vmx_update_guest_cr: checks if v->arch.hvm_vmx.exec_control was modified before actually calling vmx_update_cpu_exec_control(v). Signed-off-by: Corneliu ZUZU Acked-by: Kevin Tian --- Changed since v2: --- xen/arch/x86/hvm/vmx/vmx.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index df19579..8ab074f 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -1434,8 +1434,10 @@ static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr) if ( paging_mode_hap(v->domain) ) { /* Manage GUEST_CR3 when CR0.PE=0. */ + uint32_t old_ctls = v->arch.hvm_vmx.exec_control; uint32_t cr3_ctls = (CPU_BASED_CR3_LOAD_EXITING | CPU_BASED_CR3_STORE_EXITING); + v->arch.hvm_vmx.exec_control &= ~cr3_ctls; if ( !hvm_paging_enabled(v) && !vmx_unrestricted_guest(v) ) v->arch.hvm_vmx.exec_control |= cr3_ctls; @@ -1445,7 +1447,8 @@ static void vmx_update_guest_cr(struct vcpu *v, unsigned int cr) monitor_ctrlreg_bitmask(VM_EVENT_X86_CR3) ) v->arch.hvm_vmx.exec_control |= CPU_BASED_CR3_LOAD_EXITING; - vmx_update_cpu_exec_control(v); + if ( old_ctls != v->arch.hvm_vmx.exec_control ) + vmx_update_cpu_exec_control(v); } if ( !nestedhvm_vcpu_in_guestmode(v) )