From: "Alexei Starovoitov" <alexei.starovoitov@gmail.com>
To: "Alan Maguire" <almagui@kernel.org>
Cc: <daniel@iogearbox.net>, <andrii@kernel.org>, <eddyz87@gmail.com>,
<memxor@gmail.com>, <martin.lau@linux.dev>, <song@kernel.org>,
<yonghong.song@linux.dev>, <jolsa@kernel.org>,
<emil@etsalapatis.com>, <ihor.solodrai@linux.dev>,
<nathan@kernel.org>, <ndesaulniers@google.com>,
<morbo@google.com>, <justinstitt@google.com>,
<a.s.protopopov@gmail.com>, <bpf@vger.kernel.org>
Subject: Re: [PATCH bpf-next] resolve_btfids: Match the arm64 NOP opcode for LLVM 24 in text_mc
Date: Thu, 19 Nov 2026 01:44:07 +0000 [thread overview]
Message-ID: <DMYT224YKW0Z.2NAT6FTR68NQE@gmail.com> (raw)
In-Reply-To: <20261118194030.4103149-1-almagui@kernel.org>
On Wed, Nov 18, 2026 at 11:40 AM Alan Maguire <almagui@kernel.org> wrote:
> if (it == by_name.end()) {
> + if (pattern->optional)
> + continue;
> error() << "no opcode " << pattern->opcode << "\n";
> ok = false;
Thanks for the quick fix. Applied.
But should we go further and skip unknown names? Like:
diff --git a/tools/bpf/resolve_btfids/text_mc.cpp b/tools/bpf/resolve_btfids/text_mc.cpp
index 57f45a4..bfe9824 100644
--- a/tools/bpf/resolve_btfids/text_mc.cpp
+++ b/tools/bpf/resolve_btfids/text_mc.cpp
@@ -165,10 +165,9 @@ bool read_regs()
return ok;
}
-bool read_opcodes()
+void read_opcodes()
{
std::unordered_map<std::string_view, Opcode *> by_name;
- bool ok = true;
d.opcodes.resize(d.MII->getNumOpcodes());
by_name.reserve(d.opcodes.size());
@@ -194,10 +193,9 @@ bool read_opcodes()
for (const mc_pattern *pattern = mc_arch.patterns; pattern->opcode; pattern++) {
auto it = by_name.find(pattern->opcode);
- if (it == by_name.end()) {
- error() << "no opcode " << pattern->opcode << "\n";
- ok = false;
- } else if (pattern->kind == TEXT_RETURN) {
+ if (it == by_name.end())
+ continue;
+ if (pattern->kind == TEXT_RETURN) {
it->second->is_return = true;
} else if (pattern->kind != TEXT_OTHER) {
it->second->patterns.push_back(pattern);
@@ -208,7 +206,6 @@ bool read_opcodes()
it->second->nop = pattern;
}
}
- return ok;
}
const Reg ®_of(const MCInst &inst, const Opcode &o, u8 nr, bool def)
@@ -422,12 +419,16 @@ bool run_tests()
extern "C" const struct text_arch *text_arch_init(unsigned int machine)
{
static text_arch arch = mc_arch.arch;
+ bool ok;
if (machine != mc_arch.machine) {
errs() << "text_mc: built for " << mc_arch.triple << ", not for ELF machine " << machine << "\n";
return nullptr;
}
- if (!create() || !read_regs() || !read_opcodes() || !run_tests()) {
+ ok = create() && read_regs();
+ if (ok)
+ read_opcodes();
+ if (!ok || !run_tests()) {
error() << "the table of the arch does not fit it. Set LLVM_CONFIG to the "
"llvm-config of another LLVM, or switch CONFIG_BPF_FMODRET_SCAN off\n";
return nullptr;
diff --git a/tools/bpf/resolve_btfids/text_mc.h b/tools/bpf/resolve_btfids/text_mc.h
index f2add1f..914a00a 100644
--- a/tools/bpf/resolve_btfids/text_mc.h
+++ b/tools/bpf/resolve_btfids/text_mc.h
@@ -13,8 +13,9 @@
* It does not say what an instruction computes: the selection patterns are not
* a part of it. And the headers with the enums of a target are not installed.
* So opcodes and registers are given by name, as MCInstrInfo::getName() and
- * MCRegisterInfo::getName() return them, and looked up once. A name which this
- * LLVM does not have is an error.
+ * MCRegisterInfo::getName() return them, and looked up once. A register which
+ * this LLVM does not have is an error. A pattern for an opcode which it does
+ * not have is left out: each pattern has a test, which fails if it is missed.
*/
/* A condition on the operands of an MCInst, like an MCInstPredicate of TableGen */
diff --git a/tools/bpf/resolve_btfids/text_mc_arm64.c b/tools/bpf/resolve_btfids/text_mc_arm64.c
index 5d2fa8a..31ca6e0 100644
--- a/tools/bpf/resolve_btfids/text_mc_arm64.c
+++ b/tools/bpf/resolve_btfids/text_mc_arm64.c
@@ -25,6 +25,7 @@ static const struct mc_pattern arm64_patterns[] = {
/* HINT: nop, bti, yield, wfe ... */
{ "HINT", TEXT_OTHER }, { "AUTIASP", TEXT_OTHER }, { "PRFMui", TEXT_OTHER },
{ "HINT", TEXT_OTHER, .nop = true, .predicates = { IMM(0, 0) } }, /* nop */
+ { "NOP", TEXT_OTHER, .nop = true }, /* nop since llvm-project PR 170968 */
{ "DMB", TEXT_OTHER }, { "MRS", TEXT_OTHER }, { "MSR", TEXT_OTHER },
{ "STLRB", TEXT_OTHER }, { "STLRW", TEXT_OTHER },
WX("LDXR", "", TEXT_OTHER), WX("STXR", "", TEXT_OTHER), WX("STLXR", "", TEXT_OTHER),
next prev parent reply other threads:[~2026-11-19 1:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 19:40 [PATCH bpf-next] resolve_btfids: Match the arm64 NOP opcode for LLVM 24 in text_mc Alan Maguire
2026-11-18 20:12 ` bot+bpf-ci
2026-11-19 1:44 ` Alexei Starovoitov [this message]
2026-11-19 1:50 ` patchwork-bot+netdevbpf
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=DMYT224YKW0Z.2NAT6FTR68NQE@gmail.com \
--to=alexei.starovoitov@gmail.com \
--cc=a.s.protopopov@gmail.com \
--cc=almagui@kernel.org \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=justinstitt@google.com \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=morbo@google.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/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