[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190110162810.fgrmezgecvbekloe@treble>
Date: Thu, 10 Jan 2019 10:28:10 -0600
From: Josh Poimboeuf <jpoimboe@...hat.com>
To: Nadav Amit <namit@...are.com>
Cc: X86 ML <x86@...nel.org>, LKML <linux-kernel@...r.kernel.org>,
Ard Biesheuvel <ard.biesheuvel@...aro.org>,
Andy Lutomirski <luto@...nel.org>,
Steven Rostedt <rostedt@...dmis.org>,
Peter Zijlstra <peterz@...radead.org>,
Ingo Molnar <mingo@...nel.org>,
Thomas Gleixner <tglx@...utronix.de>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Jason Baron <jbaron@...mai.com>, Jiri Kosina <jkosina@...e.cz>,
David Laight <David.Laight@...LAB.COM>,
Borislav Petkov <bp@...en8.de>,
Julia Cartwright <julia@...com>, Jessica Yu <jeyu@...nel.org>,
"H. Peter Anvin" <hpa@...or.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Edward Cree <ecree@...arflare.com>,
Daniel Bristot de Oliveira <bristot@...hat.com>
Subject: Re: [PATCH v3 3/6] x86/static_call: Add out-of-line static call
implementation
On Thu, Jan 10, 2019 at 12:16:34AM +0000, Nadav Amit wrote:
> > On Jan 9, 2019, at 2:59 PM, Josh Poimboeuf <jpoimboe@...hat.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 )
I don't see much code duplication, because __jump_label_transform() uses
text_poke_bp(), whereas this uses text_poke().
It's true they both fall back to text_poke_early(), but I don't see any
opportunities for sharing code there, unless we decide to go back to
using breakpoints.
--
Josh
Powered by blists - more mailing lists