Messages in this thread | | | From | Nadav Amit <> | Subject | Re: [PATCH v3 3/6] x86/static_call: Add out-of-line static call implementation | Date | Thu, 10 Jan 2019 00:16:34 +0000 |
| |
> On Jan 9, 2019, at 2:59 PM, Josh Poimboeuf <jpoimboe@redhat.com> wrote: >
<snip>
> + > +void __ref arch_static_call_transform(void *site, void *tramp, void *func) > +{ > + s32 dest_relative; > + unsigned char opcode; > + void *(*poker)(void *, const void *, size_t); > + void *insn = tramp; > + > + mutex_lock(&text_mutex); > + > + /* > + * For x86-64, a 32-bit cross-modifying write to a call destination is > + * safe as long as it's within a cache line. > + */ > + opcode = *(unsigned char *)insn; > + if (opcode != 0xe8 && opcode != 0xe9) { > + WARN_ONCE(1, "unexpected static call insn opcode 0x%x at %pS", > + opcode, insn); > + goto done; > + } > + > + dest_relative = (long)(func) - (long)(insn + CALL_INSN_SIZE); > + > + poker = early_boot_irqs_disabled ? text_poke_early : text_poke; > + poker(insn + 1, &dest_relative, sizeof(dest_relative)); > + > +done: > + mutex_unlock(&text_mutex); > +} > +EXPORT_SYMBOL_GPL(arch_static_call_transform);
Err… I was rewriting __jump_label_transform(), so if this code duplication can be avoided, this would be great.
(See https://lkml.org/lkml/2018/11/14/72 ) | |