From patchwork Wed Nov 13 13:37:50 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 21487 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vb0-f71.google.com (mail-vb0-f71.google.com [209.85.212.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 45156202E2 for ; Wed, 13 Nov 2013 13:37:56 +0000 (UTC) Received: by mail-vb0-f71.google.com with SMTP id f12sf686349vbg.2 for ; Wed, 13 Nov 2013 05:37:55 -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=yKaJUMKj0M7k8N4sZgpwz/iHu6S0bkgXkFkbCr7h6D4=; b=QTwN5rR5BIHst6sz5uPETckWUy+vUAnWeSEJDuDUISmVip9uawHtpQ0aBu4hFWE0Uv nnYl7kFGwKL8+jiS3MQk/C2S86RnCc74javIUCMcX/KyRRzc3/p5GEH56Fo4lYQW45+9 RQOzAmFZRfdtaJ5A9UomJot3jUCzEzhM/pKX4Rnk/f3Q/hFqE+50N1VJaH7IFAvGf/UT OnE5nrrNFnamBTlm1xQwTQJT+IlVgGo9/Ww00urAU5/quzEuJo9UKLW3h4ANZG6eL2QZ N+bAaDAkgnuzfVKDJ/qPayM4Ww6FqCfVipuPh0BKp2lLMuP3RBIKYB9ZG7uL5QE9+LFx upBw== X-Gm-Message-State: ALoCoQmmwTA93umdEzU8bq6u5mUMGL7eyN1OfGo3vcvoPeX2AFq1D1G9NY7Bb+zh7KU179p/mgJE X-Received: by 10.58.182.167 with SMTP id ef7mr14178184vec.15.1384349875868; Wed, 13 Nov 2013 05:37:55 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.120.199 with SMTP id le7ls530255qeb.91.gmail; Wed, 13 Nov 2013 05:37:55 -0800 (PST) X-Received: by 10.58.46.171 with SMTP id w11mr34648186vem.5.1384349875723; Wed, 13 Nov 2013 05:37:55 -0800 (PST) Received: from mail-ve0-f170.google.com (mail-ve0-f170.google.com [209.85.128.170]) by mx.google.com with ESMTPS id tq4si14536104vdc.12.2013.11.13.05.37.55 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Nov 2013 05:37:55 -0800 (PST) Received-SPF: neutral (google.com: 209.85.128.170 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.128.170; Received: by mail-ve0-f170.google.com with SMTP id db12so292173veb.29 for ; Wed, 13 Nov 2013 05:37:55 -0800 (PST) X-Received: by 10.52.111.161 with SMTP id ij1mr6097363vdb.33.1384349875503; Wed, 13 Nov 2013 05:37:55 -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 u4csp239408vcz; Wed, 13 Nov 2013 05:37:55 -0800 (PST) X-Received: by 10.194.171.34 with SMTP id ar2mr80543wjc.81.1384349874610; Wed, 13 Nov 2013 05:37:54 -0800 (PST) Received: from mail-we0-f174.google.com (mail-we0-f174.google.com [74.125.82.174]) by mx.google.com with ESMTPS id r20si327512wiw.19.2013.11.13.05.37.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 13 Nov 2013 05:37:54 -0800 (PST) Received-SPF: neutral (google.com: 74.125.82.174 is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=74.125.82.174; Received: by mail-we0-f174.google.com with SMTP id t61so419593wes.19 for ; Wed, 13 Nov 2013 05:37:54 -0800 (PST) X-Received: by 10.180.83.228 with SMTP id t4mr20727639wiy.12.1384349874025; Wed, 13 Nov 2013 05:37:54 -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 e1sm55273014wij.6.2013.11.13.05.37.52 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2013 05:37:53 -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 V3] xen: Check if the range is valid in init_domheap_pages Date: Wed, 13 Nov 2013 13:37:50 +0000 Message-Id: <1384349870-4256-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.128.170 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 Acked-by: Keir Fraser Acked-by: Keir Fraser --- Changes in v3: - Invert the check 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..0701333 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 ( emfn <= smfn ) + return; + init_heap_pages(mfn_to_page(smfn), emfn - smfn); }