* [PATCH v2] arm64: mm: Align PGDs to at least 64 bytes
@ 2022-11-29 14:30 Ard Biesheuvel
2022-11-29 17:51 ` Marc Zyngier
0 siblings, 1 reply; 3+ messages in thread
From: Ard Biesheuvel @ 2022-11-29 14:30 UTC (permalink / raw)
To: linux-arm-kernel
Cc: catalin.marinas, will, anshuman.khandual, maz, mark.rutland,
Ard Biesheuvel
My copy of the ARM ARM (DDI 0487I.a) no longer describes the 64 byte
minimum alignment of root page tables as being conditional on whether
52-bit physical addressing is supported and enabled, even though I seem
to remember that this was the case formerly (and our code suggests the
same).
Section D17.2.144 "TTBR0_EL1, Translation Table Base Register 0 (EL1)"
contains the following wording:
----Note----
A translation table is required to be aligned to the size of the
table. If a table contains fewer than eight entries, it must be
aligned on a 64 byte address boundary
So align pgd_t[] allocations to 64 bytes. Note that this change only
affects 16k/4 levels configurations, which are unlikely to be in wide
use.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Acked-by: Catalin Marinas <catalin.marinas@arm.com>
---
arch/arm64/mm/pgd.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/arch/arm64/mm/pgd.c b/arch/arm64/mm/pgd.c
index 4a64089e5771c1e2..48989b9c9035e8b9 100644
--- a/arch/arm64/mm/pgd.c
+++ b/arch/arm64/mm/pgd.c
@@ -40,17 +40,10 @@ void __init pgtable_cache_init(void)
if (PGD_SIZE == PAGE_SIZE)
return;
-#ifdef CONFIG_ARM64_PA_BITS_52
/*
- * With 52-bit physical addresses, the architecture requires the
- * top-level table to be aligned to at least 64 bytes.
+ * Naturally aligned pgds required by the architecture, with a minimum
+ * alignment of 64 bytes.
*/
- BUILD_BUG_ON(PGD_SIZE < 64);
-#endif
-
- /*
- * Naturally aligned pgds required by the architecture.
- */
- pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE, PGD_SIZE,
- SLAB_PANIC, NULL);
+ pgd_cache = kmem_cache_create("pgd_cache", PGD_SIZE,
+ max(PGD_SIZE, 64UL), SLAB_PANIC, NULL);
}
--
2.35.1
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] arm64: mm: Align PGDs to at least 64 bytes
2022-11-29 14:30 [PATCH v2] arm64: mm: Align PGDs to at least 64 bytes Ard Biesheuvel
@ 2022-11-29 17:51 ` Marc Zyngier
2022-11-29 18:04 ` Ard Biesheuvel
0 siblings, 1 reply; 3+ messages in thread
From: Marc Zyngier @ 2022-11-29 17:51 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: linux-arm-kernel, catalin.marinas, will, anshuman.khandual,
mark.rutland
On Tue, 29 Nov 2022 14:30:12 +0000,
Ard Biesheuvel <ardb@kernel.org> wrote:
>
> My copy of the ARM ARM (DDI 0487I.a) no longer describes the 64 byte
> minimum alignment of root page tables as being conditional on whether
> 52-bit physical addressing is supported and enabled, even though I seem
> to remember that this was the case formerly (and our code suggests the
> same).
>
> Section D17.2.144 "TTBR0_EL1, Translation Table Base Register 0 (EL1)"
> contains the following wording:
>
> ----Note----
> A translation table is required to be aligned to the size of the
> table. If a table contains fewer than eight entries, it must be
> aligned on a 64 byte address boundary
>
> So align pgd_t[] allocations to 64 bytes. Note that this change only
> affects 16k/4 levels configurations, which are unlikely to be in wide
> use.
>
> Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> Acked-by: Catalin Marinas <catalin.marinas@arm.com>
After the VTTBR discussion, and to be extra sure of this, I reached
out to ARM and asked for clarification.
As it turns out, the omission of the "> 48 bits" restriction is an
unfortunate specification bug, and the old behaviour still applies
(Rule KBLCR is also wrong).
Can't wait for the next revision! ;-)
M.
--
Without deviation from the norm, progress is not possible.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] arm64: mm: Align PGDs to at least 64 bytes
2022-11-29 17:51 ` Marc Zyngier
@ 2022-11-29 18:04 ` Ard Biesheuvel
0 siblings, 0 replies; 3+ messages in thread
From: Ard Biesheuvel @ 2022-11-29 18:04 UTC (permalink / raw)
To: Marc Zyngier
Cc: linux-arm-kernel, catalin.marinas, will, anshuman.khandual,
mark.rutland
On Tue, 29 Nov 2022 at 18:52, Marc Zyngier <maz@kernel.org> wrote:
>
> On Tue, 29 Nov 2022 14:30:12 +0000,
> Ard Biesheuvel <ardb@kernel.org> wrote:
> >
> > My copy of the ARM ARM (DDI 0487I.a) no longer describes the 64 byte
> > minimum alignment of root page tables as being conditional on whether
> > 52-bit physical addressing is supported and enabled, even though I seem
> > to remember that this was the case formerly (and our code suggests the
> > same).
> >
> > Section D17.2.144 "TTBR0_EL1, Translation Table Base Register 0 (EL1)"
> > contains the following wording:
> >
> > ----Note----
> > A translation table is required to be aligned to the size of the
> > table. If a table contains fewer than eight entries, it must be
> > aligned on a 64 byte address boundary
> >
> > So align pgd_t[] allocations to 64 bytes. Note that this change only
> > affects 16k/4 levels configurations, which are unlikely to be in wide
> > use.
> >
> > Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
> > Acked-by: Catalin Marinas <catalin.marinas@arm.com>
>
> After the VTTBR discussion, and to be extra sure of this, I reached
> out to ARM and asked for clarification.
>
> As it turns out, the omission of the "> 48 bits" restriction is an
> unfortunate specification bug, and the old behaviour still applies
> (Rule KBLCR is also wrong).
>
> Can't wait for the next revision! ;-)
>
Thanks for that. This is good news - it means we at least have the
freedom to choose between a 47/52 and 48/52 hybrid LPA2 config for 16k
pages without the need for nasty hacks (assuming we are not interested
in 52-bit PA support when running with a reduced VA size deliberately
instead of due to lack of h/w support)
So the patch can be disregarded then.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-29 18:05 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-29 14:30 [PATCH v2] arm64: mm: Align PGDs to at least 64 bytes Ard Biesheuvel
2022-11-29 17:51 ` Marc Zyngier
2022-11-29 18:04 ` Ard Biesheuvel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox