Skip to contentSkip to conversation

UML - x86_64 ptrace support

PATCH New Jeff Dike 1 participant 1 message Jan 10, 2005

Subsystems (2)
lore
Share & tools
lore

Jeff Dike

author
#0 lore raw

PATCH 8/28 UML - x86_64 ptrace support

This adds the x86_64 ptrace support.
It also cleans up the existing code somewhat, eliminating a couple of simple header files, and generalizing the mk_ptregs buils to accomodate multiple architectures.

arch/um/include/sysdep-i386/ptrace.h +43 -2
Index: 2.6.10/arch/um/include/sysdep-i386/ptrace.h
===================================================================
@@ -9,11 +9,52 @@
 #include "uml-config.h"
 
 #ifdef UML_CONFIG_MODE_TT
-#include "ptrace-tt.h"
+#include "sysdep/sc.h"
 #endif
 
 #ifdef UML_CONFIG_MODE_SKAS
-#include "ptrace-skas.h"
+
+/* syscall emulation path in ptrace */
+
+#ifndef PTRACE_SYSEMU
+#define PTRACE_SYSEMU 31
+#endif
+
+void set_using_sysemu(int value);
+int get_using_sysemu(void);
+extern int sysemu_supported;
+
+#include "skas_ptregs.h"
+
+#define HOST_FRAME_SIZE 17
+
+#define REGS_IP(r) ((r)[HOST_IP])
+#define REGS_SP(r) ((r)[HOST_SP])
+#define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
+#define REGS_EAX(r) ((r)[HOST_EAX])
+#define REGS_EBX(r) ((r)[HOST_EBX])
+#define REGS_ECX(r) ((r)[HOST_ECX])
+#define REGS_EDX(r) ((r)[HOST_EDX])
+#define REGS_ESI(r) ((r)[HOST_ESI])
+#define REGS_EDI(r) ((r)[HOST_EDI])
+#define REGS_EBP(r) ((r)[HOST_EBP])
+#define REGS_CS(r) ((r)[HOST_CS])
+#define REGS_SS(r) ((r)[HOST_SS])
+#define REGS_DS(r) ((r)[HOST_DS])
+#define REGS_ES(r) ((r)[HOST_ES])
+#define REGS_FS(r) ((r)[HOST_FS])
+#define REGS_GS(r) ((r)[HOST_GS])
+
+#define REGS_SET_SYSCALL_RETURN(r, res) REGS_EAX(r) = (res)
+
+#define REGS_RESTART_SYSCALL(r) IP_RESTART_SYSCALL(REGS_IP(r))
+
+#define REGS_SEGV_IS_FIXABLE(r) SEGV_IS_FIXABLE((r)->trap_type)
+
+#define REGS_FAULT_ADDR(r) ((r)->fault_addr)
+
+#define REGS_FAULT_WRITE(r) FAULT_WRITE((r)->fault_type)
+
 #endif
 #ifndef PTRACE_SYSEMU_SINGLESTEP
 #define PTRACE_SYSEMU_SINGLESTEP 32
arch/um/include/sysdep-x86_64/ptrace.h +260 -0

260 lines not on this page · raw message

arch/um/include/sysdep-x86_64/ptrace_user.h +69 -0

69 lines not on this page · raw message

arch/um/kernel/ptrace.c +1 -0
Index: 2.6.10/arch/um/kernel/ptrace.c
===================================================================
@@ -16,6 +16,7 @@
 #include "asm/uaccess.h"
 #include "kern_util.h"
 #include "ptrace_user.h"
