diff options
author | Al Viro <viro@ftp.linux.org.uk> | 2011-08-18 15:05:19 -0400 |
---|---|---|
committer | Richard Weinberger <richard@nod.at> | 2011-11-02 09:14:59 -0400 |
commit | ab1c0cc7c96c17ea903ca6d3e42e7d2696b32b6c (patch) | |
tree | 9a72e06cab7b6dd293b16048d2928695c935ea46 | |
parent | 248b74c79ebb9fb55e146797a808836d90418c4b (diff) |
um: finish conversion to mcontext_t
now we don't mix host and guest signal frame layouts anymore; moreover,
we don't need host's struct sigcontext at all.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r-- | arch/um/os-Linux/signal.c | 6 | ||||
-rw-r--r-- | arch/um/os-Linux/sys-x86/Makefile | 2 | ||||
-rw-r--r-- | arch/um/os-Linux/sys-x86/mcontext.c | 31 | ||||
-rw-r--r-- | arch/um/sys-x86/shared/sysdep/mcontext.h | 31 | ||||
-rw-r--r-- | arch/um/sys-x86/shared/sysdep/sigcontext.h | 5 | ||||
-rw-r--r-- | arch/um/sys-x86/shared/sysdep/sigcontext_32.h | 32 | ||||
-rw-r--r-- | arch/um/sys-x86/shared/sysdep/sigcontext_64.h | 32 | ||||
-rw-r--r-- | arch/um/sys-x86/stub_segv.c | 2 | ||||
-rw-r--r-- | arch/um/sys-x86/user-offsets.c | 7 |
9 files changed, 67 insertions, 81 deletions
diff --git a/arch/um/os-Linux/signal.c b/arch/um/os-Linux/signal.c index 07d9905e44ef..9f2c2228f7ae 100644 --- a/arch/um/os-Linux/signal.c +++ b/arch/um/os-Linux/signal.c | |||
@@ -14,7 +14,7 @@ | |||
14 | #include "os.h" | 14 | #include "os.h" |
15 | #include "process.h" | 15 | #include "process.h" |
16 | #include "sysdep/barrier.h" | 16 | #include "sysdep/barrier.h" |
17 | #include "sysdep/sigcontext.h" | 17 | #include "sysdep/mcontext.h" |
18 | 18 | ||
19 | void (*sig_info[NSIG])(int, struct uml_pt_regs *) = { | 19 | void (*sig_info[NSIG])(int, struct uml_pt_regs *) = { |
20 | [SIGTRAP] = relay_signal, | 20 | [SIGTRAP] = relay_signal, |
@@ -34,7 +34,7 @@ static void sig_handler_common(int sig, mcontext_t *mc) | |||
34 | r.is_user = 0; | 34 | r.is_user = 0; |
35 | if (sig == SIGSEGV) { | 35 | if (sig == SIGSEGV) { |
36 | /* For segfaults, we want the data from the sigcontext. */ | 36 | /* For segfaults, we want the data from the sigcontext. */ |
37 | copy_sc(&r, (struct sigcontext *)mc); | 37 | get_regs_from_mc(&r, mc); |
38 | GET_FAULTINFO_FROM_MC(r.faultinfo, mc); | 38 | GET_FAULTINFO_FROM_MC(r.faultinfo, mc); |
39 | } | 39 | } |
40 | 40 | ||
@@ -84,7 +84,7 @@ static void real_alarm_handler(mcontext_t *mc) | |||
84 | struct uml_pt_regs regs; | 84 | struct uml_pt_regs regs; |
85 | 85 | ||
86 | if (mc != NULL) | 86 | if (mc != NULL) |
87 | copy_sc(®s, (struct sigcontext *)mc); | 87 | get_regs_from_mc(®s, mc); |
88 | regs.is_user = 0; | 88 | regs.is_user = 0; |
89 | unblock_signals(); | 89 | unblock_signals(); |
90 | timer_handler(SIGVTALRM, ®s); | 90 | timer_handler(SIGVTALRM, ®s); |
diff --git a/arch/um/os-Linux/sys-x86/Makefile b/arch/um/os-Linux/sys-x86/Makefile index 22cc5073c020..253bfb8cb702 100644 --- a/arch/um/os-Linux/sys-x86/Makefile +++ b/arch/um/os-Linux/sys-x86/Makefile | |||
@@ -3,7 +3,7 @@ | |||
3 | # Licensed under the GPL | 3 | # Licensed under the GPL |
4 | # | 4 | # |
5 | 5 | ||
6 | obj-y = registers.o task_size.o | 6 | obj-y = registers.o task_size.o mcontext.o |
7 | 7 | ||
8 | obj-$(CONFIG_X86_32) += tls.o | 8 | obj-$(CONFIG_X86_32) += tls.o |
9 | obj-$(CONFIG_64BIT) += prctl.o | 9 | obj-$(CONFIG_64BIT) += prctl.o |
diff --git a/arch/um/os-Linux/sys-x86/mcontext.c b/arch/um/os-Linux/sys-x86/mcontext.c new file mode 100644 index 000000000000..1d33d72c6284 --- /dev/null +++ b/arch/um/os-Linux/sys-x86/mcontext.c | |||
@@ -0,0 +1,31 @@ | |||
1 | #include <sys/ucontext.h> | ||
2 | #define __FRAME_OFFSETS | ||
3 | #include <asm/ptrace.h> | ||
4 | #include <sysdep/ptrace.h> | ||
5 | |||
6 | void get_regs_from_mc(struct uml_pt_regs *regs, mcontext_t *mc) | ||
7 | { | ||
8 | #ifdef __i386__ | ||
9 | #define COPY2(X,Y) regs->gp[X] = mc->gregs[REG_##Y] | ||
10 | #define COPY(X) regs->gp[X] = mc->gregs[REG_##X] | ||
11 | #define COPY_SEG(X) regs->gp[X] = mc->gregs[REG_##X] & 0xffff; | ||
12 | #define COPY_SEG_CPL3(X) regs->gp[X] = (mc->gregs[REG_##X] & 0xffff) | 3; | ||
13 | COPY_SEG(GS); COPY_SEG(FS); COPY_SEG(ES); COPY_SEG(DS); | ||
14 | COPY(EDI); COPY(ESI); COPY(EBP); | ||
15 | COPY2(UESP, ESP); /* sic */ | ||
16 | COPY(EBX); COPY(EDX); COPY(ECX); COPY(EAX); | ||
17 | COPY(EIP); COPY_SEG_CPL3(CS); COPY(EFL); COPY_SEG_CPL3(SS); | ||
18 | #else | ||
19 | #define COPY2(X,Y) regs->gp[X/sizeof(unsigned long)] = mc->gregs[REG_##Y] | ||
20 | #define COPY(X) regs->gp[X/sizeof(unsigned long)] = mc->gregs[REG_##X] | ||
21 | COPY(R8); COPY(R9); COPY(R10); COPY(R11); | ||
22 | COPY(R12); COPY(R13); COPY(R14); COPY(R15); | ||
23 | COPY(RDI); COPY(RSI); COPY(RBP); COPY(RBX); | ||
24 | COPY(RDX); COPY(RAX); COPY(RCX); COPY(RSP); | ||
25 | COPY(RIP); | ||
26 | COPY2(EFLAGS, EFL); | ||
27 | COPY2(CS, CSGSFS); | ||
28 | regs->gp[CS / sizeof(unsigned long)] &= 0xffff; | ||
29 | regs->gp[CS / sizeof(unsigned long)] |= 3; | ||
30 | #endif | ||
31 | } | ||
diff --git a/arch/um/sys-x86/shared/sysdep/mcontext.h b/arch/um/sys-x86/shared/sysdep/mcontext.h new file mode 100644 index 000000000000..b724c54da316 --- /dev/null +++ b/arch/um/sys-x86/shared/sysdep/mcontext.h | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYS_SIGCONTEXT_X86_H | ||
7 | #define __SYS_SIGCONTEXT_X86_H | ||
8 | |||
9 | extern void get_regs_from_mc(struct uml_pt_regs *, mcontext_t *); | ||
10 | |||
11 | #ifdef __i386__ | ||
12 | |||
13 | #define GET_FAULTINFO_FROM_MC(fi, mc) \ | ||
14 | { \ | ||
15 | (fi).cr2 = (mc)->cr2; \ | ||
16 | (fi).error_code = (mc)->gregs[REG_ERR]; \ | ||
17 | (fi).trap_no = (mc)->gregs[REG_TRAPNO]; \ | ||
18 | } | ||
19 | |||
20 | #else | ||
21 | |||
22 | #define GET_FAULTINFO_FROM_MC(fi, mc) \ | ||
23 | { \ | ||
24 | (fi).cr2 = (mc)->gregs[REG_CR2]; \ | ||
25 | (fi).error_code = (mc)->gregs[REG_ERR]; \ | ||
26 | (fi).trap_no = (mc)->gregs[REG_TRAPNO]; \ | ||
27 | } | ||
28 | |||
29 | #endif | ||
30 | |||
31 | #endif | ||
diff --git a/arch/um/sys-x86/shared/sysdep/sigcontext.h b/arch/um/sys-x86/shared/sysdep/sigcontext.h deleted file mode 100644 index f7f49f46c23d..000000000000 --- a/arch/um/sys-x86/shared/sysdep/sigcontext.h +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | #ifdef __i386__ | ||
2 | #include "sigcontext_32.h" | ||
3 | #else | ||
4 | #include "sigcontext_64.h" | ||
5 | #endif | ||
diff --git a/arch/um/sys-x86/shared/sysdep/sigcontext_32.h b/arch/um/sys-x86/shared/sysdep/sigcontext_32.h deleted file mode 100644 index 548c3cdb743b..000000000000 --- a/arch/um/sys-x86/shared/sysdep/sigcontext_32.h +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com) | ||
3 | * Licensed under the GPL | ||
4 | */ | ||
5 | |||
6 | #ifndef __SYS_SIGCONTEXT_I386_H | ||
7 | #define __SYS_SIGCONTEXT_I386_H | ||
8 | |||
9 | #include <generated/user_constants.h> | ||
10 | |||
11 | #define SC_OFFSET(sc, field) \ | ||
12 | *((unsigned long *) &(((char *) (sc))[HOST_##field])) | ||
13 | |||
14 | #define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO) | ||
15 | #define SC_ERR(sc) SC_OFFSET(sc, SC_ERR) | ||
16 | #define SC_CR2(sc) SC_OFFSET(sc, SC_CR2) | ||
17 | |||
18 | #define GET_FAULTINFO_FROM_SC(fi, sc) \ | ||
19 | { \ | ||
20 | (fi).cr2 = SC_CR2(sc); \ | ||
21 | (fi).error_code = SC_ERR(sc); \ | ||
22 | (fi).trap_no = SC_TRAPNO(sc); \ | ||
23 | } | ||
24 | |||
25 | #define GET_FAULTINFO_FROM_MC(fi, mc) \ | ||
26 | { \ | ||
27 | (fi).cr2 = (mc)->cr2; \ | ||
28 | (fi).error_code = (mc)->gregs[REG_ERR]; \ | ||
29 | (fi).trap_no = (mc)->gregs[REG_TRAPNO]; \ | ||
30 | } | ||
31 | |||
32 | #endif | ||
diff --git a/arch/um/sys-x86/shared/sysdep/sigcontext_64.h b/arch/um/sys-x86/shared/sysdep/sigcontext_64.h deleted file mode 100644 index 5c4a6a359141..000000000000 --- a/arch/um/sys-x86/shared/sysdep/sigcontext_64.h +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2003 PathScale, Inc. | ||
3 | * | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #ifndef __SYSDEP_X86_64_SIGCONTEXT_H | ||
8 | #define __SYSDEP_X86_64_SIGCONTEXT_H | ||
9 | |||
10 | #include <generated/user_constants.h> | ||
11 | |||
12 | #define SC_OFFSET(sc, field) \ | ||
13 | *((unsigned long *) &(((char *) (sc))[HOST_##field])) | ||
14 | #define SC_CR2(sc) SC_OFFSET(sc, SC_CR2) | ||
15 | #define SC_ERR(sc) SC_OFFSET(sc, SC_ERR) | ||
16 | #define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO) | ||
17 | |||
18 | #define GET_FAULTINFO_FROM_SC(fi, sc) \ | ||
19 | { \ | ||
20 | (fi).cr2 = SC_CR2(sc); \ | ||
21 | (fi).error_code = SC_ERR(sc); \ | ||
22 | (fi).trap_no = SC_TRAPNO(sc); \ | ||
23 | } | ||
24 | |||
25 | #define GET_FAULTINFO_FROM_MC(fi, mc) \ | ||
26 | { \ | ||
27 | (fi).cr2 = (mc)->gregs[REG_CR2]; \ | ||
28 | (fi).error_code = (mc)->gregs[REG_ERR]; \ | ||
29 | (fi).trap_no = (mc)->gregs[REG_TRAPNO]; \ | ||
30 | } | ||
31 | |||
32 | #endif | ||
diff --git a/arch/um/sys-x86/stub_segv.c b/arch/um/sys-x86/stub_segv.c index bd2eaf69103f..b7450bd22e7d 100644 --- a/arch/um/sys-x86/stub_segv.c +++ b/arch/um/sys-x86/stub_segv.c | |||
@@ -5,7 +5,7 @@ | |||
5 | 5 | ||
6 | #include "sysdep/stub.h" | 6 | #include "sysdep/stub.h" |
7 | #include "sysdep/faultinfo.h" | 7 | #include "sysdep/faultinfo.h" |
8 | #include "sysdep/sigcontext.h" | 8 | #include "sysdep/mcontext.h" |
9 | 9 | ||
10 | void __attribute__ ((__section__ (".__syscall_stub"))) | 10 | void __attribute__ ((__section__ (".__syscall_stub"))) |
11 | stub_segv_handler(int sig, siginfo_t *info, void *p) | 11 | stub_segv_handler(int sig, siginfo_t *info, void *p) |
diff --git a/arch/um/sys-x86/user-offsets.c b/arch/um/sys-x86/user-offsets.c index 718f0c0f0b0c..3c19c48a1d48 100644 --- a/arch/um/sys-x86/user-offsets.c +++ b/arch/um/sys-x86/user-offsets.c | |||
@@ -14,15 +14,8 @@ | |||
14 | #define DEFINE_LONGS(sym, val) \ | 14 | #define DEFINE_LONGS(sym, val) \ |
15 | asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long))) | 15 | asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long))) |
16 | 16 | ||
17 | #define OFFSET(sym, str, mem) \ | ||
18 | DEFINE(sym, offsetof(struct str, mem)); | ||
19 | |||
20 | void foo(void) | 17 | void foo(void) |
21 | { | 18 | { |
22 | OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); | ||
23 | OFFSET(HOST_SC_ERR, sigcontext, err); | ||
24 | OFFSET(HOST_SC_CR2, sigcontext, cr2); | ||
25 | |||
26 | #ifdef __i386__ | 19 | #ifdef __i386__ |
27 | DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct)); | 20 | DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct)); |
28 | DEFINE_LONGS(HOST_FPX_SIZE, sizeof(struct user_fpxregs_struct)); | 21 | DEFINE_LONGS(HOST_FPX_SIZE, sizeof(struct user_fpxregs_struct)); |