Re: [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
On Tue, Dec 18, 2012 at 08:10:13PM +0100, Oleg Nesterov wrote: > On 12/18, Ananth N Mavinakayanahalli wrote: > > > > On Fri, Dec 14, 2012 at 09:02:41PM +0100, Oleg Nesterov wrote: > > > > > > > > - uprobe_restore_context_sstep(>autask); > > > > + uprobe_restore_context_sstep(>autask, regs); > > > > > > I am not sure ppc needs this, but note that x86 does a bit more. > > > > > > Not only we need to restore the "single-step" state, we need to > > > send SIGTRAP if it was not set by us. The same for _skip_sstep. > > > > Do you mean restoring the TF equivalent on powerpc to what it was before? > > > > If so, powerpc has always been unique in this aspect -- the single-step > > exception handler *always* resets the sstep bit in MSR. Any user needing > > to continue single-stepping has to explicitly set it again. > > I meant another thing. > > Suppose that, say, gdb tries to single-step over the probed insn. > In this case we need to send SIGTRAP after xol/emulate. Please look at > send_sig(SIGTRAP) in arch/x86/kernel/uprobes.c:arch_uprobe_post_xol() > and arch_uprobe_skip_sstep(). Agreed. Thanks for the clarification Oleg. Ananth -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
On 12/18, Ananth N Mavinakayanahalli wrote: > > On Fri, Dec 14, 2012 at 09:02:41PM +0100, Oleg Nesterov wrote: > > > > > > - uprobe_restore_context_sstep(>autask); > > > + uprobe_restore_context_sstep(>autask, regs); > > > > I am not sure ppc needs this, but note that x86 does a bit more. > > > > Not only we need to restore the "single-step" state, we need to > > send SIGTRAP if it was not set by us. The same for _skip_sstep. > > Do you mean restoring the TF equivalent on powerpc to what it was before? > > If so, powerpc has always been unique in this aspect -- the single-step > exception handler *always* resets the sstep bit in MSR. Any user needing > to continue single-stepping has to explicitly set it again. I meant another thing. Suppose that, say, gdb tries to single-step over the probed insn. In this case we need to send SIGTRAP after xol/emulate. Please look at send_sig(SIGTRAP) in arch/x86/kernel/uprobes.c:arch_uprobe_post_xol() and arch_uprobe_skip_sstep(). Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
On 12/18, Ananth N Mavinakayanahalli wrote: On Fri, Dec 14, 2012 at 09:02:41PM +0100, Oleg Nesterov wrote: - uprobe_restore_context_sstep(utask-autask); + uprobe_restore_context_sstep(utask-autask, regs); I am not sure ppc needs this, but note that x86 does a bit more. Not only we need to restore the single-step state, we need to send SIGTRAP if it was not set by us. The same for _skip_sstep. Do you mean restoring the TF equivalent on powerpc to what it was before? If so, powerpc has always been unique in this aspect -- the single-step exception handler *always* resets the sstep bit in MSR. Any user needing to continue single-stepping has to explicitly set it again. I meant another thing. Suppose that, say, gdb tries to single-step over the probed insn. In this case we need to send SIGTRAP after xol/emulate. Please look at send_sig(SIGTRAP) in arch/x86/kernel/uprobes.c:arch_uprobe_post_xol() and arch_uprobe_skip_sstep(). Oleg. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
On Tue, Dec 18, 2012 at 08:10:13PM +0100, Oleg Nesterov wrote: On 12/18, Ananth N Mavinakayanahalli wrote: On Fri, Dec 14, 2012 at 09:02:41PM +0100, Oleg Nesterov wrote: - uprobe_restore_context_sstep(utask-autask); + uprobe_restore_context_sstep(utask-autask, regs); I am not sure ppc needs this, but note that x86 does a bit more. Not only we need to restore the single-step state, we need to send SIGTRAP if it was not set by us. The same for _skip_sstep. Do you mean restoring the TF equivalent on powerpc to what it was before? If so, powerpc has always been unique in this aspect -- the single-step exception handler *always* resets the sstep bit in MSR. Any user needing to continue single-stepping has to explicitly set it again. I meant another thing. Suppose that, say, gdb tries to single-step over the probed insn. In this case we need to send SIGTRAP after xol/emulate. Please look at send_sig(SIGTRAP) in arch/x86/kernel/uprobes.c:arch_uprobe_post_xol() and arch_uprobe_skip_sstep(). Agreed. Thanks for the clarification Oleg. Ananth -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
On Fri, Dec 14, 2012 at 09:02:41PM +0100, Oleg Nesterov wrote: > On 12/03, Suzuki K. Poulose wrote: > > > > Replace the ptrace helpers with the powerpc generic routines to > > enable/disable single step. We save/restore the MSR (and DCBR for BookE) > > across for the operation. We don't have to disable the single step, > > as restoring the MSR/DBCR would restore the previous state. > > Obviously I can't review this series (although it looks fine to me). > > Just one note, > > > @@ -121,7 +132,7 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, > > struct pt_regs *regs) > > > > WARN_ON_ONCE(current->thread.trap_nr != UPROBE_TRAP_NR); > > > > - uprobe_restore_context_sstep(>autask); > > + uprobe_restore_context_sstep(>autask, regs); > > I am not sure ppc needs this, but note that x86 does a bit more. > > Not only we need to restore the "single-step" state, we need to > send SIGTRAP if it was not set by us. The same for _skip_sstep. Do you mean restoring the TF equivalent on powerpc to what it was before? If so, powerpc has always been unique in this aspect -- the single-step exception handler *always* resets the sstep bit in MSR. Any user needing to continue single-stepping has to explicitly set it again. Ananth -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
On 12/15/2012 01:32 AM, Oleg Nesterov wrote: On 12/03, Suzuki K. Poulose wrote: Replace the ptrace helpers with the powerpc generic routines to enable/disable single step. We save/restore the MSR (and DCBR for BookE) across for the operation. We don't have to disable the single step, as restoring the MSR/DBCR would restore the previous state. Obviously I can't review this series (although it looks fine to me). Just one note, @@ -121,7 +132,7 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) WARN_ON_ONCE(current->thread.trap_nr != UPROBE_TRAP_NR); - uprobe_restore_context_sstep(>autask); + uprobe_restore_context_sstep(>autask, regs); I am not sure ppc needs this, but note that x86 does a bit more. Not only we need to restore the "single-step" state, we need to send SIGTRAP if it was not set by us. The same for _skip_sstep. Ok. I will investigate that part and do the necessary. Thanks Suzuki -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
On 12/15/2012 01:32 AM, Oleg Nesterov wrote: On 12/03, Suzuki K. Poulose wrote: Replace the ptrace helpers with the powerpc generic routines to enable/disable single step. We save/restore the MSR (and DCBR for BookE) across for the operation. We don't have to disable the single step, as restoring the MSR/DBCR would restore the previous state. Obviously I can't review this series (although it looks fine to me). Just one note, @@ -121,7 +132,7 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) WARN_ON_ONCE(current-thread.trap_nr != UPROBE_TRAP_NR); - uprobe_restore_context_sstep(utask-autask); + uprobe_restore_context_sstep(utask-autask, regs); I am not sure ppc needs this, but note that x86 does a bit more. Not only we need to restore the single-step state, we need to send SIGTRAP if it was not set by us. The same for _skip_sstep. Ok. I will investigate that part and do the necessary. Thanks Suzuki -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
On Fri, Dec 14, 2012 at 09:02:41PM +0100, Oleg Nesterov wrote: On 12/03, Suzuki K. Poulose wrote: Replace the ptrace helpers with the powerpc generic routines to enable/disable single step. We save/restore the MSR (and DCBR for BookE) across for the operation. We don't have to disable the single step, as restoring the MSR/DBCR would restore the previous state. Obviously I can't review this series (although it looks fine to me). Just one note, @@ -121,7 +132,7 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) WARN_ON_ONCE(current-thread.trap_nr != UPROBE_TRAP_NR); - uprobe_restore_context_sstep(utask-autask); + uprobe_restore_context_sstep(utask-autask, regs); I am not sure ppc needs this, but note that x86 does a bit more. Not only we need to restore the single-step state, we need to send SIGTRAP if it was not set by us. The same for _skip_sstep. Do you mean restoring the TF equivalent on powerpc to what it was before? If so, powerpc has always been unique in this aspect -- the single-step exception handler *always* resets the sstep bit in MSR. Any user needing to continue single-stepping has to explicitly set it again. Ananth -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
On 12/03, Suzuki K. Poulose wrote: > > Replace the ptrace helpers with the powerpc generic routines to > enable/disable single step. We save/restore the MSR (and DCBR for BookE) > across for the operation. We don't have to disable the single step, > as restoring the MSR/DBCR would restore the previous state. Obviously I can't review this series (although it looks fine to me). Just one note, > @@ -121,7 +132,7 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, > struct pt_regs *regs) > > WARN_ON_ONCE(current->thread.trap_nr != UPROBE_TRAP_NR); > > - uprobe_restore_context_sstep(>autask); > + uprobe_restore_context_sstep(>autask, regs); I am not sure ppc needs this, but note that x86 does a bit more. Not only we need to restore the "single-step" state, we need to send SIGTRAP if it was not set by us. The same for _skip_sstep. But even if I am right I do not suggest to change this series, this can be done as a separate patch. Oleg. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
On 12/03, Suzuki K. Poulose wrote: Replace the ptrace helpers with the powerpc generic routines to enable/disable single step. We save/restore the MSR (and DCBR for BookE) across for the operation. We don't have to disable the single step, as restoring the MSR/DBCR would restore the previous state. Obviously I can't review this series (although it looks fine to me). Just one note, @@ -121,7 +132,7 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) WARN_ON_ONCE(current-thread.trap_nr != UPROBE_TRAP_NR); - uprobe_restore_context_sstep(utask-autask); + uprobe_restore_context_sstep(utask-autask, regs); I am not sure ppc needs this, but note that x86 does a bit more. Not only we need to restore the single-step state, we need to send SIGTRAP if it was not set by us. The same for _skip_sstep. But even if I am right I do not suggest to change this series, this can be done as a separate patch. Oleg. -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
On Mon, Dec 03, 2012 at 08:40:32PM +0530, Suzuki K. Poulose wrote: > From: Suzuki K. Poulose > > Replace the ptrace helpers with the powerpc generic routines to > enable/disable single step. We save/restore the MSR (and DCBR for BookE) > across for the operation. We don't have to disable the single step, > as restoring the MSR/DBCR would restore the previous state. > > Signed-off-by: Suzuki K. Poulose Acked-by: Ananth N Mavinakayanahalli -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Re: [PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
On Mon, Dec 03, 2012 at 08:40:32PM +0530, Suzuki K. Poulose wrote: From: Suzuki K. Poulose suz...@in.ibm.com Replace the ptrace helpers with the powerpc generic routines to enable/disable single step. We save/restore the MSR (and DCBR for BookE) across for the operation. We don't have to disable the single step, as restoring the MSR/DBCR would restore the previous state. Signed-off-by: Suzuki K. Poulose suz...@in.ibm.com Acked-by: Ananth N Mavinakayanahalli ana...@in.ibm.com -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
From: Suzuki K. Poulose Replace the ptrace helpers with the powerpc generic routines to enable/disable single step. We save/restore the MSR (and DCBR for BookE) across for the operation. We don't have to disable the single step, as restoring the MSR/DBCR would restore the previous state. Signed-off-by: Suzuki K. Poulose --- arch/powerpc/include/asm/uprobes.h |4 arch/powerpc/kernel/uprobes.c | 26 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/include/asm/uprobes.h b/arch/powerpc/include/asm/uprobes.h index b532060..10a521c 100644 --- a/arch/powerpc/include/asm/uprobes.h +++ b/arch/powerpc/include/asm/uprobes.h @@ -43,6 +43,10 @@ struct arch_uprobe { struct arch_uprobe_task { unsigned long saved_trap_nr; + unsigned long saved_msr; +#ifdef CONFIG_PPC_ADV_DEBUG_REGS + unsigned long saved_dbcr0; +#endif }; extern int arch_uprobe_analyze_insn(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long addr); diff --git a/arch/powerpc/kernel/uprobes.c b/arch/powerpc/kernel/uprobes.c index 1a62353..6af55c4 100644 --- a/arch/powerpc/kernel/uprobes.c +++ b/arch/powerpc/kernel/uprobes.c @@ -52,14 +52,25 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, return 0; } -static void uprobe_save_context_sstep(struct arch_uprobe_task *autask) +static void uprobe_save_context_sstep(struct arch_uprobe_task *autask, + struct pt_regs *regs) { autask->saved_trap_nr = current->thread.trap_nr; + autask->saved_msr = regs->msr; +#ifdef CONFIG_PPC_ADV_DEBUG_REGS + autask->saved_dbcr0 = mfspr(SPRN_DBCR0); +#endif } -static void uprobe_restore_context_sstep(struct arch_uprobe_task *autask) +static void uprobe_restore_context_sstep(struct arch_uprobe_task *autask, + struct pt_regs *regs) { current->thread.trap_nr = autask->saved_trap_nr; + + regs->msr = autask->saved_msr; +#ifdef CONFIG_PPC_ADV_DEBUG_REGS + mtspr(SPRN_DBCR0, autask->saved_dbcr0); +#endif } /* @@ -71,11 +82,11 @@ int arch_uprobe_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) { struct arch_uprobe_task *autask = >utask->autask; - uprobe_save_context_sstep(autask); + uprobe_save_context_sstep(autask, regs); current->thread.trap_nr = UPROBE_TRAP_NR; regs->nip = current->utask->xol_vaddr; - user_enable_single_step(current); + enable_single_step(regs); return 0; } @@ -121,7 +132,7 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) WARN_ON_ONCE(current->thread.trap_nr != UPROBE_TRAP_NR); - uprobe_restore_context_sstep(>autask); + uprobe_restore_context_sstep(>autask, regs); /* * On powerpc, except for loads and stores, most instructions @@ -132,7 +143,6 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) */ regs->nip = utask->vaddr + MAX_UINSN_BYTES; - user_disable_single_step(current); return 0; } @@ -174,10 +184,8 @@ void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) { struct uprobe_task *utask = current->utask; - uprobe_restore_context_sstep(>autask); + uprobe_restore_context_sstep(>autask, regs); instruction_pointer_set(regs, utask->vaddr); - - user_disable_single_step(current); } /* -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[PATCH v2 4/4] uprobes/powerpc: Make use of generic routines to enable single step
From: Suzuki K. Poulose suz...@in.ibm.com Replace the ptrace helpers with the powerpc generic routines to enable/disable single step. We save/restore the MSR (and DCBR for BookE) across for the operation. We don't have to disable the single step, as restoring the MSR/DBCR would restore the previous state. Signed-off-by: Suzuki K. Poulose suz...@in.ibm.com --- arch/powerpc/include/asm/uprobes.h |4 arch/powerpc/kernel/uprobes.c | 26 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/arch/powerpc/include/asm/uprobes.h b/arch/powerpc/include/asm/uprobes.h index b532060..10a521c 100644 --- a/arch/powerpc/include/asm/uprobes.h +++ b/arch/powerpc/include/asm/uprobes.h @@ -43,6 +43,10 @@ struct arch_uprobe { struct arch_uprobe_task { unsigned long saved_trap_nr; + unsigned long saved_msr; +#ifdef CONFIG_PPC_ADV_DEBUG_REGS + unsigned long saved_dbcr0; +#endif }; extern int arch_uprobe_analyze_insn(struct arch_uprobe *aup, struct mm_struct *mm, unsigned long addr); diff --git a/arch/powerpc/kernel/uprobes.c b/arch/powerpc/kernel/uprobes.c index 1a62353..6af55c4 100644 --- a/arch/powerpc/kernel/uprobes.c +++ b/arch/powerpc/kernel/uprobes.c @@ -52,14 +52,25 @@ int arch_uprobe_analyze_insn(struct arch_uprobe *auprobe, return 0; } -static void uprobe_save_context_sstep(struct arch_uprobe_task *autask) +static void uprobe_save_context_sstep(struct arch_uprobe_task *autask, + struct pt_regs *regs) { autask-saved_trap_nr = current-thread.trap_nr; + autask-saved_msr = regs-msr; +#ifdef CONFIG_PPC_ADV_DEBUG_REGS + autask-saved_dbcr0 = mfspr(SPRN_DBCR0); +#endif } -static void uprobe_restore_context_sstep(struct arch_uprobe_task *autask) +static void uprobe_restore_context_sstep(struct arch_uprobe_task *autask, + struct pt_regs *regs) { current-thread.trap_nr = autask-saved_trap_nr; + + regs-msr = autask-saved_msr; +#ifdef CONFIG_PPC_ADV_DEBUG_REGS + mtspr(SPRN_DBCR0, autask-saved_dbcr0); +#endif } /* @@ -71,11 +82,11 @@ int arch_uprobe_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) { struct arch_uprobe_task *autask = current-utask-autask; - uprobe_save_context_sstep(autask); + uprobe_save_context_sstep(autask, regs); current-thread.trap_nr = UPROBE_TRAP_NR; regs-nip = current-utask-xol_vaddr; - user_enable_single_step(current); + enable_single_step(regs); return 0; } @@ -121,7 +132,7 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) WARN_ON_ONCE(current-thread.trap_nr != UPROBE_TRAP_NR); - uprobe_restore_context_sstep(utask-autask); + uprobe_restore_context_sstep(utask-autask, regs); /* * On powerpc, except for loads and stores, most instructions @@ -132,7 +143,6 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) */ regs-nip = utask-vaddr + MAX_UINSN_BYTES; - user_disable_single_step(current); return 0; } @@ -174,10 +184,8 @@ void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs) { struct uprobe_task *utask = current-utask; - uprobe_restore_context_sstep(utask-autask); + uprobe_restore_context_sstep(utask-autask, regs); instruction_pointer_set(regs, utask-vaddr); - - user_disable_single_step(current); } /* -- To unsubscribe from this list: send the line unsubscribe linux-kernel in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/