* [PATCH v2] powerpc/ptrace: remove BUG_ON when full register set not available
@ 2011-03-16 13:37 Michael Wolf
2011-03-17 4:20 ` Paul Mackerras
2011-03-21 0:15 ` Benjamin Herrenschmidt
0 siblings, 2 replies; 3+ messages in thread
From: Michael Wolf @ 2011-03-16 13:37 UTC (permalink / raw)
To: linuxppc-dev; +Cc: mikey, anton
In some cases during a threaded core dump not all
the threads will have a full register set. This
will cause problems when the sigkill is sent to
the thread. To solve this problem a poison value
(0xdeadbeef) will be placed in the buffer in place
of the actual register values. This will affect
gpr14 to gpr31.
Signed-off-by: Mike Wolf <mjw@linux.vnet.ibm.com>
----------
--- linux-2.6.32-71.el6.ppc64.orig/arch/powerpc/include/asm/ptrace.h 2010-08-31 23:56:50.000000000 -0500
+++ linux-2.6.32-71.el6.ppc64/arch/powerpc/include/asm/ptrace.h 2011-03-14 11:43:33.176667099 -0500
@@ -123,8 +123,14 @@ extern int ptrace_put_reg(struct task_st
#define TRAP(regs) ((regs)->trap & ~0xF)
#ifdef __powerpc64__
#define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)
+#define PARTIAL_REG_FILL 0xdeadbeefdeadbeefUL
+#define PARTIAL_REG_START 14
+#define PARTIAL_REG_END 31
#else
#define CHECK_FULL_REGS(regs) \
+#define PARTIAL_REG_FILL 0xdeadbeef
+#define PARTIAL_REG_START 14
+#define PARTIAL_REG_END 31
do { \
if ((regs)->trap & 1) \
printk(KERN_CRIT "%s: partial register set\n", __func__); \
--- linux-2.6.32-71.el6.ppc64.orig/arch/powerpc/kernel/ptrace.c 2009-12-02 21:51:21.000000000 -0600
+++ linux-2.6.32-71.el6.ppc64/arch/powerpc/kernel/ptrace.c 2011-03-14 13:01:51.955586126 -0500
@@ -125,11 +125,16 @@ static int gpr_get(struct task_struct *t
void *kbuf, void __user *ubuf)
{
int ret;
+ int partial_reg;
if (target->thread.regs == NULL)
return -EIO;
- CHECK_FULL_REGS(target->thread.regs);
+ if (!FULL_REGS(target->thread.regs))
+ /* We have a partial register set. Fill 14-31 with bogus values */
+ for(partial_reg=PARTIAL_REG_START;partial_reg <= PARTIAL_REG_END;
+ partial_reg++)
+ target->thread.regs->gpr[partial_reg] = PARTIAL_REG_FILL;
ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
target->thread.regs,
@@ -536,11 +541,16 @@ static int gpr32_get(struct task_struct
compat_ulong_t *k = kbuf;
compat_ulong_t __user *u = ubuf;
compat_ulong_t reg;
+ int partial_reg;
if (target->thread.regs == NULL)
return -EIO;
- CHECK_FULL_REGS(target->thread.regs);
+ if (!FULL_REGS(target->thread.regs))
+ /* We have a partial register set. Fill 14-31 with bogus values */
+ for(partial_reg=PARTIAL_REG_START;partial_reg <= PARTIAL_REG_END;
+ partial_reg++)
+ target->thread.regs->gpr[partial_reg] = PARTIAL_REG_FILL;
pos /= sizeof(reg);
count /= sizeof(reg);
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] powerpc/ptrace: remove BUG_ON when full register set not available
2011-03-16 13:37 [PATCH v2] powerpc/ptrace: remove BUG_ON when full register set not available Michael Wolf
@ 2011-03-17 4:20 ` Paul Mackerras
2011-03-21 0:15 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 3+ messages in thread
From: Paul Mackerras @ 2011-03-17 4:20 UTC (permalink / raw)
To: mjw; +Cc: linuxppc-dev, mikey, anton
On Wed, Mar 16, 2011 at 08:37:22AM -0500, Michael Wolf wrote:
> In some cases during a threaded core dump not all
> the threads will have a full register set. This
> will cause problems when the sigkill is sent to
> the thread. To solve this problem a poison value
> (0xdeadbeef) will be placed in the buffer in place
> of the actual register values. This will affect
> gpr14 to gpr31.
To be clear, this happens when the signal causing the core dump races
with a thread exiting. The race happens when the exiting thread has
entered the kernel for the last time before the signal arrives, but
doesn't get far enough through the exit code to avoid being included
in the core dump. So we get a thread included in the core dump which
is never going to go out to userspace again and only has a partial
register set recorded. Normally we would catch each thread as it is
about to go into userspace and capture the full register set then.
However, this exiting thread is never going to go out to userspace
again, so we have no way to capture its full register set. It doesn't
really matter, though, as this is a thread which is effectively
already dead.
Paul.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] powerpc/ptrace: remove BUG_ON when full register set not available
2011-03-16 13:37 [PATCH v2] powerpc/ptrace: remove BUG_ON when full register set not available Michael Wolf
2011-03-17 4:20 ` Paul Mackerras
@ 2011-03-21 0:15 ` Benjamin Herrenschmidt
1 sibling, 0 replies; 3+ messages in thread
From: Benjamin Herrenschmidt @ 2011-03-21 0:15 UTC (permalink / raw)
To: mjw; +Cc: linuxppc-dev, mikey, anton
On Wed, 2011-03-16 at 08:37 -0500, Michael Wolf wrote:
> In some cases during a threaded core dump not all
> the threads will have a full register set. This
> will cause problems when the sigkill is sent to
> the thread. To solve this problem a poison value
> (0xdeadbeef) will be placed in the buffer in place
> of the actual register values. This will affect
> gpr14 to gpr31.
>
> Signed-off-by: Mike Wolf <mjw@linux.vnet.ibm.com>
Patch is busted on ppc32 (you add #define's in the middle of a
multi-line macro) and of doubtful stylistic value :-) I'll merge
a slightly reworked variant that includes a new cset comment
with Paulus explanation in it.
Cheers,
Ben.
> ----------
> --- linux-2.6.32-71.el6.ppc64.orig/arch/powerpc/include/asm/ptrace.h 2010-08-31 23:56:50.000000000 -0500
> +++ linux-2.6.32-71.el6.ppc64/arch/powerpc/include/asm/ptrace.h 2011-03-14 11:43:33.176667099 -0500
> @@ -123,8 +123,14 @@ extern int ptrace_put_reg(struct task_st
> #define TRAP(regs) ((regs)->trap & ~0xF)
> #ifdef __powerpc64__
> #define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)
> +#define PARTIAL_REG_FILL 0xdeadbeefdeadbeefUL
> +#define PARTIAL_REG_START 14
> +#define PARTIAL_REG_END 31
> #else
> #define CHECK_FULL_REGS(regs) \
> +#define PARTIAL_REG_FILL 0xdeadbeef
> +#define PARTIAL_REG_START 14
> +#define PARTIAL_REG_END 31
> do { \
> if ((regs)->trap & 1) \
> printk(KERN_CRIT "%s: partial register set\n", __func__); \
> --- linux-2.6.32-71.el6.ppc64.orig/arch/powerpc/kernel/ptrace.c 2009-12-02 21:51:21.000000000 -0600
> +++ linux-2.6.32-71.el6.ppc64/arch/powerpc/kernel/ptrace.c 2011-03-14 13:01:51.955586126 -0500
> @@ -125,11 +125,16 @@ static int gpr_get(struct task_struct *t
> void *kbuf, void __user *ubuf)
> {
> int ret;
> + int partial_reg;
>
> if (target->thread.regs == NULL)
> return -EIO;
>
> - CHECK_FULL_REGS(target->thread.regs);
> + if (!FULL_REGS(target->thread.regs))
> + /* We have a partial register set. Fill 14-31 with bogus values */
> + for(partial_reg=PARTIAL_REG_START;partial_reg <= PARTIAL_REG_END;
> + partial_reg++)
> + target->thread.regs->gpr[partial_reg] = PARTIAL_REG_FILL;
>
> ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
> target->thread.regs,
> @@ -536,11 +541,16 @@ static int gpr32_get(struct task_struct
> compat_ulong_t *k = kbuf;
> compat_ulong_t __user *u = ubuf;
> compat_ulong_t reg;
> + int partial_reg;
>
> if (target->thread.regs == NULL)
> return -EIO;
>
> - CHECK_FULL_REGS(target->thread.regs);
> + if (!FULL_REGS(target->thread.regs))
> + /* We have a partial register set. Fill 14-31 with bogus values */
> + for(partial_reg=PARTIAL_REG_START;partial_reg <= PARTIAL_REG_END;
> + partial_reg++)
> + target->thread.regs->gpr[partial_reg] = PARTIAL_REG_FILL;
>
> pos /= sizeof(reg);
> count /= sizeof(reg);
>
>
> _______________________________________________
> Linuxppc-dev mailing list
> Linuxppc-dev@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/linuxppc-dev
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-03-21 0:16 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-16 13:37 [PATCH v2] powerpc/ptrace: remove BUG_ON when full register set not available Michael Wolf
2011-03-17 4:20 ` Paul Mackerras
2011-03-21 0:15 ` Benjamin Herrenschmidt
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).