2007-05-07 05:50:58 +08:00
|
|
|
/*
|
2007-10-16 16:27:00 +08:00
|
|
|
* Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
|
2005-04-17 06:20:36 +08:00
|
|
|
* Licensed under the GPL
|
|
|
|
*/
|
|
|
|
|
2007-10-16 16:27:00 +08:00
|
|
|
#include <signal.h>
|
2008-02-05 14:30:46 +08:00
|
|
|
#include "kern_util.h"
|
uml: further bugs.c tidying
bugs.c, for both i386 and x86_64, can undergo further cleaning -
The i386 arch_check_bugs only does one thing, so we might as
well inline the cmov checking.
The i386 includes can be trimmed down a bit.
arch_init_thread wasn't used, so it is deleted.
The panics in arch_handle_signal are turned into printks
because the process is about to get segfaulted anyway, so something is
dying no matter what happens here. Also, the return value was always
the same, so it contained no information, so it can be void instead.
The name is changed to arch_examine_signal because it doesn't handle
anything.
The caller of arch_handle_signal, relay_signal, does things in
a different order. The kernel-mode signal check is now first, which
puts everything else together, making things a bit clearer conceptually.
[akpm@linux-foundation.org: coding-style fixes]
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>
2008-02-05 14:30:40 +08:00
|
|
|
#include "longjmp.h"
|
2007-10-16 16:27:00 +08:00
|
|
|
#include "task.h"
|
uml: further bugs.c tidying
bugs.c, for both i386 and x86_64, can undergo further cleaning -
The i386 arch_check_bugs only does one thing, so we might as
well inline the cmov checking.
The i386 includes can be trimmed down a bit.
arch_init_thread wasn't used, so it is deleted.
The panics in arch_handle_signal are turned into printks
because the process is about to get segfaulted anyway, so something is
dying no matter what happens here. Also, the return value was always
the same, so it contained no information, so it can be void instead.
The name is changed to arch_examine_signal because it doesn't handle
anything.
The caller of arch_handle_signal, relay_signal, does things in
a different order. The kernel-mode signal check is now first, which
puts everything else together, making things a bit clearer conceptually.
[akpm@linux-foundation.org: coding-style fixes]
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>
2008-02-05 14:30:40 +08:00
|
|
|
#include "sysdep/ptrace.h"
|
2005-04-17 06:20:36 +08:00
|
|
|
|
|
|
|
/* Set during early boot */
|
2008-07-24 12:28:49 +08:00
|
|
|
static int host_has_cmov = 1;
|
2008-02-05 14:30:38 +08:00
|
|
|
static jmp_buf cmov_test_return;
|
|
|
|
|
|
|
|
static void cmov_sigill_test_handler(int sig)
|
|
|
|
{
|
|
|
|
host_has_cmov = 0;
|
|
|
|
longjmp(cmov_test_return, 1);
|
|
|
|
}
|
|
|
|
|
uml: further bugs.c tidying
bugs.c, for both i386 and x86_64, can undergo further cleaning -
The i386 arch_check_bugs only does one thing, so we might as
well inline the cmov checking.
The i386 includes can be trimmed down a bit.
arch_init_thread wasn't used, so it is deleted.
The panics in arch_handle_signal are turned into printks
because the process is about to get segfaulted anyway, so something is
dying no matter what happens here. Also, the return value was always
the same, so it contained no information, so it can be void instead.
The name is changed to arch_examine_signal because it doesn't handle
anything.
The caller of arch_handle_signal, relay_signal, does things in
a different order. The kernel-mode signal check is now first, which
puts everything else together, making things a bit clearer conceptually.
[akpm@linux-foundation.org: coding-style fixes]
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>
2008-02-05 14:30:40 +08:00
|
|
|
void arch_check_bugs(void)
|
2008-02-05 14:30:38 +08:00
|
|
|
{
|
|
|
|
struct sigaction old, new;
|
|
|
|
|
|
|
|
printk(UM_KERN_INFO "Checking for host processor cmov support...");
|
|
|
|
new.sa_handler = cmov_sigill_test_handler;
|
|
|
|
|
|
|
|
/* Make sure that SIGILL is enabled after the handler longjmps back */
|
|
|
|
new.sa_flags = SA_NODEFER;
|
|
|
|
sigemptyset(&new.sa_mask);
|
|
|
|
sigaction(SIGILL, &new, &old);
|
|
|
|
|
|
|
|
if (setjmp(cmov_test_return) == 0) {
|
|
|
|
unsigned long foo = 0;
|
|
|
|
__asm__ __volatile__("cmovz %0, %1" : "=r" (foo) : "0" (foo));
|
|
|
|
printk(UM_KERN_CONT "Yes\n");
|
|
|
|
} else
|
|
|
|
printk(UM_KERN_CONT "No\n");
|
|
|
|
|
|
|
|
sigaction(SIGILL, &old, &new);
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
uml: further bugs.c tidying
bugs.c, for both i386 and x86_64, can undergo further cleaning -
The i386 arch_check_bugs only does one thing, so we might as
well inline the cmov checking.
The i386 includes can be trimmed down a bit.
arch_init_thread wasn't used, so it is deleted.
The panics in arch_handle_signal are turned into printks
because the process is about to get segfaulted anyway, so something is
dying no matter what happens here. Also, the return value was always
the same, so it contained no information, so it can be void instead.
The name is changed to arch_examine_signal because it doesn't handle
anything.
The caller of arch_handle_signal, relay_signal, does things in
a different order. The kernel-mode signal check is now first, which
puts everything else together, making things a bit clearer conceptually.
[akpm@linux-foundation.org: coding-style fixes]
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>
2008-02-05 14:30:40 +08:00
|
|
|
void arch_examine_signal(int sig, struct uml_pt_regs *regs)
|
2005-04-17 06:20:36 +08:00
|
|
|
{
|
|
|
|
unsigned char tmp[2];
|
|
|
|
|
2007-10-16 16:27:00 +08:00
|
|
|
/*
|
|
|
|
* This is testing for a cmov (0x0f 0x4x) instruction causing a
|
2005-04-17 06:20:36 +08:00
|
|
|
* SIGILL in init.
|
|
|
|
*/
|
2007-10-16 16:27:00 +08:00
|
|
|
if ((sig != SIGILL) || (TASK_PID(get_current()) != 1))
|
uml: further bugs.c tidying
bugs.c, for both i386 and x86_64, can undergo further cleaning -
The i386 arch_check_bugs only does one thing, so we might as
well inline the cmov checking.
The i386 includes can be trimmed down a bit.
arch_init_thread wasn't used, so it is deleted.
The panics in arch_handle_signal are turned into printks
because the process is about to get segfaulted anyway, so something is
dying no matter what happens here. Also, the return value was always
the same, so it contained no information, so it can be void instead.
The name is changed to arch_examine_signal because it doesn't handle
anything.
The caller of arch_handle_signal, relay_signal, does things in
a different order. The kernel-mode signal check is now first, which
puts everything else together, making things a bit clearer conceptually.
[akpm@linux-foundation.org: coding-style fixes]
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>
2008-02-05 14:30:40 +08:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (copy_from_user_proc(tmp, (void *) UPT_IP(regs), 2)) {
|
|
|
|
printk(UM_KERN_ERR "SIGILL in init, could not read "
|
|
|
|
"instructions!\n");
|
|
|
|
return;
|
|
|
|
}
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-16 16:27:00 +08:00
|
|
|
if ((tmp[0] != 0x0f) || ((tmp[1] & 0xf0) != 0x40))
|
uml: further bugs.c tidying
bugs.c, for both i386 and x86_64, can undergo further cleaning -
The i386 arch_check_bugs only does one thing, so we might as
well inline the cmov checking.
The i386 includes can be trimmed down a bit.
arch_init_thread wasn't used, so it is deleted.
The panics in arch_handle_signal are turned into printks
because the process is about to get segfaulted anyway, so something is
dying no matter what happens here. Also, the return value was always
the same, so it contained no information, so it can be void instead.
The name is changed to arch_examine_signal because it doesn't handle
anything.
The caller of arch_handle_signal, relay_signal, does things in
a different order. The kernel-mode signal check is now first, which
puts everything else together, making things a bit clearer conceptually.
[akpm@linux-foundation.org: coding-style fixes]
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>
2008-02-05 14:30:40 +08:00
|
|
|
return;
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-16 16:27:00 +08:00
|
|
|
if (host_has_cmov == 0)
|
uml: further bugs.c tidying
bugs.c, for both i386 and x86_64, can undergo further cleaning -
The i386 arch_check_bugs only does one thing, so we might as
well inline the cmov checking.
The i386 includes can be trimmed down a bit.
arch_init_thread wasn't used, so it is deleted.
The panics in arch_handle_signal are turned into printks
because the process is about to get segfaulted anyway, so something is
dying no matter what happens here. Also, the return value was always
the same, so it contained no information, so it can be void instead.
The name is changed to arch_examine_signal because it doesn't handle
anything.
The caller of arch_handle_signal, relay_signal, does things in
a different order. The kernel-mode signal check is now first, which
puts everything else together, making things a bit clearer conceptually.
[akpm@linux-foundation.org: coding-style fixes]
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>
2008-02-05 14:30:40 +08:00
|
|
|
printk(UM_KERN_ERR "SIGILL caused by cmov, which this "
|
|
|
|
"processor doesn't implement. Boot a filesystem "
|
|
|
|
"compiled for older processors");
|
2007-10-16 16:27:00 +08:00
|
|
|
else if (host_has_cmov == 1)
|
uml: further bugs.c tidying
bugs.c, for both i386 and x86_64, can undergo further cleaning -
The i386 arch_check_bugs only does one thing, so we might as
well inline the cmov checking.
The i386 includes can be trimmed down a bit.
arch_init_thread wasn't used, so it is deleted.
The panics in arch_handle_signal are turned into printks
because the process is about to get segfaulted anyway, so something is
dying no matter what happens here. Also, the return value was always
the same, so it contained no information, so it can be void instead.
The name is changed to arch_examine_signal because it doesn't handle
anything.
The caller of arch_handle_signal, relay_signal, does things in
a different order. The kernel-mode signal check is now first, which
puts everything else together, making things a bit clearer conceptually.
[akpm@linux-foundation.org: coding-style fixes]
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>
2008-02-05 14:30:40 +08:00
|
|
|
printk(UM_KERN_ERR "SIGILL caused by cmov, which this "
|
|
|
|
"processor claims to implement");
|
|
|
|
else
|
|
|
|
printk(UM_KERN_ERR "Bad value for host_has_cmov (%d)",
|
|
|
|
host_has_cmov);
|
2005-04-17 06:20:36 +08:00
|
|
|
}
|