Skip to content

Commit ab3852a

Browse files
author
Peter Zijlstra
committed
objtool: Allow no-op CFI ops in alternatives
Randy reported a false-positive: arch/x86/hyperv/hv_apic.o: warning: objtool: hv_apic_write()+0x25: alternative modifies stack What happens is that: alternative_io("movl %0, %P1", "xchgl %0, %P1", X86_BUG_11AP, 13d: 89 9d 00 d0 7f ff mov %ebx,-0x803000(%rbp) decodes to an instruction with CFI-ops because it modifies RBP. However, due to this being a !frame-pointer build, that should not in fact change the CFI state. So instead of dis-allowing any CFI-op, verify the op would've actually changed the CFI state. Fixes: 7117f16 ("objtool: Fix ORC vs alternatives") Reported-by: Randy Dunlap <[email protected]> Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Acked-by: Randy Dunlap <[email protected]> Tested-by: Randy Dunlap <[email protected]>
1 parent cc1ac9c commit ab3852a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tools/objtool/check.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2060,17 +2060,18 @@ static int handle_insn_ops(struct instruction *insn, struct insn_state *state)
20602060
struct stack_op *op;
20612061

20622062
list_for_each_entry(op, &insn->stack_ops, list) {
2063+
struct cfi_state old_cfi = state->cfi;
20632064
int res;
20642065

2065-
if (insn->alt_group) {
2066-
WARN_FUNC("alternative modifies stack", insn->sec, insn->offset);
2067-
return -1;
2068-
}
2069-
20702066
res = update_cfi_state(insn, &state->cfi, op);
20712067
if (res)
20722068
return res;
20732069

2070+
if (insn->alt_group && memcmp(&state->cfi, &old_cfi, sizeof(struct cfi_state))) {
2071+
WARN_FUNC("alternative modifies stack", insn->sec, insn->offset);
2072+
return -1;
2073+
}
2074+
20742075
if (op->dest.type == OP_DEST_PUSHF) {
20752076
if (!state->uaccess_stack) {
20762077
state->uaccess_stack = 1;

0 commit comments

Comments
 (0)