From patchwork Mon Jun 26 09:16:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9808915 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 33F4E60209 for ; Mon, 26 Jun 2017 09:19:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3E24A28161 for ; Mon, 26 Jun 2017 09:19:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 32D062847C; Mon, 26 Jun 2017 09:19:41 +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 C7B6D28161 for ; Mon, 26 Jun 2017 09:19:40 +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 1dPQ8q-0002o6-RD; Mon, 26 Jun 2017 09:17: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 1dPQ8p-0002mc-V1 for xen-devel@lists.xen.org; Mon, 26 Jun 2017 09:17:08 +0000 Received: from [85.158.143.35] by server-11.bemta-6.messagelabs.com id FA/F9-03587-311D0595; Mon, 26 Jun 2017 09:17:07 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsVywNwkVlfoYkC kwd/XBhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8axxV+YC3aKVxyf9IC5gfGUUBcjF4eQwDRG idWvT7B3MXJySAjwShxZNoO1i5EDyPaXmLqqCqKml1Hi5rslrCA1bAL6EiseHwSzRQSkJa59v swIYjMLlEs8mdcH1issECox71opiMkioCqx7LE6SAWvgJ3E1+8PWCE2yUvsarsIZnMCxV/8PQ B2gZCArcSEXysYJzDyLmBkWMWoUZxaVJZapGtooZdUlJmeUZKbmJmja2hgppebWlycmJ6ak5h UrJecn7uJERgKDECwg/HmxoBDjJIcTEqivI3+/pFCfEn5KZUZicUZ8UWlOanFhxhlODiUJHjP nQ+IFBIsSk1PrUjLzAEGJUxagoNHSYT3wlmgNG9xQWJucWY6ROoUoy5HR8+GL0xCLHn5ealS4 ryzQGYIgBRllObBjYBFyCVGWSlhXkago4R4ClKLcjNLUOVfMYpzMCoJ87aDTOHJzCuB2/QK6A gmoCNY5oEdUZKIkJJqYGQ78O3bvinCO81FXJas4S/MMr+3xTv/1FfJo+JLFwtLNRwNlPExX8A va6MpNyk74fXHnmzeE6G1gk7Hegvc1ywrYI/MO8HnvEY27XuyslLXw84lavx/mC8+e1p/79ti y9r58ezCG7hPPIhc8Cyk9Y57/6/JbuI3tvLfmrS6kLXp+E2OzwcNryuxFGckGmoxFxUnAgBp+ 8TWiwIAAA== X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-9.tower-21.messagelabs.com!1498468609!75505562!10 X-Originating-IP: [192.55.52.93] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTkyLjU1LjUyLjkzID0+IDMyNDY2NQ==\n X-StarScan-Received: X-StarScan-Version: 9.4.19; banners=-,-,- X-VirusChecked: Checked Received: (qmail 2621 invoked from network); 26 Jun 2017 09:17:06 -0000 Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by server-9.tower-21.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 26 Jun 2017 09:17:06 -0000 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jun 2017 02:17:05 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,395,1493708400"; d="scan'208";a="985230049" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.142]) by orsmga003.jf.intel.com with ESMTP; 26 Jun 2017 02:17:04 -0700 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Mon, 26 Jun 2017 17:16:24 +0800 Message-Id: <20170626091625.19655-11-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170626091625.19655-1-haozhong.zhang@intel.com> References: <20170626091625.19655-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Ian Jackson , Wei Liu Subject: [Xen-devel] [PATCH v4 10/11] tools/libxc: add support of injecting MC# to specified CPUs 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 Though XEN_MC_inject_v2 allows injecting MC# to specified CPUs, the current xc_mca_op() does not use this feature and not provide an interface to callers. This commit add a new xc_mca_op_inject_v2() that receives a cpumap providing the set of target CPUs. Signed-off-by: Haozhong Zhang Acked-by: Wei Liu --- Cc: Ian Jackson Cc: Wei Liu --- tools/libxc/include/xenctrl.h | 2 ++ tools/libxc/xc_misc.c | 52 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/tools/libxc/include/xenctrl.h b/tools/libxc/include/xenctrl.h index 1629f412dd..85169b0553 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -1799,6 +1799,8 @@ int xc_cpuid_apply_policy(xc_interface *xch, void xc_cpuid_to_str(const unsigned int *regs, char **strs); /* some strs[] may be NULL if ENOMEM */ int xc_mca_op(xc_interface *xch, struct xen_mc *mc); +int xc_mca_op_inject_v2(xc_interface *xch, unsigned int flags, + xc_cpumap_t cpumap, unsigned int nr_cpus); #endif struct xc_px_val { diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c index 88084fde30..2303293c6c 100644 --- a/tools/libxc/xc_misc.c +++ b/tools/libxc/xc_misc.c @@ -341,7 +341,57 @@ int xc_mca_op(xc_interface *xch, struct xen_mc *mc) xc_hypercall_bounce_post(xch, mc); return ret; } -#endif + +int xc_mca_op_inject_v2(xc_interface *xch, unsigned int flags, + xc_cpumap_t cpumap, unsigned int nr_bits) +{ + int ret = -1; + struct xen_mc mc_buf, *mc = &mc_buf; + struct xen_mc_inject_v2 *inject = &mc->u.mc_inject_v2; + + DECLARE_HYPERCALL_BOUNCE(cpumap, 0, XC_HYPERCALL_BUFFER_BOUNCE_IN); + DECLARE_HYPERCALL_BOUNCE(mc, sizeof(*mc), XC_HYPERCALL_BUFFER_BOUNCE_BOTH); + + memset(mc, 0, sizeof(*mc)); + + if ( cpumap ) + { + if ( !nr_bits ) + { + errno = EINVAL; + goto out; + } + + HYPERCALL_BOUNCE_SET_SIZE(cpumap, (nr_bits + 7) / 8); + if ( xc_hypercall_bounce_pre(xch, cpumap) ) + { + PERROR("Could not bounce cpumap memory buffer"); + goto out; + } + set_xen_guest_handle(inject->cpumap.bitmap, cpumap); + inject->cpumap.nr_bits = nr_bits; + } + + inject->flags = flags; + mc->cmd = XEN_MC_inject_v2; + mc->interface_version = XEN_MCA_INTERFACE_VERSION; + + if ( xc_hypercall_bounce_pre(xch, mc) ) + { + PERROR("Could not bounce xen_mc memory buffer"); + goto out_free_cpumap; + } + + ret = xencall1(xch->xcall, __HYPERVISOR_mca, HYPERCALL_BUFFER_AS_ARG(mc)); + + xc_hypercall_bounce_post(xch, mc); +out_free_cpumap: + if ( cpumap ) + xc_hypercall_bounce_post(xch, cpumap); +out: + return ret; +} +#endif /* __i386__ || __x86_64__ */ int xc_perfc_reset(xc_interface *xch) {