From patchwork Mon Feb 8 14:23:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SsO8cmdlbiBHcm/Dnw==?= X-Patchwork-Id: 8250111 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 3AC76BEEE5 for ; Mon, 8 Feb 2016 14:26:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 6A5EE200F4 for ; Mon, 8 Feb 2016 14:26:51 +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 5A474200E9 for ; Mon, 8 Feb 2016 14:26:50 +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 1aSmjP-0002ZG-Bp; Mon, 08 Feb 2016 14:23:59 +0000 Received: from mail6.bemta4.messagelabs.com ([85.158.143.247]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1aSmjO-0002ZB-FQ for xen-devel@lists.xen.org; Mon, 08 Feb 2016 14:23:58 +0000 Received: from [85.158.143.35] by server-1.bemta-4.messagelabs.com id E8/2B-09708-DF4A8B65; Mon, 08 Feb 2016 14:23:57 +0000 X-Env-Sender: jgross@suse.com X-Msg-Ref: server-7.tower-21.messagelabs.com!1454941436!14722292!1 X-Originating-IP: [195.135.220.15] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 7.35.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 48946 invoked from network); 8 Feb 2016 14:23:57 -0000 Received: from mx2.suse.de (HELO mx2.suse.de) (195.135.220.15) by server-7.tower-21.messagelabs.com with DHE-RSA-CAMELLIA256-SHA encrypted SMTP; 8 Feb 2016 14:23:57 -0000 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 60803AB02; Mon, 8 Feb 2016 14:23:55 +0000 (UTC) From: Juergen Gross To: xen-devel@lists.xen.org, Ian.Campbell@citrix.com, ian.jackson@eu.citrix.com, stefano.stabellini@eu.citrix.com, wei.liu2@citrix.com, anthony.perard@citrix.com Date: Mon, 8 Feb 2016 15:23:52 +0100 Message-Id: <1454941432-24262-1-git-send-email-jgross@suse.com> X-Mailer: git-send-email 2.6.2 Cc: Juergen Gross Subject: [Xen-devel] [PATCH] libxc: correct memory range check in domain builder 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: , MIME-Version: 1.0 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 Commit 81a76e4b12961a9f54f5021809074196dfe6dbba ("libxc: rework of domain builder's page table handler") introduced a regression with checking the required memory size of the domain. The needed maximum pfn of the initial kernel mapping was added to the currently last used pfn resulting in doubling the estimated memory need. Correct the calculation of the last needed pfn to enable booting of small domains again. Reported-by: Anthony Perard Signed-off-by: Juergen Gross Tested-by: Anthony PERARD --- tools/libxc/xc_dom_x86.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/libxc/xc_dom_x86.c b/tools/libxc/xc_dom_x86.c index 2a3f64b..ac4dae5 100644 --- a/tools/libxc/xc_dom_x86.c +++ b/tools/libxc/xc_dom_x86.c @@ -164,7 +164,7 @@ static int count_pgtables(struct xc_dom_image *dom, xen_vaddr_t from, for ( l = domx86->params->levels - 1; l >= 0; l-- ) { - map->lvls[l].pfn = pfn + map->area.pgtables; + map->lvls[l].pfn = dom->pfn_alloc_end + map->area.pgtables; if ( l == domx86->params->levels - 1 ) { /* Top level page table in first mapping only. */ @@ -238,8 +238,7 @@ static int alloc_pgtables(struct xc_dom_image *dom) try_virt_end = round_up(dom->virt_alloc_end + pages * PAGE_SIZE_X86, bits_to_mask(22)); /* 4MB alignment */ - if ( count_pgtables(dom, dom->parms.virt_base, try_virt_end, - dom->pfn_alloc_end) ) + if ( count_pgtables(dom, dom->parms.virt_base, try_virt_end, 0) ) return -1; pages = map->area.pgtables + extra_pages;