From patchwork Mon Jul 3 03:46:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9821897 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 0E86D603FB for ; Mon, 3 Jul 2017 03:49:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EC7CE283C7 for ; Mon, 3 Jul 2017 03:49:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E12582851E; Mon, 3 Jul 2017 03:49:52 +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 7DCFB2851A for ; Mon, 3 Jul 2017 03:49:52 +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 1dRsKv-0006fA-C2; Mon, 03 Jul 2017 03:47:45 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1dRsKu-0006dt-KE for xen-devel@lists.xen.org; Mon, 03 Jul 2017 03:47:44 +0000 Received: from [85.158.139.211] by server-16.bemta-5.messagelabs.com id F6/14-01712-F5EB9595; Mon, 03 Jul 2017 03:47:43 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgkeJIrShJLcpLzFFi42I5YG5SrBu3LzL SoHuurMWSj4tZHBg9ju7+zRTAGMWamZeUX5HAmnFs8Rfmgp3iFccnPWBuYDwl1MXIxSEkMJ1R 4tSBXqYuRk4OCQFeiSPLZrBC2AESW2ZPYAOxhQR6GSX6L/GB2GwC+hIrHh8EqxERkJa49vkyI 4jNLFAu8WReH1hcWCBU4saRp2BxFgFViTPXFoPZvAK2Ej/apkDtkpfY1XYRrJ4TKH5z6k4miF 02Ensm/WOcwMi7gJFhFaNGcWpRWWqRrpGFXlJRZnpGSW5iZo6uoYGpXm5qcXFiempOYlKxXnJ +7iZGYDjUMzAw7mDsW+V3iFGSg0lJlHfltdBIIb6k/JTKjMTijPii0pzU4kOMMhwcShK8vHsj I4UEi1LTUyvSMnOAgQmTluDgURLhveYDlOYtLkjMLc5Mh0idYjTm6OjZ8IWJ49WE/9+YhFjy8 vNSpcR5xUAmCYCUZpTmwQ2CRcwlRlkpYV5GBgYGIZ6C1KLczBJU+VeM4hyMSsK8OnuApvBk5p XA7XsFdAoT0CkNPREgp5QkIqSkGhjZZjre33rCd/2fI5xcG1YqOXwPcK36LnjuTtPhunvKPif SW8xr6lrlJKe01ERMCeS+eH2bgjVry36Dv53evEvfNM76v/z9doeXC55aezLmR+d7xbKeYOGZ vvuJ6Pfzx5hLL0n4lkZ59rh/kWpiUzCfNvfnkwBPQ/lpqjIJekt8bLwauzU77ymxFGckGmoxF xUnAgBrTEzwkwIAAA== X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-6.tower-206.messagelabs.com!1499053645!100869672!10 X-Originating-IP: [192.55.52.115] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.4.25; banners=-,-,- X-VirusChecked: Checked Received: (qmail 27959 invoked from network); 3 Jul 2017 03:47:42 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-6.tower-206.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 3 Jul 2017 03:47:42 -0000 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Jul 2017 20:47:41 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.40,301,1496127600"; d="scan'208"; a="1189835681" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.142]) by fmsmga002.fm.intel.com with ESMTP; 02 Jul 2017 20:47:40 -0700 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Mon, 3 Jul 2017 11:46:25 +0800 Message-Id: <20170703034626.9429-11-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170703034626.9429-1-haozhong.zhang@intel.com> References: <20170703034626.9429-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Ian Jackson , Wei Liu Subject: [Xen-devel] [PATCH v5 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) {