[PATCH v3 14/18] tools/rv: Define CONFIG_X86_64 statically for BPF monitors

From: Gabriele Monaco

Date: Thu Nov 26 2026 - 08:01:49 EST


BPF atomic macros require CONFIG_X86_64 to determine barrier
instructions. Reading this from the system Kconfig can fail if the
configuration is missing or in an unexpected location, causing the
loading phase to fail.

Since the rv tool is compiled for the target architecture, the
architecture is known at compile-time. Define the CONFIG_X86_64 value
statically via the libbpf open options to bypass Kconfig dependency and
ensure reliable loading.

Signed-off-by: Gabriele Monaco <gmonaco@xxxxxxxxxx>
---
tools/verification/rv/src/bpf_monitor.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/tools/verification/rv/src/bpf_monitor.c b/tools/verification/rv/src/bpf_monitor.c
index 5c9c4d9b4835..1ff76a4ffb68 100644
--- a/tools/verification/rv/src/bpf_monitor.c
+++ b/tools/verification/rv/src/bpf_monitor.c
@@ -460,6 +460,12 @@ static int get_nr_cpu_ids(void)
return strtol(sep ? sep + 1 : buf, NULL, 10) + 1;
}

+#ifdef __x86_64__
+#define X86_64 'y'
+#else
+#define X86_64 'n'
+#endif
+
/*
* open_bpf_monitor - open and load a BPF monitor object from a file path
*
@@ -476,8 +482,8 @@ static struct bpf_object *open_bpf_monitor(const char *path, struct bpf_monitor_
return NULL;
}
/* Define statically what is known, Kconfig may not be available. */
- snprintf(kconfig, sizeof(kconfig), "CONFIG_NR_CPUS=%d\n",
- nproc);
+ snprintf(kconfig, sizeof(kconfig), "CONFIG_NR_CPUS=%d\nCONFIG_X86_64=%c\n",
+ nproc, X86_64);

LIBBPF_OPTS(bpf_object_open_opts, opts,
.object_name = ctx->monitor_name,
--
2.56.1