[RFC/PATCH 5/5] powerpc: Allow ptrace write to pt_regs trap

STALE7042d

5 messages, 2 authors, 2007-05-30 · open the first message on its own page

[RFC/PATCH 5/5] powerpc: Allow ptrace write to pt_regs trap

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2007-05-29 06:45:24

This patch allows a ptracer to write to the "trap" word of the
pt_regs. This, along with the previous patch, should enable gdb
to properly handle syscall restarting after executing a separate
function (at least when there's no restart block).

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

 arch/powerpc/kernel/ptrace-common.h |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: linux-cell/arch/powerpc/kernel/ptrace-common.h
===================================================================
--- linux-cell.orig/arch/powerpc/kernel/ptrace-common.h	2007-05-29 16:22:07.000000000 +1000
+++ linux-cell/arch/powerpc/kernel/ptrace-common.h	2007-05-29 16:42:04.000000000 +1000
@@ -41,10 +41,15 @@ static inline int put_reg(struct task_st
 	if (task->thread.regs == NULL)
 		return -EIO;
 
-	if (regno <= PT_MAX_PUT_REG) {
+	if (regno <= PT_MAX_PUT_REG || regno == PT_TRAP) {
 		if (regno == PT_MSR)
 			data = (data & MSR_DEBUGCHANGE)
 				| (task->thread.regs->msr & ~MSR_DEBUGCHANGE);
+		/* We prevent mucking around with the reserved area of trap
+		 * which are used internally by the kernel
+		 */
+		if (regno == PT_TRAP)
+			data &= 0xff00;
 		((unsigned long *)task->thread.regs)[regno] = data;
 		return 0;
 	}

Re: [RFC/PATCH 5/5] powerpc: Allow ptrace write to pt_regs trap

From: Ulrich Weigand <hidden>
Date: 2007-05-29 15:42:02

Benjamin Herrenschmidt [off-list ref] wrote on 05/29/2007 
08:45:24 AM:
This patch allows a ptracer to write to the "trap" word of the
pt_regs. This, along with the previous patch, should enable gdb
to properly handle syscall restarting after executing a separate
function (at least when there's no restart block).
This doesn't look sufficient.  If you want GDB to use the save/
restore style means of handling interrupted calls (like i386),
at the very least we also need the capability to *write* the
orig_gpr3 field, which is currently prohibited.  (I don't know
why this is case, though.)


Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

-- 
  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  GNU compiler/toolchain for Linux on System z and Cell BE
  IBM Deutschland Entwicklung GmbH
  Vorsitzender des Aufsichtsrats: Martin Jetter | Geschäftsführung: 
Herbert Kircher
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht 
Stuttgart, HRB 243294

Re: [RFC/PATCH 5/5] powerpc: Allow ptrace write to pt_regs trap

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2007-05-29 21:41:49

On Tue, 2007-05-29 at 17:41 +0200, Ulrich Weigand wrote:
This doesn't look sufficient.  If you want GDB to use the save/ 
restore style means of handling interrupted calls (like i386), 
at the very least we also need the capability to *write* the 
orig_gpr3 field, which is currently prohibited.  (I don't know 
why this is case, though.) 
It's not prohibited afaik ... we allow writing to everything <= MQ (39)
on 32 bits and <= CCR (38) on 64 bits and ORIG_R3 qualifies (34)

Ben.

Re: [RFC/PATCH 5/5] powerpc: Allow ptrace write to pt_regs trap

From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Date: 2007-05-30 04:33:41

This doesn't look sufficient.  If you want GDB to use the save/ 
restore style means of handling interrupted calls (like i386), 
at the very least we also need the capability to *write* the 
orig_gpr3 field, which is currently prohibited.  (I don't know 
why this is case, though.) 
Ok, I found it... put_reg doesn't filter it out but the caller does.
Fixing that too.

Ben.

Re: [RFC/PATCH 5/5] powerpc: Allow ptrace write to pt_regs trap

From: Ulrich Weigand <hidden>
Date: 2007-05-30 13:08:57

Benjamin Herrenschmidt [off-list ref] wrote on 05/29/2007 
11:41:40 PM:
On Tue, 2007-05-29 at 17:41 +0200, Ulrich Weigand wrote:
quoted
This doesn't look sufficient.  If you want GDB to use the save/ 
restore style means of handling interrupted calls (like i386), 
at the very least we also need the capability to *write* the 
orig_gpr3 field, which is currently prohibited.  (I don't know 
why this is case, though.) 
It's not prohibited afaik ... we allow writing to everything <= MQ (39)
on 32 bits and <= CCR (38) on 64 bits and ORIG_R3 qualifies (34)
Um?  I see this in the PTRACE_POKEUSR case in arch_ptrace:

                if (index == PT_ORIG_R3)
                        break;



Mit freundlichen Gruessen / Best Regards

Ulrich Weigand

-- 
  Dr. Ulrich Weigand | Phone: +49-7031/16-3727
  GNU compiler/toolchain for Linux on System z and Cell BE
  IBM Deutschland Entwicklung GmbH
  Vorsitzender des Aufsichtsrats: Martin Jetter | Geschäftsführung: 
Herbert Kircher
  Sitz der Gesellschaft: Böblingen | Registergericht: Amtsgericht 
Stuttgart, HRB 243294
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help