Blob Blame History Raw
From 8f51e3929470942e6a8744061254fdeef646cd36 Mon Sep 17 00:00:00 2001
From: Nicholas Piggin <npiggin@gmail.com>
Date: Wed, 24 Jul 2019 18:46:34 +1000
Subject: [PATCH] powerpc/64s/radix: Fix memory hotplug section page table
 creation

References: bsc#1065729
Patch-mainline: v5.4-rc1
Git-commit: 8f51e3929470942e6a8744061254fdeef646cd36

create_physical_mapping expects physical addresses, but creating and
splitting these mappings after boot is supplying virtual (effective)
addresses. This can be irritated by booting with mem= to limit memory
then probing an unused physical memory range:

  echo <addr> > /sys/devices/system/memory/probe

This mostly works by accident, firstly because __va(__va(x)) == __va(x)
so the virtual address does not get corrupted. Secondly because pfn_pte
masks out the upper bits of the pfn beyond the physical address limit,
so a pfn constructed with a 0xc000000000000000 virtual linear address
will be masked back to the correct physical address in the pte.

Fixes: 6cc27341b21a8 ("powerpc/mm: add radix__create_section_mapping()")
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20190724084638.24982-1-npiggin@gmail.com
Acked-by: Michal Suchanek <msuchanek@suse.de>
---
 arch/powerpc/mm/pgtable-radix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c
--- a/arch/powerpc/mm/pgtable-radix.c
+++ b/arch/powerpc/mm/pgtable-radix.c
@@ -808,7 +808,7 @@ static void __meminit remove_pagetable(u
 
 int __meminit radix__create_section_mapping(unsigned long start, unsigned long end)
 {
-	return create_physical_mapping(start, end);
+	return create_physical_mapping(__pa(start), __pa(end));
 }
 
 int __meminit radix__remove_section_mapping(unsigned long start, unsigned long end)