From patchwork Wed Jul 12 02:04:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9835795 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 EDB0F603F3 for ; Wed, 12 Jul 2017 02:07:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BE521283BB for ; Wed, 12 Jul 2017 02:07:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B2FEA2845C; Wed, 12 Jul 2017 02:07:07 +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 569432844C for ; Wed, 12 Jul 2017 02:07:07 +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 1dV71T-0004OE-8j; Wed, 12 Jul 2017 02:05:03 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dV71S-0004Ka-Ij for xen-devel@lists.xen.org; Wed, 12 Jul 2017 02:05:02 +0000 Received: from [193.109.254.147] by server-8.bemta-6.messagelabs.com id 67/68-09901-EC385695; Wed, 12 Jul 2017 02:05:02 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsXS1tYhoXu2OTX S4OBTBYslHxezODB6HN39mymAMYo1My8pvyKBNWPCuSvMBXOFKw7fe8fawPiKt4uRk0NIYDqj xKLPYLaEAK/EkWUzWLsYOYBsf4mHOyq7GLmASnoZJd6uWMkOUsMmoC+x4vFBVhBbREBa4trny 4wgNrNAtcTE6XPAbGGBYImfXW/AbBYBVYljU/+zgdi8AtYSVzb+Y4fYJS+xq+0i2BxOARuJ/6 dXsULcYy2x4HoH8wRG3gWMDKsY1YtTi8pSi3SN9JKKMtMzSnITM3N0DQ3M9HJTi4sT01NzEpO K9ZLzczcxAkOBAQh2MC7763SIUZKDSUmUd0d+aqQQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCd5T TUA5waLU9NSKtMwcYFDCpCU4eJREeL2jgdK8xQWJucWZ6RCpU4y6HK8m/P/GJMSSl5+XKiXO6 wYyQwCkKKM0D24ELEIuMcpKCfMyAh0lxFOQWpSbWYIq/4pRnINRSZg3AGQKT2ZeCdymV0BHMA EdsSY7BeSIkkSElFQDo0BmikS7ulTWqYuXDJMbt/7lC7nrNicv3WnqnZTrrdfnl3JXOJyRili i/sNf6Knm7Rk3Gt4cDNlWLCBqzR5+XsNZXTRA4W2CCFeQ/mHjplVxD7l0yxvv8bLacgS/ZNg7 dZFIoo740QcbrO+keEgk8bF+apx1tWx5cIlAk233vVBhQWn2JY+VWIozEg21mIuKEwGrHKiSi wIAAA== X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-8.tower-27.messagelabs.com!1499825099!96422213!1 X-Originating-IP: [134.134.136.24] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTM0LjEzNC4xMzYuMjQgPT4gMzkwOTcx\n X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 37551 invoked from network); 12 Jul 2017 02:05:01 -0000 Received: from mga09.intel.com (HELO mga09.intel.com) (134.134.136.24) by server-8.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 12 Jul 2017 02:05:01 -0000 Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Jul 2017 19:04:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,347,1496127600"; d="scan'208";a="877806797" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.142]) by FMSMGA003.fm.intel.com with ESMTP; 11 Jul 2017 19:04:57 -0700 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Wed, 12 Jul 2017 10:04:38 +0800 Message-Id: <20170712020440.777-6-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170712020440.777-1-haozhong.zhang@intel.com> References: <20170712020440.777-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH v9 5/7] xen/mce: add support of vLMCE injection to XEN_MC_inject_v2 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 Signed-off-by: Haozhong Zhang Reviewed-by: Jan Beulich --- Cc: Jan Beulich Cc: Andrew Cooper --- xen/arch/x86/cpu/mcheck/mce.c | 24 +++++++++++++++++++++++- xen/include/public/arch-x86/xen-mca.h | 1 + 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c index ee04fb54ff..30525dd78b 100644 --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -1485,11 +1485,12 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc) { const cpumask_t *cpumap; cpumask_var_t cmv; + bool broadcast = op->u.mc_inject_v2.flags & XEN_MC_INJECT_CPU_BROADCAST; if (nr_mce_banks == 0) return x86_mcerr("do_mca #MC", -ENODEV); - if ( op->u.mc_inject_v2.flags & XEN_MC_INJECT_CPU_BROADCAST ) + if ( broadcast ) cpumap = &cpu_online_map; else { @@ -1529,6 +1530,27 @@ long do_mca(XEN_GUEST_HANDLE_PARAM(xen_mc_t) u_xen_mc) } break; + case XEN_MC_INJECT_TYPE_LMCE: + if ( !lmce_support ) + { + ret = x86_mcerr("No LMCE support", -EINVAL); + break; + } + if ( broadcast ) + { + ret = x86_mcerr("Broadcast cannot be used with LMCE", -EINVAL); + break; + } + /* Ensure at most one CPU is specified. */ + if ( nr_cpu_ids > cpumask_next(cpumask_first(cpumap), cpumap) ) + { + ret = x86_mcerr("More than one CPU specified for LMCE", + -EINVAL); + break; + } + on_selected_cpus(cpumap, x86_mc_mceinject, NULL, 1); + break; + default: ret = x86_mcerr("Wrong mca type\n", -EINVAL); break; diff --git a/xen/include/public/arch-x86/xen-mca.h b/xen/include/public/arch-x86/xen-mca.h index 7db990723b..dc35267249 100644 --- a/xen/include/public/arch-x86/xen-mca.h +++ b/xen/include/public/arch-x86/xen-mca.h @@ -414,6 +414,7 @@ struct xen_mc_mceinject { #define XEN_MC_INJECT_TYPE_MASK 0x7 #define XEN_MC_INJECT_TYPE_MCE 0x0 #define XEN_MC_INJECT_TYPE_CMCI 0x1 +#define XEN_MC_INJECT_TYPE_LMCE 0x2 #define XEN_MC_INJECT_CPU_BROADCAST 0x8