From patchwork Thu Mar 30 06:20:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9652971 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 868156034C for ; Thu, 30 Mar 2017 06:22:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 759AE2856C for ; Thu, 30 Mar 2017 06:22:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 69E302856D; Thu, 30 Mar 2017 06:22:43 +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 114E82856D for ; Thu, 30 Mar 2017 06:22:43 +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 1ctTRc-0000y3-6X; Thu, 30 Mar 2017 06:20:28 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ctTRa-0000v0-Ua for xen-devel@lists.xen.org; Thu, 30 Mar 2017 06:20:27 +0000 Received: from [85.158.137.68] by server-12.bemta-3.messagelabs.com id 2D/16-12861-AA3ACD85; Thu, 30 Mar 2017 06:20:26 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrDLMWRWlGSWpSXmKPExsXS1tYhr7ty8Z0 Ig8sbdSyWfFzM4sDocXT3b6YAxijWzLyk/IoE1oxd728zFywUqVj4u4G9gXEfXxcjB4eQQKXE ws/VXYycHBICvBJHls1ghbD9JQ7dXsDcxcgFVNLLKHFpyk2wBJuAvsSKxwfBbBEBaYlrny8zg tjMAtUSE6fPAbOFBYIlZrZPYAGxWQRUJX7OWQVm8wrYSPz6eJkFYoG8xIWrp8BsTgFbidVf28 FsIaCas9cOsU1g5F3AyLCKUb04tagstUjXUi+pKDM9oyQ3MTNH19DAWC83tbg4MT01JzGpWC8 5P3cTIzAU6hkYGHcwvv7pdIhRkoNJSZR389w7EUJ8SfkplRmJxRnxRaU5qcWHGGU4OJQkeG8u AsoJFqWmp1akZeYAgxImLcHBoyTCywYMTCHe4oLE3OLMdIjUKUZFKXHekyB9AiCJjNI8uDZYJ FxilJUS5mVkYGAQ4ilILcrNLEGVf8UozsGoJMwbBjKFJzOvBG76K6DFTECLxW1ugSwuSURIST UwKv+8W/Rq86uY/YWTdy1rCZESXsf0vEom3S7DWSY4f1q44swjNtsfzNDyk2flPv9w3YlHDG1 zw2JeeDaKLBJk6vwvvY5h+vuMK3bCAhV67fmFNnqV+YuVw5YfrH37dmo/08vGH82eZ99u7wk9 /OvzqYZ9dobV+26qMW2XYs5MYTya+TNttfkUJZbijERDLeai4kQA7+W8DH8CAAA= X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-16.tower-31.messagelabs.com!1490854812!85204125!8 X-Originating-IP: [134.134.136.31] 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 26571 invoked from network); 30 Mar 2017 06:20:25 -0000 Received: from mga06.intel.com (HELO mga06.intel.com) (134.134.136.31) by server-16.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 30 Mar 2017 06:20:25 -0000 Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP; 29 Mar 2017 23:20:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,245,1486454400"; d="scan'208";a="241919494" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.153]) by fmsmga004.fm.intel.com with ESMTP; 29 Mar 2017 23:20:23 -0700 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Thu, 30 Mar 2017 14:20:01 +0800 Message-Id: <20170330062003.9119-8-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170330062003.9119-1-haozhong.zhang@intel.com> References: <20170330062003.9119-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Jan Beulich , Andrew Cooper Subject: [Xen-devel] [PATCH v3 7/9] 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 Changes in v3: * Add a check to avoid XEN_MC_INJECT_CPU_BROADCAST being used with XEN_MC_INJECT_TYPE_LMCE. --- xen/arch/x86/cpu/mcheck/mce.c | 25 ++++++++++++++++++++++++- xen/include/public/arch-x86/xen-mca.h | 1 + 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/xen/arch/x86/cpu/mcheck/mce.c b/xen/arch/x86/cpu/mcheck/mce.c index c1a59bf..0de19ae 100644 --- a/xen/arch/x86/cpu/mcheck/mce.c +++ b/xen/arch/x86/cpu/mcheck/mce.c @@ -1521,11 +1521,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 { @@ -1565,6 +1566,28 @@ 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 in platform", -EINVAL); + break; + } + if ( broadcast ) + { + ret = x86_mcerr("XEN_MC_INJECT_CPU_BROADCAST cannot be used " + "with XEN_MC_INJECT_TYPE_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", -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 7db9907..dc35267 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