Skip to content

Commit fd0d4f1

Browse files
olsajiriKernel Patches Daemon
authored andcommitted
libbpf: Add uprobe syscall feature detection
Adding uprobe syscall feature detection that will be used in following changes. Signed-off-by: Jiri Olsa <jolsa@kernel.org>
1 parent d185f2a commit fd0d4f1

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

tools/lib/bpf/features.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,25 @@ static int probe_kern_arg_ctx_tag(int token_fd)
506506
return probe_fd(prog_fd);
507507
}
508508

509+
#ifdef __x86_64__
510+
#ifndef __NR_uprobe
511+
#define __NR_uprobe 336
512+
#endif
513+
static int probe_uprobe_syscall(int token_fd)
514+
{
515+
/*
516+
* When not executed from executed kernel provided trampoline,
517+
* the uprobe syscall returns ENXIO error.
518+
*/
519+
return syscall(__NR_uprobe) == -1 && errno == ENXIO;
520+
}
521+
#else
522+
static int probe_uprobe_syscall(int token_fd)
523+
{
524+
return 0;
525+
}
526+
#endif
527+
509528
typedef int (*feature_probe_fn)(int /* token_fd */);
510529

511530
static struct kern_feature_cache feature_cache;
@@ -581,6 +600,9 @@ static struct kern_feature_desc {
581600
[FEAT_BTF_QMARK_DATASEC] = {
582601
"BTF DATASEC names starting from '?'", probe_kern_btf_qmark_datasec,
583602
},
603+
[FEAT_UPROBE_SYSCALL] = {
604+
"Kernel supports uprobe syscall", probe_uprobe_syscall,
605+
},
584606
};
585607

586608
bool feat_supported(struct kern_feature_cache *cache, enum kern_feature_id feat_id)

tools/lib/bpf/libbpf_internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,8 @@ enum kern_feature_id {
392392
FEAT_ARG_CTX_TAG,
393393
/* Kernel supports '?' at the front of datasec names */
394394
FEAT_BTF_QMARK_DATASEC,
395+
/* Kernel supports uprobe syscall */
396+
FEAT_UPROBE_SYSCALL,
395397
__FEAT_CNT,
396398
};
397399

0 commit comments

Comments
 (0)