Commit a98c04a3 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

[PATCH] uml: ptrace interface cleanup

From: Bodo Stroesser, mostly:

Gets rid of all inclusions of {sys,linux,asm}/ptrace.h since their effects and
contents are somewhat distro- and architecture-dependent.
arch/um/sysdep/ptrace_user is now responsible for providing the system's
ptrace interfaces to UML.

As such, it is a purely userspace header, and this exposed a couple of places
where kernel files were including it.  One of them needed MAX_REG_OFFSET, so
this was provided by adding a new generated header, user-constants.h, which
includes this.

Also, changed PTRACE_{PEEK,POKE}_USER to _USR since that seems to be more
standard.
Signed-off-by: default avatarJeff Dike <jdike@addtoit.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 583d8835
...@@ -182,13 +182,18 @@ $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h ...@@ -182,13 +182,18 @@ $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h
$(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task $(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task
$(call filechk,gen_header) $(call filechk,gen_header)
$(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/os/util/mk_user_constants
$(call filechk,gen_header)
$(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants
$(call filechk,gen_header) $(call filechk,gen_header)
$(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs $(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs
$(call filechk,gen_header) $(call filechk,gen_header)
$(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/util \ $(ARCH_DIR)/os/util/mk_user_constants: $(ARCH_DIR)/os/util FORCE ;
$(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/util \
FORCE ; FORCE ;
$(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ; $(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ;
...@@ -199,4 +204,7 @@ $(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h FORCE ...@@ -199,4 +204,7 @@ $(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h FORCE
$(ARCH_DIR)/kernel/skas/util: scripts_basic FORCE $(ARCH_DIR)/kernel/skas/util: scripts_basic FORCE
$(Q)$(MAKE) $(build)=$@ $(Q)$(MAKE) $(build)=$@
$(ARCH_DIR)/os/util: scripts_basic FORCE
$(Q)$(MAKE) $(build)=$@
export SUBARCH USER_CFLAGS OS export SUBARCH USER_CFLAGS OS
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "sysdep/ptrace.h" #include "sysdep/ptrace.h"
extern void init_thread_registers(union uml_pt_regs *to); extern void init_thread_registers(union uml_pt_regs *to);
extern int save_fp_registers(int pid, unsigned long *fp_regs);
extern int restore_fp_registers(int pid, unsigned long *fp_regs);
extern void save_registers(int pid, union uml_pt_regs *regs); extern void save_registers(int pid, union uml_pt_regs *regs);
extern void restore_registers(int pid, union uml_pt_regs *regs); extern void restore_registers(int pid, union uml_pt_regs *regs);
extern void init_registers(int pid); extern void init_registers(int pid);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#define __SYSDEP_I386_PTRACE_H #define __SYSDEP_I386_PTRACE_H
#include "uml-config.h" #include "uml-config.h"
#include "user_constants.h"
#ifdef UML_CONFIG_MODE_TT #ifdef UML_CONFIG_MODE_TT
#include "sysdep/sc.h" #include "sysdep/sc.h"
...@@ -14,6 +15,9 @@ ...@@ -14,6 +15,9 @@
#ifdef UML_CONFIG_MODE_SKAS #ifdef UML_CONFIG_MODE_SKAS
#define MAX_REG_NR (UM_FRAME_SIZE / sizeof(unsigned long))
#define MAX_REG_OFFSET (UM_FRAME_SIZE)
/* syscall emulation path in ptrace */ /* syscall emulation path in ptrace */
#ifndef PTRACE_SYSEMU #ifndef PTRACE_SYSEMU
...@@ -26,7 +30,7 @@ extern int sysemu_supported; ...@@ -26,7 +30,7 @@ extern int sysemu_supported;
#include "skas_ptregs.h" #include "skas_ptregs.h"
#define HOST_FRAME_SIZE 17 extern void update_debugregs(int seq);
#define REGS_IP(r) ((r)[HOST_IP]) #define REGS_IP(r) ((r)[HOST_IP])
#define REGS_SP(r) ((r)[HOST_SP]) #define REGS_SP(r) ((r)[HOST_SP])
......
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#ifndef __SYSDEP_I386_PTRACE_USER_H__ #ifndef __SYSDEP_I386_PTRACE_USER_H__
#define __SYSDEP_I386_PTRACE_USER_H__ #define __SYSDEP_I386_PTRACE_USER_H__
#include <sys/ptrace.h>
#include <linux/ptrace.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
#define PT_OFFSET(r) ((r) * sizeof(long)) #define PT_OFFSET(r) ((r) * sizeof(long))
...@@ -33,9 +35,6 @@ ...@@ -33,9 +35,6 @@
#define FP_FRAME_SIZE (27) #define FP_FRAME_SIZE (27)
#define FPX_FRAME_SIZE (128) #define FPX_FRAME_SIZE (128)
#define MAX_REG_OFFSET (FRAME_SIZE_OFFSET)
#define MAX_REG_NR (FRAME_SIZE)
#ifdef PTRACE_GETREGS #ifdef PTRACE_GETREGS
#define UM_HAVE_GETREGS #define UM_HAVE_GETREGS
#endif #endif
...@@ -60,6 +59,4 @@ ...@@ -60,6 +59,4 @@
#define UM_HAVE_SETFPXREGS #define UM_HAVE_SETFPXREGS
#endif #endif
extern void update_debugregs(int seq);
#endif #endif
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#define __SYSDEP_X86_64_PTRACE_H #define __SYSDEP_X86_64_PTRACE_H
#include "uml-config.h" #include "uml-config.h"
#include "user_constants.h"
#ifdef UML_CONFIG_MODE_TT #ifdef UML_CONFIG_MODE_TT
#include "sysdep/sc.h" #include "sysdep/sc.h"
...@@ -16,6 +17,9 @@ ...@@ -16,6 +17,9 @@
#ifdef UML_CONFIG_MODE_SKAS #ifdef UML_CONFIG_MODE_SKAS
#include "skas_ptregs.h" #include "skas_ptregs.h"
#define MAX_REG_OFFSET (UM_FRAME_SIZE)
#define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
#define REGS_IP(r) ((r)[HOST_IP]) #define REGS_IP(r) ((r)[HOST_IP])
#define REGS_SP(r) ((r)[HOST_SP]) #define REGS_SP(r) ((r)[HOST_SP])
......
...@@ -8,6 +8,8 @@ ...@@ -8,6 +8,8 @@
#define __SYSDEP_X86_64_PTRACE_USER_H__ #define __SYSDEP_X86_64_PTRACE_USER_H__
#define __FRAME_OFFSETS #define __FRAME_OFFSETS
#include <sys/ptrace.h>
#include <linux/ptrace.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
#undef __FRAME_OFFSETS #undef __FRAME_OFFSETS
...@@ -45,9 +47,6 @@ ...@@ -45,9 +47,6 @@
#define PT_ORIG_RAX_OFFSET (ORIG_RAX) #define PT_ORIG_RAX_OFFSET (ORIG_RAX)
#define PT_ORIG_RAX(regs) ((regs)[PT_INDEX(ORIG_RAX)]) #define PT_ORIG_RAX(regs) ((regs)[PT_INDEX(ORIG_RAX)])
#define MAX_REG_OFFSET (FRAME_SIZE)
#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 /* 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. Additionally, use the * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the
* 2.4 name and value for 2.4 host compatibility. * 2.4 name and value for 2.4 host compatibility.
......
...@@ -12,11 +12,6 @@ ...@@ -12,11 +12,6 @@
#include <stdlib.h> #include <stdlib.h>
#include <setjmp.h> #include <setjmp.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/ptrace.h>
/*Userspace header, must be after sys/ptrace.h, and both must be included. */
#include <linux/ptrace.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <asm/unistd.h> #include <asm/unistd.h>
...@@ -28,7 +23,6 @@ ...@@ -28,7 +23,6 @@
#include "signal_kern.h" #include "signal_kern.h"
#include "signal_user.h" #include "signal_user.h"
#include "sysdep/ptrace.h" #include "sysdep/ptrace.h"
#include "sysdep/ptrace_user.h"
#include "sysdep/sigcontext.h" #include "sysdep/sigcontext.h"
#include "irq_user.h" #include "irq_user.h"
#include "ptrace_user.h" #include "ptrace_user.h"
...@@ -36,6 +30,7 @@ ...@@ -36,6 +30,7 @@
#include "init.h" #include "init.h"
#include "os.h" #include "os.h"
#include "uml-config.h" #include "uml-config.h"
#include "ptrace_user.h"
#include "choose-mode.h" #include "choose-mode.h"
#include "mode.h" #include "mode.h"
#ifdef UML_CONFIG_MODE_SKAS #ifdef UML_CONFIG_MODE_SKAS
...@@ -259,7 +254,7 @@ static void __init check_sysemu(void) ...@@ -259,7 +254,7 @@ static void __init check_sysemu(void)
panic("check_sysemu : expected SIGTRAP, " panic("check_sysemu : expected SIGTRAP, "
"got status = %d", status); "got status = %d", status);
n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET, n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET,
os_getpid()); os_getpid());
if(n < 0) if(n < 0)
panic("check_sysemu : failed to modify system " panic("check_sysemu : failed to modify system "
...@@ -285,12 +280,12 @@ static void __init check_sysemu(void) ...@@ -285,12 +280,12 @@ static void __init check_sysemu(void)
panic("check_ptrace : expected (SIGTRAP|SYSCALL_TRAP), " panic("check_ptrace : expected (SIGTRAP|SYSCALL_TRAP), "
"got status = %d", status); "got status = %d", status);
syscall = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_NR_OFFSET, syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET,
0); 0);
if(syscall == __NR_getpid){ if(syscall == __NR_getpid){
if (!count) if (!count)
panic("check_ptrace : SYSEMU_SINGLESTEP doesn't singlestep"); panic("check_ptrace : SYSEMU_SINGLESTEP doesn't singlestep");
n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET, n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET,
os_getpid()); os_getpid());
if(n < 0) if(n < 0)
panic("check_sysemu : failed to modify system " panic("check_sysemu : failed to modify system "
...@@ -336,10 +331,10 @@ void __init check_ptrace(void) ...@@ -336,10 +331,10 @@ void __init check_ptrace(void)
panic("check_ptrace : expected SIGTRAP + 0x80, " panic("check_ptrace : expected SIGTRAP + 0x80, "
"got status = %d", status); "got status = %d", status);
syscall = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_NR_OFFSET, syscall = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET,
0); 0);
if(syscall == __NR_getpid){ if(syscall == __NR_getpid){
n = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET,
__NR_getppid); __NR_getppid);
if(n < 0) if(n < 0)
panic("check_ptrace : failed to modify system " panic("check_ptrace : failed to modify system "
......
...@@ -15,8 +15,8 @@ ...@@ -15,8 +15,8 @@
#include "asm/ptrace.h" #include "asm/ptrace.h"
#include "asm/uaccess.h" #include "asm/uaccess.h"
#include "kern_util.h" #include "kern_util.h"
#include "ptrace_user.h"
#include "skas_ptrace.h" #include "skas_ptrace.h"
#include "sysdep/ptrace.h"
/* /*
* Called by kernel/ptrace.c when detaching.. * Called by kernel/ptrace.c when detaching..
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include <errno.h> #include <errno.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/ptrace.h>
#include "mem_user.h" #include "mem_user.h"
#include "mem.h" #include "mem.h"
#include "user.h" #include "user.h"
......
...@@ -10,8 +10,6 @@ ...@@ -10,8 +10,6 @@
#include <setjmp.h> #include <setjmp.h>
#include <sched.h> #include <sched.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/ptrace.h>
#include <linux/ptrace.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/user.h> #include <sys/user.h>
#include <asm/unistd.h> #include <asm/unistd.h>
...@@ -62,7 +60,7 @@ static void handle_trap(int pid, union uml_pt_regs *regs, int local_using_sysemu ...@@ -62,7 +60,7 @@ static void handle_trap(int pid, union uml_pt_regs *regs, int local_using_sysemu
if (!local_using_sysemu) if (!local_using_sysemu)
{ {
err = ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, __NR_getpid); err = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, __NR_getpid);
if(err < 0) if(err < 0)
panic("handle_trap - nullifying syscall failed errno = %d\n", panic("handle_trap - nullifying syscall failed errno = %d\n",
errno); errno);
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include <setjmp.h> #include <setjmp.h>
#include <signal.h> #include <signal.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/ptrace.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <asm/page.h> #include <asm/page.h>
#include <asm/unistd.h> #include <asm/unistd.h>
......
...@@ -9,8 +9,6 @@ ...@@ -9,8 +9,6 @@
#include <sched.h> #include <sched.h>
#include <errno.h> #include <errno.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/ptrace.h>
#include <linux/ptrace.h>
#include <signal.h> #include <signal.h>
#include "user_util.h" #include "user_util.h"
#include "kern_util.h" #include "kern_util.h"
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <sys/ptrace.h>
#include <sys/types.h> #include <sys/types.h>
#include "ptrace_user.h"
#include "uml-config.h" #include "uml-config.h"
#include "kern_constants.h" #include "kern_constants.h"
#include "chan_user.h" #include "chan_user.h"
......
...@@ -18,9 +18,9 @@ Jeff Dike (jdike@karaya.com) : Modified for integration into uml ...@@ -18,9 +18,9 @@ Jeff Dike (jdike@karaya.com) : Modified for integration into uml
#include <termios.h> #include <termios.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/ptrace.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <asm/unistd.h> #include <asm/unistd.h>
#include "ptrace_user.h"
#include "ptproxy.h" #include "ptproxy.h"
#include "sysdep.h" #include "sysdep.h"
......
...@@ -12,9 +12,7 @@ Jeff Dike (jdike@karaya.com) : Modified for integration into uml ...@@ -12,9 +12,7 @@ Jeff Dike (jdike@karaya.com) : Modified for integration into uml
#include <signal.h> #include <signal.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/ptrace.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <asm/ptrace.h>
#include "ptproxy.h" #include "ptproxy.h"
#include "debug.h" #include "debug.h"
...@@ -127,7 +125,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, ...@@ -127,7 +125,7 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2,
case PTRACE_PEEKDATA: case PTRACE_PEEKDATA:
case PTRACE_PEEKTEXT: case PTRACE_PEEKTEXT:
case PTRACE_PEEKUSER: case PTRACE_PEEKUSR:
/* The value being read out could be -1, so we have to /* The value being read out could be -1, so we have to
* check errno to see if there's an error, and zero it * check errno to see if there's an error, and zero it
* beforehand so we're not faked out by an old error * beforehand so we're not faked out by an old error
...@@ -144,11 +142,11 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2, ...@@ -144,11 +142,11 @@ long proxy_ptrace(struct debugger *debugger, int arg1, pid_t arg2,
case PTRACE_POKEDATA: case PTRACE_POKEDATA:
case PTRACE_POKETEXT: case PTRACE_POKETEXT:
case PTRACE_POKEUSER: case PTRACE_POKEUSR:
result = ptrace(arg1, child, arg3, arg4); result = ptrace(arg1, child, arg3, arg4);
if(result == -1) return(-errno); if(result == -1) return(-errno);
if(arg1 == PTRACE_POKEUSER) ptrace_pokeuser(arg3, arg4); if(arg1 == PTRACE_POKEUSR) ptrace_pokeuser(arg3, arg4);
return(result); return(result);
#ifdef UM_HAVE_SETFPREGS #ifdef UM_HAVE_SETFPREGS
......
...@@ -11,7 +11,6 @@ terms and conditions. ...@@ -11,7 +11,6 @@ terms and conditions.
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/ptrace.h>
#include <linux/unistd.h> #include <linux/unistd.h>
#include "ptrace_user.h" #include "ptrace_user.h"
#include "user_util.h" #include "user_util.h"
...@@ -20,21 +19,21 @@ terms and conditions. ...@@ -20,21 +19,21 @@ terms and conditions.
int get_syscall(pid_t pid, long *arg1, long *arg2, long *arg3, long *arg4, int get_syscall(pid_t pid, long *arg1, long *arg2, long *arg3, long *arg4,
long *arg5) long *arg5)
{ {
*arg1 = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_ARG1_OFFSET, 0); *arg1 = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_ARG1_OFFSET, 0);
*arg2 = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_ARG2_OFFSET, 0); *arg2 = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_ARG2_OFFSET, 0);
*arg3 = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_ARG3_OFFSET, 0); *arg3 = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_ARG3_OFFSET, 0);
*arg4 = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_ARG4_OFFSET, 0); *arg4 = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_ARG4_OFFSET, 0);
*arg5 = ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_ARG5_OFFSET, 0); *arg5 = ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_ARG5_OFFSET, 0);
return(ptrace(PTRACE_PEEKUSER, pid, PT_SYSCALL_NR_OFFSET, 0)); return(ptrace(PTRACE_PEEKUSR, pid, PT_SYSCALL_NR_OFFSET, 0));
} }
void syscall_cancel(pid_t pid, int result) void syscall_cancel(pid_t pid, int result)
{ {
if((ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, if((ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET,
__NR_getpid) < 0) || __NR_getpid) < 0) ||
(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0) || (ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0) ||
(wait_for_stop(pid, SIGTRAP, PTRACE_SYSCALL, NULL) < 0) || (wait_for_stop(pid, SIGTRAP, PTRACE_SYSCALL, NULL) < 0) ||
(ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET, result) < 0) || (ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, result) < 0) ||
(ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0)) (ptrace(PTRACE_SYSCALL, pid, 0, 0) < 0))
printk("ptproxy: couldn't cancel syscall: errno = %d\n", printk("ptproxy: couldn't cancel syscall: errno = %d\n",
errno); errno);
...@@ -42,7 +41,7 @@ void syscall_cancel(pid_t pid, int result) ...@@ -42,7 +41,7 @@ void syscall_cancel(pid_t pid, int result)
void syscall_set_result(pid_t pid, long result) void syscall_set_result(pid_t pid, long result)
{ {
ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_RET_OFFSET, result); ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, result);
} }
void syscall_continue(pid_t pid) void syscall_continue(pid_t pid)
...@@ -52,7 +51,7 @@ void syscall_continue(pid_t pid) ...@@ -52,7 +51,7 @@ void syscall_continue(pid_t pid)
int syscall_pause(pid_t pid) int syscall_pause(pid_t pid)
{ {
if(ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, __NR_pause) < 0){ if(ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET, __NR_pause) < 0){
printk("syscall_change - ptrace failed, errno = %d\n", errno); printk("syscall_change - ptrace failed, errno = %d\n", errno);
return(-1); return(-1);
} }
......
...@@ -9,14 +9,13 @@ terms and conditions. ...@@ -9,14 +9,13 @@ terms and conditions.
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <sys/wait.h> #include <sys/wait.h>
#include <sys/ptrace.h>
#include "ptproxy.h" #include "ptproxy.h"
#include "sysdep.h" #include "sysdep.h"
#include "wait.h" #include "wait.h"
#include "user_util.h" #include "user_util.h"
#include "ptrace_user.h"
#include "sysdep/ptrace.h" #include "sysdep/ptrace.h"
#include "sysdep/ptrace_user.h"
#include "sysdep/sigcontext.h" #include "sysdep/sigcontext.h"
int proxy_wait_return(struct debugger *debugger, pid_t unused) int proxy_wait_return(struct debugger *debugger, pid_t unused)
...@@ -59,10 +58,10 @@ int real_wait_return(struct debugger *debugger) ...@@ -59,10 +58,10 @@ int real_wait_return(struct debugger *debugger)
pid = debugger->pid; pid = debugger->pid;
ip = ptrace(PTRACE_PEEKUSER, pid, PT_IP_OFFSET, 0); ip = ptrace(PTRACE_PEEKUSR, pid, PT_IP_OFFSET, 0);
IP_RESTART_SYSCALL(ip); IP_RESTART_SYSCALL(ip);
if(ptrace(PTRACE_POKEUSER, pid, PT_IP_OFFSET, ip) < 0) if(ptrace(PTRACE_POKEUSR, pid, PT_IP_OFFSET, ip) < 0)
tracer_panic("real_wait_return : Failed to restart system " tracer_panic("real_wait_return : Failed to restart system "
"call, errno = %d\n", errno); "call, errno = %d\n", errno);
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <errno.h> #include <errno.h>
#include <sys/ptrace.h>
#include <asm/unistd.h> #include <asm/unistd.h>
#include "sysdep/ptrace.h" #include "sysdep/ptrace.h"
#include "sigcontext.h" #include "sigcontext.h"
...@@ -73,7 +72,7 @@ void do_syscall(void *task, int pid, int local_using_sysemu) ...@@ -73,7 +72,7 @@ void do_syscall(void *task, int pid, int local_using_sysemu)
return; return;
/* syscall number -1 in sysemu skips syscall restarting in host */ /* syscall number -1 in sysemu skips syscall restarting in host */
if(ptrace(PTRACE_POKEUSER, pid, PT_SYSCALL_NR_OFFSET, if(ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_NR_OFFSET,
local_using_sysemu ? -1 : __NR_getpid) < 0) local_using_sysemu ? -1 : __NR_getpid) < 0)
tracer_panic("do_syscall : Nullifying syscall failed, " tracer_panic("do_syscall : Nullifying syscall failed, "
"errno = %d", errno); "errno = %d", errno);
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include <sched.h> #include <sched.h>
#include <string.h> #include <string.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/ptrace.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/wait.h> #include <sys/wait.h>
#include "user.h" #include "user.h"
...@@ -293,7 +292,7 @@ int tracer(int (*init_proc)(void *), void *sp) ...@@ -293,7 +292,7 @@ int tracer(int (*init_proc)(void *), void *sp)
signal_index[proc_id] = last_index; signal_index[proc_id] = last_index;
signal_record[proc_id][signal_index[proc_id]].pid = pid; signal_record[proc_id][signal_index[proc_id]].pid = pid;
gettimeofday(&signal_record[proc_id][signal_index[proc_id]].time, NULL); gettimeofday(&signal_record[proc_id][signal_index[proc_id]].time, NULL);
eip = ptrace(PTRACE_PEEKUSER, pid, PT_IP_OFFSET, 0); eip = ptrace(PTRACE_PEEKUSR, pid, PT_IP_OFFSET, 0);
signal_record[proc_id][signal_index[proc_id]].addr = eip; signal_record[proc_id][signal_index[proc_id]].addr = eip;
signal_record[proc_id][signal_index[proc_id]++].signal = sig; signal_record[proc_id][signal_index[proc_id]++].signal = sig;
#endif #endif
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include <setjmp.h> #include <setjmp.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/ptrace.h>
#include <sys/utsname.h> #include <sys/utsname.h>
#include <sys/param.h> #include <sys/param.h>
#include <sys/time.h> #include <sys/time.h>
...@@ -29,6 +28,7 @@ ...@@ -29,6 +28,7 @@
#include "mem_user.h" #include "mem_user.h"
#include "init.h" #include "init.h"
#include "helper.h" #include "helper.h"
#include "ptrace_user.h"
#include "uml-config.h" #include "uml-config.h"
#define COMMAND_LINE_SIZE _POSIX_ARG_MAX #define COMMAND_LINE_SIZE _POSIX_ARG_MAX
......
...@@ -8,9 +8,9 @@ ...@@ -8,9 +8,9 @@
#include <errno.h> #include <errno.h>
#include <signal.h> #include <signal.h>
#include <linux/unistd.h> #include <linux/unistd.h>
#include <sys/ptrace.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/wait.h> #include <sys/wait.h>
#include "ptrace_user.h"
#include "os.h" #include "os.h"
#include "user.h" #include "user.h"
#include "user_util.h" #include "user_util.h"
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <sys/ptrace.h> #include "sysdep/ptrace_user.h"
#include "sysdep/ptrace.h" #include "sysdep/ptrace.h"
#include "uml-config.h" #include "uml-config.h"
#include "skas_ptregs.h" #include "skas_ptregs.h"
...@@ -27,6 +27,23 @@ void init_thread_registers(union uml_pt_regs *to) ...@@ -27,6 +27,23 @@ void init_thread_registers(union uml_pt_regs *to)
memcpy(to->skas.xfp, exec_fpx_regs, sizeof(to->skas.xfp)); memcpy(to->skas.xfp, exec_fpx_regs, sizeof(to->skas.xfp));
} }
/* XXX These need to use [GS]ETFPXREGS and copy_sc_{to,from}_user_skas needs
* to pass in a sufficiently large buffer
*/
int save_fp_registers(int pid, unsigned long *fp_regs)
{
if(ptrace(PTRACE_GETFPREGS, pid, 0, fp_regs) < 0)
return(-errno);
return(0);
}
int restore_fp_registers(int pid, unsigned long *fp_regs)
{
if(ptrace(PTRACE_SETFPREGS, pid, 0, fp_regs) < 0)
return(-errno);
return(0);
}
static int move_registers(int pid, int int_op, union uml_pt_regs *regs, static int move_registers(int pid, int int_op, union uml_pt_regs *regs,
int fp_op, unsigned long *fp_regs) int fp_op, unsigned long *fp_regs)
{ {
......
...@@ -5,8 +5,7 @@ ...@@ -5,8 +5,7 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <sys/ptrace.h> #include "ptrace_user.h"
#include "sysdep/ptrace.h"
#include "uml-config.h" #include "uml-config.h"
#include "skas_ptregs.h" #include "skas_ptregs.h"
#include "registers.h" #include "registers.h"
......
hostprogs-y := mk_user_constants
always := $(hostprogs-y)
mk_user_constants-objs := mk_user_constants.o
#include <stdio.h>
#include <asm/types.h>
/* For some reason, x86_64 nowhere defines u64 and u32, even though they're
* used throughout the headers.
*/
typedef __u64 u64;
typedef __u32 u32;
#include <asm/user.h>
int main(int argc, char **argv)
{
printf("/*\n");
printf(" * Generated by mk_user_constants\n");
printf(" */\n");
printf("\n");
printf("#ifndef __UM_USER_CONSTANTS_H\n");
printf("#define __UM_USER_CONSTANTS_H\n");
printf("\n");
/* I'd like to use FRAME_SIZE from ptrace.h here, but that's wrong on
* x86_64 (216 vs 168 bytes). user_regs_struct is the correct size on
* both x86_64 and i386.
*/
printf("#define UM_FRAME_SIZE %d\n", (int) sizeof(struct user_regs_struct));
printf("\n");
printf("#endif\n");
return(0);
}
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "asm/ptrace.h" #include "asm/ptrace.h"
#include "asm/uaccess.h" #include "asm/uaccess.h"
#include "asm/unistd.h" #include "asm/unistd.h"
#include "ptrace_user.h" #include "sysdep/ptrace.h"
#include "sysdep/sigcontext.h" #include "sysdep/sigcontext.h"
#include "sysdep/sc.h" #include "sysdep/sc.h"
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include <errno.h> #include <errno.h>
#include <unistd.h> #include <unistd.h>
#include <linux/stddef.h> #include <linux/stddef.h>
#include <sys/ptrace.h> #include "ptrace_user.h"
#include <asm/ptrace.h> /* Grr, asm/user.h includes asm/ptrace.h, so has to follow ptrace_user.h */
#include <asm/user.h> #include <asm/user.h>
#include "kern_util.h" #include "kern_util.h"
#include "sysdep/thread.h" #include "sysdep/thread.h"
...@@ -52,7 +52,7 @@ static void write_debugregs(int pid, unsigned long *regs) ...@@ -52,7 +52,7 @@ static void write_debugregs(int pid, unsigned long *regs)
nregs = sizeof(dummy->u_debugreg)/sizeof(dummy->u_debugreg[0]); nregs = sizeof(dummy->u_debugreg)/sizeof(dummy->u_debugreg[0]);
for(i = 0; i < nregs; i++){ for(i = 0; i < nregs; i++){
if((i == 4) || (i == 5)) continue; if((i == 4) || (i == 5)) continue;
if(ptrace(PTRACE_POKEUSER, pid, &dummy->u_debugreg[i], if(ptrace(PTRACE_POKEUSR, pid, &dummy->u_debugreg[i],
regs[i]) < 0) regs[i]) < 0)
printk("write_debugregs - ptrace failed on " printk("write_debugregs - ptrace failed on "
"register %d, value = 0x%x, errno = %d\n", i, "register %d, value = 0x%x, errno = %d\n", i,
...@@ -68,7 +68,7 @@ static void read_debugregs(int pid, unsigned long *regs) ...@@ -68,7 +68,7 @@ static void read_debugregs(int pid, unsigned long *regs)
dummy = NULL; dummy = NULL;
nregs = sizeof(dummy->u_debugreg)/sizeof(dummy->u_debugreg[0]); nregs = sizeof(dummy->u_debugreg)/sizeof(dummy->u_debugreg[0]);
for(i = 0; i < nregs; i++){ for(i = 0; i < nregs; i++){
regs[i] = ptrace(PTRACE_PEEKUSER, pid, regs[i] = ptrace(PTRACE_PEEKUSR, pid,
&dummy->u_debugreg[i], 0); &dummy->u_debugreg[i], 0);
} }
} }
......
...@@ -11,8 +11,8 @@ ...@@ -11,8 +11,8 @@
#include "asm/unistd.h" #include "asm/unistd.h"
#include "frame_kern.h" #include "frame_kern.h"
#include "signal_user.h" #include "signal_user.h"
#include "ptrace_user.h"
#include "sigcontext.h" #include "sigcontext.h"
#include "registers.h"
#include "mode.h" #include "mode.h"
#ifdef CONFIG_MODE_SKAS #ifdef CONFIG_MODE_SKAS
...@@ -51,7 +51,7 @@ static int copy_sc_from_user_skas(struct pt_regs *regs, ...@@ -51,7 +51,7 @@ static int copy_sc_from_user_skas(struct pt_regs *regs,
regs->regs.skas.fault_type = FAULT_WRITE(sc.err); regs->regs.skas.fault_type = FAULT_WRITE(sc.err);
regs->regs.skas.trap_type = sc.trapno; regs->regs.skas.trap_type = sc.trapno;
err = ptrace_setfpregs(userspace_pid[0], fpregs); err = restore_fp_registers(userspace_pid[0], fpregs);
if(err < 0){ if(err < 0){
printk("copy_sc_from_user_skas - PTRACE_SETFPREGS failed, " printk("copy_sc_from_user_skas - PTRACE_SETFPREGS failed, "
"errno = %d\n", err); "errno = %d\n", err);
...@@ -90,7 +90,7 @@ int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp, ...@@ -90,7 +90,7 @@ int copy_sc_to_user_skas(struct sigcontext *to, struct _fpstate *to_fp,
sc.err = TO_SC_ERR(fault_type); sc.err = TO_SC_ERR(fault_type);
sc.trapno = regs->regs.skas.trap_type; sc.trapno = regs->regs.skas.trap_type;
err = ptrace_getfpregs(userspace_pid[0], fpregs); err = save_fp_registers(userspace_pid[0], fpregs);
if(err < 0){ if(err < 0){
printk("copy_sc_to_user_skas - PTRACE_GETFPREGS failed, " printk("copy_sc_to_user_skas - PTRACE_GETFPREGS failed, "
"errno = %d\n", err); "errno = %d\n", err);
......
#include <sys/ptrace.h>
#include <errno.h> #include <errno.h>
#include <asm/ptrace.h> #include <asm/ptrace.h>
#include "sysdep/ptrace.h" #include "sysdep/ptrace.h"
...@@ -8,7 +7,7 @@ int ptrace_getregs(long pid, unsigned long *regs_out) ...@@ -8,7 +7,7 @@ int ptrace_getregs(long pid, unsigned long *regs_out)
int i; int i;
for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) { for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) {
errno = 0; errno = 0;
regs_out->regs[i] = ptrace(PTRACE_PEEKUSER, pid, i*4, 0); regs_out->regs[i] = ptrace(PTRACE_PEEKUSR, pid, i*4, 0);
if (errno) { if (errno) {
return -errno; return -errno;
} }
...@@ -21,7 +20,7 @@ int ptrace_setregs(long pid, unsigned long *regs_in) ...@@ -21,7 +20,7 @@ int ptrace_setregs(long pid, unsigned long *regs_in)
int i; int i;
for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) { for (i=0; i < sizeof(struct sys_pt_regs)/sizeof(PPC_REG); ++i) {
if (i != 34 /* FIXME: PT_ORIG_R3 */ && i <= PT_MQ) { if (i != 34 /* FIXME: PT_ORIG_R3 */ && i <= PT_MQ) {
if (ptrace(PTRACE_POKEUSER, pid, i*4, regs_in->regs[i]) < 0) { if (ptrace(PTRACE_POKEUSR, pid, i*4, regs_in->regs[i]) < 0) {
return -errno; return -errno;
} }
} }
......
...@@ -6,9 +6,7 @@ ...@@ -6,9 +6,7 @@
#include <stddef.h> #include <stddef.h>
#include <errno.h> #include <errno.h>
#define __FRAME_OFFSETS #include "ptrace_user.h"
#include <sys/ptrace.h>
#include <asm/ptrace.h>
#include "user.h" #include "user.h"
#include "kern_constants.h" #include "kern_constants.h"
...@@ -42,12 +40,12 @@ void arch_enter_kernel(void *task, int pid) ...@@ -42,12 +40,12 @@ void arch_enter_kernel(void *task, int pid)
void arch_leave_kernel(void *task, int pid) void arch_leave_kernel(void *task, int pid)
{ {
#ifdef UM_USER_CS #ifdef UM_USER_CS
if(ptrace(PTRACE_POKEUSER, pid, CS, UM_USER_CS) < 0) if(ptrace(PTRACE_POKEUSR, pid, CS, UM_USER_CS) < 0)
printk("POKEUSR CS failed"); printk("POKEUSR CS failed");
#endif #endif
if(ptrace(PTRACE_POKEUSER, pid, DS, __USER_DS) < 0) if(ptrace(PTRACE_POKEUSR, pid, DS, __USER_DS) < 0)
printk("POKEUSR DS failed"); printk("POKEUSR DS failed");
if(ptrace(PTRACE_POKEUSER, pid, ES, __USER_DS) < 0) if(ptrace(PTRACE_POKEUSR, pid, ES, __USER_DS) < 0)
printk("POKEUSR ES failed"); printk("POKEUSR ES failed");
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment