1 #include <linux/module.h>
2 #include <linux/sched.h>
15 #define MAX_SCAN_AREAS 8
19 static unsigned __read_mostly corruption_check_size = 64*1024;
22 static struct scan_area {
26 static int num_scan_areas;
28 static __init int set_corruption_check(
char *
arg)
33 ret = kstrtoul(arg, 10, &val);
37 memory_corruption_check =
val;
40 early_param(
"memory_corruption_check", set_corruption_check);
42 static __init int set_corruption_check_period(
char *arg)
47 ret = kstrtoul(arg, 10, &val);
51 corruption_check_period =
val;
54 early_param(
"memory_corruption_check_period", set_corruption_check_period);
56 static __init int set_corruption_check_size(
char *arg)
64 corruption_check_size =
size;
66 return (size == corruption_check_size) ? 0 : -
EINVAL;
68 early_param(
"memory_corruption_check_size", set_corruption_check_size);
76 if (memory_corruption_check == -1) {
77 memory_corruption_check =
78 #ifdef CONFIG_X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK
86 if (corruption_check_size == 0)
87 memory_corruption_check = 0;
89 if (!memory_corruption_check)
103 scan_areas[num_scan_areas].addr =
start;
104 scan_areas[num_scan_areas].size = end -
start;
114 printk(
KERN_INFO "Scanning %d areas for low memory corruption\n", num_scan_areas);
123 if (!memory_corruption_check)
126 for (i = 0; i < num_scan_areas; i++) {
127 unsigned long *
addr =
__va(scan_areas[i].addr);
128 unsigned long size = scan_areas[
i].size;
130 for (;
size; addr++, size -=
sizeof(
unsigned long)) {
133 printk(
KERN_ERR "Corrupted low memory at %p (%lx phys) = %08lx\n",
134 addr,
__pa(addr), *addr);
153 static int start_periodic_check_for_corruption(
void)
155 if (!num_scan_areas || !memory_corruption_check || corruption_check_period == 0)
158 printk(
KERN_INFO "Scanning for low memory corruption every %d seconds\n",
159 corruption_check_period);