From: Julien Grall <julien@xen.org>
To: Stewart Hildebrand <stewart.hildebrand@amd.com>,
xen-devel@lists.xenproject.org
Cc: Stefano Stabellini <sstabellini@kernel.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: Re: [PATCH v2 1/6] xen/arm: fix math in add_ext_regions
Date: Wed, 14 May 2025 08:47:11 +0100 [thread overview]
Message-ID: <73d064d2-1358-4e5d-9d7d-740a22a711ba@xen.org> (raw)
In-Reply-To: <20250508132040.532898-2-stewart.hildebrand@amd.com>
Hi Stewart,
On 08/05/2025 14:20, Stewart Hildebrand wrote:
> 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;
I noticed this patch. While reading the function, I noticed this would
result to some confusing code:
if ( start > e )
return 0;
[...]
/*
* e is actually "end-1" because it is called by rangeset functions
* which are inclusive of the last address.
*/
e += 1;
size = (e - start) & ~(SZ_2M - 1);
So substract 1, but then re-add after. Is there any reason we didn't
adjust the rest of the code?
Cheers,
--
Julien Grall
next prev parent reply other threads:[~2025-05-14 7:47 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 ` [PATCH v2 1/6] xen/arm: fix math in add_ext_regions Stewart Hildebrand
2025-05-14 7:47 ` Julien Grall [this message]
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=73d064d2-1358-4e5d-9d7d-740a22a711ba@xen.org \
--to=julien@xen.org \
--cc=Volodymyr_Babchuk@epam.com \
--cc=ayan.kumar.halder@amd.com \
--cc=bertrand.marquis@arm.com \
--cc=michal.orzel@amd.com \
--cc=sstabellini@kernel.org \
--cc=stewart.hildebrand@amd.com \
--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.