6060bool no_hash_pointers __ro_after_init ;
6161EXPORT_SYMBOL_GPL (no_hash_pointers );
6262
63+ /*
64+ * Hashed pointers policy selected by "hash_pointers=..." boot param
65+ *
66+ * `auto` - Hashed pointers enabled unless disabled by slub_debug_enabled=true
67+ * `always` - Hashed pointers enabled unconditionally
68+ * `never` - Hashed pointers disabled unconditionally
69+ */
70+ enum hash_pointers_policy {
71+ HASH_PTR_AUTO = 0 ,
72+ HASH_PTR_ALWAYS ,
73+ HASH_PTR_NEVER
74+ };
75+ static enum hash_pointers_policy hash_pointers_mode __initdata ;
76+
6377noinline
6478static unsigned long long simple_strntoull (const char * startp , char * * endp , unsigned int base , size_t max_chars )
6579{
@@ -2270,12 +2284,23 @@ char *resource_or_range(const char *fmt, char *buf, char *end, void *ptr,
22702284 return resource_string (buf , end , ptr , spec , fmt );
22712285}
22722286
2273- int __init no_hash_pointers_enable ( char * str )
2287+ void __init hash_pointers_finalize ( bool slub_debug )
22742288{
2275- if (no_hash_pointers )
2276- return 0 ;
2289+ switch (hash_pointers_mode ) {
2290+ case HASH_PTR_ALWAYS :
2291+ no_hash_pointers = false;
2292+ break ;
2293+ case HASH_PTR_NEVER :
2294+ no_hash_pointers = true;
2295+ break ;
2296+ case HASH_PTR_AUTO :
2297+ default :
2298+ no_hash_pointers = slub_debug ;
2299+ break ;
2300+ }
22772301
2278- no_hash_pointers = true;
2302+ if (!no_hash_pointers )
2303+ return ;
22792304
22802305 pr_warn ("**********************************************************\n" );
22812306 pr_warn ("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n" );
@@ -2288,11 +2313,39 @@ int __init no_hash_pointers_enable(char *str)
22882313 pr_warn ("** the kernel, report this immediately to your system **\n" );
22892314 pr_warn ("** administrator! **\n" );
22902315 pr_warn ("** **\n" );
2316+ pr_warn ("** Use hash_pointers=always to force this mode off **\n" );
2317+ pr_warn ("** **\n" );
22912318 pr_warn ("** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE **\n" );
22922319 pr_warn ("**********************************************************\n" );
2320+ }
2321+
2322+ static int __init hash_pointers_mode_parse (char * str )
2323+ {
2324+ if (!str ) {
2325+ pr_warn ("Hash pointers mode empty; falling back to auto.\n" );
2326+ hash_pointers_mode = HASH_PTR_AUTO ;
2327+ } else if (strncmp (str , "auto" , 4 ) == 0 ) {
2328+ pr_info ("Hash pointers mode set to auto.\n" );
2329+ hash_pointers_mode = HASH_PTR_AUTO ;
2330+ } else if (strncmp (str , "never" , 5 ) == 0 ) {
2331+ pr_info ("Hash pointers mode set to never.\n" );
2332+ hash_pointers_mode = HASH_PTR_NEVER ;
2333+ } else if (strncmp (str , "always" , 6 ) == 0 ) {
2334+ pr_info ("Hash pointers mode set to always.\n" );
2335+ hash_pointers_mode = HASH_PTR_ALWAYS ;
2336+ } else {
2337+ pr_warn ("Unknown hash_pointers mode '%s' specified; assuming auto.\n" , str );
2338+ hash_pointers_mode = HASH_PTR_AUTO ;
2339+ }
22932340
22942341 return 0 ;
22952342}
2343+ early_param ("hash_pointers" , hash_pointers_mode_parse );
2344+
2345+ static int __init no_hash_pointers_enable (char * str )
2346+ {
2347+ return hash_pointers_mode_parse ("never" );
2348+ }
22962349early_param ("no_hash_pointers" , no_hash_pointers_enable );
22972350
22982351/*
0 commit comments