All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Masami Hiramatsu (Google)" <mhiramat@kernel.org>
To: Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, Masami Hiramatsu <mhiramat@kernel.org>,
	Oleg Nesterov <oleg@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Lukas Zobernig <lukas.zobernig@gmail.com>
Cc: "H . Peter Anvin" <hpa@zytor.com>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
	Pablo Fraile Alonso <pablo@pablofraile.net>,
	Edgecombe Rick P <rick.p.edgecombe@intel.com>
Subject: [PATCH 2/5] x86/insn: Fix gen-insn-attr-x86.awk to emit INAT_REX2_VARIANT
Date: Mon, 23 Nov 2026 11:47:33 +0900	[thread overview]
Message-ID: <179540205326.233843.2135456283107403299.stgit@devnote2> (raw)
In-Reply-To: <179540203033.233843.12951034848925983867.stgit@devnote2>

From: Masami Hiramatsu <mhiramat@kernel.org>

In gen-insn-attr-x86.awk, the check for the (REX2) superscript tag was
placed after 'if (length(flags) == 0) continue'. For opcode 0xa1
('MOV rAX,Ov (!REX2) | JMPABS O (REX2),(o64)'), the JMPABS alternative
has no flags set by convert_operands(), so the loop skipped before
emitting INAT_REX2_VARIANT and no entry in inat-tables.c ever received
INAT_REX2_VARIANT.

Move the rex2_expr check before the empty-flags skip so INAT_REX2_VARIANT
is properly added to flags and emitted in inat-tables.c.

Fixes: eada38d575a2 ("x86/insn: Add support for REX2 prefix to the instruction decoder logic")
Cc: stable@vger.kernel.org
Signed-off-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
---
 arch/x86/tools/gen-insn-attr-x86.awk       |    6 ++++--
 tools/arch/x86/tools/gen-insn-attr-x86.awk |    6 ++++--
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/arch/x86/tools/gen-insn-attr-x86.awk b/arch/x86/tools/gen-insn-attr-x86.awk
index 7ea1b75e59b7..186506a3db22 100644
--- a/arch/x86/tools/gen-insn-attr-x86.awk
+++ b/arch/x86/tools/gen-insn-attr-x86.awk
@@ -354,6 +354,10 @@ function convert_operands(count,opnd,       i,j,imm,mod)
 		if (match(ext, no_rex2_expr))
 			flags = add_flags(flags, "INAT_NO_REX2")
 
+		# check REX2 variant
+		if (match(ext, rex2_expr))
+			flags = add_flags(flags, "INAT_REX2_VARIANT")
+
 		# check REX prefix
 		if (match(opcode, rex_expr))
 			flags = add_flags(flags, "INAT_MAKE_PREFIX(INAT_PFX_REX)")
@@ -395,8 +399,6 @@ function convert_operands(count,opnd,       i,j,imm,mod)
 			lptable3[idx] = add_flags(lptable3[idx],flags)
 			variant = "INAT_VARIANT"
 		}
-		if (match(ext, rex2_expr))
-			table[idx] = add_flags(table[idx], "INAT_REX2_VARIANT")
 		if (!match(ext, lprefix_expr)){
 			table[idx] = add_flags(table[idx],flags)
 		}
diff --git a/tools/arch/x86/tools/gen-insn-attr-x86.awk b/tools/arch/x86/tools/gen-insn-attr-x86.awk
index 7ea1b75e59b7..186506a3db22 100644
--- a/tools/arch/x86/tools/gen-insn-attr-x86.awk
+++ b/tools/arch/x86/tools/gen-insn-attr-x86.awk
@@ -354,6 +354,10 @@ function convert_operands(count,opnd,       i,j,imm,mod)
 		if (match(ext, no_rex2_expr))
 			flags = add_flags(flags, "INAT_NO_REX2")
 
+		# check REX2 variant
+		if (match(ext, rex2_expr))
+			flags = add_flags(flags, "INAT_REX2_VARIANT")
+
 		# check REX prefix
 		if (match(opcode, rex_expr))
 			flags = add_flags(flags, "INAT_MAKE_PREFIX(INAT_PFX_REX)")
@@ -395,8 +399,6 @@ function convert_operands(count,opnd,       i,j,imm,mod)
 			lptable3[idx] = add_flags(lptable3[idx],flags)
 			variant = "INAT_VARIANT"
 		}
-		if (match(ext, rex2_expr))
-			table[idx] = add_flags(table[idx], "INAT_REX2_VARIANT")
 		if (!match(ext, lprefix_expr)){
 			table[idx] = add_flags(table[idx],flags)
 		}


  parent reply	other threads:[~2026-11-23  2:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-23  2:47 [PATCH 0/5] x86/insn, uprobes: Fix opcode map handling for multi-byte, REX2, and VEX/EVEX/XOP instructions None
2026-11-23  2:47 ` [PATCH 1/5] x86/insn-eval: Do not mutate struct insn in insn_is_nop() Masami Hiramatsu (Google)
2026-11-23  2:47 ` Masami Hiramatsu (Google) [this message]
2026-11-23  2:47 ` [PATCH 3/5] x86/insn: Reject invalid REX2 encodings in insn_get_opcode() Masami Hiramatsu (Google)
2026-11-23  2:47 ` [PATCH 4/5] x86/insn: Add insn_opcode_map() helper and fix insn_masking_exception() Masami Hiramatsu (Google)
2026-11-23  2:48 ` [PATCH 5/5] uprobes/x86: Fix opcode validation and analysis for multi-byte, REX2, and VEX/EVEX/XOP instructions Masami Hiramatsu (Google)
2026-11-23  7:21 ` [PATCH 0/5] x86/insn, uprobes: Fix opcode map handling " Masami Hiramatsu (Google)

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=179540205326.233843.2135456283107403299.stgit@devnote2 \
    --to=mhiramat@kernel.org \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=lukas.zobernig@gmail.com \
    --cc=mingo@redhat.com \
    --cc=oleg@redhat.com \
    --cc=pablo@pablofraile.net \
    --cc=peterz@infradead.org \
    --cc=rick.p.edgecombe@intel.com \
    --cc=tglx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.