diff options
author | Vegard Nossum <vegard.nossum@gmail.com> | 2009-02-27 05:35:55 -0500 |
---|---|---|
committer | Vegard Nossum <vegard.nossum@gmail.com> | 2009-06-15 09:49:22 -0400 |
commit | ac61a7579625ddfca3b2e0aa298879a94d15884d (patch) | |
tree | adb11c2513bfdb4825e1ac213f8116d7280ac4a9 /arch/x86/mm/kmemcheck/kmemcheck.c | |
parent | eb63657e1314ae4af5e19a61db8dc1b6e935775a (diff) |
kmemcheck: add opcode self-testing at boot
We've had some troubles in the past with weird instructions. This
patch adds a self-test framework which can be used to verify that
a certain set of opcodes are decoded correctly. Of course, the
opcodes which are not tested can still give the wrong results.
In short, this is just a safeguard to catch unintentional changes
in the opcode decoder. It does not mean that errors can't still
occur!
[rebased for mainline inclusion]
Signed-off-by: Vegard Nossum <vegard.nossum@gmail.com>
Diffstat (limited to 'arch/x86/mm/kmemcheck/kmemcheck.c')
-rw-r--r-- | arch/x86/mm/kmemcheck/kmemcheck.c | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/arch/x86/mm/kmemcheck/kmemcheck.c b/arch/x86/mm/kmemcheck/kmemcheck.c index 6931e5115bcd..2c55ed098654 100644 --- a/arch/x86/mm/kmemcheck/kmemcheck.c +++ b/arch/x86/mm/kmemcheck/kmemcheck.c | |||
@@ -29,8 +29,10 @@ | |||
29 | #include "error.h" | 29 | #include "error.h" |
30 | #include "opcode.h" | 30 | #include "opcode.h" |
31 | #include "pte.h" | 31 | #include "pte.h" |
32 | #include "selftest.h" | ||
32 | #include "shadow.h" | 33 | #include "shadow.h" |
33 | 34 | ||
35 | |||
34 | #ifdef CONFIG_KMEMCHECK_DISABLED_BY_DEFAULT | 36 | #ifdef CONFIG_KMEMCHECK_DISABLED_BY_DEFAULT |
35 | # define KMEMCHECK_ENABLED 0 | 37 | # define KMEMCHECK_ENABLED 0 |
36 | #endif | 38 | #endif |
@@ -47,8 +49,6 @@ int kmemcheck_enabled = KMEMCHECK_ENABLED; | |||
47 | 49 | ||
48 | int __init kmemcheck_init(void) | 50 | int __init kmemcheck_init(void) |
49 | { | 51 | { |
50 | printk(KERN_INFO "kmemcheck: Initialized\n"); | ||
51 | |||
52 | #ifdef CONFIG_SMP | 52 | #ifdef CONFIG_SMP |
53 | /* | 53 | /* |
54 | * Limit SMP to use a single CPU. We rely on the fact that this code | 54 | * Limit SMP to use a single CPU. We rely on the fact that this code |
@@ -61,25 +61,18 @@ int __init kmemcheck_init(void) | |||
61 | } | 61 | } |
62 | #endif | 62 | #endif |
63 | 63 | ||
64 | if (!kmemcheck_selftest()) { | ||
65 | printk(KERN_INFO "kmemcheck: self-tests failed; disabling\n"); | ||
66 | kmemcheck_enabled = 0; | ||
67 | return -EINVAL; | ||
68 | } | ||
69 | |||
70 | printk(KERN_INFO "kmemcheck: Initialized\n"); | ||
64 | return 0; | 71 | return 0; |
65 | } | 72 | } |
66 | 73 | ||
67 | early_initcall(kmemcheck_init); | 74 | early_initcall(kmemcheck_init); |
68 | 75 | ||
69 | #ifdef CONFIG_KMEMCHECK_DISABLED_BY_DEFAULT | ||
70 | # define KMEMCHECK_ENABLED 0 | ||
71 | #endif | ||
72 | |||
73 | #ifdef CONFIG_KMEMCHECK_ENABLED_BY_DEFAULT | ||
74 | # define KMEMCHECK_ENABLED 1 | ||
75 | #endif | ||
76 | |||
77 | #ifdef CONFIG_KMEMCHECK_ONESHOT_BY_DEFAULT | ||
78 | # define KMEMCHECK_ENABLED 2 | ||
79 | #endif | ||
80 | |||
81 | int kmemcheck_enabled = KMEMCHECK_ENABLED; | ||
82 | |||
83 | /* | 76 | /* |
84 | * We need to parse the kmemcheck= option before any memory is allocated. | 77 | * We need to parse the kmemcheck= option before any memory is allocated. |
85 | */ | 78 | */ |