From patchwork Fri Feb 17 06:39:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9578869 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 69073600C5 for ; Fri, 17 Feb 2017 06:43:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A4E42869B for ; Fri, 17 Feb 2017 06:43:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F4D4286A4; Fri, 17 Feb 2017 06:43:11 +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 F15642869B for ; Fri, 17 Feb 2017 06:43:10 +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 1cecDx-0002ZI-JY; Fri, 17 Feb 2017 06:40:57 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cecDx-0002Sm-6K for xen-devel@lists.xen.org; Fri, 17 Feb 2017 06:40:57 +0000 Received: from [193.109.254.147] by server-3.bemta-6.messagelabs.com id 3D/ED-13524-8FA96A85; Fri, 17 Feb 2017 06:40:56 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrFLMWRWlGSWpSXmKPExsVywNykWPfHrGU RBpPf8Vos+biYxYHR4+ju30wBjFGsmXlJ+RUJrBnHrs9iLvjDX3Gv5wlbA+M2ni5GLg4hgWmM Ej8+zWPuYuTkkBDglTiybAYrhO0nsW7pTkaIol5GiUldE8GK2AT0JVY8PghWJCIgLXHt82VGE JtZoFziybw+sLiwgLNE45fXTCA2i4CqxLZj/8FqeAXsJL4+Ws4EsUBe4sLVUywgNidQ/M/DD+ wgtpCArcT7T/eYJzDyLmBkWMWoXpxaVJZapGuil1SUmZ5RkpuYmaNraGCml5taXJyYnpqTmFS sl5yfu4kRGA4MQLCDsfuy/yFGSQ4mJVHeRdOWRQjxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4OUG hpeQYFFqempFWmYOMDBh0hIcPEoivBwgad7igsTc4sx0iNQpRl2OUzdOv2QSYsnLz0uVEue9M ROoSACkKKM0D24ELEouMcpKCfMyAh0lxFOQWpSbWYIq/4pRnINRSZj3AsgUnsy8ErhNr4COYA I6ojNiKcgRJYkIKakGRrMDBm9LYiuXyaTM4NtxRPy5vS3nldRlfSkr3k/W1nGxfvXUJOrqNZt 1e1WlPvZsKd1e2y673CX86YwG5YknY0Tfca7adal0EStv70+P9MuvVJdfn2VaIBF3Z5dVV+MC DrY9sXnx30T+zmy+v7L6PgM/c5evT29AyEWx0PSUJINC/UN/prx+rMRSnJFoqMVcVJwIAGzA8 gaNAgAA X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-15.tower-27.messagelabs.com!1487313633!34675007!11 X-Originating-IP: [192.55.52.115] 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 33452 invoked from network); 17 Feb 2017 06:40:55 -0000 Received: from mga14.intel.com (HELO mga14.intel.com) (192.55.52.115) by server-15.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 17 Feb 2017 06:40:55 -0000 Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Feb 2017 22:40:55 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.35,171,1484035200"; d="scan'208";a="65781549" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.133]) by orsmga005.jf.intel.com with ESMTP; 16 Feb 2017 22:40:54 -0800 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Fri, 17 Feb 2017 14:39:28 +0800 Message-Id: <20170217063936.13208-12-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170217063936.13208-1-haozhong.zhang@intel.com> References: <20170217063936.13208-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Ian Jackson , Wei Liu Subject: [Xen-devel] [PATCH 11/19] tools/xen-mceinj: fix the type of cpu number 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 Use uint32_t rather than int to align to the type of xen_mc_physcpuinfo.ncpus. Signed-off-by: Haozhong Zhang --- Cc: Ian Jackson Cc: Wei Liu --- tools/tests/mce-test/tools/xen-mceinj.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/tests/mce-test/tools/xen-mceinj.c b/tools/tests/mce-test/tools/xen-mceinj.c index 51abc8a..5f70a61 100644 --- a/tools/tests/mce-test/tools/xen-mceinj.c +++ b/tools/tests/mce-test/tools/xen-mceinj.c @@ -161,7 +161,7 @@ static int flush_msr_inj(xc_interface *xc_handle) return xc_mca_op(xc_handle, &mc); } -static int mca_cpuinfo(xc_interface *xc_handle) +static uint32_t mca_cpuinfo(xc_interface *xc_handle) { struct xen_mc mc; @@ -176,16 +176,19 @@ static int mca_cpuinfo(xc_interface *xc_handle) return 0; } -static int inject_cmci(xc_interface *xc_handle, int cpu_nr) +static int inject_cmci(xc_interface *xc_handle, uint32_t cpu_nr) { struct xen_mc mc; - int nr_cpus; + uint32_t nr_cpus; memset(&mc, 0, sizeof(struct xen_mc)); nr_cpus = mca_cpuinfo(xc_handle); if (!nr_cpus) err(xc_handle, "Failed to get mca_cpuinfo"); + if (cpu_nr >= nr_cpus) + err(xc_handle, "-c %"PRIu32" is larger than %"PRIu32, + cpu_nr, nr_cpus - 1); mc.cmd = XEN_MC_inject_v2; mc.interface_version = XEN_MCA_INTERFACE_VERSION; @@ -420,7 +423,7 @@ int main(int argc, char *argv[]) int c, opt_index; uint32_t domid; xc_interface *xc_handle; - int cpu_nr; + uint32_t cpu_nr; uint64_t gaddr, max_gpa; /* Default Value */ @@ -444,7 +447,7 @@ int main(int argc, char *argv[]) dump=1; break; case 'c': - cpu_nr = strtol(optarg, &optarg, 10); + cpu_nr = strtoul(optarg, &optarg, 10); if ( strlen(optarg) != 0 ) err(xc_handle, "Please input a digit parameter for CPU"); break;