diff mbox series

perf, riscv: Wire up perf trace support for RISC-V

Message ID 20241024190353.46737-1-bjorn@kernel.org (mailing list archive)
State New
Headers show
Series perf, riscv: Wire up perf trace support for RISC-V | expand

Checks

Context Check Description
conchuod/vmtest-for-next-PR fail PR summary
conchuod/patch-1-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh took 110.89s
conchuod/patch-1-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh took 965.94s
conchuod/patch-1-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh took 1134.78s
conchuod/patch-1-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh took 16.70s
conchuod/patch-1-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh took 18.27s
conchuod/patch-1-test-6 fail .github/scripts/patches/tests/checkpatch.sh took 1.16s
conchuod/patch-1-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh took 36.28s
conchuod/patch-1-test-8 success .github/scripts/patches/tests/header_inline.sh took 0.00s
conchuod/patch-1-test-9 success .github/scripts/patches/tests/kdoc.sh took 0.46s
conchuod/patch-1-test-10 success .github/scripts/patches/tests/module_param.sh took 0.01s
conchuod/patch-1-test-11 success .github/scripts/patches/tests/verify_fixes.sh took 0.00s
conchuod/patch-1-test-12 success .github/scripts/patches/tests/verify_signedoff.sh took 0.02s

Commit Message

Björn Töpel Oct. 24, 2024, 7:03 p.m. UTC
From: Björn Töpel <bjorn@rivosinc.com>

RISC-V does not currently support perf trace, since the system call
table is not generated.

Perform the copy/paste exercise, wiring up RISC-V system call table
generation.

Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
---
 tools/perf/Makefile.config                    |  6 ++-
 tools/perf/arch/riscv/Makefile                | 22 +++++++++
 .../arch/riscv/entry/syscalls/mksyscalltbl    | 47 +++++++++++++++++++
 tools/perf/util/syscalltbl.c                  |  4 ++
 4 files changed, 78 insertions(+), 1 deletion(-)
 create mode 100755 tools/perf/arch/riscv/entry/syscalls/mksyscalltbl


base-commit: c2ee9f594da826bea183ed14f2cc029c719bf4da

Comments

Namhyung Kim Oct. 30, 2024, 12:37 a.m. UTC | #1
Hello,

On Thu, Oct 24, 2024 at 12:03:51PM -0700, Björn Töpel wrote:
> From: Björn Töpel <bjorn@rivosinc.com>
> 
> RISC-V does not currently support perf trace, since the system call
> table is not generated.
> 
> Perform the copy/paste exercise, wiring up RISC-V system call table
> generation.

Can anybody with RISC-V please test this?

Thanks,
Namhyung

