Re: [PATCH v2 1/1] arm64: mm: correct the inside linear map boundaries during hotplug check

From: Pavel Tatashin
Date: Mon Feb 15 2021 - 17:30:59 EST


> >
> > Btw, the KASLR check is incorrect: memstart_addr could also be
> > negative when running the 52-bit VA kernel on hardware that is only
> > 48-bit VA capable.
>
> Good point!
>
> if (IS_ENABLED(CONFIG_ARM64_VA_BITS_52) && (vabits_actual != 52))
> memstart_addr -= _PAGE_OFFSET(48) - _PAGE_OFFSET(52);
>
> So, I will remove IS_ENABLED(CONFIG_RANDOMIZE_BASE) again.

Hi Ard,

Actually, looking more at this, I do not see how with 52VA on a 48VA
processor start offset can become negative unless randomization is
involved.
The start of the linear map will point to the first physical address
that is reported by memblock_start_of_DRAM(). However, memstart_addr
will be negative. So, I think the current approach using
IS_ENABLED(CONFIG_RANDOMIZE_BASE) is good.

48VA processor with VA_BITS_48:
memstart_addr 40000000
start_linear_pa 40000000
end_linear_pa 80003fffffff

48VA processor with VA_BITS_52:
memstart_addr fff1000040000000 <- Negative
start_linear_pa 40000000 <- positive, and the first PA address
end_linear_pa 80003fffffff

Thank you,
Pasha