bcc: Add riscv syscall prefix detection in C++ API

Fixes issue where bpf.get_syscall_fnname() on riscv64 returns bare syscall
name instead of the prefixed _riscv_sys variant, causing kprobe
attachment failures.

Upstream-Status: Submitted [https://github.com/iovisor/bcc/pull/5490]

Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Harish Sadineni 2026-03-07 21:54:11 -08:00 committed by Khem Raj
parent eed01e5cc0
commit cdf9d099b9
No known key found for this signature in database
GPG Key ID: BB053355919D3314
2 changed files with 33 additions and 0 deletions

View File

@ -0,0 +1,32 @@
From da01655f0f335584867b3427005b95384499a020 Mon Sep 17 00:00:00 2001
From: Harish Sadineni <Harish.Sadineni@windriver.com>
Date: Sat, 7 Mar 2026 20:20:04 -0800
Subject: [PATCH 2/2] Add riscv syscall prefix detection in C++ API
Fixes issue where bpf.get_syscall_fnname() on riscv64 returns bare syscall
name instead of the prefixed _riscv_sys variant, causing kprobe
attachment failures.
Upstream-Status: Submitted [https://github.com/iovisor/bcc/pull/5490]
Signed-off-by: Harish Sadineni <Harish.Sadineni@windriver.com>
---
src/cc/api/BPF.cc | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/cc/api/BPF.cc b/src/cc/api/BPF.cc
index 11c6c542..e1df8208 100644
--- a/src/cc/api/BPF.cc
+++ b/src/cc/api/BPF.cc
@@ -782,6 +782,8 @@ std::string BPF::get_syscall_fnname(const std::string& name) {
syscall_prefix_.reset(new std::string("__x64_sys_"));
else if (ksym.resolve_name(nullptr, "__arm64_sys_bpf", &addr))
syscall_prefix_.reset(new std::string("__arm64_sys_"));
+ else if (ksym.resolve_name(nullptr, "__riscv_sys_bpf", &addr))
+ syscall_prefix_.reset(new std::string("__riscv_sys_"));
else
syscall_prefix_.reset(new std::string());
}
--
2.49.0

View File

@ -23,6 +23,7 @@ SRC_URI = "gitsm://github.com/iovisor/bcc;branch=master;protocol=https;tag=v${PV
file://0001-Vendor-just-enough-extra-headers-to-allow-libbpf-to-.patch \
file://0001-Fix-a-build-failure-with-clang21-5369.patch \
file://0001-Add-ARM64-syscall-prefix-detection-in-C-API.patch \
file://0002-Add-riscv-syscall-prefix-detection-in-C-API.patch \
file://run-ptest \
file://ptest_wrapper.sh \
file://fix_for_memleak.patch \