]> err.no Git - linux-2.6/blob - arch/um/sys-i386/bugs.c
uml: remove now unused code
[linux-2.6] / arch / um / sys-i386 / bugs.c
1 /*
2  * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3  * Licensed under the GPL
4  */
5
6 #include <errno.h>
7 #include <signal.h>
8 #include <string.h>
9 #include "kern_constants.h"
10 #include "os.h"
11 #include "task.h"
12 #include "user.h"
13 #include "sysdep/archsetjmp.h"
14
15 /* Set during early boot */
16 int host_has_cmov = 1;
17 static jmp_buf cmov_test_return;
18
19 static void cmov_sigill_test_handler(int sig)
20 {
21         host_has_cmov = 0;
22         longjmp(cmov_test_return, 1);
23 }
24
25 static void test_for_host_cmov(void)
26 {
27         struct sigaction old, new;
28
29         printk(UM_KERN_INFO "Checking for host processor cmov support...");
30         new.sa_handler = cmov_sigill_test_handler;
31
32         /* Make sure that SIGILL is enabled after the handler longjmps back */
33         new.sa_flags = SA_NODEFER;
34         sigemptyset(&new.sa_mask);
35         sigaction(SIGILL, &new, &old);
36
37         if (setjmp(cmov_test_return) == 0) {
38                 unsigned long foo = 0;
39                 __asm__ __volatile__("cmovz %0, %1" : "=r" (foo) : "0" (foo));
40                 printk(UM_KERN_CONT "Yes\n");
41         } else
42                 printk(UM_KERN_CONT "No\n");
43
44         sigaction(SIGILL, &old, &new);
45 }
46
47 void arch_init_thread(void)
48 {
49 }
50
51 void arch_check_bugs(void)
52 {
53         test_for_host_cmov();
54 }
55
56 int arch_handle_signal(int sig, struct uml_pt_regs *regs)
57 {
58         unsigned char tmp[2];
59
60         /*
61          * This is testing for a cmov (0x0f 0x4x) instruction causing a
62          * SIGILL in init.
63          */
64         if ((sig != SIGILL) || (TASK_PID(get_current()) != 1))
65                 return 0;
66
67         if (copy_from_user_proc(tmp, (void *) UPT_IP(regs), 2))
68                 panic("SIGILL in init, could not read instructions!\n");
69         if ((tmp[0] != 0x0f) || ((tmp[1] & 0xf0) != 0x40))
70                 return 0;
71
72         if (host_has_cmov == 0)
73                 panic("SIGILL caused by cmov, which this processor doesn't "
74                       "implement, boot a filesystem compiled for older "
75                       "processors");
76         else if (host_has_cmov == 1)
77                 panic("SIGILL caused by cmov, which this processor claims to "
78                       "implement");
79         else panic("Bad value for host_has_cmov (%d)", host_has_cmov);
80         return 0;
81 }