]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
libbpf: Add uprobe syscall feature detection
authorJiri Olsa <jolsa@kernel.org>
Tue, 24 Feb 2026 10:39:11 +0000 (11:39 +0100)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 3 Mar 2026 16:39:21 +0000 (08:39 -0800)
Adding uprobe syscall feature detection that will be used
in following changes.

Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20260224103915.1369690-2-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/lib/bpf/features.c
tools/lib/bpf/libbpf_internal.h

index 2fa434f09cced7f3b09201eabb8901cdaf09ff08..adcad221c601e8c60a5d8377bde3cb479e57caf9 100644 (file)
@@ -568,6 +568,27 @@ static int probe_ldimm64_full_range_off(int token_fd)
        return 1;
 }
 
+#ifdef __x86_64__
+
+#ifndef __NR_uprobe
+#define __NR_uprobe 336
+#endif
+
+static int probe_uprobe_syscall(int token_fd)
+{
+       /*
+        * If kernel supports uprobe() syscall, it will return -ENXIO when called
+        * from the outside of a kernel-generated uprobe trampoline.
+        */
+       return syscall(__NR_uprobe) < 0 && errno == ENXIO;
+}
+#else
+static int probe_uprobe_syscall(int token_fd)
+{
+       return 0;
+}
+#endif
+
 typedef int (*feature_probe_fn)(int /* token_fd */);
 
 static struct kern_feature_cache feature_cache;
@@ -646,6 +667,9 @@ static struct kern_feature_desc {
        [FEAT_LDIMM64_FULL_RANGE_OFF] = {
                "full range LDIMM64 support", probe_ldimm64_full_range_off,
        },
+       [FEAT_UPROBE_SYSCALL] = {
+               "kernel supports uprobe syscall", probe_uprobe_syscall,
+       },
 };
 
 bool feat_supported(struct kern_feature_cache *cache, enum kern_feature_id feat_id)
index 974147e8a8aae97d5d723e5ffc39fbd2141fa94f..4bcb6ca69bb1e7e621ca51cb6bae5b242556c198 100644 (file)
@@ -394,6 +394,8 @@ enum kern_feature_id {
        FEAT_BTF_QMARK_DATASEC,
        /* Kernel supports LDIMM64 imm offsets past 512 MiB. */
        FEAT_LDIMM64_FULL_RANGE_OFF,
+       /* Kernel supports uprobe syscall */
+       FEAT_UPROBE_SYSCALL,
        __FEAT_CNT,
 };