Commit c64df70793a9c344874eb4af19f85e0662d2d3ee

Authored by Yinghai Lu
Committed by Ingo Molnar
1 parent 9b967106da

x86: memtest bootparam

Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

Showing 4 changed files with 56 additions and 12 deletions Side-by-side Diff

Documentation/kernel-parameters.txt
... ... @@ -1147,6 +1147,11 @@
1147 1147 or
1148 1148 memmap=0x10000$0x18690000
1149 1149  
  1150 + memtest= [KNL,X86_64] Enable memtest
  1151 + Format: <integer>
  1152 + range: 0,4 : pattern number
  1153 + default : 0 <disable>
  1154 +
1150 1155 meye.*= [HW] Set MotionEye Camera parameters
1151 1156 See Documentation/video4linux/meye.txt.
1152 1157  
... ... @@ -382,6 +382,35 @@
382 382  
383 383 endif
384 384  
  385 +config MEMTEST_BOOTPARAM
  386 + bool "Memtest boot parameter"
  387 + depends on X86_64
  388 + default y
  389 + help
  390 + This option adds a kernel parameter 'memtest', which allows memtest
  391 + to be disabled at boot. If this option is selected, memtest
  392 + functionality can be disabled with memtest=0 on the kernel
  393 + command line. The purpose of this option is to allow a single
  394 + kernel image to be distributed with memtest built in, but not
  395 + necessarily enabled.
  396 +
  397 + If you are unsure how to answer this question, answer Y.
  398 +
  399 +config MEMTEST_BOOTPARAM_VALUE
  400 + int "Memtest boot parameter default value (0-4)"
  401 + depends on MEMTEST_BOOTPARAM
  402 + range 0 4
  403 + default 0
  404 + help
  405 + This option sets the default value for the kernel parameter
  406 + 'memtest', which allows memtest to be disabled at boot. If this
  407 + option is set to 0 (zero), the memtest kernel parameter will
  408 + default to 0, disabling memtest at bootup. If this option is
  409 + set to 4, the memtest kernel parameter will default to 4,
  410 + enabling memtest at bootup, and use that as pattern number.
  411 +
  412 + If you are unsure how to answer this question, answer 0.
  413 +
385 414 config ACPI_SRAT
386 415 def_bool y
387 416 depends on X86_32 && ACPI && NUMA && (X86_SUMMIT || X86_GENERICARCH)
arch/x86/kernel/e820_64.c
... ... @@ -241,7 +241,9 @@
241 241 /*
242 242 * Find next free range after *start
243 243 */
244   -unsigned long __init find_e820_area_size(unsigned long start, unsigned long *sizep, unsigned long align)
  244 +unsigned long __init find_e820_area_size(unsigned long start,
  245 + unsigned long *sizep,
  246 + unsigned long align)
245 247 {
246 248 int i;
247 249  
248 250  
249 251  
250 252  
... ... @@ -254,17 +256,15 @@
254 256 continue;
255 257 addr = round_up(ei->addr, align);
256 258 ei_last = ei->addr + ei->size;
257   -// printk(KERN_DEBUG "find_e820_area_size : e820 %d [%llx, %lx]\n", i, ei->addr, ei_last);
258 259 if (addr < start)
259 260 addr = round_up(start, align);
260   -// printk(KERN_DEBUG "find_e820_area_size : 0 [%lx, %lx]\n", addr, ei_last);
261 261 if (addr >= ei_last)
262 262 continue;
263 263 *sizep = ei_last - addr;
264   - while (bad_addr_size(&addr, sizep, align) && addr+ *sizep <= ei_last)
  264 + while (bad_addr_size(&addr, sizep, align) &&
  265 + addr + *sizep <= ei_last)
265 266 ;
266 267 last = addr + *sizep;
267   -// printk(KERN_DEBUG "find_e820_area_size : 1 [%lx, %lx]\n", addr, last);
268 268 if (last > ei_last)
269 269 continue;
270 270 return addr;
arch/x86/mm/init_64.c
... ... @@ -427,7 +427,10 @@
427 427 direct_gbpages = 0;
428 428 }
429 429  
430   -static void __init memtest(unsigned long start_phys, unsigned long size, unsigned pattern)
  430 +#ifdef CONFIG_MEMTEST_BOOTPARAM
  431 +
  432 +static void __init memtest(unsigned long start_phys, unsigned long size,
  433 + unsigned pattern)
431 434 {
432 435 unsigned long i;
433 436 unsigned long *start;
434 437  
... ... @@ -486,11 +489,12 @@
486 489  
487 490 }
488 491  
489   -static int __initdata memtest_pattern;
  492 +static int memtest_pattern __initdata = CONFIG_MEMTEST_BOOTPARAM_VALUE;
  493 +
490 494 static int __init parse_memtest(char *arg)
491 495 {
492 496 if (arg)
493   - memtest_pattern = simple_strtoul(arg, NULL, 0) + 1;
  497 + memtest_pattern = simple_strtoul(arg, NULL, 0);
494 498 return 0;
495 499 }
496 500  
... ... @@ -501,8 +505,10 @@
501 505 unsigned long t_start, t_size;
502 506 unsigned pattern;
503 507  
504   - if (memtest_pattern)
505   - printk(KERN_INFO "early_memtest: pattern num %d", memtest_pattern);
  508 + if (!memtest_pattern)
  509 + return;
  510 +
  511 + printk(KERN_INFO "early_memtest: pattern num %d", memtest_pattern);
506 512 for (pattern = 0; pattern < memtest_pattern; pattern++) {
507 513 t_start = start;
508 514 t_size = 0;
509 515  
... ... @@ -523,9 +529,13 @@
523 529 t_start += t_size;
524 530 }
525 531 }
526   - if (memtest_pattern)
527   - printk(KERN_CONT "\n");
  532 + printk(KERN_CONT "\n");
528 533 }
  534 +#else
  535 +static void __init early_memtest(unsigned long start, unsigned long end)
  536 +{
  537 +}
  538 +#endif
529 539  
530 540 /*
531 541 * Setup the direct mapping of the physical memory at PAGE_OFFSET.