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

2021-02-16 Thread Pavel Tatashin
> There is a new generic framework which expects the platform to provide two > distinct range points (low and high) for hotplug address comparison. Those > range points can be different depending on whether address randomization > is enabled and the flip occurs. But this comparison here in the plat

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

2021-02-16 Thread Pavel Tatashin
On Tue, Feb 16, 2021 at 2:36 AM Ard Biesheuvel wrote: > > On Tue, 16 Feb 2021 at 04:12, Anshuman Khandual > wrote: > > > > > > > > On 2/16/21 1:21 AM, Pavel Tatashin wrote: > > > On Mon, Feb 15, 2021 at 2:34 PM Ard Biesheuvel wrote: > > >> > > >> On Mon, 15 Feb 2021 at 20:30, Pavel Tatashin >

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

2021-02-15 Thread Ard Biesheuvel
On Tue, 16 Feb 2021 at 04:12, Anshuman Khandual wrote: > > > > On 2/16/21 1:21 AM, Pavel Tatashin wrote: > > On Mon, Feb 15, 2021 at 2:34 PM Ard Biesheuvel wrote: > >> > >> On Mon, 15 Feb 2021 at 20:30, Pavel Tatashin > >> wrote: > >>> > Can't we simply use signed arithmetic here? This exp

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

2021-02-15 Thread Anshuman Khandual
On 2/16/21 1:21 AM, Pavel Tatashin wrote: > On Mon, Feb 15, 2021 at 2:34 PM Ard Biesheuvel wrote: >> >> On Mon, 15 Feb 2021 at 20:30, Pavel Tatashin >> wrote: >>> Can't we simply use signed arithmetic here? This expression works fine if the quantities are all interpreted as s64 inst

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

2021-02-15 Thread Anshuman Khandual
On 2/16/21 12:57 AM, Ard Biesheuvel wrote: > On Mon, 15 Feb 2021 at 20:22, Pavel Tatashin > wrote: >> >> Memory hotplug may fail on systems with CONFIG_RANDOMIZE_BASE because the >> linear map range is not checked correctly. >> >> The start physical address that linear map covers can be actual

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

2021-02-15 Thread Pavel Tatashin
> > > > 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

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

2021-02-15 Thread Pavel Tatashin
On Mon, Feb 15, 2021 at 2:34 PM Ard Biesheuvel wrote: > > On Mon, 15 Feb 2021 at 20:30, Pavel Tatashin > wrote: > > > > > Can't we simply use signed arithmetic here? This expression works fine > > > if the quantities are all interpreted as s64 instead of u64 > > > > I was thinking about that, bu

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

2021-02-15 Thread Ard Biesheuvel
On Mon, 15 Feb 2021 at 20:30, Pavel Tatashin wrote: > > > Can't we simply use signed arithmetic here? This expression works fine > > if the quantities are all interpreted as s64 instead of u64 > > I was thinking about that, but I do not like the idea of using sign > arithmetics for physical addres

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

2021-02-15 Thread Pavel Tatashin
> Can't we simply use signed arithmetic here? This expression works fine > if the quantities are all interpreted as s64 instead of u64 I was thinking about that, but I do not like the idea of using sign arithmetics for physical addresses. Also, I am worried that someone in the future will unknowin

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

2021-02-15 Thread Ard Biesheuvel
On Mon, 15 Feb 2021 at 20:22, Pavel Tatashin wrote: > > Memory hotplug may fail on systems with CONFIG_RANDOMIZE_BASE because the > linear map range is not checked correctly. > > The start physical address that linear map covers can be actually at the > end of the range because of randomization. C

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

2021-02-15 Thread Pavel Tatashin
Memory hotplug may fail on systems with CONFIG_RANDOMIZE_BASE because the linear map range is not checked correctly. The start physical address that linear map covers can be actually at the end of the range because of randomization. Check that and if so reduce it to 0. This can be verified on QEM