Re: [RFC][PATCH] objtool,ftrace: Implement UNWIND_HINT_RET_OFFSET

From: Peter Zijlstra
Date: Tue Mar 31 2020 - 17:07:34 EST


On Tue, Mar 31, 2020 at 10:40:47PM +0200, Peter Zijlstra wrote:
> On Tue, Mar 31, 2020 at 03:23:15PM -0500, Josh Poimboeuf wrote:

> > I now understand what you're trying to do with the RET_TAIL thing, and I
> > guess it's ok for the ftrace case. But I'd rather an UNWIND_HINT_IGNORE
> > before the tail cail, which would tell objtool to just silence the tail
> > call warning. It's simpler for the user to understand, it's simpler
> > logic in objtool, and I think an "ignore warnings for the next insn"
> > hint would be more generally applicable anyway.
>
> I like how this is specific on how far the stack can be off, as opposed
> so say 'ignore any warning on this instruction'.
>
> Because by saying this RET should be +8, we'll still get a warning when
> this is not the case (and in fact I should strengthen the patch to
> implement that).

Like this; I'm confused on what cfa.offset is vs stack_size though.

But this way we're strict and always warn when the unexpected happens.

--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -1423,8 +1423,7 @@ static bool has_modified_stack_frame(str
!(ret_offset && state->cfa.offset == initial_func_cfi.cfa.offset + ret_offset))
return true;

- if (state->stack_size != initial_func_cfi.cfa.offset &&
- !(ret_offset && state->stack_size == initial_func_cfi.cfa.offset + ret_offset))
+ if (state->stack_size != initial_func_cfi.cfa.offset + ret_offset)
return true;

for (i = 0; i < CFI_NUM_REGS; i++) {