From patchwork Mon Jun 26 16:28:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9810065 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 5BDB360209 for ; Mon, 26 Jun 2017 16:31:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 598CA252D5 for ; Mon, 26 Jun 2017 16:31:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4E45128550; Mon, 26 Jun 2017 16:31:40 +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 E4580252D5 for ; Mon, 26 Jun 2017 16:31:39 +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 1dPWt3-0005AX-9f; Mon, 26 Jun 2017 16:29:17 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dPWt1-00059G-Ah for xen-devel@lists.xenproject.org; Mon, 26 Jun 2017 16:29:15 +0000 Received: from [85.158.137.68] by server-13.bemta-3.messagelabs.com id FF/93-17076-A5631595; Mon, 26 Jun 2017 16:29:14 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprIIsWRWlGSWpSXmKPExsXitHRDpG6UWWC kQd9DLovvWyYzOTB6HP5whSWAMYo1My8pvyKBNaPp3lvGgoWiFQv332RsYFwp2MXIySEh4C8x a/9cdhCbTUBZ4mdnLxuILSKgJ9F04DkjiM0skCdxdvUiVhBbWMBe4tS53WA1LAKqEhfm3AOr4 RUwk9i+7S0rxEx5iV1tF8FsTgFziYbV08FsIaCaXb19bBC2gkTH9GNMEL2CEidnPmGB2CUhcf DFC+YJjLyzkKRmIUktYGRaxahRnFpUllqka2Sql1SUmZ5RkpuYmaNraGCsl5taXJyYnpqTmFS sl5yfu4kRGDz1DAyMOxhbT/gdYpTkYFIS5eV4EhApxJeUn1KZkVicEV9UmpNafIhRhoNDSYL3 mUlgpJBgUWp6akVaZg4wjGHSEhw8SiK8XZpAad7igsTc4sx0iNQpRl2OO30bvjAJseTl56VKi fPamAIVCYAUZZTmwY2AxdQlRlkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK8niBTeDLzSuA2vQ I6ggnoCJZ5ASBHlCQipKQaGOv3i2bOMEl61yHft6Dxg3/IZxG741uaUjIbBaI/1fKztXmYz2S 4NO166K7VuX+12bOP7l/lv/V95N0ZU5w6vHILZ63LfjIjN+TPVNvHk/tZ27edzFw8+Xp7052Z OybVXLtZWHF3uVVtzxnfybk3mfMNrxru8HqrOjMzhL+nIdi25ObmqcHGXEosxRmJhlrMRcWJA H8cCIOkAgAA X-Env-Sender: prvs=343741041=wei.liu2@citrix.com X-Msg-Ref: server-3.tower-31.messagelabs.com!1498494549!107434950!3 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.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 63716 invoked from network); 26 Jun 2017 16:29:13 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-3.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 26 Jun 2017 16:29:13 -0000 X-IronPort-AV: E=Sophos;i="5.39,396,1493683200"; d="scan'208";a="429383190" From: Wei Liu To: Xen-devel Date: Mon, 26 Jun 2017 17:28:35 +0100 Message-ID: <20170626162842.482-7-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170626162842.482-1-wei.liu2@citrix.com> References: <20170626162842.482-1-wei.liu2@citrix.com> MIME-Version: 1.0 Cc: Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH v5 06/13] x86: simplify guest_has_trap_callback 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 There is only one caller for that function. Simplify the function, move it close to the caller and rename it. Signed-off-by: Wei Liu --- xen/arch/x86/cpu/mcheck/vmce.c | 11 ++++++++++- xen/arch/x86/traps.c | 18 ------------------ xen/include/asm-x86/traps.h | 8 -------- 3 files changed, 10 insertions(+), 27 deletions(-) diff --git a/xen/arch/x86/cpu/mcheck/vmce.c b/xen/arch/x86/cpu/mcheck/vmce.c index d591d31600..368285810a 100644 --- a/xen/arch/x86/cpu/mcheck/vmce.c +++ b/xen/arch/x86/cpu/mcheck/vmce.c @@ -359,6 +359,15 @@ static int vmce_load_vcpu_ctxt(struct domain *d, hvm_domain_context_t *h) HVM_REGISTER_SAVE_RESTORE(VMCE_VCPU, vmce_save_vcpu_ctxt, vmce_load_vcpu_ctxt, 1, HVMSR_PER_VCPU); +static inline bool pv_callback_registered(const struct vcpu *v, uint8_t vector) +{ +#ifdef CONFIG_PV + return v->arch.pv_vcpu.trap_ctxt[vector].address; +#else + return false; +#endif +} + /* * for Intel MCE, broadcast vMCE to all vcpus * for AMD MCE, only inject vMCE to vcpu0 @@ -383,7 +392,7 @@ int inject_vmce(struct domain *d, int vcpu) continue; if ( (is_hvm_domain(d) || - guest_has_trap_callback(d, v->vcpu_id, TRAP_machine_check)) && + pv_callback_registered(v, TRAP_machine_check)) && !test_and_set_bool(v->mce_pending) ) { mce_printk(MCE_VERBOSE, "MCE: inject vMCE to %pv\n", v); diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index c43f3f1095..f3c5de6f2c 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -2008,24 +2008,6 @@ long unregister_guest_nmi_callback(void) return 0; } -int guest_has_trap_callback(struct domain *d, uint16_t vcpuid, unsigned int trap_nr) -{ - struct vcpu *v; - struct trap_info *t; - - BUG_ON(d == NULL); - BUG_ON(vcpuid >= d->max_vcpus); - - /* Sanity check - XXX should be more fine grained. */ - BUG_ON(trap_nr >= NR_VECTORS); - - v = d->vcpu[vcpuid]; - t = &v->arch.pv_vcpu.trap_ctxt[trap_nr]; - - return (t->address != 0); -} - - int send_guest_trap(struct domain *d, uint16_t vcpuid, unsigned int trap_nr) { struct vcpu *v; diff --git a/xen/include/asm-x86/traps.h b/xen/include/asm-x86/traps.h index 893b4dbe77..cc1d7d01d9 100644 --- a/xen/include/asm-x86/traps.h +++ b/xen/include/asm-x86/traps.h @@ -29,14 +29,6 @@ struct cpu_user_regs; void async_exception_cleanup(struct vcpu *); -/** - * guest_has_trap_callback - * - * returns true (non-zero) if guest registered a trap handler - */ -extern int guest_has_trap_callback(struct domain *d, uint16_t vcpuid, - unsigned int trap_nr); - /** * send_guest_trap *