Re: [PATCH V14] mm/debug: Add tests validating architecture page table helpers

From: Anshuman Khandual
Date: Wed Feb 26 2020 - 21:34:45 EST


On 02/26/2020 08:14 PM, Christophe Leroy wrote:
>
>
> Le 26/02/2020 Ã 15:12, Qian Cai a ÃcritÂ:
>> On Wed, 2020-02-26 at 09:09 -0500, Qian Cai wrote:
>>> On Mon, 2020-02-17 at 08:47 +0530, Anshuman Khandual wrote:
>>>
>>> How useful is this that straightly crash the powerpc?
>>
>> And then generate warnings on arm64,
>>
>> [ÂÂ146.634626][ÂÂÂÂT1] debug_vm_pgtable: debug_vm_pgtable: Validating
>> architecture page table helpers
>> [ÂÂ146.643995][ÂÂÂÂT1] ------------[ cut here ]------------
>> [ÂÂ146.649350][ÂÂÂÂT1] virt_to_phys used for non-linear address:
>> (____ptrval____) (start_kernel+0x0/0x580)
>
> Must be something wrong with the following in debug_vm_pgtable()
>
> ÂÂÂÂpaddr = __pa(&start_kernel);
>
> Is there any explaination why start_kernel() is not in linear memory on ARM64 ?


Cc: + James Morse <james.morse@xxxxxxx>

This warning gets exposed with DEBUG_VIRTUAL due to __pa() on a kernel symbol
i.e 'start_kernel' which might be outside the linear map. This happens due to
kernel mapping position randomization with KASLR. Adding James here in case he
might like to add more.

__pa_symbol() should have been used instead, for accessing the physical address
here. On arm64 __pa() does check for linear address with __is_lm_address() and
switch accordingly if it is a kernel text symbol. Nevertheless, its much better
to use __pa_symbol() here rather than __pa().

Rather than respining the patch once more, will just send a fix replacing this
helper __pa() with __pa_symbol() for Andrew to pick up as this patch is already
part of linux-next (next-20200226). But can definitely respin if that will be
preferred.

Thanks Qian for catching this.

>
> Christophe
>