4747#include <asm/mmu.h>
4848#include <asm/mmu_context.h>
4949#include <asm/page.h>
50+ #include <asm/pgalloc.h>
5051#include <asm/types.h>
5152#include <linux/uaccess.h>
5253#include <asm/machdep.h>
@@ -449,6 +450,7 @@ static __init void hash_kfence_map_pool(void)
449450{
450451 unsigned long kfence_pool_start , kfence_pool_end ;
451452 unsigned long prot = pgprot_val (PAGE_KERNEL );
453+ unsigned int pshift = mmu_psize_defs [mmu_linear_psize ].shift ;
452454
453455 if (!kfence_pool )
454456 return ;
@@ -459,6 +461,7 @@ static __init void hash_kfence_map_pool(void)
459461 BUG_ON (htab_bolt_mapping (kfence_pool_start , kfence_pool_end ,
460462 kfence_pool , prot , mmu_linear_psize ,
461463 mmu_kernel_ssize ));
464+ update_page_count (mmu_linear_psize , KFENCE_POOL_SIZE >> pshift );
462465 memblock_clear_nomap (kfence_pool , KFENCE_POOL_SIZE );
463466}
464467
@@ -952,7 +955,7 @@ static int __init htab_dt_scan_hugepage_blocks(unsigned long node,
952955 block_size = be64_to_cpu (addr_prop [1 ]);
953956 if (block_size != (16 * GB ))
954957 return 0 ;
955- printk ( KERN_INFO "Huge page(16GB) memory: "
958+ pr_info ( "Huge page(16GB) memory: "
956959 "addr = 0x%lX size = 0x%lX pages = %d\n" ,
957960 phys_addr , block_size , expected_pages );
958961 if (phys_addr + block_size * expected_pages <= memblock_end_of_DRAM ()) {
@@ -1135,7 +1138,7 @@ static void __init htab_init_page_sizes(void)
11351138 mmu_vmemmap_psize = mmu_virtual_psize ;
11361139#endif /* CONFIG_SPARSEMEM_VMEMMAP */
11371140
1138- printk ( KERN_DEBUG "Page orders: linear mapping = %d, "
1141+ pr_info ( "Page orders: linear mapping = %d, "
11391142 "virtual = %d, io = %d"
11401143#ifdef CONFIG_SPARSEMEM_VMEMMAP
11411144 ", vmemmap = %d"
@@ -1234,6 +1237,7 @@ int hash__create_section_mapping(unsigned long start, unsigned long end,
12341237 int nid , pgprot_t prot )
12351238{
12361239 int rc ;
1240+ unsigned int pshift = mmu_psize_defs [mmu_linear_psize ].shift ;
12371241
12381242 if (end >= H_VMALLOC_START ) {
12391243 pr_warn ("Outside the supported range\n" );
@@ -1251,17 +1255,22 @@ int hash__create_section_mapping(unsigned long start, unsigned long end,
12511255 mmu_kernel_ssize );
12521256 BUG_ON (rc2 && (rc2 != - ENOENT ));
12531257 }
1258+ update_page_count (mmu_linear_psize , (end - start ) >> pshift );
12541259 return rc ;
12551260}
12561261
12571262int hash__remove_section_mapping (unsigned long start , unsigned long end )
12581263{
1264+ unsigned int pshift = mmu_psize_defs [mmu_linear_psize ].shift ;
1265+
12591266 int rc = htab_remove_mapping (start , end , mmu_linear_psize ,
12601267 mmu_kernel_ssize );
12611268
12621269 if (resize_hpt_for_hotplug (memblock_phys_mem_size ()) == - ENOSPC )
12631270 pr_warn ("Hash collision while resizing HPT\n" );
12641271
1272+ if (!rc )
1273+ update_page_count (mmu_linear_psize , - ((end - start ) >> pshift ));
12651274 return rc ;
12661275}
12671276#endif /* CONFIG_MEMORY_HOTPLUG */
@@ -1302,27 +1311,34 @@ static void __init htab_initialize(void)
13021311 unsigned long table ;
13031312 unsigned long pteg_count ;
13041313 unsigned long prot ;
1305- phys_addr_t base = 0 , size = 0 , end ;
1314+ phys_addr_t base = 0 , size = 0 , end , limit = MEMBLOCK_ALLOC_ANYWHERE ;
13061315 u64 i ;
1316+ unsigned int pshift = mmu_psize_defs [mmu_linear_psize ].shift ;
13071317
13081318 DBG (" -> htab_initialize()\n" );
13091319
1320+ if (firmware_has_feature (FW_FEATURE_LPAR ))
1321+ limit = ppc64_rma_size ;
1322+
13101323 if (mmu_has_feature (MMU_FTR_1T_SEGMENT )) {
13111324 mmu_kernel_ssize = MMU_SEGSIZE_1T ;
13121325 mmu_highuser_ssize = MMU_SEGSIZE_1T ;
1313- printk ( KERN_INFO "Using 1TB segments\n" );
1326+ pr_info ( "Using 1TB segments\n" );
13141327 }
13151328
13161329 if (stress_slb_enabled )
13171330 static_branch_enable (& stress_slb_key );
13181331
1332+ if (no_slb_preload )
1333+ static_branch_enable (& no_slb_preload_key );
1334+
13191335 if (stress_hpt_enabled ) {
13201336 unsigned long tmp ;
13211337 static_branch_enable (& stress_hpt_key );
13221338 // Too early to use nr_cpu_ids, so use NR_CPUS
13231339 tmp = memblock_phys_alloc_range (sizeof (struct stress_hpt_struct ) * NR_CPUS ,
13241340 __alignof__(struct stress_hpt_struct ),
1325- 0 , MEMBLOCK_ALLOC_ANYWHERE );
1341+ MEMBLOCK_LOW_LIMIT , limit );
13261342 memset ((void * )tmp , 0xff , sizeof (struct stress_hpt_struct ) * NR_CPUS );
13271343 stress_hpt_struct = __va (tmp );
13281344
@@ -1356,11 +1372,10 @@ static void __init htab_initialize(void)
13561372 mmu_hash_ops .hpte_clear_all ();
13571373#endif
13581374 } else {
1359- unsigned long limit = MEMBLOCK_ALLOC_ANYWHERE ;
13601375
13611376 table = memblock_phys_alloc_range (htab_size_bytes ,
13621377 htab_size_bytes ,
1363- 0 , limit );
1378+ MEMBLOCK_LOW_LIMIT , limit );
13641379 if (!table )
13651380 panic ("ERROR: Failed to allocate %pa bytes below %pa\n" ,
13661381 & htab_size_bytes , & limit );
@@ -1392,8 +1407,8 @@ static void __init htab_initialize(void)
13921407 size = end - base ;
13931408 base = (unsigned long )__va (base );
13941409
1395- DBG ("creating mapping for region: %lx..%lx (prot: %lx)\n" ,
1396- base , size , prot );
1410+ pr_debug ("creating mapping for region: 0x%pa..0x%pa (prot: %lx)\n" ,
1411+ & base , & size , prot );
13971412
13981413 if ((base + size ) >= H_VMALLOC_START ) {
13991414 pr_warn ("Outside the supported range\n" );
@@ -1402,6 +1417,8 @@ static void __init htab_initialize(void)
14021417
14031418 BUG_ON (htab_bolt_mapping (base , base + size , __pa (base ),
14041419 prot , mmu_linear_psize , mmu_kernel_ssize ));
1420+
1421+ update_page_count (mmu_linear_psize , size >> pshift );
14051422 }
14061423 hash_kfence_map_pool ();
14071424 memblock_set_current_limit (MEMBLOCK_ALLOC_ANYWHERE );
@@ -1423,6 +1440,8 @@ static void __init htab_initialize(void)
14231440 BUG_ON (htab_bolt_mapping (tce_alloc_start , tce_alloc_end ,
14241441 __pa (tce_alloc_start ), prot ,
14251442 mmu_linear_psize , mmu_kernel_ssize ));
1443+ update_page_count (mmu_linear_psize ,
1444+ (tce_alloc_end - tce_alloc_start ) >> pshift );
14261445 }
14271446
14281447
@@ -1867,7 +1886,7 @@ int hash_page_mm(struct mm_struct *mm, unsigned long ea,
18671886 * in vmalloc space, so switch vmalloc
18681887 * to 4k pages
18691888 */
1870- printk ( KERN_ALERT "Reducing vmalloc segment "
1889+ pr_alert ( "Reducing vmalloc segment "
18711890 "to 4kB pages because of "
18721891 "non-cacheable mapping\n" );
18731892 psize = mmu_vmalloc_psize = MMU_PAGE_4K ;
@@ -2432,6 +2451,8 @@ DEFINE_DEBUGFS_ATTRIBUTE(fops_hpt_order, hpt_order_get, hpt_order_set, "%llu\n")
24322451
24332452static int __init hash64_debugfs (void )
24342453{
2454+ if (radix_enabled ())
2455+ return 0 ;
24352456 debugfs_create_file ("hpt_order" , 0600 , arch_debugfs_dir , NULL ,
24362457 & fops_hpt_order );
24372458 return 0 ;
0 commit comments