[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190611155248.GA3436@hirez.programming.kicks-ass.net>
Date: Tue, 11 Jun 2019 17:52:48 +0200
From: Peter Zijlstra <peterz@...radead.org>
To: Steven Rostedt <rostedt@...dmis.org>
Cc: x86@...nel.org, linux-kernel@...r.kernel.org,
Ard Biesheuvel <ard.biesheuvel@...aro.org>,
Andy Lutomirski <luto@...nel.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>, Nadav Amit <namit@...are.com>,
Rasmus Villemoes <linux@...musvillemoes.dk>,
Edward Cree <ecree@...arflare.com>,
Daniel Bristot de Oliveira <bristot@...hat.com>
Subject: Re: [PATCH 08/15] x86/alternatives: Teach text_poke_bp() to emulate
instructions
On Tue, Jun 11, 2019 at 11:14:10AM -0400, Steven Rostedt wrote:
> On Wed, 05 Jun 2019 15:08:01 +0200
> Peter Zijlstra <peterz@...radead.org> wrote:
>
> > -void text_poke_bp(void *addr, const void *opcode, size_t len, void *handler)
> > +void text_poke_bp(void *addr, const void *opcode, size_t len, const void *emulate)
> > {
> > unsigned char int3 = 0xcc;
> >
> > - bp_int3_handler = handler;
> > + bp_int3_opcode = emulate ?: opcode;
> > bp_int3_addr = (u8 *)addr + sizeof(int3);
> > bp_patching_in_progress = true;
> >
> > lockdep_assert_held(&text_mutex);
> >
> > /*
> > + * poke_int3_handler() relies on @opcode being a 5 byte instruction;
> > + * notably a JMP, CALL or NOP5_ATOMIC.
> > + */
> > + BUG_ON(len != 5);
>
> If we have a bug on here, why bother with passing in len at all? Just
> force it to be 5.
Masami said the same.
> We could make it a WARN_ON() and return without doing anything.
>
> This also prevents us from ever changing two byte jmps.
It doesn't; that is, we'd need to add emulation for the 3 byte jump, but
that'd be pretty trivial.
Powered by blists - more mailing lists