diff --git a/libavcodec/riscv/Makefile b/libavcodec/riscv/Makefile
index 590655f829..c180223141 100644
--- a/libavcodec/riscv/Makefile
+++ b/libavcodec/riscv/Makefile
@@ -77,3 +77,5 @@ RVV-OBJS-$(CONFIG_VP9_DECODER) += riscv/vp9_intra_rvv.o \
                                   riscv/vp9_mc_rvv.o
 OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_init.o
 RVV-OBJS-$(CONFIG_VORBIS_DECODER) += riscv/vorbisdsp_rvv.o
+
+SHLIBOBJS += riscv/cpu_common.o
diff --git a/libavcodec/riscv/cpu_common.c b/libavcodec/riscv/cpu_common.c
new file mode 100644
index 0000000000..17c9b392c9
--- /dev/null
+++ b/libavcodec/riscv/cpu_common.c
@@ -0,0 +1 @@
+#include "libavutil/riscv/cpu_common.c"
diff --git a/libavdevice/riscv/Makefile b/libavdevice/riscv/Makefile
new file mode 100644
index 0000000000..52857aacba
--- /dev/null
+++ b/libavdevice/riscv/Makefile
@@ -0,0 +1 @@
+SHLIBOBJS += riscv/cpu_common.o
diff --git a/libavdevice/riscv/cpu_common.c b/libavdevice/riscv/cpu_common.c
new file mode 100644
index 0000000000..17c9b392c9
--- /dev/null
+++ b/libavdevice/riscv/cpu_common.c
@@ -0,0 +1 @@
+#include "libavutil/riscv/cpu_common.c"
diff --git a/libavfilter/riscv/Makefile b/libavfilter/riscv/Makefile
index 277dde2aed..14a4470d96 100644
--- a/libavfilter/riscv/Makefile
+++ b/libavfilter/riscv/Makefile
@@ -1,2 +1,4 @@
 OBJS-$(CONFIG_AFIR_FILTER)                   += riscv/af_afir_init.o
 RVV-OBJS-$(CONFIG_AFIR_FILTER)               += riscv/af_afir_rvv.o
+
+SHLIBOBJS += riscv/cpu_common.o
diff --git a/libavfilter/riscv/cpu_common.c b/libavfilter/riscv/cpu_common.c
new file mode 100644
index 0000000000..17c9b392c9
--- /dev/null
+++ b/libavfilter/riscv/cpu_common.c
@@ -0,0 +1 @@
+#include "libavutil/riscv/cpu_common.c"
diff --git a/libavformat/riscv/Makefile b/libavformat/riscv/Makefile
new file mode 100644
index 0000000000..52857aacba
--- /dev/null
+++ b/libavformat/riscv/Makefile
@@ -0,0 +1 @@
+SHLIBOBJS += riscv/cpu_common.o
diff --git a/libavformat/riscv/cpu_common.c b/libavformat/riscv/cpu_common.c
new file mode 100644
index 0000000000..17c9b392c9
--- /dev/null
+++ b/libavformat/riscv/cpu_common.c
@@ -0,0 +1 @@
+#include "libavutil/riscv/cpu_common.c"
diff --git a/libavutil/riscv/Makefile b/libavutil/riscv/Makefile
index 7e9a51194b..5db4c432d9 100644
--- a/libavutil/riscv/Makefile
+++ b/libavutil/riscv/Makefile
@@ -1,7 +1,8 @@
 OBJS +=     riscv/float_dsp_init.o \
             riscv/fixed_dsp_init.o \
             riscv/lls_init.o \
-            riscv/cpu.o
+            riscv/cpu.o \
+            riscv/cpu_common.o
 RVV-OBJS += riscv/float_dsp_rvv.o \
             riscv/fixed_dsp_rvv.o \
             riscv/lls_rvv.o
diff --git a/libavutil/riscv/cpu.h b/libavutil/riscv/cpu.h
index af1440f626..bb8e08aa14 100644
--- a/libavutil/riscv/cpu.h
+++ b/libavutil/riscv/cpu.h
@@ -24,8 +24,22 @@
 #include "config.h"
 #include <stdbool.h>
 #include <stddef.h>
+#include "libavutil/attributes_internal.h"
 #include "libavutil/cpu.h"
 
+#ifndef __riscv_zbb
+extern attribute_visibility_hidden bool ff_rv_zbb_supported;
+#endif
+
+static inline av_const bool ff_rv_zbb_support(void)
+{
+#ifndef __riscv_zbb
+    return ff_rv_zbb_supported;
+#else
+    return true;
+#endif
+}
+
 #if HAVE_RVV
 /**
  * Returns the vector size in bytes (always a power of two and at least 4).
diff --git a/libavutil/riscv/cpu_common.c b/libavutil/riscv/cpu_common.c
new file mode 100644
index 0000000000..3ecf95809b
--- /dev/null
+++ b/libavutil/riscv/cpu_common.c
@@ -0,0 +1,33 @@
+/*
+ * Copyright © 2024 Rémi Denis-Courmont.
+ *
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * FFmpeg is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "libavutil/cpu.h"
+
+#ifndef __riscv_zbb
+unsigned char ff_rv_zbb_supported = 0;
+
+#ifdef __ELF__
+__attribute__((constructor))
+static void probe_zbb(void)
+{
+    ff_rv_zbb_supported = (av_get_cpu_flags() & AV_CPU_FLAG_RVB_BASIC) != 0;
+}
+#endif
+#endif
diff --git a/libswscale/riscv/Makefile b/libswscale/riscv/Makefile
index 48afaf62aa..ea324bdc5f 100644
--- a/libswscale/riscv/Makefile
+++ b/libswscale/riscv/Makefile
@@ -1,3 +1,5 @@
 OBJS += riscv/rgb2rgb.o
 RV-OBJS += riscv/rgb2rgb_rvb.o
 RVV-OBJS += riscv/rgb2rgb_rvv.o
+
+SHLIBOBJS += riscv/cpu_common.o
diff --git a/libswscale/riscv/cpu_common.c b/libswscale/riscv/cpu_common.c
new file mode 100644
index 0000000000..17c9b392c9
--- /dev/null
+++ b/libswscale/riscv/cpu_common.c
@@ -0,0 +1 @@
+#include "libavutil/riscv/cpu_common.c"
diff --git a/tests/ref/fate/source b/tests/ref/fate/source
index a3beb35093..0abeff8036 100644
--- a/tests/ref/fate/source
+++ b/tests/ref/fate/source
@@ -3,17 +3,22 @@ libavcodec/file_open.c
 libavcodec/interplayacm.c
 libavcodec/log2_tab.c
 libavcodec/reverse.c
+libavcodec/riscv/cpu_common.c
 libavdevice/file_open.c
 libavdevice/reverse.c
+libavdevice/riscv/cpu_common.c
 libavfilter/file_open.c
 libavfilter/log2_tab.c
+libavfilter/riscv/cpu_common.c
 libavformat/bitstream.c
 libavformat/file_open.c
 libavformat/golomb_tab.c
 libavformat/log2_tab.c
 libavformat/rangecoder_dec.c
+libavformat/riscv/cpu_common.c
 libswresample/log2_tab.c
 libswscale/log2_tab.c
+libswscale/riscv/cpu_common.c
 tools/uncoded_frame.c
 tools/yuvcmp.c
 Headers without standard inclusion guards:
