Re: [RFC PATCH v1 22/25] unwind_user/eh_frame/x86: Handle DRAP expressions

From
Jens Remus <hidden>
Date
2026-08-21 19:42:00
Also in
linux-s390, sashiko-reviews
Reply to
sashiko-bot@kernel.org, 2026-08-18
On 8/18/2026 5:10 PM, sashiko-bot@kernel.org wrote:
GCC uses DRAP (Dynamic Realign Argument Pointer) when the stack needs
to be dynamically realigned. This patch adds x86-specific handling for
the CFA and FP DWARF expressions patterns used to describe how to unwind
through such frames.
quoted
diff --git a/kernel/unwind/eh_frame.c b/kernel/unwind/eh_frame.c
quoted
@@ -1206,6 +1231,16 @@ static __always_inline int __find_frame_row(struct eh_frame_section *sec,
 		frame->fp.regnum = ctx.state.reg_regnum[FP_IDX];
 		frame->fp.offset = 0;
 		break;
+	case REG_REGISTER_OFFSET_DEREF:
+		if (ctx.state.reg_regnum[FP_IDX] > UINT_MAX)
+			return -EINVAL;
+		if (ctx.state.reg_offset[FP_IDX] < INT_MIN ||
+		    ctx.state.reg_offset[FP_IDX] > INT_MAX)
+			return -EOPNOTSUPP;
+		frame->fp.rule = UNWIND_USER_RULE_REG_OFFSET_DEREF;
[Severity: High]
Will this rule cause unwinding to fail for inner stack frames?

When an inner stack frame requires DRAP evaluation, the unwinder evaluates
UNWIND_USER_RULE_REG_OFFSET_DEREF in kernel/unwind/user.c:unwind_user_next_common()
like this:

	if (!state->topmost || unwind_user_get_reg(&fp, frame->fp.regnum))
		return -EINVAL;

Since inner frames are not topmost, this check will return -EINVAL and
abort the unwinding process. Could this truncate backtraces that pass
through dynamically realigned stack frames?
True, iif inner stack frame requires DRAP evaluation.  This is a
limitation of the common unwind user framework to only unwind SP, FP,
and RA instead of all registers.

But IIUC the requirement to evaluate DRAP can only occur for the topmost
frame, as an inner function would already be past DRAP once it calls
another function.  So this should not occur.
quoted
+		frame->fp.regnum = ctx.state.reg_regnum[FP_IDX];
+		frame->fp.offset = ctx.state.reg_offset[FP_IDX];
+		break;
Regards,
Jens
-- 
Jens Remus
Linux on Z Development (D3303)
jremus@de.ibm.com / jremus@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/
Thread (67 messages) 67 messages, 3 authors, last reply 2026-08-21
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help