aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
Diffstat (limited to 'arch')
-rw-r--r--arch/um/kernel/process.c2
-rw-r--r--arch/um/kernel/skas/syscall.c2
-rw-r--r--arch/x86/um/asm/elf.h42
-rw-r--r--arch/x86/um/asm/ptrace.h34
-rw-r--r--arch/x86/um/asm/ptrace_32.h23
-rw-r--r--arch/x86/um/asm/ptrace_64.h26
-rw-r--r--arch/x86/um/shared/sysdep/ptrace.h67
-rw-r--r--arch/x86/um/shared/sysdep/ptrace_32.h92
-rw-r--r--arch/x86/um/shared/sysdep/ptrace_64.h101
-rw-r--r--arch/x86/um/signal.c22
-rw-r--r--arch/x86/um/sysrq_32.c8
-rw-r--r--arch/x86/um/sysrq_64.c8
-rw-r--r--arch/x86/um/tls_32.c2
13 files changed, 150 insertions, 279 deletions
diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c
index 4d9af3172d9f..3a2235e0abc3 100644
--- a/arch/um/kernel/process.c
+++ b/arch/um/kernel/process.c
@@ -196,7 +196,7 @@ int copy_thread(unsigned long clone_flags, unsigned long sp,
196 if (current->thread.forking) { 196 if (current->thread.forking) {
197 memcpy(&p->thread.regs.regs, &regs->regs, 197 memcpy(&p->thread.regs.regs, &regs->regs,
198 sizeof(p->thread.regs.regs)); 198 sizeof(p->thread.regs.regs));
199 REGS_SET_SYSCALL_RETURN(p->thread.regs.regs.gp, 0); 199 UPT_SET_SYSCALL_RETURN(&p->thread.regs.regs, 0);
200 if (sp != 0) 200 if (sp != 0)
201 REGS_SP(p->thread.regs.regs.gp) = sp; 201 REGS_SP(p->thread.regs.regs.gp) = sp;
202 202
diff --git a/arch/um/kernel/skas/syscall.c b/arch/um/kernel/skas/syscall.c
index f5173e1ec3ac..05fbeb480e0b 100644
--- a/arch/um/kernel/skas/syscall.c
+++ b/arch/um/kernel/skas/syscall.c
@@ -34,7 +34,7 @@ void handle_syscall(struct uml_pt_regs *r)
34 result = -ENOSYS; 34 result = -ENOSYS;
35 else result = EXECUTE_SYSCALL(syscall, regs); 35 else result = EXECUTE_SYSCALL(syscall, regs);
36 36
37 REGS_SET_SYSCALL_RETURN(r->gp, result); 37 UPT_SET_SYSCALL_RETURN(r, result);
38 38
39 syscall_trace(r, 1); 39 syscall_trace(r, 1);
40} 40}
diff --git a/arch/x86/um/asm/elf.h b/arch/x86/um/asm/elf.h
index f3b0633b69a1..0e07adc8cbe4 100644
--- a/arch/x86/um/asm/elf.h
+++ b/arch/x86/um/asm/elf.h
@@ -34,25 +34,25 @@
34#define ELF_ARCH EM_386 34#define ELF_ARCH EM_386
35 35
36#define ELF_PLAT_INIT(regs, load_addr) do { \ 36#define ELF_PLAT_INIT(regs, load_addr) do { \
37 PT_REGS_EBX(regs) = 0; \ 37 PT_REGS_BX(regs) = 0; \
38 PT_REGS_ECX(regs) = 0; \ 38 PT_REGS_CX(regs) = 0; \
39 PT_REGS_EDX(regs) = 0; \ 39 PT_REGS_DX(regs) = 0; \
40 PT_REGS_ESI(regs) = 0; \ 40 PT_REGS_SI(regs) = 0; \
41 PT_REGS_EDI(regs) = 0; \ 41 PT_REGS_DI(regs) = 0; \
42 PT_REGS_EBP(regs) = 0; \ 42 PT_REGS_BP(regs) = 0; \
43 PT_REGS_EAX(regs) = 0; \ 43 PT_REGS_AX(regs) = 0; \
44} while (0) 44} while (0)
45 45
46/* Shamelessly stolen from include/asm-i386/elf.h */ 46/* Shamelessly stolen from include/asm-i386/elf.h */
47 47
48#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \ 48#define ELF_CORE_COPY_REGS(pr_reg, regs) do { \
49 pr_reg[0] = PT_REGS_EBX(regs); \ 49 pr_reg[0] = PT_REGS_BX(regs); \
50 pr_reg[1] = PT_REGS_ECX(regs); \ 50 pr_reg[1] = PT_REGS_CX(regs); \
51 pr_reg[2] = PT_REGS_EDX(regs); \ 51 pr_reg[2] = PT_REGS_DX(regs); \
52 pr_reg[3] = PT_REGS_ESI(regs); \ 52 pr_reg[3] = PT_REGS_SI(regs); \
53 pr_reg[4] = PT_REGS_EDI(regs); \ 53 pr_reg[4] = PT_REGS_DI(regs); \
54 pr_reg[5] = PT_REGS_EBP(regs); \ 54 pr_reg[5] = PT_REGS_BP(regs); \
55 pr_reg[6] = PT_REGS_EAX(regs); \ 55 pr_reg[6] = PT_REGS_AX(regs); \
56 pr_reg[7] = PT_REGS_DS(regs); \ 56 pr_reg[7] = PT_REGS_DS(regs); \
57 pr_reg[8] = PT_REGS_ES(regs); \ 57 pr_reg[8] = PT_REGS_ES(regs); \
58 /* fake once used fs and gs selectors? */ \ 58 /* fake once used fs and gs selectors? */ \
@@ -130,13 +130,13 @@ do { \
130#define ELF_ARCH EM_X86_64 130#define ELF_ARCH EM_X86_64
131 131
132#define ELF_PLAT_INIT(regs, load_addr) do { \ 132#define ELF_PLAT_INIT(regs, load_addr) do { \
133 PT_REGS_RBX(regs) = 0; \ 133 PT_REGS_BX(regs) = 0; \
134 PT_REGS_RCX(regs) = 0; \ 134 PT_REGS_CX(regs) = 0; \
135 PT_REGS_RDX(regs) = 0; \ 135 PT_REGS_DX(regs) = 0; \
136 PT_REGS_RSI(regs) = 0; \ 136 PT_REGS_SI(regs) = 0; \
137 PT_REGS_RDI(regs) = 0; \ 137 PT_REGS_DI(regs) = 0; \
138 PT_REGS_RBP(regs) = 0; \ 138 PT_REGS_BP(regs) = 0; \
139 PT_REGS_RAX(regs) = 0; \ 139 PT_REGS_AX(regs) = 0; \
140 PT_REGS_R8(regs) = 0; \ 140 PT_REGS_R8(regs) = 0; \
141 PT_REGS_R9(regs) = 0; \ 141 PT_REGS_R9(regs) = 0; \
142 PT_REGS_R10(regs) = 0; \ 142 PT_REGS_R10(regs) = 0; \
diff --git a/arch/x86/um/asm/ptrace.h b/arch/x86/um/asm/ptrace.h
index c8aca8c501b0..950dfb7b8417 100644
--- a/arch/x86/um/asm/ptrace.h
+++ b/arch/x86/um/asm/ptrace.h
@@ -1,5 +1,39 @@
1#ifndef __UM_X86_PTRACE_H
2#define __UM_X86_PTRACE_H
3
1#ifdef CONFIG_X86_32 4#ifdef CONFIG_X86_32
2# include "ptrace_32.h" 5# include "ptrace_32.h"
3#else 6#else
4# include "ptrace_64.h" 7# include "ptrace_64.h"
5#endif 8#endif
9
10#define PT_REGS_AX(r) UPT_AX(&(r)->regs)
11#define PT_REGS_BX(r) UPT_BX(&(r)->regs)
12#define PT_REGS_CX(r) UPT_CX(&(r)->regs)
13#define PT_REGS_DX(r) UPT_DX(&(r)->regs)
14
15#define PT_REGS_SI(r) UPT_SI(&(r)->regs)
16#define PT_REGS_DI(r) UPT_DI(&(r)->regs)
17#define PT_REGS_BP(r) UPT_BP(&(r)->regs)
18#define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs)
19
20#define PT_REGS_CS(r) UPT_CS(&(r)->regs)
21#define PT_REGS_SS(r) UPT_SS(&(r)->regs)
22#define PT_REGS_DS(r) UPT_DS(&(r)->regs)
23#define PT_REGS_ES(r) UPT_ES(&(r)->regs)
24
25#define PT_REGS_ORIG_SYSCALL(r) PT_REGS_AX(r)
26#define PT_REGS_SYSCALL_RET(r) PT_REGS_AX(r)
27
28#define PT_FIX_EXEC_STACK(sp) do ; while(0)
29
30#define profile_pc(regs) PT_REGS_IP(regs)
31
32#define UPT_RESTART_SYSCALL(r) (UPT_IP(r) -= 2)
33#define UPT_SET_SYSCALL_RETURN(r, res) (UPT_AX(r) = (res))
34
35static inline long regs_return_value(struct uml_pt_regs *regs)
36{
37 return UPT_AX(regs);
38}
39#endif /* __UM_X86_PTRACE_H */
diff --git a/arch/x86/um/asm/ptrace_32.h b/arch/x86/um/asm/ptrace_32.h
index 5d2a59112537..2cf225351b65 100644
--- a/arch/x86/um/asm/ptrace_32.h
+++ b/arch/x86/um/asm/ptrace_32.h
@@ -11,29 +11,6 @@
11#include "linux/compiler.h" 11#include "linux/compiler.h"
12#include "asm/ptrace-generic.h" 12#include "asm/ptrace-generic.h"
13 13
14#define PT_REGS_EAX(r) UPT_EAX(&(r)->regs)
15#define PT_REGS_EBX(r) UPT_EBX(&(r)->regs)
16#define PT_REGS_ECX(r) UPT_ECX(&(r)->regs)
17#define PT_REGS_EDX(r) UPT_EDX(&(r)->regs)
18#define PT_REGS_ESI(r) UPT_ESI(&(r)->regs)
19#define PT_REGS_EDI(r) UPT_EDI(&(r)->regs)
20#define PT_REGS_EBP(r) UPT_EBP(&(r)->regs)
21
22#define PT_REGS_CS(r) UPT_CS(&(r)->regs)
23#define PT_REGS_SS(r) UPT_SS(&(r)->regs)
24#define PT_REGS_DS(r) UPT_DS(&(r)->regs)
25#define PT_REGS_ES(r) UPT_ES(&(r)->regs)
26#define PT_REGS_FS(r) UPT_FS(&(r)->regs)
27#define PT_REGS_GS(r) UPT_GS(&(r)->regs)
28
29#define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs)
30
31#define PT_REGS_ORIG_SYSCALL(r) PT_REGS_EAX(r)
32#define PT_REGS_SYSCALL_RET(r) PT_REGS_EAX(r)
33#define PT_FIX_EXEC_STACK(sp) do ; while(0)
34
35#define profile_pc(regs) PT_REGS_IP(regs)
36
37#define user_mode(r) UPT_IS_USER(&(r)->regs) 14#define user_mode(r) UPT_IS_USER(&(r)->regs)
38 15
39/* 16/*
diff --git a/arch/x86/um/asm/ptrace_64.h b/arch/x86/um/asm/ptrace_64.h
index 706a0d80545c..ea7bff394320 100644
--- a/arch/x86/um/asm/ptrace_64.h
+++ b/arch/x86/um/asm/ptrace_64.h
@@ -15,13 +15,6 @@
15 15
16#define HOST_AUDIT_ARCH AUDIT_ARCH_X86_64 16#define HOST_AUDIT_ARCH AUDIT_ARCH_X86_64
17 17
18#define PT_REGS_RBX(r) UPT_RBX(&(r)->regs)
19#define PT_REGS_RCX(r) UPT_RCX(&(r)->regs)
20#define PT_REGS_RDX(r) UPT_RDX(&(r)->regs)
21#define PT_REGS_RSI(r) UPT_RSI(&(r)->regs)
22#define PT_REGS_RDI(r) UPT_RDI(&(r)->regs)
23#define PT_REGS_RBP(r) UPT_RBP(&(r)->regs)
24#define PT_REGS_RAX(r) UPT_RAX(&(r)->regs)
25#define PT_REGS_R8(r) UPT_R8(&(r)->regs) 18#define PT_REGS_R8(r) UPT_R8(&(r)->regs)
26#define PT_REGS_R9(r) UPT_R9(&(r)->regs) 19#define PT_REGS_R9(r) UPT_R9(&(r)->regs)
27#define PT_REGS_R10(r) UPT_R10(&(r)->regs) 20#define PT_REGS_R10(r) UPT_R10(&(r)->regs)
@@ -31,27 +24,8 @@
31#define PT_REGS_R14(r) UPT_R14(&(r)->regs) 24#define PT_REGS_R14(r) UPT_R14(&(r)->regs)
32#define PT_REGS_R15(r) UPT_R15(&(r)->regs) 25#define PT_REGS_R15(r) UPT_R15(&(r)->regs)
33 26
34#define PT_REGS_FS(r) UPT_FS(&(r)->regs)
35#define PT_REGS_GS(r) UPT_GS(&(r)->regs)
36#define PT_REGS_DS(r) UPT_DS(&(r)->regs)
37#define PT_REGS_ES(r) UPT_ES(&(r)->regs)
38#define PT_REGS_SS(r) UPT_SS(&(r)->regs)
39#define PT_REGS_CS(r) UPT_CS(&(r)->regs)
40
41#define PT_REGS_ORIG_RAX(r) UPT_ORIG_RAX(&(r)->regs)
42#define PT_REGS_RIP(r) UPT_IP(&(r)->regs)
43#define PT_REGS_SP(r) UPT_SP(&(r)->regs)
44
45#define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs)
46
47/* XXX */ 27/* XXX */
48#define user_mode(r) UPT_IS_USER(&(r)->regs) 28#define user_mode(r) UPT_IS_USER(&(r)->regs)
49#define PT_REGS_ORIG_SYSCALL(r) PT_REGS_RAX(r)
50#define PT_REGS_SYSCALL_RET(r) PT_REGS_RAX(r)
51
52#define PT_FIX_EXEC_STACK(sp) do ; while(0)
53
54#define profile_pc(regs) PT_REGS_IP(regs)
55 29
56struct user_desc; 30struct user_desc;
57 31
diff --git a/arch/x86/um/shared/sysdep/ptrace.h b/arch/x86/um/shared/sysdep/ptrace.h
index 2bbe1ec2d96a..6ce2d76eb908 100644
--- a/arch/x86/um/shared/sysdep/ptrace.h
+++ b/arch/x86/um/shared/sysdep/ptrace.h
@@ -1,15 +1,74 @@
1#ifndef __SYSDEP_X86_PTRACE_H 1#ifndef __SYSDEP_X86_PTRACE_H
2#define __SYSDEP_X86_PTRACE_H 2#define __SYSDEP_X86_PTRACE_H
3 3
4#include <generated/user_constants.h>
5#include "sysdep/faultinfo.h"
6
7#define MAX_REG_OFFSET (UM_FRAME_SIZE)
8#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
9
10#define REGS_IP(r) ((r)[HOST_IP])
11#define REGS_SP(r) ((r)[HOST_SP])
12#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
13#define REGS_AX(r) ((r)[HOST_AX])
14#define REGS_BX(r) ((r)[HOST_BX])
15#define REGS_CX(r) ((r)[HOST_CX])
16#define REGS_DX(r) ((r)[HOST_DX])
17#define REGS_SI(r) ((r)[HOST_SI])
18#define REGS_DI(r) ((r)[HOST_DI])
19#define REGS_BP(r) ((r)[HOST_BP])
20#define REGS_CS(r) ((r)[HOST_CS])
21#define REGS_SS(r) ((r)[HOST_SS])
22#define REGS_DS(r) ((r)[HOST_DS])
23#define REGS_ES(r) ((r)[HOST_ES])
24
25#define UPT_IP(r) REGS_IP((r)->gp)
26#define UPT_SP(r) REGS_SP((r)->gp)
27#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
28#define UPT_AX(r) REGS_AX((r)->gp)
29#define UPT_BX(r) REGS_BX((r)->gp)
30#define UPT_CX(r) REGS_CX((r)->gp)
31#define UPT_DX(r) REGS_DX((r)->gp)
32#define UPT_SI(r) REGS_SI((r)->gp)
33#define UPT_DI(r) REGS_DI((r)->gp)
34#define UPT_BP(r) REGS_BP((r)->gp)
35#define UPT_CS(r) REGS_CS((r)->gp)
36#define UPT_SS(r) REGS_SS((r)->gp)
37#define UPT_DS(r) REGS_DS((r)->gp)
38#define UPT_ES(r) REGS_ES((r)->gp)
39
4#ifdef __i386__ 40#ifdef __i386__
5#include "ptrace_32.h" 41#include "ptrace_32.h"
6#else 42#else
7#include "ptrace_64.h" 43#include "ptrace_64.h"
8#endif 44#endif
9 45
10static inline long regs_return_value(struct uml_pt_regs *regs) 46struct syscall_args {
11{ 47 unsigned long args[6];
12 return UPT_SYSCALL_RET(regs); 48};
13} 49
50#define SYSCALL_ARGS(r) ((struct syscall_args) \
51 { .args = { UPT_SYSCALL_ARG1(r), \
52 UPT_SYSCALL_ARG2(r), \
53 UPT_SYSCALL_ARG3(r), \
54 UPT_SYSCALL_ARG4(r), \
55 UPT_SYSCALL_ARG5(r), \
56 UPT_SYSCALL_ARG6(r) } } )
57
58struct uml_pt_regs {
59 unsigned long gp[MAX_REG_NR];
60 unsigned long fp[MAX_FP_NR];
61 struct faultinfo faultinfo;
62 long syscall;
63 int is_user;
64};
65
66#define EMPTY_UML_PT_REGS { }
67
68#define UPT_SYSCALL_NR(r) ((r)->syscall)
69#define UPT_FAULTINFO(r) (&(r)->faultinfo)
70#define UPT_IS_USER(r) ((r)->is_user)
71
72extern int user_context(unsigned long sp);
14 73
15#endif /* __SYSDEP_X86_PTRACE_H */ 74#endif /* __SYSDEP_X86_PTRACE_H */
diff --git a/arch/x86/um/shared/sysdep/ptrace_32.h b/arch/x86/um/shared/sysdep/ptrace_32.h
index befd1df32ed0..b94a108de1dc 100644
--- a/arch/x86/um/shared/sysdep/ptrace_32.h
+++ b/arch/x86/um/shared/sysdep/ptrace_32.h
@@ -6,11 +6,7 @@
6#ifndef __SYSDEP_I386_PTRACE_H 6#ifndef __SYSDEP_I386_PTRACE_H
7#define __SYSDEP_I386_PTRACE_H 7#define __SYSDEP_I386_PTRACE_H
8 8
9#include <generated/user_constants.h> 9#define MAX_FP_NR HOST_FPX_SIZE
10#include "sysdep/faultinfo.h"
11
12#define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long))
13#define MAX_REG_OFFSET (UM_FRAME_SIZE)
14 10
15static inline void update_debugregs(int seq) {} 11static inline void update_debugregs(int seq) {}
16 12
@@ -24,90 +20,16 @@ void set_using_sysemu(int value);
24int get_using_sysemu(void); 20int get_using_sysemu(void);
25extern int sysemu_supported; 21extern int sysemu_supported;
26 22
27#define REGS_IP(r) ((r)[HOST_IP])
28#define REGS_SP(r) ((r)[HOST_SP])
29#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
30#define REGS_EAX(r) ((r)[HOST_AX])
31#define REGS_EBX(r) ((r)[HOST_BX])
32#define REGS_ECX(r) ((r)[HOST_CX])
33#define REGS_EDX(r) ((r)[HOST_DX])
34#define REGS_ESI(r) ((r)[HOST_SI])
35#define REGS_EDI(r) ((r)[HOST_DI])
36#define REGS_EBP(r) ((r)[HOST_BP])
37#define REGS_CS(r) ((r)[HOST_CS])
38#define REGS_SS(r) ((r)[HOST_SS])
39#define REGS_DS(r) ((r)[HOST_DS])
40#define REGS_ES(r) ((r)[HOST_ES])
41#define REGS_FS(r) ((r)[HOST_FS])
42#define REGS_GS(r) ((r)[HOST_GS])
43
44#define REGS_SET_SYSCALL_RETURN(r, res) REGS_EAX(r) = (res)
45
46#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
47#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
48
49#ifndef PTRACE_SYSEMU_SINGLESTEP 23#ifndef PTRACE_SYSEMU_SINGLESTEP
50#define PTRACE_SYSEMU_SINGLESTEP 32 24#define PTRACE_SYSEMU_SINGLESTEP 32
51#endif 25#endif
52 26
53struct uml_pt_regs { 27#define UPT_SYSCALL_ARG1(r) UPT_BX(r)
54 unsigned long gp[MAX_REG_NR]; 28#define UPT_SYSCALL_ARG2(r) UPT_CX(r)
55 unsigned long fp[HOST_FPX_SIZE]; 29#define UPT_SYSCALL_ARG3(r) UPT_DX(r)
56 struct faultinfo faultinfo; 30#define UPT_SYSCALL_ARG4(r) UPT_SI(r)
57 long syscall; 31#define UPT_SYSCALL_ARG5(r) UPT_DI(r)
58 int is_user; 32#define UPT_SYSCALL_ARG6(r) UPT_BP(r)
59};
60
61#define EMPTY_UML_PT_REGS { }
62
63#define UPT_IP(r) REGS_IP((r)->gp)
64#define UPT_SP(r) REGS_SP((r)->gp)
65#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
66#define UPT_EAX(r) REGS_EAX((r)->gp)
67#define UPT_EBX(r) REGS_EBX((r)->gp)
68#define UPT_ECX(r) REGS_ECX((r)->gp)
69#define UPT_EDX(r) REGS_EDX((r)->gp)
70#define UPT_ESI(r) REGS_ESI((r)->gp)
71#define UPT_EDI(r) REGS_EDI((r)->gp)
72#define UPT_EBP(r) REGS_EBP((r)->gp)
73#define UPT_ORIG_EAX(r) ((r)->syscall)
74#define UPT_CS(r) REGS_CS((r)->gp)
75#define UPT_SS(r) REGS_SS((r)->gp)
76#define UPT_DS(r) REGS_DS((r)->gp)
77#define UPT_ES(r) REGS_ES((r)->gp)
78#define UPT_FS(r) REGS_FS((r)->gp)
79#define UPT_GS(r) REGS_GS((r)->gp)
80
81#define UPT_SYSCALL_ARG1(r) UPT_EBX(r)
82#define UPT_SYSCALL_ARG2(r) UPT_ECX(r)
83#define UPT_SYSCALL_ARG3(r) UPT_EDX(r)
84#define UPT_SYSCALL_ARG4(r) UPT_ESI(r)
85#define UPT_SYSCALL_ARG5(r) UPT_EDI(r)
86#define UPT_SYSCALL_ARG6(r) UPT_EBP(r)
87
88extern int user_context(unsigned long sp);
89
90#define UPT_IS_USER(r) ((r)->is_user)
91
92struct syscall_args {
93 unsigned long args[6];
94};
95
96#define SYSCALL_ARGS(r) ((struct syscall_args) \
97 { .args = { UPT_SYSCALL_ARG1(r), \
98 UPT_SYSCALL_ARG2(r), \
99 UPT_SYSCALL_ARG3(r), \
100 UPT_SYSCALL_ARG4(r), \
101 UPT_SYSCALL_ARG5(r), \
102 UPT_SYSCALL_ARG6(r) } } )
103
104#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp)
105
106#define UPT_ORIG_SYSCALL(r) UPT_EAX(r)
107#define UPT_SYSCALL_NR(r) UPT_ORIG_EAX(r)
108#define UPT_SYSCALL_RET(r) UPT_EAX(r)
109
110#define UPT_FAULTINFO(r) (&(r)->faultinfo)
111 33
112extern void arch_init_registers(int pid); 34extern void arch_init_registers(int pid);
113 35
diff --git a/arch/x86/um/shared/sysdep/ptrace_64.h b/arch/x86/um/shared/sysdep/ptrace_64.h
index 031edc53ac57..919789f1071e 100644
--- a/arch/x86/um/shared/sysdep/ptrace_64.h
+++ b/arch/x86/um/shared/sysdep/ptrace_64.h
@@ -8,22 +8,8 @@
8#ifndef __SYSDEP_X86_64_PTRACE_H 8#ifndef __SYSDEP_X86_64_PTRACE_H
9#define __SYSDEP_X86_64_PTRACE_H 9#define __SYSDEP_X86_64_PTRACE_H
10 10
11#include <generated/user_constants.h> 11#define MAX_FP_NR HOST_FP_SIZE
12#include "sysdep/faultinfo.h"
13 12
14#define MAX_REG_OFFSET (UM_FRAME_SIZE)
15#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
16
17#define REGS_IP(r) ((r)[HOST_IP])
18#define REGS_SP(r) ((r)[HOST_SP])
19
20#define REGS_RBX(r) ((r)[HOST_BX])
21#define REGS_RCX(r) ((r)[HOST_CX])
22#define REGS_RDX(r) ((r)[HOST_DX])
23#define REGS_RSI(r) ((r)[HOST_SI])
24#define REGS_RDI(r) ((r)[HOST_DI])
25#define REGS_RBP(r) ((r)[HOST_BP])
26#define REGS_RAX(r) ((r)[HOST_AX])
27#define REGS_R8(r) ((r)[HOST_R8]) 13#define REGS_R8(r) ((r)[HOST_R8])
28#define REGS_R9(r) ((r)[HOST_R9]) 14#define REGS_R9(r) ((r)[HOST_R9])
29#define REGS_R10(r) ((r)[HOST_R10]) 15#define REGS_R10(r) ((r)[HOST_R10])
@@ -32,9 +18,6 @@
32#define REGS_R13(r) ((r)[HOST_R13]) 18#define REGS_R13(r) ((r)[HOST_R13])
33#define REGS_R14(r) ((r)[HOST_R14]) 19#define REGS_R14(r) ((r)[HOST_R14])
34#define REGS_R15(r) ((r)[HOST_R15]) 20#define REGS_R15(r) ((r)[HOST_R15])
35#define REGS_CS(r) ((r)[HOST_CS])
36#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
37#define REGS_SS(r) ((r)[HOST_SS])
38 21
39#define HOST_FS_BASE 21 22#define HOST_FS_BASE 21
40#define HOST_GS_BASE 22 23#define HOST_GS_BASE 22
@@ -58,45 +41,6 @@
58#define GS (HOST_GS * sizeof(long)) 41#define GS (HOST_GS * sizeof(long))
59#endif 42#endif
60 43
61#define REGS_FS_BASE(r) ((r)[HOST_FS_BASE])
62#define REGS_GS_BASE(r) ((r)[HOST_GS_BASE])
63#define REGS_DS(r) ((r)[HOST_DS])
64#define REGS_ES(r) ((r)[HOST_ES])
65#define REGS_FS(r) ((r)[HOST_FS])
66#define REGS_GS(r) ((r)[HOST_GS])
67
68#define REGS_ORIG_RAX(r) ((r)[HOST_ORIG_AX])
69
70#define REGS_SET_SYSCALL_RETURN(r, res) REGS_RAX(r) = (res)
71
72#define IP_RESTART_SYSCALL(ip) ((ip) -= 2)
73#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
74
75#define REGS_FAULT_ADDR(r) ((r)->fault_addr)
76
77#define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type)
78
79#define REGS_TRAP(r) ((r)->trap_type)
80
81#define REGS_ERR(r) ((r)->fault_type)
82
83struct uml_pt_regs {
84 unsigned long gp[MAX_REG_NR];
85 unsigned long fp[HOST_FP_SIZE];
86 struct faultinfo faultinfo;
87 long syscall;
88 int is_user;
89};
90
91#define EMPTY_UML_PT_REGS { }
92
93#define UPT_RBX(r) REGS_RBX((r)->gp)
94#define UPT_RCX(r) REGS_RCX((r)->gp)
95#define UPT_RDX(r) REGS_RDX((r)->gp)
96#define UPT_RSI(r) REGS_RSI((r)->gp)
97#define UPT_RDI(r) REGS_RDI((r)->gp)
98#define UPT_RBP(r) REGS_RBP((r)->gp)
99#define UPT_RAX(r) REGS_RAX((r)->gp)
100#define UPT_R8(r) REGS_R8((r)->gp) 44#define UPT_R8(r) REGS_R8((r)->gp)
101#define UPT_R9(r) REGS_R9((r)->gp) 45#define UPT_R9(r) REGS_R9((r)->gp)
102#define UPT_R10(r) REGS_R10((r)->gp) 46#define UPT_R10(r) REGS_R10((r)->gp)
@@ -105,51 +49,14 @@ struct uml_pt_regs {
105#define UPT_R13(r) REGS_R13((r)->gp) 49#define UPT_R13(r) REGS_R13((r)->gp)
106#define UPT_R14(r) REGS_R14((r)->gp) 50#define UPT_R14(r) REGS_R14((r)->gp)
107#define UPT_R15(r) REGS_R15((r)->gp) 51#define UPT_R15(r) REGS_R15((r)->gp)
108#define UPT_CS(r) REGS_CS((r)->gp)
109#define UPT_FS_BASE(r) REGS_FS_BASE((r)->gp)
110#define UPT_FS(r) REGS_FS((r)->gp)
111#define UPT_GS_BASE(r) REGS_GS_BASE((r)->gp)
112#define UPT_GS(r) REGS_GS((r)->gp)
113#define UPT_DS(r) REGS_DS((r)->gp)
114#define UPT_ES(r) REGS_ES((r)->gp)
115#define UPT_CS(r) REGS_CS((r)->gp)
116#define UPT_SS(r) REGS_SS((r)->gp)
117#define UPT_ORIG_RAX(r) REGS_ORIG_RAX((r)->gp)
118
119#define UPT_IP(r) REGS_IP((r)->gp)
120#define UPT_SP(r) REGS_SP((r)->gp)
121
122#define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
123#define UPT_SYSCALL_NR(r) ((r)->syscall)
124#define UPT_SYSCALL_RET(r) UPT_RAX(r)
125
126extern int user_context(unsigned long sp);
127 52
128#define UPT_IS_USER(r) ((r)->is_user) 53#define UPT_SYSCALL_ARG1(r) UPT_DI(r)
129 54#define UPT_SYSCALL_ARG2(r) UPT_SI(r)
130#define UPT_SYSCALL_ARG1(r) UPT_RDI(r) 55#define UPT_SYSCALL_ARG3(r) UPT_DX(r)
131#define UPT_SYSCALL_ARG2(r) UPT_RSI(r)
132#define UPT_SYSCALL_ARG3(r) UPT_RDX(r)
133#define UPT_SYSCALL_ARG4(r) UPT_R10(r) 56#define UPT_SYSCALL_ARG4(r) UPT_R10(r)
134#define UPT_SYSCALL_ARG5(r) UPT_R8(r) 57#define UPT_SYSCALL_ARG5(r) UPT_R8(r)
135#define UPT_SYSCALL_ARG6(r) UPT_R9(r) 58#define UPT_SYSCALL_ARG6(r) UPT_R9(r)
136 59
137struct syscall_args {
138 unsigned long args[6];
139};
140
141#define SYSCALL_ARGS(r) ((struct syscall_args) \
142 { .args = { UPT_SYSCALL_ARG1(r), \
143 UPT_SYSCALL_ARG2(r), \
144 UPT_SYSCALL_ARG3(r), \
145 UPT_SYSCALL_ARG4(r), \
146 UPT_SYSCALL_ARG5(r), \
147 UPT_SYSCALL_ARG6(r) } } )
148
149#define UPT_RESTART_SYSCALL(r) REGS_RESTART_SYSCALL((r)->gp)
150
151#define UPT_FAULTINFO(r) (&(r)->faultinfo)
152
153static inline void arch_init_registers(int pid) 60static inline void arch_init_registers(int pid)
154{ 61{
155} 62}
diff --git a/arch/x86/um/signal.c b/arch/x86/um/signal.c
index 72eafa6c6a52..35b283d3df0c 100644
--- a/arch/x86/um/signal.c
+++ b/arch/x86/um/signal.c
@@ -413,9 +413,9 @@ int setup_signal_stack_sc(unsigned long stack_top, int sig,
413 413
414 PT_REGS_SP(regs) = (unsigned long) frame; 414 PT_REGS_SP(regs) = (unsigned long) frame;
415 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler; 415 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;
416 PT_REGS_EAX(regs) = (unsigned long) sig; 416 PT_REGS_AX(regs) = (unsigned long) sig;
417 PT_REGS_EDX(regs) = (unsigned long) 0; 417 PT_REGS_DX(regs) = (unsigned long) 0;
418 PT_REGS_ECX(regs) = (unsigned long) 0; 418 PT_REGS_CX(regs) = (unsigned long) 0;
419 419
420 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED)) 420 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))
421 ptrace_notify(SIGTRAP); 421 ptrace_notify(SIGTRAP);
@@ -463,9 +463,9 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
463 463
464 PT_REGS_SP(regs) = (unsigned long) frame; 464 PT_REGS_SP(regs) = (unsigned long) frame;
465 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler; 465 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;
466 PT_REGS_EAX(regs) = (unsigned long) sig; 466 PT_REGS_AX(regs) = (unsigned long) sig;
467 PT_REGS_EDX(regs) = (unsigned long) &frame->info; 467 PT_REGS_DX(regs) = (unsigned long) &frame->info;
468 PT_REGS_ECX(regs) = (unsigned long) &frame->uc; 468 PT_REGS_CX(regs) = (unsigned long) &frame->uc;
469 469
470 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED)) 470 if ((current->ptrace & PT_DTRACE) && (current->ptrace & PT_PTRACED))
471 ptrace_notify(SIGTRAP); 471 ptrace_notify(SIGTRAP);
@@ -573,17 +573,17 @@ int setup_signal_stack_si(unsigned long stack_top, int sig,
573 } 573 }
574 574
575 PT_REGS_SP(regs) = (unsigned long) frame; 575 PT_REGS_SP(regs) = (unsigned long) frame;
576 PT_REGS_RDI(regs) = sig; 576 PT_REGS_DI(regs) = sig;
577 /* In case the signal handler was declared without prototypes */ 577 /* In case the signal handler was declared without prototypes */
578 PT_REGS_RAX(regs) = 0; 578 PT_REGS_AX(regs) = 0;
579 579
580 /* 580 /*
581 * This also works for non SA_SIGINFO handlers because they expect the 581 * This also works for non SA_SIGINFO handlers because they expect the
582 * next argument after the signal number on the stack. 582 * next argument after the signal number on the stack.
583 */ 583 */
584 PT_REGS_RSI(regs) = (unsigned long) &frame->info; 584 PT_REGS_SI(regs) = (unsigned long) &frame->info;
585 PT_REGS_RDX(regs) = (unsigned long) &frame->uc; 585 PT_REGS_DX(regs) = (unsigned long) &frame->uc;
586 PT_REGS_RIP(regs) = (unsigned long) ka->sa.sa_handler; 586 PT_REGS_IP(regs) = (unsigned long) ka->sa.sa_handler;
587 out: 587 out:
588 return err; 588 return err;
589} 589}
diff --git a/arch/x86/um/sysrq_32.c b/arch/x86/um/sysrq_32.c
index 171b3e9dc867..2d5cc51e9bef 100644
--- a/arch/x86/um/sysrq_32.c
+++ b/arch/x86/um/sysrq_32.c
@@ -23,12 +23,10 @@ void show_regs(struct pt_regs *regs)
23 printk(" EFLAGS: %08lx\n %s\n", PT_REGS_EFLAGS(regs), 23 printk(" EFLAGS: %08lx\n %s\n", PT_REGS_EFLAGS(regs),
24 print_tainted()); 24 print_tainted());
25 printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n", 25 printk("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n",
26 PT_REGS_EAX(regs), PT_REGS_EBX(regs), 26 PT_REGS_AX(regs), PT_REGS_BX(regs),
27 PT_REGS_ECX(regs), 27 PT_REGS_CX(regs), PT_REGS_DX(regs));
28 PT_REGS_EDX(regs));
29 printk("ESI: %08lx EDI: %08lx EBP: %08lx", 28 printk("ESI: %08lx EDI: %08lx EBP: %08lx",
30 PT_REGS_ESI(regs), PT_REGS_EDI(regs), 29 PT_REGS_SI(regs), PT_REGS_DI(regs), PT_REGS_BP(regs));
31 PT_REGS_EBP(regs));
32 printk(" DS: %04lx ES: %04lx\n", 30 printk(" DS: %04lx ES: %04lx\n",
33 0xffff & PT_REGS_DS(regs), 31 0xffff & PT_REGS_DS(regs),
34 0xffff & PT_REGS_ES(regs)); 32 0xffff & PT_REGS_ES(regs));
diff --git a/arch/x86/um/sysrq_64.c b/arch/x86/um/sysrq_64.c
index e8913436d7dc..08258f179969 100644
--- a/arch/x86/um/sysrq_64.c
+++ b/arch/x86/um/sysrq_64.c
@@ -19,15 +19,15 @@ void __show_regs(struct pt_regs *regs)
19 printk(KERN_INFO "Pid: %d, comm: %.20s %s %s\n", task_pid_nr(current), 19 printk(KERN_INFO "Pid: %d, comm: %.20s %s %s\n", task_pid_nr(current),
20 current->comm, print_tainted(), init_utsname()->release); 20 current->comm, print_tainted(), init_utsname()->release);
21 printk(KERN_INFO "RIP: %04lx:[<%016lx>]\n", PT_REGS_CS(regs) & 0xffff, 21 printk(KERN_INFO "RIP: %04lx:[<%016lx>]\n", PT_REGS_CS(regs) & 0xffff,
22 PT_REGS_RIP(regs)); 22 PT_REGS_IP(regs));
23 printk(KERN_INFO "RSP: %016lx EFLAGS: %08lx\n", PT_REGS_SP(regs), 23 printk(KERN_INFO "RSP: %016lx EFLAGS: %08lx\n", PT_REGS_SP(regs),
24 PT_REGS_EFLAGS(regs)); 24 PT_REGS_EFLAGS(regs));
25 printk(KERN_INFO "RAX: %016lx RBX: %016lx RCX: %016lx\n", 25 printk(KERN_INFO "RAX: %016lx RBX: %016lx RCX: %016lx\n",
26 PT_REGS_RAX(regs), PT_REGS_RBX(regs), PT_REGS_RCX(regs)); 26 PT_REGS_AX(regs), PT_REGS_BX(regs), PT_REGS_CX(regs));
27 printk(KERN_INFO "RDX: %016lx RSI: %016lx RDI: %016lx\n", 27 printk(KERN_INFO "RDX: %016lx RSI: %016lx RDI: %016lx\n",
28 PT_REGS_RDX(regs), PT_REGS_RSI(regs), PT_REGS_RDI(regs)); 28 PT_REGS_DX(regs), PT_REGS_SI(regs), PT_REGS_DI(regs));
29 printk(KERN_INFO "RBP: %016lx R08: %016lx R09: %016lx\n", 29 printk(KERN_INFO "RBP: %016lx R08: %016lx R09: %016lx\n",
30 PT_REGS_RBP(regs), PT_REGS_R8(regs), PT_REGS_R9(regs)); 30 PT_REGS_BP(regs), PT_REGS_R8(regs), PT_REGS_R9(regs));
31 printk(KERN_INFO "R10: %016lx R11: %016lx R12: %016lx\n", 31 printk(KERN_INFO "R10: %016lx R11: %016lx R12: %016lx\n",
32 PT_REGS_R10(regs), PT_REGS_R11(regs), PT_REGS_R12(regs)); 32 PT_REGS_R10(regs), PT_REGS_R11(regs), PT_REGS_R12(regs));
33 printk(KERN_INFO "R13: %016lx R14: %016lx R15: %016lx\n", 33 printk(KERN_INFO "R13: %016lx R14: %016lx R15: %016lx\n",
diff --git a/arch/x86/um/tls_32.c b/arch/x86/um/tls_32.c
index c6c7131e563b..baba84f8ecb8 100644
--- a/arch/x86/um/tls_32.c
+++ b/arch/x86/um/tls_32.c
@@ -219,7 +219,7 @@ int arch_copy_tls(struct task_struct *new)
219 int idx, ret = -EFAULT; 219 int idx, ret = -EFAULT;
220 220
221 if (copy_from_user(&info, 221 if (copy_from_user(&info,
222 (void __user *) UPT_ESI(&new->thread.regs.regs), 222 (void __user *) UPT_SI(&new->thread.regs.regs),
223 sizeof(info))) 223 sizeof(info)))
224 goto out; 224 goto out;
225 225