Re: [RFC PATCH v1 22/25] unwind_user/eh_frame/x86: Handle DRAP expressions
Jens Remus <[email protected]>
| Newsgroups | dev.linux.lists.sashiko-reviews,org.kernel.vger.linux-s390,org.kernel.vger.linux-trace-kernel |
|---|---|
| Organization | IBM Deutschland Research & Development GmbH |
| Message-ID | <[email protected]> |
On 8/18/2026 5:10 PM, [email protected] 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. >> diff --git a/kernel/unwind/eh_frame.c b/kernel/unwind/eh_frame.c >> @@ -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. > >> + 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) [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/