diff -Nru papi-7.1.0/debian/changelog papi-7.1.0/debian/changelog
--- papi-7.1.0/debian/changelog	2024-03-02 15:14:24.000000000 +0800
+++ papi-7.1.0/debian/changelog	2025-06-06 10:22:57.000000000 +0800
@@ -1,3 +1,9 @@
+papi (7.1.0-5.1) UNRELEASED; urgency=medium
+
+  * Support for riscv. 
+
+ -- Gui-Yue <yuemeng.gui@gmail.com>  Fri, 06 Jun 2025 10:22:57 +0800
+
 papi (7.1.0-5) unstable; urgency=medium
 
   * Make papi-examples arch:any due to arch-specific paths in Makefiles.
diff -Nru papi-7.1.0/debian/patches/add-support-for-riscv.patch papi-7.1.0/debian/patches/add-support-for-riscv.patch
--- papi-7.1.0/debian/patches/add-support-for-riscv.patch	1970-01-01 08:00:00.000000000 +0800
+++ papi-7.1.0/debian/patches/add-support-for-riscv.patch	2025-06-06 10:22:51.000000000 +0800
@@ -0,0 +1,39 @@
+--- a/src/linux-context.h
++++ b/src/linux-context.h
+@@ -41,6 +41,8 @@
+ #define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.pc
+ #elif defined(__hppa__)
+ #define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.sc_iaoq[0]
++#elif defined(__riscv)
++#define OVERFLOW_ADDRESS(ctx) ctx.ucontext->uc_mcontext.__gregs[REG_PC]
+ #else
+ #error "OVERFLOW_ADDRESS() undefined!"
+ #endif
+--- a/src/linux-timer.c
++++ b/src/linux-timer.c
+@@ -297,7 +297,7 @@
+     return retval;
+ }
+ 
+-#elif (defined(__arm__) || defined(__mips__) || defined(__hppa__))
++#elif (defined(__arm__) || defined(__mips__) || defined(__hppa__)) || defined(__riscv)
+ static inline long long
+ get_cycles( void )
+ {
+--- a/src/mb.h
++++ b/src/mb.h
+@@ -66,6 +66,14 @@
+ #define rmb() asm volatile("lfence":::"memory")
+ #endif
+ 
++#elif defined(__riscv)
++#define RISCV_FENCE(p, s) \
++    __asm__ __volatile__ ("fence " #p "," #s : : : "memory")
++/* These barriers need to enforce ordering on both devices or memory. */
++#define mb()		RISCV_FENCE(iorw,iorw)
++#define rmb()		RISCV_FENCE(ir,ir)
++#define wmb()		RISCV_FENCE(ow,ow)
++
+ #else
+ #error Need to define rmb for this architecture!
+ #error See the kernel source directory: tools/perf/perf.h file
diff -Nru papi-7.1.0/debian/patches/series papi-7.1.0/debian/patches/series
--- papi-7.1.0/debian/patches/series	2024-03-02 15:14:24.000000000 +0800
+++ papi-7.1.0/debian/patches/series	2025-06-06 10:16:32.000000000 +0800
@@ -12,3 +12,4 @@
 0001-factor-out-Makefile.tests.patch
 0002-sde-tests-create-lib-dir-if-needed.patch
 0003-fix-Makefiles-for-installed-tests.patch
+add-support-for-riscv.patch
