Skip to content

Commit 87ccc82

Browse files
author
Peter Zijlstra
committed
x86/unwind/orc: Change REG_SP_INDIRECT
Currently REG_SP_INDIRECT is unused but means (%rsp + offset), change it to mean (%rsp) + offset. The reason is that we're going to swizzle stack in the middle of a C function with non-trivial stack footprint. This means that when the unwinder finds the ToS, it needs to dereference it (%rsp) and then add the offset to the next frame, resulting in: (%rsp) + offset This is somewhat unfortunate, since REG_BP_INDIRECT is used (by DRAP) and thus needs to retain the current (%rbp + offset). Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Reviewed-by: Miroslav Benes <mbenes@suse.cz> Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
1 parent 9077c01 commit 87ccc82

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

‎arch/x86/kernel/unwind_orc.c‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ bool unwind_next_frame(struct unwind_state *state)
471471
break;
472472

473473
case ORC_REG_SP_INDIRECT:
474-
sp = state->sp + orc->sp_offset;
474+
sp = state->sp;
475475
indirect = true;
476476
break;
477477

@@ -521,6 +521,9 @@ bool unwind_next_frame(struct unwind_state *state)
521521
if (indirect) {
522522
if (!deref_stack_reg(state, sp, &sp))
523523
goto err;
524+
525+
if (orc->sp_reg == ORC_REG_SP_INDIRECT)
526+
sp += orc->sp_offset;
524527
}
525528

526529
/* Find IP, SP and possibly regs: */

‎tools/objtool/orc_dump.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ static void print_reg(unsigned int reg, int offset)
5555
if (reg == ORC_REG_BP_INDIRECT)
5656
printf("(bp%+d)", offset);
5757
else if (reg == ORC_REG_SP_INDIRECT)
58-
printf("(sp%+d)", offset);
58+
printf("(sp)%+d", offset);
5959
else if (reg == ORC_REG_UNDEFINED)
6060
printf("(und)");
6161
else

0 commit comments

Comments
 (0)