+#include "skas_ptrace.h"
 
 /*
  * Called by kernel/ptrace.c when detaching..
arch/um/kernel/skas/Makefile +0 -2
Index: 2.6.10/arch/um/kernel/skas/Makefile
===================================================================
@@ -6,8 +6,6 @@
 obj-y := exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \
 	syscall_kern.o syscall_user.o time.o tlb.o trap_user.o uaccess.o \
 
-subdir-y := util
-
 USER_OBJS = $(filter %_user.o,$(obj-y)) process.o time.o
 USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
arch/um/kernel/skas/include/ptrace-skas.h +0 -57

57 lines not on this page · raw message

arch/um/kernel/skas/util/Makefile +2 -0
Index: 2.6.10/arch/um/kernel/skas/util/Makefile
===================================================================
@@ -1,2 +1,4 @@
 hostprogs-y		:= mk_ptregs
 always			:= $(hostprogs-y)
+
+mk_ptregs-objs := mk_ptregs-$(SUBARCH).o
arch/um/kernel/skas/util/mk_ptregs-i386.c +51 -0

51 lines not on this page · raw message

arch/um/kernel/skas/util/mk_ptregs-x86_64.c +68 -0

68 lines not on this page · raw message

arch/um/kernel/skas/util/mk_ptregs.c +0 -51

51 lines not on this page · raw message

arch/um/kernel/tt/include/ptrace-tt.h +0 -26
Index: 2.6.10/arch/um/kernel/tt/include/ptrace-tt.h
===================================================================
@@ -1,26 +0,0 @@
-/* 
- * Copyright (C) 2000, 2001, 2002 Jeff Dike ([email protected])
- * Licensed under the GPL
- */
-
-#ifndef __PTRACE_TT_H
-#define __PTRACE_TT_H
-
-#include "uml-config.h"
-
-#ifdef UML_CONFIG_MODE_TT
-#include "sysdep/sc.h"
-#endif
-
-#endif
-
-/*
- * Overrides for Emacs so that we follow Linus's tabbing style.
- * Emacs will notice this stuff at the end of the file and automatically
- * adjust the settings for this buffer only.  This must remain at the end
- * of the file.
- * ---------------------------------------------------------------------------
- * Local variables:
- * c-file-style: "linux"
- * End:
- */
arch/um/sys-i386/ldt.c +2 -0
Index: 2.6.10/arch/um/sys-i386/ldt.c
===================================================================
@@ -25,6 +25,8 @@
 #ifdef CONFIG_MODE_SKAS
 extern int userspace_pid;
 
+#include "skas_ptrace.h"
+
 int sys_modify_ldt_skas(int func, void *ptr, unsigned long bytecount)
 {
 	struct ptrace_ldt ldt;
arch/um/sys-x86_64/Makefile +3 -3
Index: 2.6.10/arch/um/sys-x86_64/Makefile
===================================================================
@@ -5,10 +5,10 @@
 #
 
 lib-y = bitops.o bugs.o csum-partial.o fault.o mem.o memcpy.o \
-	ptrace.o semaphore.o sigcontext.o signal.o syscalls.o \
-	sysrq.o thunk.o
+	ptrace.o ptrace_user.o semaphore.o sigcontext.o signal.o \
+	syscalls.o sysrq.o thunk.o
 
-USER_OBJS := sigcontext.o
+USER_OBJS := ptrace_user.o sigcontext.o
 USER_OBJS := $(foreach file,$(USER_OBJS),$(obj)/$(file))
 
 SYMLINKS = bitops.c csum-copy.S csum-partial.c csum-wrappers.c memcpy.S \
arch/um/sys-x86_64/ptrace.c +138 -0

138 lines not on this page · raw message

arch/um/sys-x86_64/ptrace_user.c +64 -0

64 lines not on this page · raw message

include/asm-um/ptrace-generic.h +0 -1
Index: 2.6.10/include/asm-um/ptrace-generic.h
===================================================================
@@ -21,7 +21,6 @@
 #undef instruction_pointer
 
 #include "sysdep/ptrace.h"
-#include "skas_ptrace.h"
 
 struct pt_regs {
 	union uml_pt_regs regs;
include/asm-um/ptrace-x86_64.h +75 -0

75 lines not on this page · raw message