Skip to content

Commit ac790d0

Browse files
kvaneeshmpe
authored andcommitted
powerpc/memhotplug: Add add_pages override for PPC
With commit ffa0b64 ("powerpc: Fix virt_addr_valid() for 64-bit Book3E & 32-bit") the kernel now validate the addr against high_memory value. This results in the below BUG_ON with dax pfns. [ 635.798741][T26531] kernel BUG at mm/page_alloc.c:5521! 1:mon> e cpu 0x1: Vector: 700 (Program Check) at [c000000007287630] pc: c00000000055ed48: free_pages.part.0+0x48/0x110 lr: c00000000053ca70: tlb_finish_mmu+0x80/0xd0 sp: c0000000072878d0 msr: 800000000282b033 current = 0xc00000000afabe00 paca = 0xc00000037ffff300 irqmask: 0x03 irq_happened: 0x05 pid = 26531, comm = 50-landscape-sy kernel BUG at :5521! Linux version 5.19.0-rc3-14659-g4ec05be7c2e1 (kvaneesh@ltc-boston8) (gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0, GNU ld (GNU Binutils for Ubuntu) 2.34) torvalds#625 SMP Thu Jun 23 00:35:43 CDT 2022 1:mon> t [link register ] c00000000053ca70 tlb_finish_mmu+0x80/0xd0 [c0000000072878d0] c00000000053ca54 tlb_finish_mmu+0x64/0xd0 (unreliable) [c000000007287900] c000000000539424 exit_mmap+0xe4/0x2a0 [c0000000072879e0] c00000000019fc1c mmput+0xcc/0x210 [c000000007287a20] c000000000629230 begin_new_exec+0x5e0/0xf40 [c000000007287ae0] c00000000070b3cc load_elf_binary+0x3ac/0x1e00 [c000000007287c10] c000000000627af0 bprm_execve+0x3b0/0xaf0 [c000000007287cd0] c000000000628414 do_execveat_common.isra.0+0x1e4/0x310 [c000000007287d80] c00000000062858c sys_execve+0x4c/0x60 [c000000007287db0] c00000000002c1b0 system_call_exception+0x160/0x2c0 [c000000007287e10] c00000000000c53c system_call_common+0xec/0x250 The fix is to make sure we update high_memory on memory hotplug. This is similar to what x86 does in commit 3072e41 ("mm/memory_hotplug: introduce add_pages") Fixes: ffa0b64 ("powerpc: Fix virt_addr_valid() for 64-bit Book3E & 32-bit") Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com> Reviewed-by: Kefeng Wang <wangkefeng.wang@huawei.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20220629050925.31447-1-aneesh.kumar@linux.ibm.com
1 parent b21bd5a commit ac790d0

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

arch/powerpc/Kconfig

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -358,6 +358,10 @@ config ARCH_SUSPEND_NONZERO_CPU
358358
def_bool y
359359
depends on PPC_POWERNV || PPC_PSERIES
360360

361+
config ARCH_HAS_ADD_PAGES
362+
def_bool y
363+
depends on ARCH_ENABLE_MEMORY_HOTPLUG
364+
361365
config PPC_DCR_NATIVE
362366
bool
363367

arch/powerpc/mm/mem.c

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,37 @@ void __ref arch_remove_linear_mapping(u64 start, u64 size)
105105
vm_unmap_aliases();
106106
}
107107

108+
/*
109+
* After memory hotplug the variables max_pfn, max_low_pfn and high_memory need
110+
* updating.
111+
*/
112+
static void update_end_of_memory_vars(u64 start, u64 size)
113+
{
114+
unsigned long end_pfn = PFN_UP(start + size);
115+
116+
if (end_pfn > max_pfn) {
117+
max_pfn = end_pfn;
118+
max_low_pfn = end_pfn;
119+
high_memory = (void *)__va(max_pfn * PAGE_SIZE - 1) + 1;
120+
}
121+
}
122+
123+
int __ref add_pages(int nid, unsigned long start_pfn, unsigned long nr_pages,
124+
struct mhp_params *params)
125+
{
126+
int ret;
127+
128+
ret = __add_pages(nid, start_pfn, nr_pages, params);
129+
if (ret)
130+
return ret;
131+
132+
/* update max_pfn, max_low_pfn and high_memory */
133+
update_end_of_memory_vars(start_pfn << PAGE_SHIFT,
134+
nr_pages << PAGE_SHIFT);
135+
136+
return ret;
137+
}
138+
108139
int __ref arch_add_memory(int nid, u64 start, u64 size,
109140
struct mhp_params *params)
110141
{
@@ -115,7 +146,7 @@ int __ref arch_add_memory(int nid, u64 start, u64 size,
115146
rc = arch_create_linear_mapping(nid, start, size, params);
116147
if (rc)
117148
return rc;
118-
rc = __add_pages(nid, start_pfn, nr_pages, params);
149+
rc = add_pages(nid, start_pfn, nr_pages, params);
119150
if (rc)
120151
arch_remove_linear_mapping(start, size);
121152
return rc;

0 commit comments

Comments
 (0)