From patchwork Fri Feb 17 06:39:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9578859 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 DAA8960586 for ; Fri, 17 Feb 2017 06:43:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CB8E82869B for ; Fri, 17 Feb 2017 06:43:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3CAD286A1; Fri, 17 Feb 2017 06:43:03 +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 4E546286A1 for ; Fri, 17 Feb 2017 06:43:03 +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 1cecE8-0002nI-Tx; Fri, 17 Feb 2017 06:41:08 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cecE7-0002l8-Oh for xen-devel@lists.xen.org; Fri, 17 Feb 2017 06:41:07 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 71/3E-13524-30B96A85; Fri, 17 Feb 2017 06:41:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrPLMWRWlGSWpSXmKPExsVywNykWJdp9rI Ig76byhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bCzZ3MBZtlKhp+32NqYFwn0sXIxSEkMI1R Yt3uO6xdjJwcEgK8EkeWzYCy/STat6xmgijqBSr6Oo0FJMEmoC+x4vFBsCIRAWmJa58vM4IUM QucZZRYcreBCSQhLOArsWjjb7AiFgFViX9XvjOC2LwCdhKzP35khtggL3Hh6imwoZxA8T8PP7 CD2EICthLvP91jnsDIu4CRYRWjenFqUVlqka6JXlJRZnpGSW5iZo6uoYGZXm5qcXFiempOYlK xXnJ+7iZGYEAwAMEOxu7L/ocYJTmYlER5F01bFiHEl5SfUpmRWJwRX1Sak1p8iFGGg0NJgpd7 FlBOsCg1PbUiLTMHGJowaQkOHiURXg6QNG9xQWJucWY6ROoUo6KUOO+NmUAJAZBERmkeXBssH i4xykoJ8zICHSLEU5BalJtZgir/ilGcg1FJmPcCyBSezLwSuOmvgBYzAS3ujFgKsrgkESEl1c DYtubm02fGyxmD+F0ePLi0raTU+2/b7KQdrBrdmZe2/5vCzN65J95V/2b63BtyD1T8FN+yPHh i++Nawg2ZGZwyZ7wXfzo4d58Jz1Le149OyVtOK79T8lyweeFUfZGODY68R8rmPbvVbL91n9zk 14VqSZ7fPk9fsfhS6Zto3t9J5vvfL0hnFtH7rcRSnJFoqMVcVJwIABXlCn6CAgAA X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1487313633!34675007!16 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.2.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 33976 invoked from network); 17 Feb 2017 06:41:06 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-15.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 17 Feb 2017 06:41:06 -0000 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Feb 2017 22:41:05 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,171,1484035200"; d="scan'208";a="65781612" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.133]) by orsmga005.jf.intel.com with ESMTP; 16 Feb 2017 22:41:04 -0800 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Fri, 17 Feb 2017 14:39:33 +0800 Message-Id: <20170217063936.13208-17-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170217063936.13208-1-haozhong.zhang@intel.com> References: <20170217063936.13208-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Christoph Egger , Andrew Cooper , Jan Beulich , Liu Jinsong Subject: [Xen-devel] [PATCH 16/19] x86/vmce: enable injecting LMCE to guest on Intel host 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 Inject LMCE to guest if the host MCE is LMCE and the affected vcpu is known. Otherwise, broadcast MCE to all vcpus on Intel host. Signed-off-by: Haozhong Zhang --- Cc: Christoph Egger Cc: Liu Jinsong Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/cpu/mcheck/mcaction.c | 14 ++++++++------ xen/arch/x86/cpu/mcheck/vmce.c | 9 ++++++++- xen/arch/x86/cpu/mcheck/vmce.h | 2 +- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/xen/arch/x86/cpu/mcheck/mcaction.c b/xen/arch/x86/cpu/mcheck/mcaction.c index 90c68ff..3410bfd 100644 --- a/xen/arch/x86/cpu/mcheck/mcaction.c +++ b/xen/arch/x86/cpu/mcheck/mcaction.c @@ -88,17 +88,19 @@ mc_memerr_dhandler(struct mca_binfo *binfo, goto vmce_failed; } - if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL ) + vmce_vcpuid = global->mc_vcpuid; + if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL && + (vmce_vcpuid == -1 || + global->mc_domid != bank->mc_domid || + !(global->mc_gstatus & MCG_STATUS_LMCE) || + !d->vcpu[vmce_vcpuid]->arch.vmce.lmce_enabled) ) vmce_vcpuid = VMCE_INJECT_BROADCAST; - else - vmce_vcpuid = global->mc_vcpuid; bank->mc_addr = gfn << PAGE_SHIFT | (bank->mc_addr & (PAGE_SIZE -1 )); - /* TODO: support injecting LMCE */ if ( fill_vmsr_data(bank, d, - global->mc_gstatus & ~MCG_STATUS_LMCE, - vmce_vcpuid == VMCE_INJECT_BROADCAST) == -1 ) + global->mc_gstatus, + vmce_vcpuid) == -1 ) { mce_printk(MCE_QUIET, "Fill vMCE# data for DOM%d " "failed\n", bank->mc_domid); diff --git a/xen/arch/x86/cpu/mcheck/vmce.c b/xen/arch/x86/cpu/mcheck/vmce.c index 1278839..2a4d3f0 100644 --- a/xen/arch/x86/cpu/mcheck/vmce.c +++ b/xen/arch/x86/cpu/mcheck/vmce.c @@ -444,14 +444,21 @@ static int vcpu_fill_mc_msrs(struct vcpu *v, uint64_t mcg_status, } int fill_vmsr_data(struct mcinfo_bank *mc_bank, struct domain *d, - uint64_t gstatus, bool broadcast) + uint64_t gstatus, int vmce_vcpuid) { struct vcpu *v = d->vcpu[0]; + bool broadcast = (vmce_vcpuid == VMCE_INJECT_BROADCAST); int ret; if ( mc_bank->mc_domid == (uint16_t)~0 ) return -EINVAL; + if ( (gstatus & MCG_STATUS_LMCE) && !broadcast ) + v = d->vcpu[vmce_vcpuid]; + + if ( broadcast ) + gstatus &= ~MCG_STATUS_LMCE; + ret = vcpu_fill_mc_msrs(v, gstatus, mc_bank->mc_status, mc_bank->mc_addr, mc_bank->mc_misc); if ( ret || !broadcast ) diff --git a/xen/arch/x86/cpu/mcheck/vmce.h b/xen/arch/x86/cpu/mcheck/vmce.h index 74f6381..2797e00 100644 --- a/xen/arch/x86/cpu/mcheck/vmce.h +++ b/xen/arch/x86/cpu/mcheck/vmce.h @@ -17,7 +17,7 @@ int vmce_amd_rdmsr(const struct vcpu *, uint32_t msr, uint64_t *val); int vmce_amd_wrmsr(struct vcpu *, uint32_t msr, uint64_t val); int fill_vmsr_data(struct mcinfo_bank *mc_bank, struct domain *d, - uint64_t gstatus, bool broadcast); + uint64_t gstatus, int vmce_vcpuid); #define VMCE_INJECT_BROADCAST (-1) int inject_vmce(struct domain *d, int vcpu);