# Re: \[RFC PATCH v2 1/1\] powerpc: update ppc\_save\_regs to save current r1 in pt\_regs

- From: Aditya Gupta \<hidden\>
- Date: 2023-06-19 03:49:26 
- List: linuxppc-dev
- Page: https://ratatoskr.run/linuxppc-dev/2023/06/9531290
- Thread: https://ratatoskr.run/linuxppc-dev/2023/06/9531260/t.md

```text
On 15/06/23 17:40, Nicholas Piggin wrote:
> On Thu Jun 15, 2023 at 7:10 PM AEST, Aditya Gupta wrote:
>> ppc_save_regs() skips one stack frame while saving the CPU register states.
>> Instead of saving current R1, it pulls the previous stack frame pointer.
>>
>> ...
>>
>> So this now saves regs as though it was an interrupt taken in the
>> caller, at the instruction after the call to ppc_save_regs, whereas
>> previously the NIP was there, but R1 came from the caller's caller
>> and that mismatch is what causes gdb's dwarf unwinder to go haywire.
>>
>> Nice catch, and I think I follow the fix and I think I agree with it.
>> Before the bug was introduced, NIP also came from the grandparent.
>> Which is what xmon presumably wanted, but since then I think maybe it
>> makes more sense to just have the parent caller.
>>
>> Reivewed-by: Nicholas Piggin [ref]
>> Fixes: d16a58f8854b1 ("powerpc: Improve ppc_save_regs()")

Thanks for reviewing this, and providing a Fixes tag too.

Thanks
- Aditya

```
