From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: <linuxppc-dev@ozlabs.org>
Cc: Paul Mackerras <paulus@samba.org>, Christoph Hellwig <hch@lst.de>,
cbe-oss-dev@ozlabs.org
Subject: [PATCH 10/21] powerpc: Allow ptrace write to pt_regs trap and orig_r3
Date: Mon, 04 Jun 2007 15:15:46 +1000 [thread overview]
Message-ID: <20070604051550.C152BDDF07@ozlabs.org> (raw)
In-Reply-To: <1180934134.603289.870346178920.qpush@grosgo>
This patch allows a ptracer to write to the "trap" and "orig_r3" words
of the pt_regs.
This, along with a subsequent patch to the signal restart code, should
enable gdb to properly handle syscall restarting after executing a separate
function (at least when there's no restart block).
This patch also removes ptrace32.c code toying directly with the registers
and makes it use the ptrace_get/put_reg() accessors for everything so that
the logic for checking what is permitted is in only one place.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
arch/powerpc/kernel/ptrace.c | 9 ++++++---
arch/powerpc/kernel/ptrace32.c | 27 ++++++++++++++-------------
2 files changed, 20 insertions(+), 16 deletions(-)
Index: linux-cell/arch/powerpc/kernel/ptrace.c
===================================================================
--- linux-cell.orig/arch/powerpc/kernel/ptrace.c 2007-06-04 14:42:13.000000000 +1000
+++ linux-cell/arch/powerpc/kernel/ptrace.c 2007-06-04 14:42:26.000000000 +1000
@@ -75,10 +75,15 @@ int ptrace_put_reg(struct task_struct *t
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 &= 0xfff0;
((unsigned long *)task->thread.regs)[regno] = data;
return 0;
}
@@ -409,8 +414,6 @@ long arch_ptrace(struct task_struct *chi
break;
CHECK_FULL_REGS(child->thread.regs);
- if (index == PT_ORIG_R3)
- break;
if (index < PT_FPR0) {
ret = ptrace_put_reg(child, index, data);
} else {
Index: linux-cell/arch/powerpc/kernel/ptrace32.c
===================================================================
--- linux-cell.orig/arch/powerpc/kernel/ptrace32.c 2007-06-04 14:42:13.000000000 +1000
+++ linux-cell/arch/powerpc/kernel/ptrace32.c 2007-06-04 14:43:22.000000000 +1000
@@ -206,7 +206,9 @@ long compat_sys_ptrace(int request, int
else
part = 0; /* want the 1st half of the register (left-most). */
- /* Validate the input - check to see if address is on the wrong boundary or beyond the end of the user area */
+ /* Validate the input - check to see if address is on the wrong boundary
+ * or beyond the end of the user area
+ */
if ((addr & 3) || numReg > PT_FPSCR)
break;
@@ -270,8 +272,6 @@ long compat_sys_ptrace(int request, int
if ((addr & 3) || (index > PT_FPSCR32))
break;
- if (index == PT_ORIG_R3)
- break;
if (index < PT_FPR0) {
ret = ptrace_put_reg(child, index, data);
} else {
@@ -302,24 +302,25 @@ long compat_sys_ptrace(int request, int
/* Determine which register the user wants */
index = (u64)addr >> 2;
numReg = index / 2;
+
/*
* Validate the input - check to see if address is on the
* wrong boundary or beyond the end of the user area
*/
if ((addr & 3) || (numReg > PT_FPSCR))
break;
- /* Insure it is a register we let them change */
- if ((numReg == PT_ORIG_R3)
- || ((numReg > PT_CCR) && (numReg < PT_FPR0)))
- break;
- if (numReg >= PT_FPR0) {
+ if (numReg < PT_FPR0) {
+ unsigned long freg = ptrace_get_reg(child, numReg);
+ if (index % 2)
+ freg = (freg & ~0xfffffffful) | (data & 0xfffffffful);
+ else
+ freg = (freg & 0xfffffffful) | (data << 32);
+ ret = ptrace_put_reg(child, numReg, freg);
+ } else {
flush_fp_to_thread(child);
+ ((unsigned int *)child->thread.regs)[index] = data;
+ ret = 0;
}
- if (numReg == PT_MSR)
- data = (data & MSR_DEBUGCHANGE)
- | (child->thread.regs->msr & ~MSR_DEBUGCHANGE);
- ((u32*)child->thread.regs)[index] = data;
- ret = 0;
break;
}
next prev parent reply other threads:[~2007-06-04 5:15 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-04 5:15 [PATCH 0/21] This is my pending series for 2.6.23 Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 1/21] unmap_vm_area becomes unmap_kernel_range for the public Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 2/21] powerpc: Rewrite IO allocation & mapping on powerpc64 Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 3/21] spufs: Add support for SPU single stepping Benjamin Herrenschmidt
2007-06-04 13:06 ` Jeremy Kerr
2007-06-04 5:15 ` [PATCH 4/21] spufs: Add a "capabilities" file to spu contexts Benjamin Herrenschmidt
2007-06-04 13:06 ` Jeremy Kerr
2007-06-04 5:15 ` [PATCH 5/21] powerpc: Disable broken PPC_PTRACE_GETFPREGS on 32 bits Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 6/21] powerpc: ptrace cleanups Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 7/21] powerpc: ptrace updates & new better requests Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 8/21] powerpc: uninline common ptrace bits Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 9/21] powerpc: remove some useless ifdef's in ptrace Benjamin Herrenschmidt
2007-06-04 5:15 ` Benjamin Herrenschmidt [this message]
2007-06-04 5:15 ` [PATCH 12/21] powerpc: ptrace can set DABR on both 32 and 64 bits Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 11/21] powerpc: ptrace shouldn't touch FP exec mode Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 13/21] powerpc: Always apply DABR changes on context switches Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 14/21] powerpc: Make syscall restart code more common Benjamin Herrenschmidt
2007-06-04 7:06 ` Christoph Hellwig
2007-06-04 5:15 ` [PATCH 15/21] powerpc: consolidate sys_sigaltstack Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 16/21] powerpc: consolidate restore_sigmask Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 17/21] powerpc: consolidate do_signal Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 18/21] powerpc: Remove obsolete freezer bits Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 19/21] powerpc: Merge creation of signal frame Benjamin Herrenschmidt
2007-06-04 7:22 ` PATCH 19/21] powerpc: Merge creation of signal frame (#2) Benjamin Herrenschmidt
2007-06-04 8:01 ` Christoph Hellwig
2007-06-04 10:04 ` Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 20/21] powerpc: remove #ifdef around set_dabr in signal code Benjamin Herrenschmidt
2007-06-04 5:15 ` [PATCH 21/21] powerpc: Less ifdef's in signal.c/signal.h Benjamin Herrenschmidt
2007-06-04 7:00 ` [PATCH 0/21] This is my pending series for 2.6.23 Benjamin Herrenschmidt
2007-06-04 7:21 ` Benjamin Herrenschmidt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070604051550.C152BDDF07@ozlabs.org \
--to=benh@kernel.crashing.org \
--cc=cbe-oss-dev@ozlabs.org \
--cc=hch@lst.de \
--cc=linuxppc-dev@ozlabs.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).