Commit 642116d4 authored by Linus Torvalds's avatar Linus Torvalds

Merge branch 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 boot updates from Ingo Molnar:
 "Two cleanups and a bugfix for a rare boot option combination"

* 'x86-boot-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/boot/KASLR: Remove return value from handle_mem_options()
  x86/corruption-check: Use pr_*() instead of printk()
  x86/corruption-check: Fix panic in memory_corruption_check() when boot option without value is provided
parents e1d20bea 44060e8a
...@@ -241,7 +241,7 @@ static void parse_gb_huge_pages(char *param, char *val) ...@@ -241,7 +241,7 @@ static void parse_gb_huge_pages(char *param, char *val)
} }
static int handle_mem_options(void) static void handle_mem_options(void)
{ {
char *args = (char *)get_cmd_line_ptr(); char *args = (char *)get_cmd_line_ptr();
size_t len = strlen((char *)args); size_t len = strlen((char *)args);
...@@ -251,7 +251,7 @@ static int handle_mem_options(void) ...@@ -251,7 +251,7 @@ static int handle_mem_options(void)
if (!strstr(args, "memmap=") && !strstr(args, "mem=") && if (!strstr(args, "memmap=") && !strstr(args, "mem=") &&
!strstr(args, "hugepages")) !strstr(args, "hugepages"))
return 0; return;
tmp_cmdline = malloc(len + 1); tmp_cmdline = malloc(len + 1);
if (!tmp_cmdline) if (!tmp_cmdline)
...@@ -269,8 +269,7 @@ static int handle_mem_options(void) ...@@ -269,8 +269,7 @@ static int handle_mem_options(void)
/* Stop at -- */ /* Stop at -- */
if (!val && strcmp(param, "--") == 0) { if (!val && strcmp(param, "--") == 0) {
warn("Only '--' specified in cmdline"); warn("Only '--' specified in cmdline");
free(tmp_cmdline); goto out;
return -1;
} }
if (!strcmp(param, "memmap")) { if (!strcmp(param, "memmap")) {
...@@ -283,16 +282,16 @@ static int handle_mem_options(void) ...@@ -283,16 +282,16 @@ static int handle_mem_options(void)
if (!strcmp(p, "nopentium")) if (!strcmp(p, "nopentium"))
continue; continue;
mem_size = memparse(p, &p); mem_size = memparse(p, &p);
if (mem_size == 0) { if (mem_size == 0)
free(tmp_cmdline); goto out;
return -EINVAL;
}
mem_limit = mem_size; mem_limit = mem_size;
} }
} }
out:
free(tmp_cmdline); free(tmp_cmdline);
return 0; return;
} }
/* /*
...@@ -578,7 +577,6 @@ static void process_mem_region(struct mem_vector *entry, ...@@ -578,7 +577,6 @@ static void process_mem_region(struct mem_vector *entry,
unsigned long image_size) unsigned long image_size)
{ {
struct mem_vector region, overlap; struct mem_vector region, overlap;
struct slot_area slot_area;
unsigned long start_orig, end; unsigned long start_orig, end;
struct mem_vector cur_entry; struct mem_vector cur_entry;
......
// SPDX-License-Identifier: GPL-2.0 // SPDX-License-Identifier: GPL-2.0
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
#include <linux/init.h> #include <linux/init.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/kthread.h> #include <linux/kthread.h>
...@@ -31,11 +34,17 @@ static __init int set_corruption_check(char *arg) ...@@ -31,11 +34,17 @@ static __init int set_corruption_check(char *arg)
ssize_t ret; ssize_t ret;
unsigned long val; unsigned long val;
if (!arg) {
pr_err("memory_corruption_check config string not provided\n");
return -EINVAL;
}
ret = kstrtoul(arg, 10, &val); ret = kstrtoul(arg, 10, &val);
if (ret) if (ret)
return ret; return ret;
memory_corruption_check = val; memory_corruption_check = val;
return 0; return 0;
} }
early_param("memory_corruption_check", set_corruption_check); early_param("memory_corruption_check", set_corruption_check);
...@@ -45,6 +54,11 @@ static __init int set_corruption_check_period(char *arg) ...@@ -45,6 +54,11 @@ static __init int set_corruption_check_period(char *arg)
ssize_t ret; ssize_t ret;
unsigned long val; unsigned long val;
if (!arg) {
pr_err("memory_corruption_check_period config string not provided\n");
return -EINVAL;
}
ret = kstrtoul(arg, 10, &val); ret = kstrtoul(arg, 10, &val);
if (ret) if (ret)
return ret; return ret;
...@@ -59,6 +73,11 @@ static __init int set_corruption_check_size(char *arg) ...@@ -59,6 +73,11 @@ static __init int set_corruption_check_size(char *arg)
char *end; char *end;
unsigned size; unsigned size;
if (!arg) {
pr_err("memory_corruption_check_size config string not provided\n");
return -EINVAL;
}
size = memparse(arg, &end); size = memparse(arg, &end);
if (*end == '\0') if (*end == '\0')
...@@ -113,7 +132,7 @@ void __init setup_bios_corruption_check(void) ...@@ -113,7 +132,7 @@ void __init setup_bios_corruption_check(void)
} }
if (num_scan_areas) if (num_scan_areas)
printk(KERN_INFO "Scanning %d areas for low memory corruption\n", num_scan_areas); pr_info("Scanning %d areas for low memory corruption\n", num_scan_areas);
} }
...@@ -132,8 +151,7 @@ void check_for_bios_corruption(void) ...@@ -132,8 +151,7 @@ void check_for_bios_corruption(void)
for (; size; addr++, size -= sizeof(unsigned long)) { for (; size; addr++, size -= sizeof(unsigned long)) {
if (!*addr) if (!*addr)
continue; continue;
printk(KERN_ERR "Corrupted low memory at %p (%lx phys) = %08lx\n", pr_err("Corrupted low memory at %p (%lx phys) = %08lx\n", addr, __pa(addr), *addr);
addr, __pa(addr), *addr);
corruption = 1; corruption = 1;
*addr = 0; *addr = 0;
} }
...@@ -157,11 +175,11 @@ static int start_periodic_check_for_corruption(void) ...@@ -157,11 +175,11 @@ static int start_periodic_check_for_corruption(void)
if (!num_scan_areas || !memory_corruption_check || corruption_check_period == 0) if (!num_scan_areas || !memory_corruption_check || corruption_check_period == 0)
return 0; return 0;
printk(KERN_INFO "Scanning for low memory corruption every %d seconds\n", pr_info("Scanning for low memory corruption every %d seconds\n", corruption_check_period);
corruption_check_period);
/* First time we run the checks right away */ /* First time we run the checks right away */
schedule_delayed_work(&bios_check_work, 0); schedule_delayed_work(&bios_check_work, 0);
return 0; return 0;
} }
device_initcall(start_periodic_check_for_corruption); device_initcall(start_periodic_check_for_corruption);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment