diff options
| author | Bodo Stroesser <bstroesser@fujitsu-siemens.com> | 2005-02-10 16:02:33 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@ppc970.osdl.org> | 2005-02-10 16:02:33 -0800 |
| commit | e920feb56b94c187602fb96f109f63c595e23c00 (patch) | |
| tree | b1842d758fba507d3f20c9377b53cb125cef95ec | |
| parent | 18f2f62072e9d36dfba726064b9c6cf966b88038 (diff) | |
[PATCH] uml: use PTRACE_OLDSETOPTIONS instead of PTRACE_SETOPTIONS
In linux 2.6, PTRACE_SETOPTIONS is redefined to 0x4200, while the old 2.4
value (21) is still available as PTRACE_OLDSETOPTIONS.
So, if UML uses PTRACE_SETOPTIONS, an UML-kernel built on a 2.6 won't run
on a 2.4 host. Hence we must use PTRACE_OLDSETOPTIONS.
For cases when PTRACE_OLDSETOPTIONS does not exists (i.e. 2.4 host or
archs which miss it because they don't have a "deprecated" value), we
fallback this macro to PTRACE_SETOPTIONS.
Signed-off-by: Bodo Stroesser <bstroesser@fujitsu-siemens.com>
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <blaisorblade@yahoo.it>
Cc: <jdike@addtoit.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
| -rw-r--r-- | arch/um/include/ptrace_user.h | 20 | ||||
| -rw-r--r-- | arch/um/include/sysdep-x86_64/ptrace_user.h | 7 | ||||
| -rw-r--r-- | arch/um/kernel/process.c | 2 | ||||
| -rw-r--r-- | arch/um/kernel/skas/process.c | 2 | ||||
| -rw-r--r-- | arch/um/kernel/tt/exec_user.c | 2 | ||||
| -rw-r--r-- | arch/um/kernel/tt/tracer.c | 4 |
6 files changed, 29 insertions, 8 deletions
diff --git a/arch/um/include/ptrace_user.h b/arch/um/include/ptrace_user.h index 92c2bd79ce94..f3450e6bc18d 100644 --- a/arch/um/include/ptrace_user.h +++ b/arch/um/include/ptrace_user.h @@ -26,6 +26,26 @@ extern void ptrace_pokeuser(unsigned long addr, unsigned long data); #define PTRACE_SYSEMU_SINGLESTEP 32 #endif +/* On architectures, that started to support PTRACE_O_TRACESYSGOOD + * in linux 2.4, there are two different definitions of + * PTRACE_SETOPTIONS: linux 2.4 uses 21 while linux 2.6 uses 0x4200. + * For binary compatibility, 2.6 also supports the old "21", named + * PTRACE_OLDSETOPTION. On these architectures, UML always must use + * "21", to ensure the kernel runs on 2.4 and 2.6 host without + * recompilation. So, we use PTRACE_OLDSETOPTIONS in UML. + * We also want to be able to build the kernel on 2.4, which doesn't + * have PTRACE_OLDSETOPTIONS. So, if it is missing, we declare + * PTRACE_OLDSETOPTIONS to to be the same as PTRACE_SETOPTIONS. + * + * On architectures, that start to support PTRACE_O_TRACESYSGOOD on + * linux 2.6, PTRACE_OLDSETOPTIONS never is defined, and also isn't + * supported by the host kernel. In that case, our trick lets us use + * the new 0x4200 with the name PTRACE_OLDSETOPTIONS. + */ +#ifndef PTRACE_OLDSETOPTIONS +#define PTRACE_OLDSETOPTIONS PTRACE_SETOPTIONS +#endif + void set_using_sysemu(int value); int get_using_sysemu(void); extern int sysemu_supported; diff --git a/arch/um/include/sysdep-x86_64/ptrace_user.h b/arch/um/include/sysdep-x86_64/ptrace_user.h index a7bb52bbe624..24cb4ee521be 100644 --- a/arch/um/include/sysdep-x86_64/ptrace_user.h +++ b/arch/um/include/sysdep-x86_64/ptrace_user.h @@ -49,10 +49,11 @@ #define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long)) /* x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though - * it's defined in the kernel's include/linux/ptrace.h + * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the + * 2.4 name and value for 2.4 host compatibility. */ -#ifndef PTRACE_SETOPTIONS -#define PTRACE_SETOPTIONS 0x4200 +#ifndef PTRACE_OLDSETOPTIONS +#define PTRACE_OLDSETOPTIONS 21 #endif #endif diff --git a/arch/um/kernel/process.c b/arch/um/kernel/process.c index 03ad0b55dbd7..7a2be31a9766 100644 --- a/arch/um/kernel/process.c +++ b/arch/um/kernel/process.c @@ -322,7 +322,7 @@ void __init check_ptrace(void) printk("Checking that ptrace can change system call numbers..."); pid = start_ptraced_child(&stack); - if(ptrace(PTRACE_SETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) + if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) panic("check_ptrace: PTRACE_SETOPTIONS failed, errno = %d", errno); while(1){ diff --git a/arch/um/kernel/skas/process.c b/arch/um/kernel/skas/process.c index 50e49523b29d..db53368ec51a 100644 --- a/arch/um/kernel/skas/process.c +++ b/arch/um/kernel/skas/process.c @@ -124,7 +124,7 @@ void start_userspace(int cpu) panic("start_userspace : expected SIGSTOP, got status = %d", status); - if (ptrace(PTRACE_SETOPTIONS, pid, NULL, (void *)PTRACE_O_TRACESYSGOOD) < 0) + if (ptrace(PTRACE_OLDSETOPTIONS, pid, NULL, (void *)PTRACE_O_TRACESYSGOOD) < 0) panic("start_userspace : PTRACE_SETOPTIONS failed, errno=%d\n", errno); diff --git a/arch/um/kernel/tt/exec_user.c b/arch/um/kernel/tt/exec_user.c index c52c83e1e69b..26a120a8415e 100644 --- a/arch/um/kernel/tt/exec_user.c +++ b/arch/um/kernel/tt/exec_user.c @@ -39,7 +39,7 @@ void do_exec(int old_pid, int new_pid) os_kill_ptraced_process(old_pid, 0); - if (ptrace(PTRACE_SETOPTIONS, new_pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) + if (ptrace(PTRACE_OLDSETOPTIONS, new_pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) tracer_panic("do_exec: PTRACE_SETOPTIONS failed, errno = %d", errno); if(ptrace_setregs(new_pid, regs) < 0) diff --git a/arch/um/kernel/tt/tracer.c b/arch/um/kernel/tt/tracer.c index 2e85e0187317..257a16e84da5 100644 --- a/arch/um/kernel/tt/tracer.c +++ b/arch/um/kernel/tt/tracer.c @@ -72,7 +72,7 @@ void attach_process(int pid) (ptrace(PTRACE_CONT, pid, 0, 0) < 0)) tracer_panic("OP_FORK failed to attach pid"); wait_for_stop(pid, SIGSTOP, PTRACE_CONT, NULL); - if (ptrace(PTRACE_SETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) + if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) tracer_panic("OP_FORK: PTRACE_SETOPTIONS failed, errno = %d", errno); if(ptrace(PTRACE_CONT, pid, 0, 0) < 0) tracer_panic("OP_FORK failed to continue process"); @@ -200,7 +200,7 @@ int tracer(int (*init_proc)(void *), void *sp) printf("waitpid on idle thread failed, errno = %d\n", errno); exit(1); } - if (ptrace(PTRACE_SETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) { + if (ptrace(PTRACE_OLDSETOPTIONS, pid, 0, (void *)PTRACE_O_TRACESYSGOOD) < 0) { printf("Failed to PTRACE_SETOPTIONS for idle thread, errno = %d\n", errno); exit(1); } |
