Skip to content

Commit 17b45cc

Browse files
riteshharjanimaddy-kerneldev
authored andcommitted
powerpc/64s/hash: Restrict stress_hpt_struct memblock region to within RMA limit
When HV=0 & IR/DR=0, the Hash MMU is said to be in Virtual Real Addressing Mode during early boot. During this, we should ensure that memory region allocations for stress_hpt_struct should happen from within RMA region as otherwise the boot might get stuck while doing memset of this region. History behind why do we have RMA region limitation is better explained in these 2 patches [1] & [2]. This patch ensures that memset to stress_hpt_struct during early boot does not cross ppc64_rma_size boundary. [1]: https://lore.kernel.org/all/20190710052018.14628-1-sjitindarsingh@gmail.com/ [2]: https://lore.kernel.org/all/87wp54usvj.fsf@linux.vnet.ibm.com/ Fixes: 6b34a09 ("powerpc/64s/hash: add stress_hpt kernel boot option to increase hash faults") Signed-off-by: Ritesh Harjani (IBM) <ritesh.list@gmail.com> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/ada1173933ea7617a994d6ee3e54ced8797339fc.1761834163.git.ritesh.list@gmail.com
1 parent 0031241 commit 17b45cc

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

arch/powerpc/mm/book3s64/hash_utils.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,11 +1302,14 @@ static void __init htab_initialize(void)
13021302
unsigned long table;
13031303
unsigned long pteg_count;
13041304
unsigned long prot;
1305-
phys_addr_t base = 0, size = 0, end;
1305+
phys_addr_t base = 0, size = 0, end, limit = MEMBLOCK_ALLOC_ANYWHERE;
13061306
u64 i;
13071307

13081308
DBG(" -> htab_initialize()\n");
13091309

1310+
if (firmware_has_feature(FW_FEATURE_LPAR))
1311+
limit = ppc64_rma_size;
1312+
13101313
if (mmu_has_feature(MMU_FTR_1T_SEGMENT)) {
13111314
mmu_kernel_ssize = MMU_SEGSIZE_1T;
13121315
mmu_highuser_ssize = MMU_SEGSIZE_1T;
@@ -1322,7 +1325,7 @@ static void __init htab_initialize(void)
13221325
// Too early to use nr_cpu_ids, so use NR_CPUS
13231326
tmp = memblock_phys_alloc_range(sizeof(struct stress_hpt_struct) * NR_CPUS,
13241327
__alignof__(struct stress_hpt_struct),
1325-
0, MEMBLOCK_ALLOC_ANYWHERE);
1328+
MEMBLOCK_LOW_LIMIT, limit);
13261329
memset((void *)tmp, 0xff, sizeof(struct stress_hpt_struct) * NR_CPUS);
13271330
stress_hpt_struct = __va(tmp);
13281331

@@ -1356,11 +1359,10 @@ static void __init htab_initialize(void)
13561359
mmu_hash_ops.hpte_clear_all();
13571360
#endif
13581361
} else {
1359-
unsigned long limit = MEMBLOCK_ALLOC_ANYWHERE;
13601362

13611363
table = memblock_phys_alloc_range(htab_size_bytes,
13621364
htab_size_bytes,
1363-
0, limit);
1365+
MEMBLOCK_LOW_LIMIT, limit);
13641366
if (!table)
13651367
panic("ERROR: Failed to allocate %pa bytes below %pa\n",
13661368
&htab_size_bytes, &limit);

0 commit comments

Comments
 (0)