Skip to content

Commit 75ada8f

Browse files
cfd-36Linus Torvalds
authored andcommitted
uml: move sig_handler_common_skas
This patch moves sig_handler_common_skas from arch/um/os-Linux/skas/trap.c to its only caller in arch/um/os-Linux/signal.c. trap.c is now empty, so it can be removed. This is code movement only - the significant cleanup needed here is done in the next patch. 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>
1 parent e06173b commit 75ada8f

4 files changed

Lines changed: 65 additions & 79 deletions

File tree

‎arch/um/include/os.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,6 @@ extern int add_sigio_fd(int fd);
292292
extern int ignore_sigio_fd(int fd);
293293
extern void maybe_sigio_broken(int fd, int read);
294294

295-
/* skas/trap */
296-
extern void sig_handler_common_skas(int sig, void *sc_ptr);
297-
298295
/* sys-x86_64/prctl.c */
299296
extern int os_arch_prctl(int pid, int code, unsigned long *addr);
300297

‎arch/um/os-Linux/signal.c‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,74 @@
99
#include <errno.h>
1010
#include <signal.h>
1111
#include <strings.h>
12+
#include "as-layout.h"
13+
#include "kern_constants.h"
1214
#include "kern_util.h"
1315
#include "os.h"
1416
#include "sysdep/barrier.h"
1517
#include "sysdep/sigcontext.h"
18+
#include "task.h"
1619
#include "user.h"
1720

21+
void (*sig_info[NSIG])(int, struct uml_pt_regs *) = {
22+
[SIGTRAP] = relay_signal,
23+
[SIGFPE] = relay_signal,
24+
[SIGILL] = relay_signal,
25+
[SIGWINCH] = winch,
26+
[SIGBUS] = bus_handler,
27+
[SIGSEGV] = segv_handler,
28+
[SIGIO] = sigio_handler,
29+
[SIGVTALRM] = timer_handler };
30+
31+
static struct uml_pt_regs ksig_regs[UM_NR_CPUS];
32+
33+
void sig_handler_common_skas(int sig, void *sc_ptr)
34+
{
35+
struct sigcontext *sc = sc_ptr;
36+
struct uml_pt_regs *r;
37+
void (*handler)(int, struct uml_pt_regs *);
38+
int save_user, save_errno = errno;
39+
40+
/*
41+
* This is done because to allow SIGSEGV to be delivered inside a SEGV
42+
* handler. This can happen in copy_user, and if SEGV is disabled,
43+
* the process will die.
44+
* XXX Figure out why this is better than SA_NODEFER
45+
*/
46+
if (sig == SIGSEGV) {
47+
change_sig(SIGSEGV, 1);
48+
/*
49+
* For segfaults, we want the data from the
50+
* sigcontext. In this case, we don't want to mangle
51+
* the process registers, so use a static set of
52+
* registers. For other signals, the process
53+
* registers are OK.
54+
*/
55+
r = &ksig_regs[cpu()];
56+
copy_sc(r, sc_ptr);
57+
} else
58+
r = TASK_REGS(get_current());
59+
60+
save_user = r->is_user;
61+
r->is_user = 0;
62+
if ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
63+
(sig == SIGILL) || (sig == SIGTRAP))
64+
GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
65+
66+
change_sig(SIGUSR1, 1);
67+
68+
handler = sig_info[sig];
69+
70+
/* unblock SIGVTALRM, SIGIO if sig isn't IRQ signal */
71+
if ((sig != SIGIO) && (sig != SIGWINCH) && (sig != SIGVTALRM))
72+
unblock_signals();
73+
74+
handler(sig, r);
75+
76+
errno = save_errno;
77+
r->is_user = save_user;
78+
}
79+
1880
/* Copied from linux/compiler-gcc.h since we can't include it directly */
1981
#define barrier() __asm__ __volatile__("": : :"memory")
2082

‎arch/um/os-Linux/skas/Makefile‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
#
2-
# Copyright (C) 2002 - 2004 Jeff Dike (jdike@addtoit.com)
2+
# Copyright (C) 2002 - 2007 Jeff Dike (jdike@{linux.intel,addtoit}.com)
33
# Licensed under the GPL
44
#
55

6-
obj-y := mem.o process.o trap.o
6+
obj-y := mem.o process.o
77

8-
USER_OBJS := mem.o process.o trap.o
8+
USER_OBJS := $(obj-y)
99

1010
include arch/um/scripts/Makefile.rules

‎arch/um/os-Linux/skas/trap.c‎

Lines changed: 0 additions & 73 deletions
This file was deleted.

0 commit comments

Comments
 (0)