Skip to content
  • Mark Rutland's avatar
    arm64: kasan: avoid bad virt_to_pfn() · b0de0ccc
    Mark Rutland authored
    
    
    Booting a v4.11-rc1 kernel with DEBUG_VIRTUAL and KASAN enabled produces
    the following splat (trimmed for brevity):
    
    [    0.000000] virt_to_phys used for non-linear address: ffff200008080000 (0xffff200008080000)
    [    0.000000] WARNING: CPU: 0 PID: 0 at arch/arm64/mm/physaddr.c:14 __virt_to_phys+0x48/0x70
    [    0.000000] PC is at __virt_to_phys+0x48/0x70
    [    0.000000] LR is at __virt_to_phys+0x48/0x70
    [    0.000000] Call trace:
    [    0.000000] [<ffff2000080b1ac0>] __virt_to_phys+0x48/0x70
    [    0.000000] [<ffff20000a03b86c>] kasan_init+0x1c0/0x498
    [    0.000000] [<ffff20000a034018>] setup_arch+0x2fc/0x948
    [    0.000000] [<ffff20000a030c68>] start_kernel+0xb8/0x570
    [    0.000000] [<ffff20000a0301e8>] __primary_switched+0x6c/0x74
    
    This is because we use virt_to_pfn() on a kernel image address when
    trying to figure out its nid, so that we can allocate its shadow from
    the same node.
    
    As with other recent changes, this patch uses lm_alias() to solve this.
    
    We could instead use NUMA_NO_NODE, as x86 does for all shadow
    allocations, though we'll likely want the "real" memory shadow to be
    backed from its corresponding nid anyway, so we may as well be
    consistent and find the nid for the image shadow.
    
    Cc: Catalin Marinas <catalin.marinas@arm.com>
    Cc: Will Deacon <will.deacon@arm.com>
    Acked-by: default avatarLaura Abbott <labbott@redhat.com>
    Signed-off-by: default avatarMark Rutland <mark.rutland@arm.com>
    Signed-off-by: default avatarWill Deacon <will.deacon@arm.com>
    b0de0ccc