* [PATCH] xen/arm: mm: Encode existing constraints of the memory layout
@ 2022-02-28 10:06 Julien Grall
2022-03-03 16:04 ` Bertrand Marquis
0 siblings, 1 reply; 3+ messages in thread
From: Julien Grall @ 2022-02-28 10:06 UTC (permalink / raw)
To: xen-devel
Cc: julien, Julien Grall, Stefano Stabellini, Bertrand Marquis,
Volodymyr Babchuk
From: Julien Grall <jgrall@amazon.com>
The boot code expects the regions XEN_VIRT_START, FIXMAP_ADDR(0),
BOOT_FDT_VIRT_START to use the same 0th (arm64 only) and 1st slot.
Add some BUILD_BUG_ON() to confirm that. This is helpful if one wants
to re-order the memory layout.
Signed-off-by: Julien Grall <jgrall@amazon.com>
---
xen/arch/arm/mm.c | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
index 8a17222109c6..40423a70f0ae 100644
--- a/xen/arch/arm/mm.c
+++ b/xen/arch/arm/mm.c
@@ -211,6 +211,22 @@ static void __init __maybe_unused build_assertions(void)
#ifdef CONFIG_DOMAIN_PAGE
BUILD_BUG_ON(DOMHEAP_VIRT_START & ~FIRST_MASK);
#endif
+ /*
+ * The boot code expects the regions XEN_VIRT_START, FIXMAP_ADDR(0),
+ * BOOT_FDT_VIRT_START to use the same 0th (arm64 only) and 1st
+ * slot.
+ */
+#define CHECK_SAME_SLOT(level, virt1, virt2) \
+ BUILD_BUG_ON(level##_table_offset(virt1) != level##_table_offset(virt2))
+
+#ifdef CONFIG_ARM_64
+ CHECK_SAME_SLOT(zeroeth, XEN_VIRT_START, FIXMAP_ADDR(0));
+ CHECK_SAME_SLOT(zeroeth, XEN_VIRT_START, BOOT_FDT_VIRT_START);
+#endif
+ CHECK_SAME_SLOT(first, XEN_VIRT_START, FIXMAP_ADDR(0));
+ CHECK_SAME_SLOT(first, XEN_VIRT_START, BOOT_FDT_VIRT_START);
+
+#undef CHECK_SAME_SLOT
}
void dump_pt_walk(paddr_t ttbr, paddr_t addr,
--
2.32.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] xen/arm: mm: Encode existing constraints of the memory layout
2022-02-28 10:06 [PATCH] xen/arm: mm: Encode existing constraints of the memory layout Julien Grall
@ 2022-03-03 16:04 ` Bertrand Marquis
2022-03-03 20:18 ` Julien Grall
0 siblings, 1 reply; 3+ messages in thread
From: Bertrand Marquis @ 2022-03-03 16:04 UTC (permalink / raw)
To: Julien Grall
Cc: xen-devel, Julien Grall, Stefano Stabellini, Volodymyr Babchuk
Hi Julien,
> On 28 Feb 2022, at 10:06, Julien Grall <julien@xen.org> wrote:
>
> From: Julien Grall <jgrall@amazon.com>
>
> The boot code expects the regions XEN_VIRT_START, FIXMAP_ADDR(0),
> BOOT_FDT_VIRT_START to use the same 0th (arm64 only) and 1st slot.
>
> Add some BUILD_BUG_ON() to confirm that. This is helpful if one wants
> to re-order the memory layout.
Very good idea :-)
>
> Signed-off-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
Just a small NIT after if you want to do it on commit...
> ---
> xen/arch/arm/mm.c | 16 ++++++++++++++++
> 1 file changed, 16 insertions(+)
>
> diff --git a/xen/arch/arm/mm.c b/xen/arch/arm/mm.c
> index 8a17222109c6..40423a70f0ae 100644
> --- a/xen/arch/arm/mm.c
> +++ b/xen/arch/arm/mm.c
> @@ -211,6 +211,22 @@ static void __init __maybe_unused build_assertions(void)
> #ifdef CONFIG_DOMAIN_PAGE
> BUILD_BUG_ON(DOMHEAP_VIRT_START & ~FIRST_MASK);
> #endif
> + /*
> + * The boot code expects the regions XEN_VIRT_START, FIXMAP_ADDR(0),
> + * BOOT_FDT_VIRT_START to use the same 0th (arm64 only) and 1st
> + * slot.
NIT: I would just add at the end of the sentence “in the page tables.”
Cheers
Bertrand
> + */
> +#define CHECK_SAME_SLOT(level, virt1, virt2) \
> + BUILD_BUG_ON(level##_table_offset(virt1) != level##_table_offset(virt2))
> +
> +#ifdef CONFIG_ARM_64
> + CHECK_SAME_SLOT(zeroeth, XEN_VIRT_START, FIXMAP_ADDR(0));
> + CHECK_SAME_SLOT(zeroeth, XEN_VIRT_START, BOOT_FDT_VIRT_START);
> +#endif
> + CHECK_SAME_SLOT(first, XEN_VIRT_START, FIXMAP_ADDR(0));
> + CHECK_SAME_SLOT(first, XEN_VIRT_START, BOOT_FDT_VIRT_START);
> +
> +#undef CHECK_SAME_SLOT
> }
>
> void dump_pt_walk(paddr_t ttbr, paddr_t addr,
> --
> 2.32.0
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] xen/arm: mm: Encode existing constraints of the memory layout
2022-03-03 16:04 ` Bertrand Marquis
@ 2022-03-03 20:18 ` Julien Grall
0 siblings, 0 replies; 3+ messages in thread
From: Julien Grall @ 2022-03-03 20:18 UTC (permalink / raw)
To: Bertrand Marquis
Cc: xen-devel, Julien Grall, Stefano Stabellini, Volodymyr Babchuk
On 03/03/2022 16:04, Bertrand Marquis wrote:
> Hi Julien,
Hi Bertrand,
>> On 28 Feb 2022, at 10:06, Julien Grall <julien@xen.org> wrote:
>>
>> From: Julien Grall <jgrall@amazon.com>
>>
>> The boot code expects the regions XEN_VIRT_START, FIXMAP_ADDR(0),
>> BOOT_FDT_VIRT_START to use the same 0th (arm64 only) and 1st slot.
>>
>> Add some BUILD_BUG_ON() to confirm that. This is helpful if one wants
>> to re-order the memory layout.
>
> Very good idea :-)
I actually hit this issue when trying to re-order the memory layout for
testing a patch.
>
>>
>> Signed-off-by: Julien Grall <jgrall@amazon.com>
>
> Reviewed-by: Bertrand Marquis <bertrand.marquis@arm.com>
>
> Just a small NIT after if you want to do it on commit...
I have update the comment and committed the patch.
Thanks!
Cheers,
--
Julien Grall
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-03-03 20:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 10:06 [PATCH] xen/arm: mm: Encode existing constraints of the memory layout Julien Grall
2022-03-03 16:04 ` Bertrand Marquis
2022-03-03 20:18 ` Julien Grall
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.