> 
> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
> ---
>  tools/perf/Makefile.config                    |  6 ++-
>  tools/perf/arch/riscv/Makefile                | 22 +++++++++
>  .../arch/riscv/entry/syscalls/mksyscalltbl    | 47 +++++++++++++++++++
>  tools/perf/util/syscalltbl.c                  |  4 ++
>  4 files changed, 78 insertions(+), 1 deletion(-)
>  create mode 100755 tools/perf/arch/riscv/entry/syscalls/mksyscalltbl
> 
> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
> index 4ddb27a48eed..1d388e71e0cc 100644
> --- a/tools/perf/Makefile.config
> +++ b/tools/perf/Makefile.config
> @@ -31,7 +31,7 @@ $(call detected_var,SRCARCH)
>  ifneq ($(NO_SYSCALL_TABLE),1)
>    NO_SYSCALL_TABLE := 1
>  
> -  ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 powerpc arm64 s390 mips loongarch))
> +  ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 powerpc arm64 s390 mips loongarch riscv))
>      NO_SYSCALL_TABLE := 0
>    endif
>  
> @@ -83,6 +83,10 @@ ifeq ($(ARCH),mips)
>    LIBUNWIND_LIBS = -lunwind -lunwind-mips
>  endif
>  
> +ifeq ($(ARCH),riscv)
> +  CFLAGS += -I$(OUTPUT)arch/riscv/include/generated
> +endif
> +
>  # So far there's only x86 and arm libdw unwind support merged in perf.
>  # Disable it on all other architectures in case libdw unwind
>  # support is detected in system. Add supported architectures
> diff --git a/tools/perf/arch/riscv/Makefile b/tools/perf/arch/riscv/Makefile
> index 90c3c476a242..481da4518695 100644
> --- a/tools/perf/arch/riscv/Makefile
> +++ b/tools/perf/arch/riscv/Makefile
> @@ -4,3 +4,25 @@ endif
>  PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
>  PERF_HAVE_JITDUMP := 1
>  HAVE_KVM_STAT_SUPPORT := 1
> +
> +#
> +# Syscall table generation for perf
> +#
> +
> +out    := $(OUTPUT)arch/riscv/include/generated/asm
> +header := $(out)/syscalls.c
> +incpath := $(srctree)/tools
> +sysdef := $(srctree)/tools/arch/riscv/include/uapi/asm/unistd.h
> +sysprf := $(srctree)/tools/perf/arch/riscv/entry/syscalls/
> +systbl := $(sysprf)/mksyscalltbl
> +
> +# Create output directory if not already present
> +$(shell [ -d '$(out)' ] || mkdir -p '$(out)')
> +
> +$(header): $(sysdef) $(systbl)
> +	$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(incpath) $(sysdef) > $@
> +
> +clean::
> +	$(call QUIET_CLEAN, riscv) $(RM) $(header)
> +
> +archheaders: $(header)
> diff --git a/tools/perf/arch/riscv/entry/syscalls/mksyscalltbl b/tools/perf/arch/riscv/entry/syscalls/mksyscalltbl
> new file mode 100755
> index 000000000000..c59f5e852b97
> --- /dev/null
> +++ b/tools/perf/arch/riscv/entry/syscalls/mksyscalltbl
> @@ -0,0 +1,47 @@
> +#!/bin/sh
> +# SPDX-License-Identifier: GPL-2.0
> +#
> +# Generate system call table for perf. Derived from
> +# powerpc script.
> +#
> +# Copyright IBM Corp. 2017
> +# Author(s):  Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
> +# Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
> +# Changed by: Kim Phillips <kim.phillips@arm.com>
> +# Changed by: Björn Töpel <bjorn@rivosinc.com>
> +
> +gcc=$1
> +hostcc=$2
> +incpath=$3
> +input=$4
> +
> +if ! test -r $input; then
> +	echo "Could not read input file" >&2
> +	exit 1
> +fi
> +
> +create_sc_table()
> +{
> +	local sc nr max_nr
> +
> +	while read sc nr; do
> +		printf "%s\n" "	[$nr] = \"$sc\","
> +		max_nr=$nr
> +	done
> +
> +	echo "#define SYSCALLTBL_RISCV_MAX_ID $max_nr"
> +}
> +
> +create_table()
> +{
> +	echo "#include \"$input\""
> +	echo "static const char *const syscalltbl_riscv[] = {"
> +	create_sc_table
> +	echo "};"
> +}
> +
> +$gcc -E -dM -x c -I $incpath/include/uapi $input \
> +	|awk '$2 ~ "__NR" && $3 !~ "__NR3264_" {
> +		sub("^#define __NR(3264)?_", "");
> +		print | "sort -k2 -n"}' \
> +	|create_table
> diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
> index 7c15dec6900d..349986f6e5f5 100644
> --- a/tools/perf/util/syscalltbl.c
> +++ b/tools/perf/util/syscalltbl.c
> @@ -46,6 +46,10 @@ static const char *const *syscalltbl_native = syscalltbl_mips_n64;
>  #include <asm/syscalls.c>
>  const int syscalltbl_native_max_id = SYSCALLTBL_LOONGARCH_MAX_ID;
>  static const char *const *syscalltbl_native = syscalltbl_loongarch;
> +#elif defined(__riscv)
> +#include <asm/syscalls.c>
> +const int syscalltbl_native_max_id = SYSCALLTBL_RISCV_MAX_ID;
> +static const char *const *syscalltbl_native = syscalltbl_riscv;
>  #endif
>  
>  struct syscall {
> 
> base-commit: c2ee9f594da826bea183ed14f2cc029c719bf4da
> -- 
> 2.45.2
>
Alexandre Ghiti Oct. 30, 2024, 7:31 a.m. UTC | #2
Hi Bjorn, Namhyung,

On 30/10/2024 01:37, Namhyung Kim wrote:
> Hello,
>
> On Thu, Oct 24, 2024 at 12:03:51PM -0700, Björn Töpel wrote:
>> From: Björn Töpel <bjorn@rivosinc.com>
>>
>> RISC-V does not currently support perf trace, since the system call
>> table is not generated.
>>
>> Perform the copy/paste exercise, wiring up RISC-V system call table
>> generation.
> Can anybody with RISC-V please test this?


So before this patch, I get:

Error::5File /sys/kernel/tracing//events/raw_syscalls/sys_(enter|exit) 
not found.
Hint:    Perhaps this kernel misses some CONFIG_ setting to enable this 
feature?.

After applying this patch, I get a proper trace:
....

      7.435 ( 0.332 ms): ls/1307 openat(dfd: CWD, filename: 0xb36ef668, 
flags: RDONLY|CLOEXEC)         = 3
      8.023 ( 0.454 ms): ls/1307 mmap(len: 23171, prot: READ, flags: 
PRIVATE, fd: 3)                   = 0x7fffb36cd000
      8.558 ( 0.065 ms): ls/1307 close(fd: 
3)                                                          = 0
      8.850 ( 0.294 ms): ls/1307 openat(dfd: CWD, filename: 0xb36f9f80, 
flags: RDONLY|CLOEXEC)         = 3
      9.223 ( 0.152 ms): ls/1307 read(fd: 3, buf: 0x7fffe27b3c20, count: 
832)

...

So you can add:

Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks,

Alex


>
> Thanks,
> Namhyung
>
>> Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
>> ---
>>   tools/perf/Makefile.config                    |  6 ++-
>>   tools/perf/arch/riscv/Makefile                | 22 +++++++++
>>   .../arch/riscv/entry/syscalls/mksyscalltbl    | 47 +++++++++++++++++++
>>   tools/perf/util/syscalltbl.c                  |  4 ++
>>   4 files changed, 78 insertions(+), 1 deletion(-)
>>   create mode 100755 tools/perf/arch/riscv/entry/syscalls/mksyscalltbl
>>
>> diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
>> index 4ddb27a48eed..1d388e71e0cc 100644
>> --- a/tools/perf/Makefile.config
>> +++ b/tools/perf/Makefile.config
>> @@ -31,7 +31,7 @@ $(call detected_var,SRCARCH)
>>   ifneq ($(NO_SYSCALL_TABLE),1)
>>     NO_SYSCALL_TABLE := 1
>>   
>> -  ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 powerpc arm64 s390 mips loongarch))
>> +  ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 powerpc arm64 s390 mips loongarch riscv))
>>       NO_SYSCALL_TABLE := 0
>>     endif
>>   
>> @@ -83,6 +83,10 @@ ifeq ($(ARCH),mips)
>>     LIBUNWIND_LIBS = -lunwind -lunwind-mips
>>   endif
>>   
>> +ifeq ($(ARCH),riscv)
>> +  CFLAGS += -I$(OUTPUT)arch/riscv/include/generated
>> +endif
>> +
>>   # So far there's only x86 and arm libdw unwind support merged in perf.
>>   # Disable it on all other architectures in case libdw unwind
>>   # support is detected in system. Add supported architectures
>> diff --git a/tools/perf/arch/riscv/Makefile b/tools/perf/arch/riscv/Makefile
>> index 90c3c476a242..481da4518695 100644
>> --- a/tools/perf/arch/riscv/Makefile
>> +++ b/tools/perf/arch/riscv/Makefile
>> @@ -4,3 +4,25 @@ endif
>>   PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
>>   PERF_HAVE_JITDUMP := 1
>>   HAVE_KVM_STAT_SUPPORT := 1
>> +
>> +#
>> +# Syscall table generation for perf
>> +#
>> +
>> +out    := $(OUTPUT)arch/riscv/include/generated/asm
>> +header := $(out)/syscalls.c
>> +incpath := $(srctree)/tools
>> +sysdef := $(srctree)/tools/arch/riscv/include/uapi/asm/unistd.h
>> +sysprf := $(srctree)/tools/perf/arch/riscv/entry/syscalls/
>> +systbl := $(sysprf)/mksyscalltbl
>> +
>> +# Create output directory if not already present
>> +$(shell [ -d '$(out)' ] || mkdir -p '$(out)')
>> +
>> +$(header): $(sysdef) $(systbl)
>> +	$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(incpath) $(sysdef) > $@
>> +
>> +clean::
>> +	$(call QUIET_CLEAN, riscv) $(RM) $(header)
>> +
>> +archheaders: $(header)
>> diff --git a/tools/perf/arch/riscv/entry/syscalls/mksyscalltbl b/tools/perf/arch/riscv/entry/syscalls/mksyscalltbl
>> new file mode 100755
>> index 000000000000..c59f5e852b97
>> --- /dev/null
>> +++ b/tools/perf/arch/riscv/entry/syscalls/mksyscalltbl
>> @@ -0,0 +1,47 @@
>> +#!/bin/sh
>> +# SPDX-License-Identifier: GPL-2.0
>> +#
>> +# Generate system call table for perf. Derived from
>> +# powerpc script.
>> +#
>> +# Copyright IBM Corp. 2017
>> +# Author(s):  Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
>> +# Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
>> +# Changed by: Kim Phillips <kim.phillips@arm.com>
>> +# Changed by: Björn Töpel <bjorn@rivosinc.com>
>> +
>> +gcc=$1
>> +hostcc=$2
>> +incpath=$3
>> +input=$4
>> +
>> +if ! test -r $input; then
>> +	echo "Could not read input file" >&2
>> +	exit 1
>> +fi
>> +
>> +create_sc_table()
>> +{
>> +	local sc nr max_nr
>> +
>> +	while read sc nr; do
>> +		printf "%s\n" "	[$nr] = \"$sc\","
>> +		max_nr=$nr
>> +	done
>> +
>> +	echo "#define SYSCALLTBL_RISCV_MAX_ID $max_nr"
>> +}
>> +
>> +create_table()
>> +{
>> +	echo "#include \"$input\""
>> +	echo "static const char *const syscalltbl_riscv[] = {"
>> +	create_sc_table
>> +	echo "};"
>> +}
>> +
>> +$gcc -E -dM -x c -I $incpath/include/uapi $input \
>> +	|awk '$2 ~ "__NR" && $3 !~ "__NR3264_" {
>> +		sub("^#define __NR(3264)?_", "");
>> +		print | "sort -k2 -n"}' \
>> +	|create_table
>> diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
>> index 7c15dec6900d..349986f6e5f5 100644
>> --- a/tools/perf/util/syscalltbl.c
>> +++ b/tools/perf/util/syscalltbl.c
>> @@ -46,6 +46,10 @@ static const char *const *syscalltbl_native = syscalltbl_mips_n64;
>>   #include <asm/syscalls.c>
>>   const int syscalltbl_native_max_id = SYSCALLTBL_LOONGARCH_MAX_ID;
>>   static const char *const *syscalltbl_native = syscalltbl_loongarch;
>> +#elif defined(__riscv)
>> +#include <asm/syscalls.c>
>> +const int syscalltbl_native_max_id = SYSCALLTBL_RISCV_MAX_ID;
>> +static const char *const *syscalltbl_native = syscalltbl_riscv;
>>   #endif
>>   
>>   struct syscall {
>>
>> base-commit: c2ee9f594da826bea183ed14f2cc029c719bf4da
>> -- 
>> 2.45.2
>>
> _______________________________________________
> linux-riscv mailing list
> linux-riscv@lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/linux-riscv
Namhyung Kim Oct. 31, 2024, 6:39 a.m. UTC | #3
Hello,

On Wed, Oct 30, 2024 at 08:31:35AM +0100, Alexandre Ghiti wrote:
> Hi Bjorn, Namhyung,
> 
> On 30/10/2024 01:37, Namhyung Kim wrote:
> > Hello,
> > 
> > On Thu, Oct 24, 2024 at 12:03:51PM -0700, Björn Töpel wrote:
> > > From: Björn Töpel <bjorn@rivosinc.com>
> > > 
> > > RISC-V does not currently support perf trace, since the system call
> > > table is not generated.
> > > 
> > > Perform the copy/paste exercise, wiring up RISC-V system call table
> > > generation.
> > Can anybody with RISC-V please test this?
> 
> 
> So before this patch, I get:
> 
> Error::5File /sys/kernel/tracing//events/raw_syscalls/sys_(enter|exit) not
> found.
> Hint:    Perhaps this kernel misses some CONFIG_ setting to enable this
> feature?.
> 
> After applying this patch, I get a proper trace:
> ....
> 
>      7.435 ( 0.332 ms): ls/1307 openat(dfd: CWD, filename: 0xb36ef668,
> flags: RDONLY|CLOEXEC)         = 3
>      8.023 ( 0.454 ms): ls/1307 mmap(len: 23171, prot: READ, flags: PRIVATE,
> fd: 3)                   = 0x7fffb36cd000
>      8.558 ( 0.065 ms): ls/1307 close(fd:
> 3)                                                          = 0
>      8.850 ( 0.294 ms): ls/1307 openat(dfd: CWD, filename: 0xb36f9f80,
> flags: RDONLY|CLOEXEC)         = 3
>      9.223 ( 0.152 ms): ls/1307 read(fd: 3, buf: 0x7fffe27b3c20, count: 832)
> 
> ...
> 
> So you can add:
> 
> Tested-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Thanks for your test!
Namhyung
Namhyung Kim Oct. 31, 2024, 5:12 p.m. UTC | #4
On Thu, 24 Oct 2024 12:03:51 -0700, Björn Töpel wrote:

> RISC-V does not currently support perf trace, since the system call
> table is not generated.
> 
> Perform the copy/paste exercise, wiring up RISC-V system call table
> generation.
> 
> 
> [...]

Applied to perf-tools-next, thanks!

Best regards,
Namhyung
diff mbox series

Patch

diff --git a/tools/perf/Makefile.config b/tools/perf/Makefile.config
index 4ddb27a48eed..1d388e71e0cc 100644
--- a/tools/perf/Makefile.config
+++ b/tools/perf/Makefile.config
@@ -31,7 +31,7 @@  $(call detected_var,SRCARCH)
 ifneq ($(NO_SYSCALL_TABLE),1)
   NO_SYSCALL_TABLE := 1
 
-  ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 powerpc arm64 s390 mips loongarch))
+  ifeq ($(SRCARCH),$(filter $(SRCARCH),x86 powerpc arm64 s390 mips loongarch riscv))
     NO_SYSCALL_TABLE := 0
   endif
 
