From: Alejandro Vallejo <alejandro.vallejo@cloud.com>
To: Julien Grall <julien@xen.org>
Cc: Xen-devel <xen-devel@lists.xenproject.org>,
Stefano Stabellini <sstabellini@kernel.org>,
Bertrand Marquis <bertrand.marquis@arm.com>,
Volodymyr Babchuk <Volodymyr_Babchuk@epam.com>
Subject: Re: [PATCH 2/8] arm/mm: Document the differences between arm32 and arm64 directmaps
Date: Fri, 21 Jul 2023 16:09:02 +0100 [thread overview]
Message-ID: <64ba9f91.170a0220.bad4d.8728@mx.google.com> (raw)
In-Reply-To: <437849e6-08a3-8fac-a594-2003d5b94b41@xen.org>
Hi Julian,
On Thu, Jul 20, 2023 at 09:05:55PM +0100, Julien Grall wrote:
> Hi Alejandro,
>
> On 17/07/2023 17:03, Alejandro Vallejo wrote:
> > arm32 merely covers the XENHEAP, whereas arm64 currently covers anything in
> > the frame table. These comments highlight why arm32 doesn't need to account for PDX
> > compression in its __va() implementation while arm64 does.
> >
> > Signed-off-by: Alejandro Vallejo <alejandro.vallejo@cloud.com>
> > ---
> > xen/arch/arm/include/asm/mm.h | 27 +++++++++++++++++++++++++++
> > 1 file changed, 27 insertions(+)
> >
> > diff --git a/xen/arch/arm/include/asm/mm.h b/xen/arch/arm/include/asm/mm.h
> > index 4262165ce2..1a83f41879 100644
> > --- a/xen/arch/arm/include/asm/mm.h
> > +++ b/xen/arch/arm/include/asm/mm.h
> > @@ -280,6 +280,19 @@ static inline paddr_t __virt_to_maddr(vaddr_t va)
> > #define virt_to_maddr(va) __virt_to_maddr((vaddr_t)(va))
> > #ifdef CONFIG_ARM_32
> > +/**
> > + * Find the virtual address corresponding to a machine address
> > + *
> > + * Only memory backing the XENHEAP has a corresponding virtual address to
> > + * be found. This is so we can save precious virtual space, as it's in
> > + * short supply on arm32. This mapping is not subject to PDX compression
> > + * because XENHEAP is known to be physically contiguous and can't hence
> > + * jump over the PDX hole. This means we can avoid the roundtrips
> > + * converting to/from pdx.
> > + *
> > + * @param ma Machine address
> > + * @return Virtual address mapped to `ma`
> > + */
> > static inline void *maddr_to_virt(paddr_t ma)
> > {
> > ASSERT(is_xen_heap_mfn(maddr_to_mfn(ma)));
> > @@ -287,6 +300,20 @@ static inline void *maddr_to_virt(paddr_t ma)
> > return (void *)(unsigned long) ma + XENHEAP_VIRT_START;
> > }
> > #else
> > +/**
> > + * Find the virtual address corresponding to a machine address
> > + *
> > + * The directmap covers all conventional memory accesible by the
> > + * hypervisor. This means it's subject to PDX compression.
> > + *
> > + * More specifically to arm64, the directmap mappings start at the first
> > + * GiB boundary containing valid RAM. This means there's an extra offset
> > + * applied (directmap_base_pdx) on top of the regular PDX compression
> > + * logic.
>
> I find this paragraph a bit confusing to read because it leads to think that
> pdx_to_maddr(directmap_base_pdx) will return a GiB aligned address.
>
> The base PDX corresponds to the start of the first region and the only
> requirement is it should be page-aligned. However, when mapping in the
> virtual address space we also offset the start to ensure that superpage can
> be used (this is where the GiB alignment is used).
>
> That's why XENHEAP_VIRT_START points to directmap_virt_start rather than
> DIRECTMAP_VIRT_START. I think it would make sense to have the logic
> following what you suggest as it would remove a memory read. But I would
> understand if you don't want to take that extra work. :)
>
> So for now, I would suggest to remove "GiB boundary containing".
>
> Cheers,
>
> --
> Julien Grall
Just to make sure it's the wording and not my understanding at fault
(definitely having DIRECTMAP_VIRT_START != directmap_virt_start doesn't do
any favours cognitive load).
/GiB boundary
|
| /offset=address of 1st region of RAM % 1GiB
| |
|---------|
V V
--------------------------------------------------------------------------
| padding | directmap | padding |
--------------------------------------------------------------------------
^ ^
| |
| \directmap_virt_start=pdx[directmap_base_pdx]
|
\DIRECTMAP_VIRT_START
In actual words, I considered DIRECTMAP_VIRT_START the beginning of the
directmap, not directmap_virt_start.
If this is it, you probably want to document somewhere what's what. In
particular, you want a big scary message in DIRECTMAP_VIRT_START stating
that it merely delimits the virtual range where the directmap can be, not
where the directmap is, with a "See directmap_virt_start for the address
where the directmap actually starts" message attached.
With that considered I'm happy to amend as you suggested on v2.
IMO, the ARM port should not keep that base pdx variable around, but
integrate it in the pdx logic, so the first valid address always
corresponds to pdx[0]. Then given a pdx it's immediate to find frame table
entries and directmap frames. It would also greatly simplify the definition
of a pdx.
Alejandro
next prev parent reply other threads:[~2023-07-21 15:09 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-17 16:03 [PATCH 0/8] Make PDX compression optional Alejandro Vallejo
2023-07-17 16:03 ` [PATCH 1/8] mm/pdx: Add comments throughout the codebase for pdx Alejandro Vallejo
2023-07-18 9:14 ` Jan Beulich
2023-07-17 16:03 ` [PATCH 2/8] arm/mm: Document the differences between arm32 and arm64 directmaps Alejandro Vallejo
2023-07-20 20:05 ` Julien Grall
2023-07-21 15:09 ` Alejandro Vallejo [this message]
2023-07-21 17:51 ` Julien Grall
2023-07-17 16:03 ` [PATCH 3/8] pdx: Mark pdx hole description globals readonly after boot Alejandro Vallejo
2023-07-18 9:14 ` Jan Beulich
2023-07-17 16:03 ` [PATCH 4/8] build: Remove CONFIG_HAS_PDX Alejandro Vallejo
2023-07-18 9:19 ` Jan Beulich
2023-07-18 9:35 ` Andrew Cooper
2023-07-18 9:38 ` Jan Beulich
2023-07-18 13:35 ` Alejandro Vallejo
2023-07-17 16:03 ` [PATCH 5/8] mm: Factor out the pdx compression logic in ma/va converters Alejandro Vallejo
2023-07-21 16:11 ` Julien Grall
2023-07-17 16:03 ` [PATCH 6/8] mm/pdx: Standardize region validation wrt pdx compression Alejandro Vallejo
2023-07-21 17:05 ` Julien Grall
2023-07-24 12:18 ` Alejandro Vallejo
2023-07-24 18:20 ` Julien Grall
2023-07-25 6:51 ` Jan Beulich
2023-07-25 14:27 ` Julien Grall
2023-07-25 14:34 ` Jan Beulich
2023-07-27 10:14 ` Alejandro Vallejo
2023-07-27 10:19 ` Jan Beulich
2023-07-17 16:03 ` [PATCH 7/8] pdx: Reorder pdx.[ch] Alejandro Vallejo
2023-07-17 16:24 ` Alejandro Vallejo
2023-07-17 16:03 ` [PATCH 8/8] pdx: Add CONFIG_HAS_PDX_COMPRESSION as a Kconfig option Alejandro Vallejo
2023-07-18 9:33 ` [PATCH 0/8] Make PDX compression optional Jan Beulich
2023-07-18 12:58 ` Alejandro Vallejo
2023-07-18 13:06 ` Jan Beulich
2023-07-18 13:40 ` Alejandro Vallejo
2023-07-20 22:00 ` Julien Grall
2023-07-20 22:13 ` Andrew Cooper
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=64ba9f91.170a0220.bad4d.8728@mx.google.com \
--to=alejandro.vallejo@cloud.com \
--cc=Volodymyr_Babchuk@epam.com \
--cc=bertrand.marquis@arm.com \
--cc=julien@xen.org \
--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.