From patchwork Thu Jun 30 18:42:37 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corneliu ZUZU X-Patchwork-Id: 9208833 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 A677D607D8 for ; Thu, 30 Jun 2016 18:44:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C0FF28683 for ; Thu, 30 Jun 2016 18:44:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 904A92866B; Thu, 30 Jun 2016 18:44:35 +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 177F72866B for ; Thu, 30 Jun 2016 18:44:34 +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 1bIgvK-0001Pf-0o; Thu, 30 Jun 2016 18:42:50 +0000 Received: from mail6.bemta6.messagelabs.com ([85.158.143.247]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bIgvI-0001PQ-NQ for xen-devel@lists.xen.org; Thu, 30 Jun 2016 18:42:48 +0000 Received: from [85.158.143.35] by server-2.bemta-6.messagelabs.com id E5/B1-11548-82865775; Thu, 30 Jun 2016 18:42:48 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRWlGSWpSXmKPExsUSfTxjoa56Rmm 4wZ4dqhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8a2q/eYCi5wV3TdvsHYwPiOo4uRk0NIwENi wv9edgh7LaNE6ybPLkYuIPsko8TL7uVQCXeJpp+3WCESQEVHDk5gBkmwCWhLnDt0jwnEFhGQl rj2+TIjSBGzwGxGie8Hn7KCJIQFHCRuTJoPNolFQFXizNbnQA0cHLwCLhL9HxNBTAkBOYkFF9 JBKjgFXCW2/O5nhtjrIvH7124WEFtCIEfi046FTBDlUhL/W5VANkkIdLNIbHy1ix2iRkbi0cS bbBMYhRYwMqxiVC9OLSpLLdI11ksqykzPKMlNzMzRNTQw08tNLS5OTE/NSUwq1kvOz93ECAxC BiDYwdjxz+kQoyQHk5Io772Q0nAhvqT8lMqMxOKM+KLSnNTiQ4wyHBxKEryd6UA5waLU9NSKt MwcYDzApCU4eJREeOtB0rzFBYm5xZnpEKlTjIpS4rzSIAkBkERGaR5cGywGLzHKSgnzMgIdIs RTkFqUm1mCKv+KUZyDUUmYNxBkCk9mXgnc9FdAi5mAFjOXFoMsLklESEk1MErvO/Jf5nZx2fR nPZ+mLGn6GOu/pv8nwz+Nq4YLHi81uaZfEHDiQZmCzxqJa4db+kxna611t5g0XYyBXa+qIktc 8f+jZO3d4oYSohp5WgstZqef4VkmH7jz0x+PhmtiNlKW3N902pZJpL32DNlu7MJQ5P3xSYbED 9OipQfjQvJ3Pol0OpEUocRSnJFoqMVcVJwIAFfBINq8AgAA X-Env-Sender: czuzu@bitdefender.com X-Msg-Ref: server-15.tower-21.messagelabs.com!1467312166!21678883!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 24541 invoked from network); 30 Jun 2016 18:42:47 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-15.tower-21.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 30 Jun 2016 18:42:47 -0000 Received: (qmail 23020 invoked from network); 30 Jun 2016 21:42:46 +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; 30 Jun 2016 21:42:46 +0300 Received: from smtp02.buh.bitdefender.net (unknown [10.17.80.76]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 8F2E57FBE5 for ; Thu, 30 Jun 2016 21:42:46 +0300 (EEST) Received: (qmail 3555 invoked from network); 30 Jun 2016 21:42:46 +0300 Received: from 188-24-82-29.rdsnet.ro (HELO localhost.localdomain) (czuzu@bitdefender.com@188.24.82.29) by smtp02.buh.bitdefender.net with SMTP; 30 Jun 2016 21:42:46 +0300 From: Corneliu ZUZU To: xen-devel@lists.xen.org Date: Thu, 30 Jun 2016 21:42:37 +0300 Message-Id: <1467312157-2966-1-git-send-email-czuzu@bitdefender.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1467312015-2867-1-git-send-email-czuzu@bitdefender.com> References: <1467312015-2867-1-git-send-email-czuzu@bitdefender.com> X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp02.buh.bitdefender.net, sigver: 7.66124 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 425113, Stamp: 3], Multi: [Enabled, t: (0.000009, 0.001950)], BW: [Enabled, t: (0.000007,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.002378), 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.007080)], URL: [Enabled, t: (0.000006)], RTDA: [Enabled, t: (0.028932), Hit: No, Details: v2.3.10; Id: 2m1ghjn.1amgkn6ss.19l7], total: 0(775) X-BitDefender-CF-Stamp: none Cc: Andrew Cooper , Kevin Tian , Jan Beulich , Jun Nakajima Subject: [Xen-devel] [PATCH 2/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 --- 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 a0f5793..15c84c2 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) )