mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Zijlstra <peterz@infradead.org>
To: x86@kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: Re: [RFC][PATCH] x86/alternatives: Optimize optimize_nops()
Date: Mon, 15 Mar 2021 17:23:03 +0100	[thread overview]
Message-ID: <YE+J56MHUcSOyTTb@hirez.programming.kicks-ass.net> (raw)
In-Reply-To: <YE+BFIil8wj+q8Qi@hirez.programming.kicks-ass.net>

On Mon, Mar 15, 2021 at 04:45:24PM +0100, Peter Zijlstra wrote:
> --- a/arch/x86/kernel/alternative.c
> +++ b/arch/x86/kernel/alternative.c
> @@ -345,19 +345,39 @@ recompute_jump(struct alt_instr *a, u8 *
>  static void __init_or_module noinline optimize_nops(struct alt_instr *a, u8 *instr)
>  {
>  	unsigned long flags;
> +	int nops = 0, i = 0;
> +	struct insn insn;
> +	u8 *nop = NULL;
> +
> +	do {
> +		kernel_insn_init(&insn, &instr[i], MAX_INSN_SIZE);
> +		insn_get_length(&insn);
> +

I suppose you'd like to see that replaced with something like this,
rite?


--- a/arch/x86/kernel/alternative.c
+++ b/arch/x86/kernel/alternative.c
@@ -350,8 +350,8 @@ static void __init_or_module noinline op
 	u8 *nop = NULL;
 
 	do {
-		kernel_insn_init(&insn, &instr[i], MAX_INSN_SIZE);
-		insn_get_length(&insn);
+		if (insn_decode(&insn, &instr[i], MAX_INSN_SIZE, INSN_MODE_KERN))
+			return;
 
 		if (insn.length == 1 && insn.opcode.bytes[0] == 0x90) {
 			if (!nop) {

  reply	other threads:[~2021-03-15 16:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-15 15:45 Peter Zijlstra
2021-03-15 16:23 ` Peter Zijlstra [this message]
2021-03-15 16:45 ` David Laight

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YE+J56MHUcSOyTTb@hirez.programming.kicks-ass.net \
    --to=peterz@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®