diff options
author | Peter Zijlstra <peterz@infradead.org> | 2022-03-08 16:30:19 +0100 |
---|---|---|
committer | Peter Zijlstra <peterz@infradead.org> | 2022-03-15 10:32:33 +0100 |
commit | bbf92368b0b1fe472d489e62d3340d7897e9c697 (patch) | |
tree | 553037eaf52a16ec704ff9108ae26b5e2a20cea8 /arch/x86/include/asm/text-patching.h | |
parent | c8c301abeae58ec756b8fcb2178a632bd3c9e284 (diff) | |
download | lwn-bbf92368b0b1fe472d489e62d3340d7897e9c697.tar.gz lwn-bbf92368b0b1fe472d489e62d3340d7897e9c697.zip |
x86/text-patching: Make text_gen_insn() play nice with ANNOTATE_NOENDBR
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: Josh Poimboeuf <jpoimboe@redhat.com>
Link: https://lore.kernel.org/r/20220308154317.638561109@infradead.org
Diffstat (limited to 'arch/x86/include/asm/text-patching.h')
-rw-r--r-- | arch/x86/include/asm/text-patching.h | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/arch/x86/include/asm/text-patching.h b/arch/x86/include/asm/text-patching.h index b7421780e4e9..1c4cfb1c6e4f 100644 --- a/arch/x86/include/asm/text-patching.h +++ b/arch/x86/include/asm/text-patching.h @@ -101,13 +101,21 @@ void *text_gen_insn(u8 opcode, const void *addr, const void *dest) static union text_poke_insn insn; /* per instance */ int size = text_opcode_size(opcode); + /* + * Hide the addresses to avoid the compiler folding in constants when + * referencing code, these can mess up annotations like + * ANNOTATE_NOENDBR. + */ + OPTIMIZER_HIDE_VAR(addr); + OPTIMIZER_HIDE_VAR(dest); + insn.opcode = opcode; if (size > 1) { insn.disp = (long)dest - (long)(addr + size); if (size == 2) { /* - * Ensure that for JMP9 the displacement + * Ensure that for JMP8 the displacement * actually fits the signed byte. */ BUG_ON((insn.disp >> 31) != (insn.disp >> 7)); |