[PATCH v3 8/8] unwind: arm64: Use sframe to unwind interrupt frames.
Jens Remus
jremus at linux.ibm.com
Mon Apr 20 01:42:35 PDT 2026
On 4/20/2026 7:56 AM, Dylan Hatch wrote:
> On Fri, Apr 17, 2026 at 8:45 AM Jens Remus <jremus at linux.ibm.com> wrote:
>>> + case UNWIND_CFA_RULE_REG_OFFSET:
>>> + case UNWIND_CFA_RULE_REG_OFFSET_DEREF:
>>> + if (!regs)
>>
>> if (!regs || frame.cfa.regnum > 30)
>>
>>> + return -EINVAL;
>>> + cfa = regs->regs[frame.cfa.regnum];
>>
>> In unwind user this is guarded by a topmost frame check, as arbitrary
>> registers are otherwise not available. Isn't this necessary in the
>> kernel case?
>
> It is necessary, though as you point out the way I wrote the check is
> not as obvious as it probably should be.
>
> The saved state->regs is set when the current frame is recovered from
> the saved PC of a struct pt_regs, and then immediately set back to
> NULL after the next frame has been recovered. In other words, the
> state->regs is only ever set when it is relevant to the current frame,
> which occurs when state->source == KUNWIND_SOURCE_REGS_PC. This only
> happens when the topmost frame is recovered from a pt_regs, or when a
> pt_regs is recovered from the stack due to an interrupt.
>
> I can make this more readable by adding an explicit check for
> KUNWIND_SOURCE_REGS_PC in addition to state->regs != NULL.
Thanks for the explanation! Maybe just add an explanation to the commit
message and a short comment above the (!regs) test?
/* regs only available in topmost frame */
Regards,
Jens
--
Jens Remus
Linux on Z Development (D3303)
jremus at de.ibm.com / jremus at linux.ibm.com
IBM Deutschland Research & Development GmbH; Vorsitzender des Aufsichtsrats: Wolfgang Wendt; Geschäftsführung: David Faller; Sitz der Gesellschaft: Ehningen; Registergericht: Amtsgericht Stuttgart, HRB 243294
IBM Data Privacy Statement: https://www.ibm.com/privacy/
More information about the linux-arm-kernel
mailing list