linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH x86/mm 1/6] x86-64 ia32 ptrace pt_regs cleanup
@ 2007-11-29  0:38 Roland McGrath
  2007-11-29  0:40 ` [PATCH x86/mm 2/6] x86-64 ptrace whitespace Roland McGrath
                   ` (5 more replies)
  0 siblings, 6 replies; 28+ messages in thread
From: Roland McGrath @ 2007-11-29  0:38 UTC (permalink / raw)
  To: Andrew Morton, Linus Torvalds
  Cc: linux-kernel, Thomas Gleixner, Ingo Molnar, H. Peter Anvin


This cleans up the getreg32/putreg32 functions to use struct pt_regs in a
straightforward fashion, instead of equivalent ugly pointer arithmetic.

Signed-off-by: Roland McGrath <roland@redhat.com>
---
 arch/x86/ia32/ptrace32.c |   21 +++++++++------------
 1 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/arch/x86/ia32/ptrace32.c b/arch/x86/ia32/ptrace32.c
index 1e382e3..c52d066 100644
--- a/arch/x86/ia32/ptrace32.c
+++ b/arch/x86/ia32/ptrace32.c
@@ -37,11 +37,11 @@
 
 #define R32(l,q)							\
 	case offsetof(struct user32, regs.l):				\
-		stack[offsetof(struct pt_regs, q) / 8] = val; break
+		regs->q = val; break;
 
 static int putreg32(struct task_struct *child, unsigned regno, u32 val)
 {
-	__u64 *stack = (__u64 *)task_pt_regs(child);
+	struct pt_regs *regs = task_pt_regs(child);
 
 	switch (regno) {
 	case offsetof(struct user32, regs.fs):
@@ -65,12 +65,12 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
 	case offsetof(struct user32, regs.ss):
 		if ((val & 3) != 3)
 			return -EIO;
-		stack[offsetof(struct pt_regs, ss)/8] = val & 0xffff;
+		regs->ss = val & 0xffff;
 		break;
 	case offsetof(struct user32, regs.cs):
 		if ((val & 3) != 3)
 			return -EIO;
-		stack[offsetof(struct pt_regs, cs)/8] = val & 0xffff;
+		regs->cs = val & 0xffff;
 		break;
 
 	R32(ebx, bx);
@@ -84,9 +84,7 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
 	R32(eip, ip);
 	R32(esp, sp);
 
-	case offsetof(struct user32, regs.eflags): {
-		__u64 *flags = &stack[offsetof(struct pt_regs, flags)/8];
-
+	case offsetof(struct user32, regs.eflags):
 		val &= FLAG_MASK;
 		/*
 		 * If the user value contains TF, mark that
@@ -97,9 +95,8 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
 			clear_tsk_thread_flag(child, TIF_FORCED_TF);
 		else if (test_tsk_thread_flag(child, TIF_FORCED_TF))
 			val |= X86_EFLAGS_TF;
-		*flags = val | (*flags & ~FLAG_MASK);
+		regs->flags = val | (regs->flags & ~FLAG_MASK);
 		break;
-	}
 
 	case offsetof(struct user32, u_debugreg[0]) ...
 		offsetof(struct user32, u_debugreg[7]):
@@ -123,11 +120,11 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val)
 
 #define R32(l,q)							\
 	case offsetof(struct user32, regs.l):				\
-		*val = stack[offsetof(struct pt_regs, q)/8]; break
+		*val = regs->q; break
 
 static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
 {
-	__u64 *stack = (__u64 *)task_pt_regs(child);
+	struct pt_regs *regs = task_pt_regs(child);
 
 	switch (regno) {
 	case offsetof(struct user32, regs.fs):
@@ -160,7 +157,7 @@ static int getreg32(struct task_struct *child, unsigned regno, u32 *val)
 		/*
 		 * If the debugger set TF, hide it from the readout.
 		 */
-		*val = stack[offsetof(struct pt_regs, flags)/8];
+		*val = regs->flags;
 		if (test_tsk_thread_flag(child, TIF_FORCED_TF))
 			*val &= ~X86_EFLAGS_TF;
 		break;

^ permalink raw reply related	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2007-12-01 23:45 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-29  0:38 [PATCH x86/mm 1/6] x86-64 ia32 ptrace pt_regs cleanup Roland McGrath
2007-11-29  0:40 ` [PATCH x86/mm 2/6] x86-64 ptrace whitespace Roland McGrath
2007-11-29  0:40 ` [PATCH x86/mm 3/6] x86-32 " Roland McGrath
2007-11-29  0:41 ` [PATCH x86/mm 4/6] x86-64 ptrace get/putreg current task Roland McGrath
2007-11-29 17:39   ` Christoph Hellwig
2007-11-29  0:42 ` [PATCH x86/mm 5/6] x86-32 " Roland McGrath
2007-11-29  0:42 ` [PATCH x86/mm 6/6] x86-64 ia32 ptrace get/putreg32 " Roland McGrath
2007-11-29 17:34   ` Chuck Ebbert
2007-11-29 18:09     ` Linus Torvalds
2007-11-29 18:16       ` H. Peter Anvin
2007-11-29 18:31         ` Linus Torvalds
2007-11-29 18:45           ` H. Peter Anvin
2007-11-29 19:08             ` Linus Torvalds
2007-11-29 19:16               ` H. Peter Anvin
2007-11-29 19:27                 ` Andi Kleen
2007-11-29 19:44                   ` Ingo Molnar
2007-11-29 20:01                     ` H. Peter Anvin
2007-12-01 23:44                     ` Jeremy Fitzhardinge
2007-11-29 19:49                   ` Linus Torvalds
2007-11-29 20:11                     ` Andi Kleen
2007-11-29 20:23                       ` Linus Torvalds
2007-11-29 18:17       ` Chuck Ebbert
2007-11-29 18:23         ` H. Peter Anvin
2007-11-29 22:25       ` Roland McGrath
2007-11-29 22:34         ` Linus Torvalds
2007-11-29 22:21     ` Roland McGrath
2007-11-29 23:00       ` Chuck Ebbert
2007-11-29 10:39 ` [PATCH x86/mm 1/6] x86-64 ia32 ptrace pt_regs cleanup Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).