@@ -83,6 +83,10 @@  ifeq ($(ARCH),mips)
   LIBUNWIND_LIBS = -lunwind -lunwind-mips
 endif
 
+ifeq ($(ARCH),riscv)
+  CFLAGS += -I$(OUTPUT)arch/riscv/include/generated
+endif
+
 # So far there's only x86 and arm libdw unwind support merged in perf.
 # Disable it on all other architectures in case libdw unwind
 # support is detected in system. Add supported architectures
diff --git a/tools/perf/arch/riscv/Makefile b/tools/perf/arch/riscv/Makefile
index 90c3c476a242..481da4518695 100644
--- a/tools/perf/arch/riscv/Makefile
+++ b/tools/perf/arch/riscv/Makefile
@@ -4,3 +4,25 @@  endif
 PERF_HAVE_ARCH_REGS_QUERY_REGISTER_OFFSET := 1
 PERF_HAVE_JITDUMP := 1
 HAVE_KVM_STAT_SUPPORT := 1
+
+#
+# Syscall table generation for perf
+#
+
+out    := $(OUTPUT)arch/riscv/include/generated/asm
+header := $(out)/syscalls.c
+incpath := $(srctree)/tools
+sysdef := $(srctree)/tools/arch/riscv/include/uapi/asm/unistd.h
+sysprf := $(srctree)/tools/perf/arch/riscv/entry/syscalls/
+systbl := $(sysprf)/mksyscalltbl
+
+# Create output directory if not already present
+$(shell [ -d '$(out)' ] || mkdir -p '$(out)')
+
+$(header): $(sysdef) $(systbl)
+	$(Q)$(SHELL) '$(systbl)' '$(CC)' '$(HOSTCC)' $(incpath) $(sysdef) > $@
+
+clean::
+	$(call QUIET_CLEAN, riscv) $(RM) $(header)
+
+archheaders: $(header)
diff --git a/tools/perf/arch/riscv/entry/syscalls/mksyscalltbl b/tools/perf/arch/riscv/entry/syscalls/mksyscalltbl
new file mode 100755
index 000000000000..c59f5e852b97
--- /dev/null
+++ b/tools/perf/arch/riscv/entry/syscalls/mksyscalltbl
@@ -0,0 +1,47 @@ 
+#!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+#
+# Generate system call table for perf. Derived from
+# powerpc script.
+#
+# Copyright IBM Corp. 2017
+# Author(s):  Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
+# Changed by: Ravi Bangoria <ravi.bangoria@linux.vnet.ibm.com>
+# Changed by: Kim Phillips <kim.phillips@arm.com>
+# Changed by: Björn Töpel <bjorn@rivosinc.com>
+
+gcc=$1
+hostcc=$2
+incpath=$3
+input=$4
+
+if ! test -r $input; then
+	echo "Could not read input file" >&2
+	exit 1
+fi
+
+create_sc_table()
+{
+	local sc nr max_nr
+
+	while read sc nr; do
+		printf "%s\n" "	[$nr] = \"$sc\","
+		max_nr=$nr
+	done
+
+	echo "#define SYSCALLTBL_RISCV_MAX_ID $max_nr"
+}
+
+create_table()
+{
+	echo "#include \"$input\""
+	echo "static const char *const syscalltbl_riscv[] = {"
+	create_sc_table
+	echo "};"
+}
+
+$gcc -E -dM -x c -I $incpath/include/uapi $input \
+	|awk '$2 ~ "__NR" && $3 !~ "__NR3264_" {
+		sub("^#define __NR(3264)?_", "");
+		print | "sort -k2 -n"}' \
+	|create_table
diff --git a/tools/perf/util/syscalltbl.c b/tools/perf/util/syscalltbl.c
index 7c15dec6900d..349986f6e5f5 100644
--- a/tools/perf/util/syscalltbl.c
+++ b/tools/perf/util/syscalltbl.c
@@ -46,6 +46,10 @@  static const char *const *syscalltbl_native = syscalltbl_mips_n64;
 #include <asm/syscalls.c>
 const int syscalltbl_native_max_id = SYSCALLTBL_LOONGARCH_MAX_ID;
 static const char *const *syscalltbl_native = syscalltbl_loongarch;
+#elif defined(__riscv)
+#include <asm/syscalls.c>
+const int syscalltbl_native_max_id = SYSCALLTBL_RISCV_MAX_ID;
+static const char *const *syscalltbl_native = syscalltbl_riscv;
 #endif
 
 struct syscall {