[PATCH v2 1/4] arm64: mm: use single quantity to represent the PA to VA translation

Will Deacon will at kernel.org
Thu Oct 15 06:47:25 EDT 2020


On Thu, Oct 08, 2020 at 05:35:59PM +0200, Ard Biesheuvel wrote:
> On arm64, the global variable memstart_addr represents the physical
> address of PAGE_OFFSET, and so physical to virtual translations or
> vice versa used to come down to simple additions or subtractions
> involving the values of PAGE_OFFSET and memstart_addr.
> 
> When support for 52-bit virtual addressing was introduced, we had to
> deal with PAGE_OFFSET potentially being outside of the region that
> can be covered by the virtual range (as the 52-bit VA capable build
> needs to be able to run on systems that are only 48-bit VA capable),
> and for this reason, another translation was introduced, and recorded
> in the global variable physvirt_offset.
> 
> However, if we go back to the original definition of memstart_addr,
> i.e., the physical address of PAGE_OFFSET, it turns out that there is
> no need for two separate translations: instead, we can simply subtract
> the size of the unaddressable VA space from memstart_addr to make the
> available physical memory appear in the 48-bit addressable VA region.
> 
> This simplifies things, but also fixes a bug on KASLR builds, which
> may update memstart_addr later on in arm64_memblock_init(), but fails
> to update vmemmap and physvirt_offset accordingly.
> 
> Fixes: 5383cc6efed13 ("arm64: mm: Introduce vabits_actual")
> Signed-off-by: Ard Biesheuvel <ardb at kernel.org>
> ---
>  arch/arm64/include/asm/memory.h  |  5 ++--
>  arch/arm64/include/asm/pgtable.h |  4 +--
>  arch/arm64/mm/init.c             | 30 +++++++-------------
>  3 files changed, 14 insertions(+), 25 deletions(-)

I'll pick this one patch up for 5.10, thanks.

Will



More information about the linux-arm-kernel mailing list