From patchwork Mon Feb 27 05:09:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haozhong Zhang X-Patchwork-Id: 9592687 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 3742060574 for ; Mon, 27 Feb 2017 05:12:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29CC927FB1 for ; Mon, 27 Feb 2017 05:12:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1B48128389; Mon, 27 Feb 2017 05:12:36 +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 5E46427FB1 for ; Mon, 27 Feb 2017 05:12:34 +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 1ciDZX-0006WW-9W; Mon, 27 Feb 2017 05:10:07 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ciDZW-0006Ej-5p for xen-devel@lists.xen.org; Mon, 27 Feb 2017 05:10:06 +0000 Received: from [85.158.137.68] by server-6.bemta-3.messagelabs.com id 08/E5-08534-DA4B3B85; Mon, 27 Feb 2017 05:10:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrOLMWRWlGSWpSXmKPExsXS1taRort2y+Y IgyndEhZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8arrfcYC9YKVLx5JNTA+JKni5GTQ0igUuL2 m6+MILaEAK/EkWUzWCHsAIlVzbeAbC6gml5GiQVbX7GDJNgE9CVWPD4IViQiIC1x7fNlsGZmg XKJJ/P6gOIcHMICLhKr9/KChFkEVCV2zngFVsIrYCvRef01G8R8eYkLV0+xgNicAnYSt860Mo O0CgHVrP4uMoGRdwEjwypGjeLUorLUIl0jE72kosz0jJLcxMwcXUMDY73c1OLixPTUnMSkYr3 k/NxNjMBAqGdgYNzB+Oq43yFGSQ4mJVHeRcYbI4T4kvJTKjMSizPii0pzUosPMcpwcChJ8PZv 3hwhJFiUmp5akZaZAwxJmLQEB4+SCO/+TUBp3uKCxNzizHSI1ClGXY45s3e/YRJiycvPS5US5 60GmSEAUpRRmgc3AhYflxhlpYR5GRkYGIR4ClKLcjNLUOVfMYpzMCoJ81aATOHJzCuB2/QK6A gmoCNmg9zPW1ySiJCSamAsFrypZnjpyXbzLLdKhdWWU+bu+vek13FHV4nJGbmZ9pMO1/k7p2w 8Mv/K/V5bE/7KOdrbMufP267NferWlSfKTBObzp6eIczuuMlD9k3l0nSnqgmixWbueyV5c6fF Xs4+fcd7HmdIo78VX6zIvwv7Hkz87N/pMydKalP0sz3HK1OmLjC9/1ZDiaU4I9FQi7moOBEAS vRv54oCAAA= X-Env-Sender: haozhong.zhang@intel.com X-Msg-Ref: server-4.tower-31.messagelabs.com!1488172192!29448017!7 X-Originating-IP: [134.134.136.100] 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 25523 invoked from network); 27 Feb 2017 05:10:05 -0000 Received: from mga07.intel.com (HELO mga07.intel.com) (134.134.136.100) by server-4.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 27 Feb 2017 05:10:05 -0000 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP; 26 Feb 2017 21:10:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos; i="5.35,212,1484035200"; d="scan'208"; a="1115945564" Received: from hz-desktop.sh.intel.com (HELO localhost) ([10.239.159.133]) by fmsmga001.fm.intel.com with ESMTP; 26 Feb 2017 21:10:02 -0800 From: Haozhong Zhang To: xen-devel@lists.xen.org Date: Mon, 27 Feb 2017 13:09:12 +0800 Message-Id: <20170227050912.28824-8-haozhong.zhang@intel.com> X-Mailer: git-send-email 2.10.1 In-Reply-To: <20170227050912.28824-1-haozhong.zhang@intel.com> References: <20170227050912.28824-1-haozhong.zhang@intel.com> Cc: Haozhong Zhang , Ian Jackson , Wei Liu Subject: [Xen-devel] [PATCH v2 7/7] 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 "unsigned int" rather than "int" to align to the type "uint32_t" of xen_mc_physcpuinfo.ncpus. Signed-off-by: Haozhong Zhang Acked-by: Wei Liu --- Cc: Ian Jackson Cc: Wei Liu --- tools/tests/mce-test/tools/xen-mceinj.c | 12 +++++++----- 1 file changed, 7 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..bae5a46 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 unsigned int mca_cpuinfo(xc_interface *xc_handle) { struct xen_mc mc; @@ -176,16 +176,18 @@ 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, unsigned int cpu_nr) { struct xen_mc mc; - int nr_cpus; + unsigned int 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 %u is larger than %u", cpu_nr, nr_cpus - 1); mc.cmd = XEN_MC_inject_v2; mc.interface_version = XEN_MCA_INTERFACE_VERSION; @@ -420,7 +422,7 @@ int main(int argc, char *argv[]) int c, opt_index; uint32_t domid; xc_interface *xc_handle; - int cpu_nr; + unsigned int cpu_nr; uint64_t gaddr, max_gpa; /* Default Value */ @@ -444,7 +446,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;