[PATCH v2 07/19] arm64: mm: Handle LVA support as a CPU feature
Ryan Roberts
ryan.roberts at arm.com
Mon Nov 28 06:54:40 PST 2022
Hi Ard,
On 24/11/2022 12:39, Ard Biesheuvel wrote:
> Currently, we detect CPU support for 52-bit virtual addressing (LVA)
> extremely early, before creating the kernel page tables or enabling the
> MMU. We cannot override the feature this early, and so large virtual
> addressing is always enabled on CPUs that implement support for it if
> the software support for it was enabled at build time. It also means we
> rely on non-trivial code in asm to deal with this feature.
>
> Given that both the ID map and the TTBR1 mapping of the kernel image are
> guaranteed to be 48-bit addressable, it is not actually necessary to
> enable support this early, and instead, we can model it as a CPU
> feature. That way, we can rely on code patching to get the correct
> TCR.T1SZ values programmed on secondary boot and suspend from resume.
nit: I think you mean "resume from suspend"?
>
> On the primary boot path, we simply enable the MMU with 48-bit virtual
> addressing initially, and update TCR.T1SZ if LVA is supported from C
> code, right before creating the kernel mapping. Given that TTBR1 still
> points to reserved_pg_dir at this point, updating TCR.T1SZ should be
> safe without the need for explicit TLB maintenance.
>
> Since this gets rid of all accesses to the vabits_actual variable from
> asm code that occurred before TCR.T1SZ had been programmed, we no longer
> have a need for this variable, and we can replace it with a C expression
> that produces the correct value directly, based on the value of TCR.T1SZ.
>
> Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
> ---
> arch/arm64/include/asm/memory.h | 13 ++++++++++-
> arch/arm64/kernel/cpufeature.c | 13 +++++++++++
> arch/arm64/kernel/head.S | 24 +++-----------------
> arch/arm64/kernel/pi/map_kernel.c | 12 ++++++++++
> arch/arm64/kernel/sleep.S | 3 ---
> arch/arm64/mm/mmu.c | 5 ----
> arch/arm64/mm/proc.S | 17 +++++++-------
> arch/arm64/tools/cpucaps | 1 +
> 8 files changed, 49 insertions(+), 39 deletions(-)
>
> [...]
Thanks,
Ryan
More information about the linux-arm-kernel
mailing list