diff options
author | Karol Swietlicki <magotari@gmail.com> | 2008-02-05 01:30:38 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-05 12:44:25 -0500 |
commit | 235a6f06eb5571db600a743cda7c73fd4f74127f (patch) | |
tree | 218c05cfe030a2debdfe8dc66485ad2bec4c1bc3 /arch | |
parent | 0ba9d3f91d213f6d07c84230a0b3e2b16a0bb176 (diff) |
uml: improve detection of host cmov
This patch introduces a new way of checking for the cmov instruction. I use
signal handling instead of reading /proc/cpuinfo.
[ jdike - Fiddled the asm to make it obvious that it didn't mess with
any in-use registers and made test_for_host_cmov void ]
[akpm@linux-foundation.org: coding-style fixes]
Signed-off-by: Karol Swietlicki <magotari@gmail.com>
Signed-off-by: Jeff Dike <jdike@linux.intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/um/include/common-offsets.h | 1 | ||||
-rw-r--r-- | arch/um/sys-i386/bugs.c | 40 |
2 files changed, 32 insertions, 9 deletions
diff --git a/arch/um/include/common-offsets.h b/arch/um/include/common-offsets.h index 0edab695ed4e..b54bd35585c2 100644 --- a/arch/um/include/common-offsets.h +++ b/arch/um/include/common-offsets.h | |||
@@ -18,6 +18,7 @@ DEFINE_STR(UM_KERN_WARNING, KERN_WARNING); | |||
18 | DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE); | 18 | DEFINE_STR(UM_KERN_NOTICE, KERN_NOTICE); |
19 | DEFINE_STR(UM_KERN_INFO, KERN_INFO); | 19 | DEFINE_STR(UM_KERN_INFO, KERN_INFO); |
20 | DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG); | 20 | DEFINE_STR(UM_KERN_DEBUG, KERN_DEBUG); |
21 | DEFINE_STR(UM_KERN_CONT, KERN_CONT); | ||
21 | 22 | ||
22 | DEFINE(UM_ELF_CLASS, ELF_CLASS); | 23 | DEFINE(UM_ELF_CLASS, ELF_CLASS); |
23 | DEFINE(UM_ELFCLASS32, ELFCLASS32); | 24 | DEFINE(UM_ELFCLASS32, ELFCLASS32); |
diff --git a/arch/um/sys-i386/bugs.c b/arch/um/sys-i386/bugs.c index 5ee4c366074e..797945cd3df2 100644 --- a/arch/um/sys-i386/bugs.c +++ b/arch/um/sys-i386/bugs.c | |||
@@ -10,11 +10,41 @@ | |||
10 | #include "os.h" | 10 | #include "os.h" |
11 | #include "task.h" | 11 | #include "task.h" |
12 | #include "user.h" | 12 | #include "user.h" |
13 | #include "sysdep/archsetjmp.h" | ||
13 | 14 | ||
14 | #define MAXTOKEN 64 | 15 | #define MAXTOKEN 64 |
15 | 16 | ||
16 | /* Set during early boot */ | 17 | /* Set during early boot */ |
17 | int host_has_cmov = 1; | 18 | int host_has_cmov = 1; |
19 | static jmp_buf cmov_test_return; | ||
20 | |||
21 | static void cmov_sigill_test_handler(int sig) | ||
22 | { | ||
23 | host_has_cmov = 0; | ||
24 | longjmp(cmov_test_return, 1); | ||
25 | } | ||
26 | |||
27 | static void test_for_host_cmov(void) | ||
28 | { | ||
29 | struct sigaction old, new; | ||
30 | |||
31 | printk(UM_KERN_INFO "Checking for host processor cmov support..."); | ||
32 | new.sa_handler = cmov_sigill_test_handler; | ||
33 | |||
34 | /* Make sure that SIGILL is enabled after the handler longjmps back */ | ||
35 | new.sa_flags = SA_NODEFER; | ||
36 | sigemptyset(&new.sa_mask); | ||
37 | sigaction(SIGILL, &new, &old); | ||
38 | |||
39 | if (setjmp(cmov_test_return) == 0) { | ||
40 | unsigned long foo = 0; | ||
41 | __asm__ __volatile__("cmovz %0, %1" : "=r" (foo) : "0" (foo)); | ||
42 | printk(UM_KERN_CONT "Yes\n"); | ||
43 | } else | ||
44 | printk(UM_KERN_CONT "No\n"); | ||
45 | |||
46 | sigaction(SIGILL, &old, &new); | ||
47 | } | ||
18 | 48 | ||
19 | static char token(int fd, char *buf, int len, char stop) | 49 | static char token(int fd, char *buf, int len, char stop) |
20 | { | 50 | { |
@@ -153,15 +183,7 @@ void arch_init_thread(void) | |||
153 | 183 | ||
154 | void arch_check_bugs(void) | 184 | void arch_check_bugs(void) |
155 | { | 185 | { |
156 | int have_it; | 186 | test_for_host_cmov(); |
157 | |||
158 | if (os_access("/proc/cpuinfo", OS_ACC_R_OK) < 0) { | ||
159 | printk(UM_KERN_ERR "/proc/cpuinfo not available - skipping CPU " | ||
160 | "capability checks\n"); | ||
161 | return; | ||
162 | } | ||
163 | if (check_cpu_flag("cmov", &have_it)) | ||
164 | host_has_cmov = have_it; | ||
165 | } | 187 | } |
166 | 188 | ||
167 | int arch_handle_signal(int sig, struct uml_pt_regs *regs) | 189 | int arch_handle_signal(int sig, struct uml_pt_regs *regs) |