# \[PATCH\] powerpc/interrupt: Do not call single\_step\_exception() from other exceptions

- Subsystems: LINUX FOR POWERPC (32-BIT AND 64-BIT), THE REST
- Maintainers: Madhavan Srinivasan, Linus Torvalds
- Status: LANDED (01fcac8e4dfc · 2021-08-12 12:22)
- Landed in mainline as 01fcac8e4dfc on 2021-08-12.
- List: linuxppc-dev
- 3 messages, 3 authors
- Page: https://ratatoskr.run/linuxppc-dev/2021/08/1473415/t

## \[PATCH\] powerpc/interrupt: Do not call single\_step\_exception() from other exceptions

- From: Christophe Leroy \<hidden\>
- Date: 2021-08-10 16:13:25 
- Message: https://ratatoskr.run/linuxppc-dev/2021/08/1473415.md

```text
single_step_exception() is called by emulate_single_step() which
is called from (at least) alignment exception() handler and
program_check_exception() handler.

Redefine it as a regular __single_step_exception() which is called
by both single_step_exception() handler and emulate_single_step()
function.

Fixes: 3a96570ffceb ("powerpc: convert interrupt handlers to use wrappers")
Cc: <redacted>
Cc: Stan Johnson <redacted>
Cc: Nicholas Piggin <npiggin@gmail.com>
Cc: Finn Thain <fthain@linux-m68k.org>
Signed-off-by: Christophe Leroy <redacted>
---
 arch/powerpc/kernel/traps.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
index dfbce527c98e..d56254f05e17 100644
--- a/arch/powerpc/kernel/traps.c
+++ b/arch/powerpc/kernel/traps.c
@@ -1104,7 +1104,7 @@ DEFINE_INTERRUPT_HANDLER(RunModeException)
 	_exception(SIGTRAP, regs, TRAP_UNK, 0);
 }
 
-DEFINE_INTERRUPT_HANDLER(single_step_exception)
+static void __single_step_exception(struct pt_regs *regs)
 {
 	clear_single_step(regs);
 	clear_br_trace(regs);
@@ -1121,6 +1121,11 @@ DEFINE_INTERRUPT_HANDLER(single_step_exception)
 	_exception(SIGTRAP, regs, TRAP_TRACE, regs->nip);
 }
 
+DEFINE_INTERRUPT_HANDLER(single_step_exception)
+{
+	__single_step_exception(regs);
+}
+
 /*
  * After we have successfully emulated an instruction, we have to
  * check if the instruction was being single-stepped, and if so,
@@ -1130,7 +1135,7 @@ DEFINE_INTERRUPT_HANDLER(single_step_exception)
 static void emulate_single_step(struct pt_regs *regs)
 {
 	if (single_stepping(regs))
-		single_step_exception(regs);
+		__single_step_exception(regs);
 }
 
 static inline int __parse_fpscr(unsigned long fpscr)
-- 
2.25.0

```

## Re: \[PATCH\] powerpc/interrupt: Do not call single\_step\_exception() from other exceptions

- From: Nicholas Piggin \<npiggin@gmail.com\>
- Date: 2021-08-12 10:01:17 
- Message: https://ratatoskr.run/linuxppc-dev/2021/08/1475928.md

```text
Excerpts from Christophe Leroy's message of August 11, 2021 2:13 am:
> single_step_exception() is called by emulate_single_step() which
> is called from (at least) alignment exception() handler and
> program_check_exception() handler.
> 
> Redefine it as a regular __single_step_exception() which is called
> by both single_step_exception() handler and emulate_single_step()
> function.
> 

Reviewed-by: Nicholas Piggin <npiggin@gmail.com>

> Fixes: 3a96570ffceb ("powerpc: convert interrupt handlers to use wrappers")
> Cc: <redacted>
> Cc: Stan Johnson <redacted>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Finn Thain <fthain@linux-m68k.org>
> Signed-off-by: Christophe Leroy <redacted>
> ---
>  arch/powerpc/kernel/traps.c | 9 +++++++--
>  1 file changed, 7 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/powerpc/kernel/traps.c b/arch/powerpc/kernel/traps.c
> index dfbce527c98e..d56254f05e17 100644
> --- a/arch/powerpc/kernel/traps.c
> +++ b/arch/powerpc/kernel/traps.c
> @@ -1104,7 +1104,7 @@ DEFINE_INTERRUPT_HANDLER(RunModeException)
>  	_exception(SIGTRAP, regs, TRAP_UNK, 0);
>  }
>  
> -DEFINE_INTERRUPT_HANDLER(single_step_exception)
> +static void __single_step_exception(struct pt_regs *regs)
>  {
>  	clear_single_step(regs);
>  	clear_br_trace(regs);
> @@ -1121,6 +1121,11 @@ DEFINE_INTERRUPT_HANDLER(single_step_exception)
>  	_exception(SIGTRAP, regs, TRAP_TRACE, regs->nip);
>  }
>  
> +DEFINE_INTERRUPT_HANDLER(single_step_exception)
> +{
> +	__single_step_exception(regs);
> +}
> +
>  /*
>   * After we have successfully emulated an instruction, we have to
>   * check if the instruction was being single-stepped, and if so,
> @@ -1130,7 +1135,7 @@ DEFINE_INTERRUPT_HANDLER(single_step_exception)
>  static void emulate_single_step(struct pt_regs *regs)
>  {
>  	if (single_stepping(regs))
> -		single_step_exception(regs);
> +		__single_step_exception(regs);
>  }
>  
>  static inline int __parse_fpscr(unsigned long fpscr)
> -- 
> 2.25.0
> 
> 
```

## Re: \[PATCH\] powerpc/interrupt: Do not call single\_step\_exception() from other exceptions

- From: Michael Ellerman \<hidden\>
- Date: 2021-08-13 11:59:03 
- Message: https://ratatoskr.run/linuxppc-dev/2021/08/1476939.md

```text
On Tue, 10 Aug 2021 16:13:17 +0000 (UTC), Christophe Leroy wrote:
> single_step_exception() is called by emulate_single_step() which
> is called from (at least) alignment exception() handler and
> program_check_exception() handler.
> 
> Redefine it as a regular __single_step_exception() which is called
> by both single_step_exception() handler and emulate_single_step()
> function.

Applied to powerpc/fixes.

[1/1] powerpc/interrupt: Do not call single_step_exception() from other exceptions
      https://git.kernel.org/powerpc/c/01fcac8e4dfc112f420dcaeb70056a74e326cacf

cheers
```
