[PATCH] x86-64 only: ia32entry.S reg changes dropped during debugging

From: Chris Gottbrath
Date: Wed May 26 2004 - 17:52:18 EST



Andi,

We develop a debugger for linux x86-64 called TotalView. We have
recently tracked down a problem to the fact that some register changes
made by the debugger in the target are getting discarded. This is only
happening with the 2.4.x kernels on x86-64. It appears that the
bug may have been fixed as a side effect of some other change in 2.6.x.

The scenario is that the debugger uses ptrace(PTRACE_SYSCALL,) and
changes some registers in the process while it is stopped in a
system call. We are finding that the system call entry code discards
changes to R15, R14, R13, R12, RBP, and RBX.

The following patch is against arch/x86_64/ia32/ia32entry.S in 2.4.26.

--- ia32entry.S.orig 2004-02-18 08:36:31.000000000 -0500
+++ ia32entry.S 2004-05-19 17:39:22.000000000 -0400
@@ -71,7 +71,7 @@
movq %rsp,%rdi /* &pt_regs -> arg1 */
call syscall_trace
LOAD_ARGS ARGOFFSET /* reload args from stack in case ptrace changed it */
- addq $ARGOFFSET,%rsp
+ RESTORE_REST
cmpl $(IA32_NR_syscalls),%eax
jae 1f
IA32_ARG_FIXUP
@@ -81,7 +81,7 @@
1: SAVE_REST
movq %rsp,%rdi /* &pt_regs -> arg1 */
call syscall_trace
- addq $ARGOFFSET,%rsp
+ RESTORE_REST
jmp int_ret_from_sys_call

ia32_badsys:


Please CC me with any feedback.

Cheers,
Chris


--
Chris Gottbrath
Partner Technologies Engineer Etnus, LLC
Chris.Gottbrath@xxxxxxxxx http://www.etnus.com/
Voice: 508-652-7700 x7735 Fax: 508-652-7787
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/