Patchwork [v6,5/5] powerpc/book3e/kgdb: Fix a single stgep case of lazy IRQ

login
register
mail settings
Submitter Tiejun Chen
Date Oct. 23, 2013, 9:31 a.m.
Message ID <1382520685-11609-6-git-send-email-tiejun.chen@windriver.com>
Download mbox | patch
Permalink /patch/285593/
State Changes Requested
Delegated to: Scott Wood
Headers show

Comments

Tiejun Chen - Oct. 23, 2013, 9:31 a.m.
In lazy EE magic, we may have a lazy interrupt occured while
entering kgdb, but we really don't want to replay that interrupt
for kgdb, so we have to clear the PACA_IRQ_HARD_DIS force to
make sure we can exit directly from this debug exception.

Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>
---
 arch/powerpc/kernel/kgdb.c |    8 ++++++++
 1 file changed, 8 insertions(+)
Scott Wood - Dec. 18, 2013, 2:45 a.m.
On Wed, 2013-10-23 at 17:31 +0800, Tiejun Chen wrote:
> In lazy EE magic, we may have a lazy interrupt occured while
> entering kgdb, but we really don't want to replay that interrupt
> for kgdb, so we have to clear the PACA_IRQ_HARD_DIS force to
> make sure we can exit directly from this debug exception.
> 
> Signed-off-by: Tiejun Chen <tiejun.chen@windriver.com>

s/stgep/step/ in subject

> ---
>  arch/powerpc/kernel/kgdb.c |    8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c
> index 447c14b..9872f58 100644
> --- a/arch/powerpc/kernel/kgdb.c
> +++ b/arch/powerpc/kernel/kgdb.c
> @@ -185,6 +185,14 @@ static int kgdb_singlestep(struct pt_regs *regs)
>  		/* Restore current_thread_info lastly. */
>  		memcpy(exception_thread_info, backup_current_thread_info, sizeof *thread_info);
>  
> +#ifdef CONFIG_PPC64
> +	/*
> +	 * Clear the PACA_IRQ_HARD_DIS from the pending mask
> +	 * since we are about to exit this directly from debug
> +	 * exception without any replay interrupt in lazy EE case.
> +	 */
> +	local_paca->irq_happened &= ~PACA_IRQ_HARD_DIS;
> +#endif
>  	return 1;
>  }
>  

What happens to those interrupts you discarded once we get back to a
state when they can be safely replayed?  I don't think just dropping
them is the answer.

I'm not sure what the actual problem is.  I can understand not wanting
kgdb to cause interrupts to appear to run when the interrupted context
has external interrupts disabled, but the replay code in entry_64.S
doesn't run if interrupts are soft-disabled in the context to be
returned to.  What harm does it cause to run the interrupts if we're
returning to an EE=1 context?

Does KGDB enable interrupts in its handler?  If not, how do we even get
into the situation where there are interrupts pending when the
interrupted context has EE soft-enabled (i.e. we went directly from a
context where the interrupt handler should have run, to a hard-disabled
context)?

-Scott

Patch

diff --git a/arch/powerpc/kernel/kgdb.c b/arch/powerpc/kernel/kgdb.c
index 447c14b..9872f58 100644
--- a/arch/powerpc/kernel/kgdb.c
+++ b/arch/powerpc/kernel/kgdb.c
@@ -185,6 +185,14 @@  static int kgdb_singlestep(struct pt_regs *regs)
 		/* Restore current_thread_info lastly. */
 		memcpy(exception_thread_info, backup_current_thread_info, sizeof *thread_info);
 
+#ifdef CONFIG_PPC64
+	/*
+	 * Clear the PACA_IRQ_HARD_DIS from the pending mask
+	 * since we are about to exit this directly from debug
+	 * exception without any replay interrupt in lazy EE case.
+	 */
+	local_paca->irq_happened &= ~PACA_IRQ_HARD_DIS;
+#endif
 	return 1;
 }