diff options
author | Andreas Herrmann <andreas.herrmann3@amd.com> | 2009-02-25 05:26:18 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2009-02-25 06:19:44 -0500 |
commit | 40823f737e5bd186a1156fb1c28f360260e1e084 (patch) | |
tree | 67fc9fe9752ad585e6e2c5b13086c98820ddd75c /arch/x86/mm/memtest.c | |
parent | a852cbfaaf8122827602027b1614971cfd832304 (diff) |
x86: memtest: reuse test patterns when memtest parameter exceeds number of available patterns
Impact: fix unexpected behaviour when pattern number is out of range
Current implementation provides 4 patterns for memtest. The code doesn't
check whether the memtest parameter value exceeds the maximum pattern number.
Instead the memtest code pretends to test with non-existing patterns, e.g.
when booting with memtest=10 I've observed the following
...
early_memtest: pattern num 10
0000001000 - 0000006000 pattern 0
...
0000001000 - 0000006000 pattern 1
...
0000001000 - 0000006000 pattern 2
...
0000001000 - 0000006000 pattern 3
...
0000001000 - 0000006000 pattern 4
...
0000001000 - 0000006000 pattern 5
...
0000001000 - 0000006000 pattern 6
...
0000001000 - 0000006000 pattern 7
...
0000001000 - 0000006000 pattern 8
...
0000001000 - 0000006000 pattern 9
...
But in fact Linux didn't test anything for patterns > 4 as the default
case in memtest() is to leave the function.
I suggest to use the memtest parameter as the number of tests to be
performed and to re-iterate over all existing patterns.
Signed-off-by: Andreas Herrmann <andreas.herrmann3@amd.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'arch/x86/mm/memtest.c')
-rw-r--r-- | arch/x86/mm/memtest.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/arch/x86/mm/memtest.c b/arch/x86/mm/memtest.c index 9cab18b0b857..00b8bdc64c3e 100644 --- a/arch/x86/mm/memtest.c +++ b/arch/x86/mm/memtest.c | |||
@@ -9,6 +9,8 @@ | |||
9 | 9 | ||
10 | #include <asm/e820.h> | 10 | #include <asm/e820.h> |
11 | 11 | ||
12 | #define _MAX_MEM_PATTERNS 4 | ||
13 | |||
12 | static void __init memtest(unsigned long start_phys, unsigned long size, | 14 | static void __init memtest(unsigned long start_phys, unsigned long size, |
13 | unsigned pattern) | 15 | unsigned pattern) |
14 | { | 16 | { |
@@ -21,6 +23,8 @@ static void __init memtest(unsigned long start_phys, unsigned long size, | |||
21 | unsigned long count; | 23 | unsigned long count; |
22 | unsigned long incr; | 24 | unsigned long incr; |
23 | 25 | ||
26 | pattern = pattern % _MAX_MEM_PATTERNS; | ||
27 | |||
24 | switch (pattern) { | 28 | switch (pattern) { |
25 | case 0: | 29 | case 0: |
26 | val = 0UL; | 30 | val = 0UL; |
@@ -110,8 +114,9 @@ void __init early_memtest(unsigned long start, unsigned long end) | |||
110 | t_size = end - t_start; | 114 | t_size = end - t_start; |
111 | 115 | ||
112 | printk(KERN_CONT "\n %010llx - %010llx pattern %d", | 116 | printk(KERN_CONT "\n %010llx - %010llx pattern %d", |
113 | (unsigned long long)t_start, | 117 | (unsigned long long)t_start, |
114 | (unsigned long long)t_start + t_size, pattern); | 118 | (unsigned long long)t_start + t_size, |
119 | pattern % _MAX_MEM_PATTERNS); | ||
115 | 120 | ||
116 | memtest(t_start, t_size, pattern); | 121 | memtest(t_start, t_size, pattern); |
117 | 122 | ||