From patchwork Wed Nov 13 13:15:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 21486 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-yh0-f70.google.com (mail-yh0-f70.google.com [209.85.213.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E0DC723FBD for ; Wed, 13 Nov 2013 13:15:34 +0000 (UTC) Received: by mail-yh0-f70.google.com with SMTP id c41sf681708yho.1 for ; Wed, 13 Nov 2013 05:15:34 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=RFLccaLYJL9dxGkIDfnDp61auIHOwObd+FZi7VRxrmE=; b=ANdjXtKLl9QtcJnFUlPZ3uu/beZFWsug/EXtYbsTbN8Jn7KEP/IrDHvypaeAAg5ZHy 0RLPgGKR4Ozjk85BIl45y0PInFmHmeTRSqgl6xHyuVT+o0etfwFh3AJin3KIsdtAes66 TQ/xwqjQ0mjorccf+iU///Xu+xqL32EgSi/suEe5dt5BxwNGwhnfkhAG2fSxgStHJxxR R0wmwS6TeuZV1imQmzDmWI6+G15i8JZmu5dglze9p0KIAcPR6sO0QKc2rhooVoXpvaSy fLbrZUBty7/y4KcX09z2cBkjEcyUNnlMU9eclchq8gMia5PG/m38vP0Xm3Y1QlHqQwHX slHg== X-Gm-Message-State: ALoCoQmVQAbn9I7U1e5F0AXgAlpky7+Cw+ggACHap9aeC3ywFTN7r9wJXrIStfoQ+qDpeUx04W3N X-Received: by 10.58.237.102 with SMTP id vb6mr13766003vec.31.1384348534176; Wed, 13 Nov 2013 05:15:34 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.38.105 with SMTP id f9ls305769qek.81.gmail; Wed, 13 Nov 2013 05:15:34 -0800 (PST) X-Received: by 10.221.47.193 with SMTP id ut1mr34266211vcb.8.1384348533969; Wed, 13 Nov 2013 05:15:33 -0800 (PST) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id st7si14477143vdc.81.2013.11.13.05.15.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Nov 2013 05:15:33 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id ib11so253520vcb.39 for ; Wed, 13 Nov 2013 05:15:33 -0800 (PST) X-Received: by 10.220.11.7 with SMTP id r7mr34353152vcr.12.1384348533843; Wed, 13 Nov 2013 05:15:33 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp237798vcz; Wed, 13 Nov 2013 05:15:33 -0800 (PST) X-Received: by 10.205.74.69 with SMTP id yv5mr1392144bkb.35.1384348532976; Wed, 13 Nov 2013 05:15:32 -0800 (PST) Received: from mail-bk0-f45.google.com (mail-bk0-f45.google.com [209.85.214.45]) by mx.google.com with ESMTPS id of10si5293037bkb.85.2013.11.13.05.15.32 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Nov 2013 05:15:32 -0800 (PST) Received-SPF: neutral (google.com: 209.85.214.45 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=209.85.214.45; Received: by mail-bk0-f45.google.com with SMTP id r7so328247bkg.18 for ; Wed, 13 Nov 2013 05:15:32 -0800 (PST) X-Received: by 10.204.233.129 with SMTP id jy1mr20887699bkb.27.1384348532076; Wed, 13 Nov 2013 05:15:32 -0800 (PST) Received: from localhost.localdomain (cpc8-cmbg15-2-0-cust169.5-4.cable.virginm.net. [86.30.140.170]) by mx.google.com with ESMTPSA id t2sm22780615bkh.3.2013.11.13.05.15.30 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2013 05:15:31 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Cc: ian.campbell@citrix.com, tim@xen.org, patches@linaro.org, stefano.stabellini@eu.citrix.com, Julien Grall , Keir Fraser , Jan Beulich Subject: [PATCH V2] xen: Check if the range is valid in init_domheap_pages Date: Wed, 13 Nov 2013 13:15:25 +0000 Message-Id: <1384348525-3230-1-git-send-email-julien.grall@linaro.org> X-Mailer: git-send-email 1.8.3.1 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , On ARM, when an initrd is given to xen by U-boot, it will reserve the memory in the device tree. In this case, when xen decides to free unused memory, dt_unreserved_regions will call init_domheap_pages with the start and the end of range equals. But the latter assumes that (start > end), if not Xen will hang because the number of pages is equals to (unsigned)-1. Signed-off-by: Julien Grall CC: Keir Fraser CC: Jan Beulich --- Changes in v2: - Change commit title - Move the check in init_domheap_pages --- xen/common/page_alloc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 4c17fbd..10f67a1 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -1429,6 +1429,9 @@ void init_domheap_pages(paddr_t ps, paddr_t pe) smfn = round_pgup(ps) >> PAGE_SHIFT; emfn = round_pgdown(pe) >> PAGE_SHIFT; + if ( smfn <= emfn ) + return; + init_heap_pages(mfn_to_page(smfn), emfn - smfn); }