All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stewart Hildebrand <stewart.hildebrand@amd.com>
To: <xen-devel@lists.xenproject.org>
Cc: Stewart Hildebrand <stewart.hildebrand@amd.com>,
	Stefano Stabellini <sstabellini@kernel.org>,
	Julien Grall <julien@xen.org>,
	Bertrand Marquis <bertrand.marquis@arm.com>,
	Michal Orzel <michal.orzel@amd.com>,
	"Volodymyr Babchuk" <Volodymyr_Babchuk@epam.com>,
	Ayan Kumar Halder <ayan.kumar.halder@amd.com>
Subject: [PATCH v2 1/6] xen/arm: fix math in add_ext_regions
Date: Thu, 8 May 2025 09:20:30 -0400	[thread overview]
Message-ID: <20250508132040.532898-2-stewart.hildebrand@amd.com> (raw)
In-Reply-To: <20250508132040.532898-1-stewart.hildebrand@amd.com>

In commit f37a59813979, the arguments to add_ext_regions() were switched
from addresses to frame numbers. add_ext_regions() converts the frame
numbers back to addresses, but the end address (e) is rounded down to
page size alignment. The logic to calculate the size assumes e points to
the last address, not page, effectively leading to the region size being
erroneously calculated to be 2M smaller than the actual size of the
region.

Fix by adding 1 to the frame number before converting back to address.

Fixes: f37a59813979 ("xen/arm: domain_build: Track unallocated pages using the frame number")
Signed-off-by: Stewart Hildebrand <stewart.hildebrand@amd.com>
Acked-by: Michal Orzel <michal.orzel@amd.com>
---
v1->v2:
* add Michal's A-b
---
 xen/arch/arm/domain_build.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/arch/arm/domain_build.c b/xen/arch/arm/domain_build.c
index df29619c4007..2f2b021dec3e 100644
--- a/xen/arch/arm/domain_build.c
+++ b/xen/arch/arm/domain_build.c
@@ -761,7 +761,7 @@ int __init add_ext_regions(unsigned long s_gfn, unsigned long e_gfn,
     struct membanks *ext_regions = data;
     paddr_t start, size;
     paddr_t s = pfn_to_paddr(s_gfn);
-    paddr_t e = pfn_to_paddr(e_gfn);
+    paddr_t e = pfn_to_paddr(e_gfn + 1) - 1;
 
     if ( ext_regions->nr_banks >= ext_regions->max_banks )
         return 0;
-- 
2.49.0



  reply	other threads:[~2025-05-08 13:21 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-08 13:20 [PATCH v2 0/6] arm: extended regions fixes Stewart Hildebrand
2025-05-08 13:20 ` Stewart Hildebrand [this message]
2025-05-14  7:47   ` [PATCH v2 1/6] xen/arm: fix math in add_ext_regions Julien Grall
2025-05-08 13:20 ` [PATCH v2 2/6] xen/arm: fix math in add_hwdom_free_regions Stewart Hildebrand
2025-05-08 13:20 ` [PATCH v2 3/6] xen/arm: switch find_domU_holes to rangesets Stewart Hildebrand
2025-05-08 13:20 ` [PATCH v2 4/6] rangeset: introduce rangeset_subtract Stewart Hildebrand
2025-05-08 23:42   ` Stefano Stabellini
2025-05-13 15:39   ` Jan Beulich
2025-05-13 17:01     ` Stewart Hildebrand
2025-05-14  6:15       ` Jan Beulich
2025-05-15  8:52   ` Roger Pau Monné
2025-05-08 13:20 ` [PATCH v2 5/6] xen/arm: exclude xen,reg from domU extended regions Stewart Hildebrand
2025-05-08 23:39   ` Stefano Stabellini
2025-05-09  6:54   ` Orzel, Michal
2025-05-12 19:55     ` Stewart Hildebrand
2025-05-13  6:39       ` Orzel, Michal
2025-05-08 13:20 ` [PATCH v2 6/6] tools/arm: exclude iomem " Stewart Hildebrand
2025-05-30  0:31   ` Stefano Stabellini
2025-06-03  0:38   ` Stefano Stabellini
2025-06-03  6:33     ` Orzel, Michal
2025-06-03 18:12       ` Stefano Stabellini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250508132040.532898-2-stewart.hildebrand@amd.com \
    --to=stewart.hildebrand@amd.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=ayan.kumar.halder@amd.com \
    --cc=bertrand.marquis@arm.com \
    --cc=julien@xen.org \
    --cc=michal.orzel@amd.com \
    --cc=sstabellini@kernel.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.