From patchwork Mon Jul 10 02:52:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9832231 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 9887860318 for ; Mon, 10 Jul 2017 02:55:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A383522B39 for ; Mon, 10 Jul 2017 02:55:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9811226E76; Mon, 10 Jul 2017 02:55:14 +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 4049622B39 for ; Mon, 10 Jul 2017 02:55:14 +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 1dUOoR-0002qj-BG; Mon, 10 Jul 2017 02:52:39 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dUOoP-0002oB-NW for xen-devel@lists.xen.org; Mon, 10 Jul 2017 02:52:37 +0000 Received: from [85.158.139.211] by server-10.bemta-5.messagelabs.com id EE/5A-01732-5FBE2695; Mon, 10 Jul 2017 02:52:37 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPLMWRWlGSWpSXmKPExsVywNwkVvfL66R Igw9tZhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8ali82sBTvFK9YcfMncwHhKqIuRi0NIYBqj ROPxX6xdjJwcEgK8EkeWzQCyOYBsf4l7U9gganoZJR7O6GQGqWET0JdY8fggWL2IgLTEtc+XG UFsZoFyiSfz+sDiwgLBEte+zGACsVkEVCVW3fgENpNXwFbi6AlPiFXyErvaLoKVcwrYSZx5OY ENxBYCKtnZtIltAiPvAkaGVYwaxalFZalFuoYGeklFmekZJbmJmTlAnqlebmpxcWJ6ak5iUrF ecn7uJkZgMDAAwQ7GNVOdDzFKcjApifKK9SZECvEl5adUZiQWZ8QXleakFh9ilOHgUJLgTXyV FCkkWJSanlqRlpkDDEuYtAQHj5IIr95JoDRvcUFibnFmOkTqFKMxR0fPhi9MHK8m/P/GJMSSl 5+XKiXOKwEMeCEBkNKM0jy4QbB4ucQoKyXMywh0mhBPQWpRbmYJqvwrRnEORiVh3uIXQFN4Mv NK4Pa9AjqFCegUtroEkFNKEhFSUg2MEscCLKde82pLdwz2SzLX7uqqYvidur5azHPZ003Lfbd emp5Wf8JnilnNqyc5F93WX49/0ZKVv/WNYsXTJ0EzOv58+GgaMnfyEbt3jgcVTPwUuJn8jT+c ulw439/A+tMp0fs6D006O7ddeTznsM5KXgbODeLs4r76t243vV2eHDxb+xzXlcnJSizFGYmGW sxFxYkAuFNSxpICAAA= X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-12.tower-206.messagelabs.com!1499655147!65819316!6 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.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 8375 invoked from network); 10 Jul 2017 02:52:36 -0000 Received: from mga11.intel.com (HELO mga11.intel.com) (192.55.52.93) by server-12.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 10 Jul 2017 02:52:36 -0000 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Jul 2017 19:52:36 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,337,1496127600"; d="scan'208";a="109361576" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.142]) by orsmga002.jf.intel.com with ESMTP; 09 Jul 2017 19:52:34 -0700 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Mon, 10 Jul 2017 10:52:14 +0800 Message-Id: <20170710025215.22143-7-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170710025215.22143-1-haozhong.zhang@intel.com> References: <20170710025215.22143-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Ian Jackson , Wei Liu Subject: [Xen-devel] [PATCH v8 6/7] 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 c51bb3b448..552a4fd47d 100644 --- a/tools/libxc/include/xenctrl.h +++ b/tools/libxc/include/xenctrl.h @@ -1809,6 +1809,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) {