lkml.org 
[lkml]   [2019]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    From
    SubjectRe: [PATCH v3 3/6] x86/static_call: Add out-of-line static call implementation
    Date
    > 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 )
    \
     
     \ /
      Last update: 2019-01-10 01:17    [W:4.256 / U:0.064 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site