x86/text-patching: Make text_gen_insn() play nice with ANNOTATE_NOENDBR
Upstream commit: bbf92368b0b1fe472d489e62d3340d7897e9c697 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 Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
c13d426040
commit
e752912ce1
@ -101,13 +101,21 @@ void *text_gen_insn(u8 opcode, const void *addr, const void *dest)
|
|||||||
static union text_poke_insn insn; /* per instance */
|
static union text_poke_insn insn; /* per instance */
|
||||||
int size = text_opcode_size(opcode);
|
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;
|
insn.opcode = opcode;
|
||||||
|
|
||||||
if (size > 1) {
|
if (size > 1) {
|
||||||
insn.disp = (long)dest - (long)(addr + size);
|
insn.disp = (long)dest - (long)(addr + size);
|
||||||
if (size == 2) {
|
if (size == 2) {
|
||||||
/*
|
/*
|
||||||
* Ensure that for JMP9 the displacement
|
* Ensure that for JMP8 the displacement
|
||||||
* actually fits the signed byte.
|
* actually fits the signed byte.
|
||||||
*/
|
*/
|
||||||
BUG_ON((insn.disp >> 31) != (insn.disp >> 7));
|
BUG_ON((insn.disp >> 31) != (insn.disp >> 7));
|
||||||
|
Loading…
Reference in New Issue
Block a user