Re: [PATCH v14 13/19] unwind_user: Enable archs that pass RA in a register

Jens Remus <[email protected]> Tue, 19 May 2026 14:24:34 +0200
Newsgroups dev.linux.lists.sashiko,org.kernel.vger.bpf
Organization IBM Deutschland Research & Development GmbH
Message-ID <[email protected]>
On 5/18/2026 6:31 PM, Steven Rostedt wrote:
> On Mon, 18 May 2026 18:16:52 +0200
> Jens Remus <[email protected]> wrote:
> 
>>>>> +#ifndef unwind_user_get_ra_reg
>>>>> +static inline int unwind_user_get_ra_reg(unsigned long *val)
>>>>> +{
>>>>> +	WARN_ON_ONCE(1);  
>>>
>>> Replace with the following to resolve below issue:
>>>
>>> 	dbg_once("unwind_user_get_ra_reg() not implemented\n");  
>>
>> Omit or replace by the following?
>>
>> 	pr_debug_once("%s (%d): unwind_user_get_ra_reg() not implemented\n",
>> 		      current->comm, current->pid);
>>
>> This did not work with dbg_once() defined in kernel/unwind/user.c as
>> follows, as linux/unwind_deferred.h includes linux/unwind_user.h and
>> therefore gets included into other modules that do not define dbg_once()
>> (e.g. via linux/irq-entry-common.h including linux/unwind_deferred.h).
>>
>> Steven, Should I omit the dbg_once() or could I replace by the above
>> unguarded pr_debug_once()?
> 
> Question, should the above ever get hit? That is, should all architectures
> that support sframes have unwind_user_get_ra_reg() defined?

No.  Architectures that do not pass the RA in a register, such as x86-64
that passes the RA on the stack, do not implement unwind_user_get_ra_reg().

> How can this be triggered? Does it require an architecture to implement
> only partial sframe to trigger?

On x86-64 it can be triggered from user space using forged .sframe that
incorrectly specifies no fixed RA offset and thus causes the common
unwind user (sframe) logic to recover RA from the RA register using 
the dummy unwind_user_get_ra_reg().

> If the trigger is due to an architecture not supporting sframe correctly,
> then a WARN_ON() is appropriate.
> 
> But if this is not implemented by the architecture for normal reasons, why
> bother printing anything?

For unwind_user_get_ra_reg() that might be appropriate.  Although the
dynamic debug message could help developers to implement sframe for
another architecture.

Let me outline this for unwind_user_get_reg() and arm64:  This is used
to recover CFA/RA/FP from arbitrary registers in the topmost frame.
In SFrame such rules require SFrame V3 flexible FDE.  GNU assembler
does not support/generate flexible FDE for arm64.  Therefore arm64
would currently not need to implement unwind_user_get_reg().  But if a
toolchain would be enabled to support/generate flexible FDE on arm64 in
the future, the dynamic debug message might be helpful to quickly
determine why some of the stacktraces are incomplete and which piece
is missing to resolve.

Regards,
Jens
-- 
Jens Remus
Linux on Z Development (D3303)
[email protected] / [email protected]

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/