From patchwork Wed Feb 3 13:21:23 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Roger_Pau_Monn=C3=A9?= X-Patchwork-Id: 8202731 Return-Path: X-Original-To: patchwork-xen-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0EC33BEEE5 for ; Wed, 3 Feb 2016 13:23:46 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3C66B2027D for ; Wed, 3 Feb 2016 13:23:45 +0000 (UTC) Received: from lists.xen.org (lists.xenproject.org [50.57.142.19]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 64CF2201BB for ; Wed, 3 Feb 2016 13:23:44 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQxNG-0003Mc-9s; Wed, 03 Feb 2016 13:21:34 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aQxNE-0003MM-EV for xen-devel@lists.xenproject.org; Wed, 03 Feb 2016 13:21:32 +0000 Received: from [85.158.137.68] by server-11.bemta-3.messagelabs.com id 3D/4B-32641-BDEF1B65; Wed, 03 Feb 2016 13:21:31 +0000 X-Env-Sender: prvs=8342f37c0=roger.pau@citrix.com X-Msg-Ref: server-6.tower-31.messagelabs.com!1454505689!20067909!1 X-Originating-IP: [66.165.176.63] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogNjYuMTY1LjE3Ni42MyA9PiAzMDYwNDg=\n, received_headers: No Received headers X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 12320 invoked from network); 3 Feb 2016 13:21:30 -0000 Received: from smtp02.citrix.com (HELO SMTP02.CITRIX.COM) (66.165.176.63) by server-6.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 3 Feb 2016 13:21:30 -0000 X-IronPort-AV: E=Sophos;i="5.22,390,1449532800"; d="scan'208";a="335797665" From: Roger Pau Monne To: Date: Wed, 3 Feb 2016 14:21:23 +0100 Message-ID: <1454505683-2534-1-git-send-email-roger.pau@citrix.com> X-Mailer: git-send-email 2.5.4 (Apple Git-61) In-Reply-To: <1454496845.25207.59.camel@citrix.com> References: <1454496845.25207.59.camel@citrix.com> MIME-Version: 1.0 X-DLP: MIA2 Cc: Wei Liu , Roger Pau Monne , Ian Jackson , Ian Campbell , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= Subject: [Xen-devel] [PATCH v2] libxc: fix uninitialised usage of rc in meminit_hvm X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Roger Pau Monne Due to the HVMlite changes there's a chance that the value in rc is checked without being initialised. Fix this by initialising it to 0 prior to the while loop. Also add a specific error check to a previous populate_physmap call, this prevents us from overwriting this error. Signed-off-by: Roger Pau Monné Reported-by: Olaf Hering --- Cc: Ian Jackson Cc: Ian Campbell Cc: Wei Liu --- Changes since v1: - Only set rc = 0 prior to the while loop. - Add an error check to the previous populate_physmap call. --- tools/libxc/xc_dom_x86.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c index ef474a8..2a3f64b 100644 --- a/tools/libxc/xc_dom_x86.c +++ b/tools/libxc/xc_dom_x86.c @@ -1412,8 +1412,15 @@ static int meminit_hvm(struct xc_dom_image *dom) * ensure that we can be preempted and hence dom0 remains responsive. */ if ( dom->device_model ) + { rc = xc_domain_populate_physmap_exact( xch, domid, 0xa0, 0, memflags, &dom->p2m_host[0x00]); + if ( rc != 0 ) + { + DOMPRINTF("Could not populate low memory (< 0xA0).\n"); + goto error_out; + } + } stat_normal_pages = 0; for ( vmemid = 0; vmemid < nr_vmemranges; vmemid++ ) @@ -1440,6 +1447,7 @@ static int meminit_hvm(struct xc_dom_image *dom) else cur_pages = vmemranges[vmemid].start >> PAGE_SHIFT; + rc = 0; while ( (rc == 0) && (end_pages > cur_pages) ) { /* Clip count to maximum 1GB extent. */