aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAl Viro <viro@ftp.linux.org.uk>2011-08-18 15:12:19 -0400
committerRichard Weinberger <richard@nod.at>2011-11-02 09:15:27 -0400
commit966e803ab12538faf2b236dbe83f7fb796a031d6 (patch)
tree508ab798c9ce5cc0f6f53a2fd9f0b0942a4b32b0
parenta10c95d84c2d04a4bfb02104644bbf2811b99690 (diff)
um: unify ptrace_user.h
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk> Signed-off-by: Richard Weinberger <richard@nod.at>
-rw-r--r--arch/um/include/shared/ptrace_user.h3
-rw-r--r--arch/um/os-Linux/skas/process.c3
-rw-r--r--arch/um/os-Linux/start_up.c9
-rw-r--r--arch/x86/um/ptrace_64.c2
-rw-r--r--arch/x86/um/shared/sysdep/ptrace_64.h2
-rw-r--r--arch/x86/um/shared/sysdep/ptrace_user.h26
-rw-r--r--arch/x86/um/shared/sysdep/ptrace_user_32.h26
-rw-r--r--arch/x86/um/shared/sysdep/ptrace_user_64.h38
-rw-r--r--arch/x86/um/user-offsets.c3
9 files changed, 35 insertions, 77 deletions
diff --git a/arch/um/include/shared/ptrace_user.h b/arch/um/include/shared/ptrace_user.h
index 7fd8539bc19..56b2f284b10 100644
--- a/arch/um/include/shared/ptrace_user.h
+++ b/arch/um/include/shared/ptrace_user.h
@@ -6,7 +6,8 @@
6#ifndef __PTRACE_USER_H__ 6#ifndef __PTRACE_USER_H__
7#define __PTRACE_USER_H__ 7#define __PTRACE_USER_H__
8 8
9#include "sysdep/ptrace_user.h" 9#include <sys/ptrace.h>
10#include <sysdep/ptrace_user.h>
10 11
11extern int ptrace_getregs(long pid, unsigned long *regs_out); 12extern int ptrace_getregs(long pid, unsigned long *regs_out);
12extern int ptrace_setregs(long pid, unsigned long *regs_in); 13extern int ptrace_setregs(long pid, unsigned long *regs_in);
diff --git a/arch/um/os-Linux/skas/process.c b/arch/um/os-Linux/skas/process.c
index 6c34f14708a..cd65727854e 100644
--- a/arch/um/os-Linux/skas/process.c
+++ b/arch/um/os-Linux/skas/process.c
@@ -9,7 +9,6 @@
9#include <errno.h> 9#include <errno.h>
10#include <string.h> 10#include <string.h>
11#include <sys/mman.h> 11#include <sys/mman.h>
12#include <sys/ptrace.h>
13#include <sys/wait.h> 12#include <sys/wait.h>
14#include <asm/unistd.h> 13#include <asm/unistd.h>
15#include "as-layout.h" 14#include "as-layout.h"
@@ -162,7 +161,7 @@ static void handle_trap(int pid, struct uml_pt_regs *regs,
162 161
163 if (!local_using_sysemu) 162 if (!local_using_sysemu)
164 { 163 {
165 err = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, 164 err = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET,
166 __NR_getpid); 165 __NR_getpid);
167 if (err < 0) { 166 if (err < 0) {
168 printk(UM_KERN_ERR "handle_trap - nullifying syscall " 167 printk(UM_KERN_ERR "handle_trap - nullifying syscall "
diff --git a/arch/um/os-Linux/start_up.c b/arch/um/os-Linux/start_up.c
index b6986809b8e..425162e22af 100644
--- a/arch/um/os-Linux/start_up.c
+++ b/arch/um/os-Linux/start_up.c
@@ -13,7 +13,6 @@
13#include <signal.h> 13#include <signal.h>
14#include <string.h> 14#include <string.h>
15#include <sys/mman.h> 15#include <sys/mman.h>
16#include <sys/ptrace.h>
17#include <sys/stat.h> 16#include <sys/stat.h>
18#include <sys/wait.h> 17#include <sys/wait.h>
19#include <asm/unistd.h> 18#include <asm/unistd.h>
@@ -224,7 +223,7 @@ static void __init check_sysemu(void)
224 goto fail; 223 goto fail;
225 } 224 }
226 225
227 n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, os_getpid()); 226 n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET, os_getpid());
228 if (n < 0) { 227 if (n < 0) {
229 non_fatal("check_sysemu : failed to modify system call " 228 non_fatal("check_sysemu : failed to modify system call "
230 "return"); 229 "return");
@@ -260,7 +259,7 @@ static void __init check_sysemu(void)
260 "doesn't singlestep"); 259 "doesn't singlestep");
261 goto fail; 260 goto fail;
262 } 261 }
263 n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, 262 n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET,
264 os_getpid()); 263 os_getpid());
265 if (n < 0) 264 if (n < 0)
266 fatal_perror("check_sysemu : failed to modify " 265 fatal_perror("check_sysemu : failed to modify "
@@ -316,10 +315,10 @@ static void __init check_ptrace(void)
316 fatal("check_ptrace : expected (SIGTRAP|0x80), " 315 fatal("check_ptrace : expected (SIGTRAP|0x80), "
317 "got status = %d", status); 316 "got status = %d", status);
318 317
319 syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET, 318 syscall = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_NR_OFFSET,
320 0); 319 0);
321 if (syscall == __NR_getpid) { 320 if (syscall == __NR_getpid) {
322 n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, 321 n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET,
323 __NR_getppid); 322 __NR_getppid);
324 if (n < 0) 323 if (n < 0)
325 fatal_perror("check_ptrace : failed to modify " 324 fatal_perror("check_ptrace : failed to modify "
diff --git a/arch/x86/um/ptrace_64.c b/arch/x86/um/ptrace_64.c
index 6e6343e7329..3b52bf0b418 100644
--- a/arch/x86/um/ptrace_64.c
+++ b/arch/x86/um/ptrace_64.c
@@ -46,7 +46,7 @@ static const int reg_offsets[] =
46 [FS >> 3] = HOST_FS, 46 [FS >> 3] = HOST_FS,
47 [GS >> 3] = HOST_GS, 47 [GS >> 3] = HOST_GS,
48 [EFLAGS >> 3] = HOST_EFLAGS, 48 [EFLAGS >> 3] = HOST_EFLAGS,
49 [ORIG_RAX >> 3] = HOST_ORIG_RAX, 49 [ORIG_RAX >> 3] = HOST_ORIG_AX,
50}; 50};
51 51
52int putreg(struct task_struct *child, int regno, unsigned long value) 52int putreg(struct task_struct *child, int regno, unsigned long value)
diff --git a/arch/x86/um/shared/sysdep/ptrace_64.h b/arch/x86/um/shared/sysdep/ptrace_64.h
index 430dedc2505..031edc53ac5 100644
--- a/arch/x86/um/shared/sysdep/ptrace_64.h
+++ b/arch/x86/um/shared/sysdep/ptrace_64.h
@@ -65,7 +65,7 @@
65#define REGS_FS(r) ((r)[HOST_FS]) 65#define REGS_FS(r) ((r)[HOST_FS])
66#define REGS_GS(r) ((r)[HOST_GS]) 66#define REGS_GS(r) ((r)[HOST_GS])
67 67
68#define REGS_ORIG_RAX(r) ((r)[HOST_ORIG_RAX]) 68#define REGS_ORIG_RAX(r) ((r)[HOST_ORIG_AX])
69 69
70#define REGS_SET_SYSCALL_RETURN(r, res) REGS_RAX(r) = (res) 70#define REGS_SET_SYSCALL_RETURN(r, res) REGS_RAX(r) = (res)
71 71
diff --git a/arch/x86/um/shared/sysdep/ptrace_user.h b/arch/x86/um/shared/sysdep/ptrace_user.h
index a92f883264e..16cd6b5e71f 100644
--- a/arch/x86/um/shared/sysdep/ptrace_user.h
+++ b/arch/x86/um/shared/sysdep/ptrace_user.h
@@ -1,5 +1,27 @@
1#include <generated/user_constants.h>
2
3#define PT_OFFSET(r) ((r) * sizeof(long))
4
5#define PT_SYSCALL_NR(regs) ((regs)[HOST_ORIG_AX])
6#define PT_SYSCALL_NR_OFFSET PT_OFFSET(HOST_ORIG_AX)
7
8#define PT_SYSCALL_RET_OFFSET PT_OFFSET(HOST_AX)
9
10#define REGS_IP_INDEX HOST_IP
11#define REGS_SP_INDEX HOST_SP
12
1#ifdef __i386__ 13#ifdef __i386__
2#include "ptrace_user_32.h" 14#define FP_SIZE ((HOST_FPX_SIZE > HOST_FP_SIZE) ? HOST_FPX_SIZE : HOST_FP_SIZE)
3#else 15#else
4#include "ptrace_user_64.h" 16#define FP_SIZE HOST_FP_SIZE
17
18/*
19 * x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though
20 * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the
21 * 2.4 name and value for 2.4 host compatibility.
22 */
23#ifndef PTRACE_OLDSETOPTIONS
24#define PTRACE_OLDSETOPTIONS 21
25#endif
26
5#endif 27#endif
diff --git a/arch/x86/um/shared/sysdep/ptrace_user_32.h b/arch/x86/um/shared/sysdep/ptrace_user_32.h
deleted file mode 100644
index 9d88a79a138..00000000000
--- a/arch/x86/um/shared/sysdep/ptrace_user_32.h
+++ /dev/null
@@ -1,26 +0,0 @@
1/*
2 * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
3 * Licensed under the GPL
4 */
5
6#ifndef __SYSDEP_I386_PTRACE_USER_H__
7#define __SYSDEP_I386_PTRACE_USER_H__
8
9#include <sys/ptrace.h>
10#include <linux/ptrace.h>
11#include <asm/ptrace.h>
12#include <generated/user_constants.h>
13
14#define PT_OFFSET(r) ((r) * sizeof(long))
15
16#define PT_SYSCALL_NR(regs) ((regs)[ORIG_EAX])
17#define PT_SYSCALL_NR_OFFSET PT_OFFSET(ORIG_EAX)
18
19#define PT_SYSCALL_RET_OFFSET PT_OFFSET(EAX)
20
21#define REGS_IP_INDEX EIP
22#define REGS_SP_INDEX UESP
23
24#define FP_SIZE ((HOST_FPX_SIZE > HOST_FP_SIZE) ? HOST_FPX_SIZE : HOST_FP_SIZE)
25
26#endif
diff --git a/arch/x86/um/shared/sysdep/ptrace_user_64.h b/arch/x86/um/shared/sysdep/ptrace_user_64.h
deleted file mode 100644
index 2f1b6e33d59..00000000000
--- a/arch/x86/um/shared/sysdep/ptrace_user_64.h
+++ /dev/null
@@ -1,38 +0,0 @@
1/*
2 * Copyright 2003 PathScale, Inc.
3 *
4 * Licensed under the GPL
5 */
6
7#ifndef __SYSDEP_X86_64_PTRACE_USER_H__
8#define __SYSDEP_X86_64_PTRACE_USER_H__
9
10#define __FRAME_OFFSETS
11#include <sys/ptrace.h>
12#include <linux/ptrace.h>
13#include <asm/ptrace.h>
14#undef __FRAME_OFFSETS
15#include <generated/user_constants.h>
16
17#define PT_INDEX(off) ((off) / sizeof(unsigned long))
18
19#define PT_SYSCALL_NR(regs) ((regs)[PT_INDEX(ORIG_RAX)])
20#define PT_SYSCALL_NR_OFFSET (ORIG_RAX)
21
22#define PT_SYSCALL_RET_OFFSET (RAX)
23
24/*
25 * x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though
26 * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the
27 * 2.4 name and value for 2.4 host compatibility.
28 */
29#ifndef PTRACE_OLDSETOPTIONS
30#define PTRACE_OLDSETOPTIONS 21
31#endif
32
33#define REGS_IP_INDEX PT_INDEX(RIP)
34#define REGS_SP_INDEX PT_INDEX(RSP)
35
36#define FP_SIZE (HOST_FP_SIZE)
37
38#endif
diff --git a/arch/x86/um/user-offsets.c b/arch/x86/um/user-offsets.c
index 88d125516ee..ca49be8ddd0 100644
--- a/arch/x86/um/user-offsets.c
+++ b/arch/x86/um/user-offsets.c
@@ -36,6 +36,7 @@ void foo(void)
36 DEFINE(HOST_FS, FS); 36 DEFINE(HOST_FS, FS);
37 DEFINE(HOST_ES, ES); 37 DEFINE(HOST_ES, ES);
38 DEFINE(HOST_GS, GS); 38 DEFINE(HOST_GS, GS);
39 DEFINE(HOST_ORIG_AX, ORIG_EAX);
39#else 40#else
40 DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long)); 41 DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
41 DEFINE_LONGS(HOST_BX, RBX); 42 DEFINE_LONGS(HOST_BX, RBX);
@@ -53,7 +54,7 @@ void foo(void)
53 DEFINE_LONGS(HOST_R13, R13); 54 DEFINE_LONGS(HOST_R13, R13);
54 DEFINE_LONGS(HOST_R14, R14); 55 DEFINE_LONGS(HOST_R14, R14);
55 DEFINE_LONGS(HOST_R15, R15); 56 DEFINE_LONGS(HOST_R15, R15);
56 DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX); 57 DEFINE_LONGS(HOST_ORIG_AX, ORIG_RAX);
57 DEFINE_LONGS(HOST_CS, CS); 58 DEFINE_LONGS(HOST_CS, CS);
58 DEFINE_LONGS(HOST_SS, SS); 59 DEFINE_LONGS(HOST_SS, SS);
59 DEFINE_LONGS(HOST_EFLAGS, EFLAGS); 60 DEFINE_LONGS(HOST_EFLAGS, EFLAGS);