2 * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
3 * Licensed under the GPL
9 #include "kern_constants.h"
13 #include "sysdep/archsetjmp.h"
15 /* Set during early boot */
16 int host_has_cmov = 1;
17 static jmp_buf cmov_test_return;
19 static void cmov_sigill_test_handler(int sig)
22 longjmp(cmov_test_return, 1);
25 static void test_for_host_cmov(void)
27 struct sigaction old, new;
29 printk(UM_KERN_INFO "Checking for host processor cmov support...");
30 new.sa_handler = cmov_sigill_test_handler;
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);
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");
42 printk(UM_KERN_CONT "No\n");
44 sigaction(SIGILL, &old, &new);
47 void arch_init_thread(void)
51 void arch_check_bugs(void)
56 int arch_handle_signal(int sig, struct uml_pt_regs *regs)
61 * This is testing for a cmov (0x0f 0x4x) instruction causing a
64 if ((sig != SIGILL) || (TASK_PID(get_current()) != 1))
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))
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 "
76 else if (host_has_cmov == 1)
77 panic("SIGILL caused by cmov, which this processor claims to "
79 else panic("Bad value for host_has_cmov (%d)", host_has_cmov);