From patchwork Mon Sep 11 14:07:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wei Liu X-Patchwork-Id: 9947449 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 E7B57603F3 for ; Mon, 11 Sep 2017 14:10:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE00328BFC for ; Mon, 11 Sep 2017 14:10:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D20CC28BFF; Mon, 11 Sep 2017 14:10:34 +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 6BE0528BFC for ; Mon, 11 Sep 2017 14:10: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 1drPNf-0003ld-9b; Mon, 11 Sep 2017 14:08:07 +0000 Received: from mail6.bemta5.messagelabs.com ([195.245.231.135]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1drPNe-0003lX-Lq for xen-devel@lists.xenproject.org; Mon, 11 Sep 2017 14:08:06 +0000 Received: from [85.158.139.211] by server-13.bemta-5.messagelabs.com id 21/F5-01754-5C896B95; Mon, 11 Sep 2017 14:08:05 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrPLMWRWlGSWpSXmKPExsXitHRDpO7RGds iDfoWK1l83zKZyYHR4/CHKywBjFGsmXlJ+RUJrBnr77WxFJxjr9i2+S5zA+Mcti5GTg4JAX+J uycPM4LYbALKEj87e8HiIgJ6Ek0HnoPFmQXyJB6vagWLCwv4SSw9284KYrMIqEq8fLWdHcTmF bCQOHH2CiPETHmJXW0XwWqEBBQkOqYfY4KoEZQ4OfMJC8RMCYmDL14wT2DknoUkNQtJagEj0y pGjeLUorLUIl0jS72kosz0jJLcxMwcXUMDU73c1OLixPTUnMSkYr3k/NxNjMBgqGdgYNzBeHm L3yFGSQ4mJVHed8e3RArxJeWnVGYkFmfEF5XmpBYfYpTh4FCS4H00fVukkGBRanpqRVpmDjAs YdISHDxKIrxbQNK8xQWJucWZ6RCpU4zGHDceXv/DxNFx8+4fJiGWvPy8VClx3icgpQIgpRmle XCDYPFyiVFWSpiXkYGBQYinILUoN7MEVf4VozgHo5Iwby3IFJ7MvBK4fa+ATmECOoXn0haQU0 oSEVJSDYxR69busui4ufmubv6enb3G1Vc+PGXx7VilsvNL8W1Le9858fPrfbvuG17+/nbGg+I DbOzhbN9PRbZkT9vqGH2h0TmBT+tl2aaopta0spivTQv3z5l54GY8x4S1U9ccnnNNe2IAE9P0 5GfxUxlq55v3SoktOVvA1130zHZfgINcZ5hGoYlljpcSS3FGoqEWc1FxIgCUpVnUkgIAAA== X-Env-Sender: prvs=4209e1772=wei.liu2@citrix.com X-Msg-Ref: server-5.tower-206.messagelabs.com!1505138883!109356278!1 X-Originating-IP: [66.165.176.89] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni44OSA9PiAyMDMwMDc=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 9.4.45; banners=-,-,- X-VirusChecked: Checked Received: (qmail 9073 invoked from network); 11 Sep 2017 14:08:05 -0000 Received: from smtp.citrix.com (HELO SMTP.CITRIX.COM) (66.165.176.89) by server-5.tower-206.messagelabs.com with RC4-SHA encrypted SMTP; 11 Sep 2017 14:08:05 -0000 X-IronPort-AV: E=Sophos;i="5.42,378,1500940800"; d="scan'208";a="439268492" From: Wei Liu To: Xen-devel Date: Mon, 11 Sep 2017 15:07:53 +0100 Message-ID: <20170911140753.19067-1-wei.liu2@citrix.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 Cc: Andrew Cooper , Wei Liu , Jan Beulich Subject: [Xen-devel] [PATCH] hvmloader: cast to avoid potential overflow in shadow_gs_test 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: , Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP e2fc5bb5cb4 ("hvmloader: dynamically determine scratch memory range for tests") makes the test dependent on _end. Coverity reported that the shift might overflow and suggested we cast i to uint64_t. Coverity-ID: 1417660 Signed-off-by: Wei Liu --- Cc: Jan Beulich Cc: Andrew Cooper --- tools/firmware/hvmloader/tests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/firmware/hvmloader/tests.c b/tools/firmware/hvmloader/tests.c index a70c72dffb..3c4c29a6c7 100644 --- a/tools/firmware/hvmloader/tests.c +++ b/tools/firmware/hvmloader/tests.c @@ -231,7 +231,7 @@ static int shadow_gs_test(void) pd += 512; /* Level 2: */ for ( i = 0; i <= (unsigned long)(_end - 1) >> (PAGE_SHIFT + 9); i++ ) - *pd++ = (i << (PAGE_SHIFT + 9)) + 0x1e3; + *pd++ = ((uint64_t)i << (PAGE_SHIFT + 9)) + 0x1e3; asm volatile ( /* CR4.PAE=1 */