From patchwork Sat Jul 9 04:21:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corneliu ZUZU X-Patchwork-Id: 9221993 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 CE35260467 for ; Sat, 9 Jul 2016 04:24:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BFD92285C3 for ; Sat, 9 Jul 2016 04:24:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B194928613; Sat, 9 Jul 2016 04:24:33 +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 45256285C3 for ; Sat, 9 Jul 2016 04:24:33 +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 1bLjmd-00037E-Bu; Sat, 09 Jul 2016 04:22:27 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bLjmb-00036m-Ry for xen-devel@lists.xen.org; Sat, 09 Jul 2016 04:22:25 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id E2/EB-03780-10C70875; Sat, 09 Jul 2016 04:22:25 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrNIsWRWlGSWpSXmKPExsUSfTxjoS5DTUO 4we4+RYslHxezODB6HN39mymAMYo1My8pvyKBNeNZ8zS2gq08FZs+NTM1MO7l7GLk5BAScJdY 0fSFvYuRC8hewyhx6fdyZgjnJKNES2s7M0SVm8TudWehqtYxSkzac44RJMEmoC1x7tA9JhBbR EBa4trny4wgRcwCSxklZn95yQ6SEBaIkOg61QBWxCKgKvHz/kNWEJtXwEWi7fp+oAYODgkBOY kFF9JBwpwCrhLn3r5mhVjsInFj3ySwVgmBHImVz2axQ5RLSfxvVQJZJSHQzSLx8PZkRogaGYl HE2+yTWAUWsDIsIpRvTi1qCy1SNdUL6koMz2jJDcxM0fX0MBYLze1uDgxPTUnMalYLzk/dxMj MBDrGRgYdzBe/up0iFGSg0lJlPeCbUO4EF9SfkplRmJxRnxRaU5q8SFGGQ4OJQlelmqgnGBRa npqRVpmDjAmYNISHDxKIrzSIGne4oLE3OLMdIjUKUZFKXHeBVVACQGQREZpHlwbLA4vMcpKCf MyMjAwCPEUpBblZpagyr9iFOdgVBLmfQgyhSczrwRu+iugxUxAiw0C6kEWlyQipKQaGDMk/Jb 833vmmabDz8m7rb03GXtuOrVvfY8xy4pMEfNtnBrid6OT54rW22/qejD/+dMd3+8f+MSe+yXs 6tLvRxdK8aZ/0GBaJbA7WPA0k3x+6lzVl6xH9rIZTLq3ubVdxUCF22yB87tluclJFupxz0v3P Vf3F1/mM+Pr3uBT2TXJ3VVbTFpsziuxFGckGmoxFxUnAgAc3esIvgIAAA== X-Env-Sender: czuzu@bitdefender.com X-Msg-Ref: server-2.tower-31.messagelabs.com!1468038144!49597248!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 52593 invoked from network); 9 Jul 2016 04:22:24 -0000 Received: from mx01.bbu.dsd.mx.bitdefender.com (HELO mx01.bbu.dsd.mx.bitdefender.com) (91.199.104.161) by server-2.tower-31.messagelabs.com with DHE-RSA-AES128-GCM-SHA256 encrypted SMTP; 9 Jul 2016 04:22:24 -0000 Received: (qmail 12155 invoked from network); 9 Jul 2016 07:22:23 +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; 9 Jul 2016 07:22:23 +0300 Received: from smtp03.buh.bitdefender.org (unknown [10.17.80.77]) by mx-sr.buh.bitdefender.com (Postfix) with ESMTP id 8BA6C7FBEA for ; Sat, 9 Jul 2016 07:22:23 +0300 (EEST) Received: (qmail 4601 invoked from network); 9 Jul 2016 07:22:23 +0300 Received: from 188-24-34-246.rdsnet.ro (HELO localhost.localdomain) (czuzu@bitdefender.com@188.24.34.246) by smtp03.buh.bitdefender.org with SMTP; 9 Jul 2016 07:22:23 +0300 From: Corneliu ZUZU To: xen-devel@lists.xen.org Date: Sat, 9 Jul 2016 07:21:38 +0300 Message-Id: <1468038098-7027-1-git-send-email-czuzu@bitdefender.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1468037509-6428-1-git-send-email-czuzu@bitdefender.com> References: <1468037509-6428-1-git-send-email-czuzu@bitdefender.com> X-BitDefender-Scanner: Clean, Agent: BitDefender qmail 3.1.6 on smtp03.buh.bitdefender.org, sigver: 7.66242 X-BitDefender-Spam: No (0) X-BitDefender-SpamStamp: Build: [Engines: 2.15.6.911, Dats: 425852, Stamp: 3], Multi: [Enabled, t: (0.000009, 0.002162)], BW: [Enabled, t: (0.000006,0.000001)], RBL DNSBL: [Disabled], APM: [Enabled, Score: 500, t: (0.003068), Flags: 85D2ED72; 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.011323)], URL: [Enabled, t: (0.000006)], RTDA: [Enabled, t: (0.017005), Hit: No, Details: v2.3.10; Id: 2m1ghm1.1amgkp5go.ucsg], total: 0(775) X-BitDefender-CF-Stamp: none Cc: Andrew Cooper , Tamas K Lengyel , Jan Beulich , Razvan Cojocaru Subject: [Xen-devel] [PATCH 13/16] x86/monitor: introduce writes_pending field in monitor_write_data 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 Introduce writes_pending field in monitor_write_data structure to slightly optimize code @ monitor_write_data(): avoid having to check each bit when -all- bits are zero (which is likely). Signed-off-by: Corneliu ZUZU --- xen/arch/x86/monitor.c | 3 +++ xen/include/asm-x86/domain.h | 17 +++++++++++------ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/monitor.c b/xen/arch/x86/monitor.c index c558f46..0763ed7 100644 --- a/xen/arch/x86/monitor.c +++ b/xen/arch/x86/monitor.c @@ -127,6 +127,9 @@ void monitor_ctrlreg_write_data(struct vcpu *v) { struct monitor_write_data *w = &v->arch.vm_event->write_data; + if ( likely(!w->writes_pending) ) + return; + if ( w->do_write.msr ) { hvm_msr_write_intercept(w->msr, w->value, 0); diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 8f64ae9..ae1dcb4 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -260,12 +260,17 @@ struct pv_domain }; struct monitor_write_data { - struct { - unsigned int msr : 1; - unsigned int cr0 : 1; - unsigned int cr3 : 1; - unsigned int cr4 : 1; - } do_write; + union { + struct { + unsigned int msr : 1; + unsigned int cr0 : 1; + unsigned int cr3 : 1; + unsigned int cr4 : 1; + } do_write; + + /* Non-zero when at least one of do_write fields is 1. */ + unsigned int writes_pending; + }; uint32_t msr; uint64_t value;