aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorJeff Dike <jdike@addtoit.com>2008-02-05 01:30:40 -0500
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2008-02-05 12:44:25 -0500
commit9226b8384776798986640ce07764d17ba66aa54f (patch)
treecffd1f6e14124729da114192aee83fe88e9f21e5 /arch
parent06d9bd3ad6da2422f838fd11d5d5348fa579bdb2 (diff)
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>
Diffstat (limited to 'arch')
-rw-r--r--arch/um/include/arch.h2
-rw-r--r--arch/um/kernel/trap.c5
-rw-r--r--arch/um/sys-i386/bugs.c46
-rw-r--r--arch/um/sys-x86_64/bugs.c7
4 files changed, 24 insertions, 36 deletions
diff --git a/arch/um/include/arch.h b/arch/um/include/arch.h
index 49c601ff2bac..2de92a08a76b 100644
--- a/arch/um/include/arch.h
+++ b/arch/um/include/arch.h
@@ -10,6 +10,6 @@
10 10
11extern void arch_check_bugs(void); 11extern void arch_check_bugs(void);
12extern int arch_fixup(unsigned long address, struct uml_pt_regs *regs); 12extern int arch_fixup(unsigned long address, struct uml_pt_regs *regs);
13extern int arch_handle_signal(int sig, struct uml_pt_regs *regs); 13extern void arch_examine_signal(int sig, struct uml_pt_regs *regs);
14 14
15#endif 15#endif
diff --git a/arch/um/kernel/trap.c b/arch/um/kernel/trap.c
index cb3321f8e0a9..e3a3ab8f8635 100644
--- a/arch/um/kernel/trap.c
+++ b/arch/um/kernel/trap.c
@@ -216,9 +216,6 @@ unsigned long segv(struct faultinfo fi, unsigned long ip, int is_user,
216 216
217void relay_signal(int sig, struct uml_pt_regs *regs) 217void relay_signal(int sig, struct uml_pt_regs *regs)
218{ 218{
219 if (arch_handle_signal(sig, regs))
220 return;
221
222 if (!UPT_IS_USER(regs)) { 219 if (!UPT_IS_USER(regs)) {
223 if (sig == SIGBUS) 220 if (sig == SIGBUS)
224 printk(KERN_ERR "Bus error - the host /dev/shm or /tmp " 221 printk(KERN_ERR "Bus error - the host /dev/shm or /tmp "
@@ -226,6 +223,8 @@ void relay_signal(int sig, struct uml_pt_regs *regs)
226 panic("Kernel mode signal %d", sig); 223 panic("Kernel mode signal %d", sig);
227 } 224 }
228 225
226 arch_examine_signal(sig, regs);
227
229 current->thread.arch.faultinfo = *UPT_FAULTINFO(regs); 228 current->thread.arch.faultinfo = *UPT_FAULTINFO(regs);
230 force_sig(sig, current); 229 force_sig(sig, current);
231} 230}
diff --git a/arch/um/sys-i386/bugs.c b/arch/um/sys-i386/bugs.c
index fc991184850c..b0cb05228a97 100644
--- a/arch/um/sys-i386/bugs.c
+++ b/arch/um/sys-i386/bugs.c
@@ -3,14 +3,12 @@
3 * Licensed under the GPL 3 * Licensed under the GPL
4 */ 4 */
5 5
6#include <errno.h>
7#include <signal.h> 6#include <signal.h>
8#include <string.h>
9#include "kern_constants.h" 7#include "kern_constants.h"
10#include "os.h" 8#include "longjmp.h"
11#include "task.h" 9#include "task.h"
12#include "user.h" 10#include "user.h"
13#include "sysdep/archsetjmp.h" 11#include "sysdep/ptrace.h"
14 12
15/* Set during early boot */ 13/* Set during early boot */
16int host_has_cmov = 1; 14int host_has_cmov = 1;
@@ -22,7 +20,7 @@ static void cmov_sigill_test_handler(int sig)
22 longjmp(cmov_test_return, 1); 20 longjmp(cmov_test_return, 1);
23} 21}
24 22
25static void test_for_host_cmov(void) 23void arch_check_bugs(void)
26{ 24{
27 struct sigaction old, new; 25 struct sigaction old, new;
28 26
@@ -44,16 +42,7 @@ static void test_for_host_cmov(void)
44 sigaction(SIGILL, &old, &new); 42 sigaction(SIGILL, &old, &new);
45} 43}
46 44
47void arch_init_thread(void) 45void arch_examine_signal(int sig, struct uml_pt_regs *regs)
48{
49}
50
51void arch_check_bugs(void)
52{
53 test_for_host_cmov();
54}
55
56int arch_handle_signal(int sig, struct uml_pt_regs *regs)
57{ 46{
58 unsigned char tmp[2]; 47 unsigned char tmp[2];
59 48
@@ -62,20 +51,25 @@ int arch_handle_signal(int sig, struct uml_pt_regs *regs)
62 * SIGILL in init. 51 * SIGILL in init.
63 */ 52 */
64 if ((sig != SIGILL) || (TASK_PID(get_current()) != 1)) 53 if ((sig != SIGILL) || (TASK_PID(get_current()) != 1))
65 return 0; 54 return;
55
56 if (copy_from_user_proc(tmp, (void *) UPT_IP(regs), 2)) {
57 printk(UM_KERN_ERR "SIGILL in init, could not read "
58 "instructions!\n");
59 return;
60 }
66 61
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)) 62 if ((tmp[0] != 0x0f) || ((tmp[1] & 0xf0) != 0x40))
70 return 0; 63 return;
71 64
72 if (host_has_cmov == 0) 65 if (host_has_cmov == 0)
73 panic("SIGILL caused by cmov, which this processor doesn't " 66 printk(UM_KERN_ERR "SIGILL caused by cmov, which this "
74 "implement, boot a filesystem compiled for older " 67 "processor doesn't implement. Boot a filesystem "
75 "processors"); 68 "compiled for older processors");
76 else if (host_has_cmov == 1) 69 else if (host_has_cmov == 1)
77 panic("SIGILL caused by cmov, which this processor claims to " 70 printk(UM_KERN_ERR "SIGILL caused by cmov, which this "
78 "implement"); 71 "processor claims to implement");
79 else panic("Bad value for host_has_cmov (%d)", host_has_cmov); 72 else
80 return 0; 73 printk(UM_KERN_ERR "Bad value for host_has_cmov (%d)",
74 host_has_cmov);
81} 75}
diff --git a/arch/um/sys-x86_64/bugs.c b/arch/um/sys-x86_64/bugs.c
index 506b6765bbcb..44e02ba2a265 100644
--- a/arch/um/sys-x86_64/bugs.c
+++ b/arch/um/sys-x86_64/bugs.c
@@ -6,15 +6,10 @@
6 6
7#include "sysdep/ptrace.h" 7#include "sysdep/ptrace.h"
8 8
9void arch_init_thread(void)
10{
11}
12
13void arch_check_bugs(void) 9void arch_check_bugs(void)
14{ 10{
15} 11}
16 12
17int arch_handle_signal(int sig, struct uml_pt_regs *regs) 13void arch_examine_signal(int sig, struct uml_pt_regs *regs)
18{ 14{
19 return 0;
20} 15}