From: Peter Zijlstra Date: Tue, 8 Mar 2022 15:30:19 +0000 (+0100) Subject: x86/text-patching: Make text_gen_insn() play nice with ANNOTATE_NOENDBR X-Git-Tag: v6.1-rc5~1704^2~47 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bbf92368b0b1fe472d489e62d3340d7897e9c697;p=platform%2Fkernel%2Flinux-starfive.git x86/text-patching: Make text_gen_insn() play nice with ANNOTATE_NOENDBR Signed-off-by: Peter Zijlstra (Intel) Acked-by: Josh Poimboeuf Link: https://lore.kernel.org/r/20220308154317.638561109@infradead.org --- diff --git a/arch/x86/include/asm/text-patching.h b/arch/x86/include/asm/text-patching.h index b742178..1c4cfb1 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));