Skip to content

【bugfix】riscv: strnlen: fix ZBB path overflow and SIZE_MAX fallback - #340

Open
uestc-gr wants to merge 1508 commits into
RVCK-Project:rvck-6.6from
uestc-gr:string-bugfix
Open

【bugfix】riscv: strnlen: fix ZBB path overflow and SIZE_MAX fallback#340
uestc-gr wants to merge 1508 commits into
RVCK-Project:rvck-6.6from
uestc-gr:string-bugfix

Conversation

@uestc-gr

@uestc-gr uestc-gr commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

fixed: #339

功能正确性:原先的 ZBB 优化路径在 SIZE_MAX 或地址溢出情况下可能出现错误行为,需要强制回退到安全的通用实现。
边界安全:通过调整对齐边界和增加溢出检查,避免在极端输入下访问越界内存。
测试覆盖率:KUnit 增加了 SIZE_MAX 的测试,确保补丁中的回退逻辑在单元测试中得到验证,避免未来回归。

kunit测试结果

[ 8.764244] KTAP version 1
[ 8.764864] 1..2
[ 8.772373] KTAP version 1
[ 8.772967] # Subtest: string
[ 8.773905] # module: string_kunit
[ 8.774887] 1..27
[ 11.301053] # string_test_memset16: Test should be marked slow (runtime: 2.521287200s)
[ 11.308437] ok 1 string_test_memset16
[ 13.585242] # string_test_memset32: Test should be marked slow (runtime: 2.271439400s)
[ 13.590329] ok 2 string_test_memset32
[ 16.230879] # string_test_memset64: Test should be marked slow (runtime: 2.635710400s)
[ 16.235740] ok 3 string_test_memset64
[ 16.245111] ok 4 string_test_strlen
[ 16.284992] ok 5 string_test_strnlen
[ 16.292649] ok 6 string_test_strchr
[ 16.301462] ok 7 string_test_strnchr
[ 16.323942] ok 8 string_test_strrchr
[ 16.331929] ok 9 string_test_strspn
[ 16.342969] ok 10 string_test_strcmp
[ 16.351371] ok 11 string_test_strcmp_long_strings
[ 16.359479] ok 12 string_test_strncmp
[ 16.367889] ok 13 string_test_strncmp_long_strings
[ 16.375196] ok 14 string_test_strcasecmp
[ 16.383982] ok 15 string_test_strcasecmp_long_strings
[ 16.391826] ok 16 string_test_strncasecmp
[ 16.401226] ok 17 string_test_strncasecmp_long_strings
[ 16.416002] ok 18 string_test_strscpy
[ 16.423712] ok 19 string_test_strcat
[ 16.431317] ok 20 string_test_strncat
[ 16.439672] ok 21 string_test_strlcat
[ 16.448099] ok 22 string_test_strtomem
[ 16.456061] ok 23 string_test_memtostr
[ 16.464160] ok 24 string_bench_strlen # SKIP not enabled
[ 16.472060] ok 25 string_bench_strnlen # SKIP not enabled
[ 16.479556] ok 26 string_bench_strchr # SKIP not enabled
[ 16.487241] ok 27 string_bench_strrchr # SKIP not enabled
[ 16.488490] # string: pass:23 fail:0 skip:4 total:27
[ 16.489580] # Totals: pass:23 fail:0 skip:4 total:27

andreas-schwab and others added 30 commits July 1, 2026 10:17
…d handler

mainline inclusion
from mainline-6.16-rc7
commit b351018
category: feature
bugzilla: RVCK-Project#229

--------------------------------

Add missing cast to signed long.

Signed-off-by: Andreas Schwab <schwab@suse.de>
Fixes: 956d705 ("riscv: Unaligned load/store handling for M_MODE")
Tested-by: Clément Léger <cleger@rivosinc.com>
Link: https://lore.kernel.org/r/mvmikk0goil.fsf@suse.de
Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17-rc7
commit 932131f
category: feature
bugzilla: RVCK-Project#239

--------------------------------

Simply fix a typo.

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Clément Léger <cleger@rivosinc.com>
Link: https://lore.kernel.org/r/20250620-dev-alex-insn_duplicate_v5_manual-v5-1-d865dc9ad180@rivosinc.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17-rc7
commit 833bbb0
category: feature
bugzilla: RVCK-Project#239

--------------------------------

RV_X() macro is defined in two different ways which is error prone.

So harmonize its first definition and add another macro RV_X_MASK() for
the second one.

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Link: https://lore.kernel.org/r/20250620-dev-alex-insn_duplicate_v5_manual-v5-2-d865dc9ad180@rivosinc.com
[pjw@kernel.org: upcase the macro name to conform with previous practice]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17-rc7
commit a601732
category: feature
bugzilla: RVCK-Project#239

--------------------------------

kernel/traps_misaligned.c and kvm/vcpu_insn.c define the same macros to
extract information from the instructions.

Let's move the definitions into asm/insn.h to avoid this duplication.

Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Clément Léger <cleger@rivosinc.com>
Link: https://lore.kernel.org/r/20250620-dev-alex-insn_duplicate_v5_manual-v5-3-d865dc9ad180@rivosinc.com
[pjw@kernel.org: updated to apply]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
…gned access handling"

mainline inclusion
from mainline-6.16-rc4
commit 2f73c62
category: feature
bugzilla: RVCK-Project#239

--------------------------------

This reverts commit 61a74ad ("riscv: misaligned: fix sleeping function
called during misaligned access handling"). The commit addresses a sleeping
in atomic context problem, but it is not the correct fix as explained by
Clément:

"Using nofault would lead to failure to read from user memory that is paged
out for instance. This is not really acceptable, we should handle user
misaligned access even at an address that would generate a page fault."

This bug has been properly fixed by commit 453805f ("riscv:
misaligned: enable IRQs while handling misaligned accesses").

Revert this improper fix.

Link: https://lore.kernel.org/linux-riscv/b779beed-e44e-4a5e-9551-4647682b0d21@rivosinc.com/
Signed-off-by: Nam Cao <namcao@linutronix.de>
Cc: stable@vger.kernel.org
Reviewed-by: Clément Léger <cleger@rivosinc.com>
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Fixes: 61a74ad ("riscv: misaligned: fix sleeping function called during misaligned access handling")
Link: https://lore.kernel.org/r/20250620110939.1642735-1-namcao@linutronix.de
Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
category: feature
bugzilla: RVCK-Project#248

--------------------------------

Add the device tree for the Spacemit MUSE Pi Pro board.
Enable the basic peripherals and board-specific devices used
on the platform.

Signed-off-by: jichuan Feng <jichuan.or@isrc.iscas.ac.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
category: feature
bugzilla: RVCK-Project#248

--------------------------------

Add the device tree for the Spacemit MUSE Pi board.
Enable the basic peripherals and board-specific devices used
on the platform.

Signed-off-by: jichuan Feng <jichuan.or@isrc.iscas.ac.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
category: feature
bugzilla: RVCK-Project#248

--------------------------------

Add the device tree for the Milk-V Jupiter board.
Enable the basic peripherals and board-specific devices used
on the platform.

Signed-off-by: jichuan Feng <jichuan.or@isrc.iscas.ac.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
category: feature
bugzilla: RVCK-Project#248

--------------------------------

Add the device tree for the Spacemit OrangePi RV2 board.
Enable the basic peripherals and board-specific devices used
on the platform.

Signed-off-by: jichuan Feng <jichuan.or@isrc.iscas.ac.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
dist inclusion
category: cleanup
Link: RVCK-Project#249

--------------------------------

This reverts commit 8297afc.

Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
dist inclusion
category: cleanup
Link: RVCK-Project#249

--------------------------------

This reverts commit a7bf54d.

Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
dist inclusion
category: cleanup
Link: RVCK-Project#249

--------------------------------

This reverts commit 44dc885.

Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
dist inclusion
category: cleanup
Link: RVCK-Project#249

---------------------------------

This reverts commit d0c9470.

Signed-off-by: Fangyu Yu <fangyu.yu@linux.alibaba.com>
Signed-off-by: ZhenXing Zhu <zhenxing.zhu@linux.alibaba.com>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.7-rc3
commit 9880702
category: feature
bugzilla: RVCK-Project#243

--------------------------------

In order to allow referencing data nodes directly, which is not possible
currently, add support for representing references in device properties
as strings (relative or absolute name paths).  For example, after this
change, the "mipi-img-flash-leds" property in the ASL snippet below will
be treated as a proper reference to the LED0 object under LEDD.

 Package ()
 {
     "mipi-img-flash-leds",  "\\_SB.PCI0.I2C2.LEDD.LED0",
 }

 Device (LEDD)
 {
     Name (_DSD, Package ()  // _DSD: Device-Specific Data
     {
         ToUUID ("dbb8e3e6-5886-4ba6-8795-1319f52a966b"), /* Hierarchical Data Extension */,
         Package ()
         {
             Package ()
             {
                 "mipi-img-flash-led-0",
                 "LED0",
             }
         },
     })
     Name (LED0, Package ()  // _DSD: Device-Specific Data
     {
         ToUUID ("daffd814-6eba-4d8c-8a91-bc9bbf4aa301") /* Device Properties */,
         Package ()
         {
             Package ()
             {
                 "mipi-img-max-current",
                 1000000,
             }
         }
     })
 }

Also remove the mechanism allowing data nodes to be referenced
indirectly, with the help of an object reference pointing to the
"ancestor" device and a path relative to it (this mechanism is not
expected to be in use in any production platform firmware in the field).

Note that this change allows also using strings for referencing device
objects, in addition to object references that have been supported
already.

While at it, add pr_fmt() macro to prefix printouts and update
copyright.

Co-developed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.15-rc2
commit 6db0261
category: feature
bugzilla: RVCK-Project#243

--------------------------------

Document that references to data nodes shall use string-only references
instead of a device reference and a succession of the first package
entries of hierarchical data node references.

Fixes: 9880702 ("ACPI: property: Support using strings in reference properties")
Cc: 6.8+ <stable@vger.kernel.org> # 6.8+
Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com>
Link: https://patch.msgid.link/20250409084738.3657079-1-sakari.ailus@linux.intel.com
[ rjw: Clarifying edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.8-rc3
commit 66a5c40
category: feature
bugzilla: RVCK-Project#243

--------------------------------

This patch creates wordpart.h and includes it in asm/word-at-a-time.h
for all architectures. WORD_AT_A_TIME_CONSTANTS depends on kernel.h
because of REPEAT_BYTE. Moving this to another header and including it
where necessary allows us to not include the bloated kernel.h. Making
this implicit dependency on REPEAT_BYTE explicit allows for later
improvements in the lib/string.c inclusion list.

Suggested-by: Al Viro <viro@zeniv.linux.org.uk>
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Tanzir Hasan <tanzirh@google.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20231226-libstringheader-v6-1-80aa08c7652c@google.com
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.8-rc3
commit 38b9baf
category: feature
bugzilla: RVCK-Project#243

--------------------------------

This diff uses an open source tool include-what-you-use (IWYU) to modify
the include list, changing indirect includes to direct includes. IWYU is
implemented using the IWYUScripts github repository which is a tool that
is currently undergoing development. These changes seek to improve build
times.

This change to lib/string.c resulted in a preprocessed size of
lib/string.i from 26371 lines to 5321 lines (-80%) for the x86
defconfig.

Link: https://github.com/ClangBuiltLinux/IWYUScripts
Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Tanzir Hasan <tanzirh@google.com>
Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Link: https://lore.kernel.org/r/20231226-libstringheader-v6-2-80aa08c7652c@google.com
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.14-rc5
commit a21cad9
category: feature
bugzilla: RVCK-Project#243

--------------------------------

device.h is a huge header which is hard to follow and easy to miss
something. Improve that by splitting devres APIs to device/devres.h.

In particular this helps to speedup the build of the code that includes
device.h solely for a devres APIs.

While at it, cast the error pointers to __iomem using IOMEM_ERR_PTR()
and fix sparse warnings.

Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17
commit 492263f
category: feature
bugzilla: RVCK-Project#243

--------------------------------

Add device tree bindings for the common RISC-V Platform Management
Interface (RPMI) shared memory transport as a mailbox controller.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Link: https://lore.kernel.org/r/20250818040920.272664-2-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17
commit 581b4da
category: feature
bugzilla: RVCK-Project#243

--------------------------------

Add device tree bindings for the RISC-V SBI Message Proxy (MPXY)
extension as a mailbox controller.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Link: https://lore.kernel.org/r/20250818040920.272664-3-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17
commit 508da38
category: feature
bugzilla: RVCK-Project#229

--------------------------------

Add defines for the new SBI message proxy extension which is part
of the SBI v3.0 specification.

Reviewed-by: Atish Patra <atishp@rivosinc.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Co-developed-by: Rahul Pathak <rpathak@ventanamicro.com>
Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Link: https://lore.kernel.org/r/20250818040920.272664-4-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17
commit 340974c
category: feature
bugzilla: RVCK-Project#243

--------------------------------

The RPMI based mailbox controller drivers and mailbox clients need to
share defines related to RPMI messages over mailbox interface so add
a common header for this purpose.

Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Co-developed-by: Rahul Pathak <rpathak@ventanamicro.com>
Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Link: https://lore.kernel.org/r/20250818040920.272664-5-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17
commit 6f01c24
category: feature
bugzilla: RVCK-Project#243

--------------------------------

Add common memcpy APIs for copying u32 array to/from __le32 array.

Suggested-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Link: https://lore.kernel.org/r/20250818040920.272664-7-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17
commit bf3022a
category: feature
bugzilla: RVCK-Project#243

--------------------------------

Add a mailbox controller driver for the new SBI message proxy extension
which is part of the SBI v3.0 specification.

Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Co-developed-by: Rahul Pathak <rpathak@ventanamicro.com>
Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Link: https://lore.kernel.org/r/20250818040920.272664-8-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17
commit 54e184f
category: feature
bugzilla: RVCK-Project#243

--------------------------------

Add device tree bindings for the RPMI clock service group based
message proxy implemented by the SBI implementation (machine mode
firmware or hypervisor).

The RPMI clock service group is defined by the RISC-V platform
management interface (RPMI) specification.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Acked-by: Stephen Boyd <sboyd@kernel.org>
Link: https://lore.kernel.org/r/20250818040920.272664-9-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17
commit b385830
category: feature
bugzilla: RVCK-Project#243

--------------------------------

Add device tree bindings for the RPMI clock service group based
controller for the supervisor software.

The RPMI clock service group is defined by the RISC-V platform
management interface (RPMI) specification.

Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Link: https://lore.kernel.org/r/20250818040920.272664-10-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17
commit 5ba9f52
category: feature
bugzilla: RVCK-Project#243

--------------------------------

The RPMI specification defines a clock service group which can be
accessed via SBI MPXY extension or dedicated S-mode RPMI transport.

Add mailbox client based clock driver for the RISC-V RPMI clock
service group.

Reviewed-by: Stephen Boyd <sboyd@kernel.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Co-developed-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Signed-off-by: Rahul Pathak <rpathak@ventanamicro.com>
Link: https://lore.kernel.org/r/20250818040920.272664-11-apatel@ventanamicro.com
[pjw@kernel.org: converted rpmi_clkrate_u64 macro to a function; replaced bare constant with a macro]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17
commit a72ab25
category: feature
bugzilla: RVCK-Project#243

--------------------------------

Add device tree bindings for the RPMI system MSI service group
based message proxy implemented by the SBI implementation (machine
mode firmware or hypervisor).

The RPMI system MSI service group is defined by the RISC-V
platform management interface (RPMI) specification.

Reviewed-by: Atish Patra <atishp@rivosinc.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Link: https://lore.kernel.org/r/20250818040920.272664-12-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17
commit 3e6cf38
category: feature
bugzilla: RVCK-Project#243

--------------------------------

Add device tree bindings for the RPMI system MSI service group
based interrupt controller for the supervisor software.

The RPMI system MSI service group is defined by the RISC-V
platform management interface (RPMI) specification.

Reviewed-by: Atish Patra <atishp@rivosinc.com>
Reviewed-by: Conor Dooley <conor.dooley@microchip.com>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Acked-by: Jassi Brar <jassisinghbrar@gmail.com>
Link: https://lore.kernel.org/r/20250818040920.272664-13-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
mainline inclusion
from mainline-6.17
commit aa43953
category: feature
bugzilla: RVCK-Project#243

--------------------------------

The RPMI specification defines a system MSI service group which
allows application processors to receive MSIs upon system events
such as graceful shutdown/reboot request, CPU hotplug event, memory
hotplug event, etc.

Add an irqchip driver for the RISC-V RPMI system MSI service group
to directly receive system MSIs in Linux kernel.

Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
Link: https://lore.kernel.org/r/20250818040920.272664-14-apatel@ventanamicro.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
Signed-off-by: Yanteng Si <si.yanteng@linux.dev>
Alexandre Ghiti and others added 21 commits July 1, 2026 14:17
mainline inclusion
from mainline-6.11
commit d25599b
category: feature
bugzilla: RVCK-Project#304

--------------------------------

Add description for the Svvptc ISA extension which was ratified recently.

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20240717060125.139416-3-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-6.12-rc5
commit 8727163
category: feature
bugzilla: RVCK-Project#304

--------------------------------

The RISC-V Pointer Masking specification defines three extensions:
Smmpm, Smnpm, and Ssnpm. Document the behavior of these extensions as
following the ratified version 1.0 of the specification.

Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Charlie Jenkins <charlie@rivosinc.com>
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
Link: https://lore.kernel.org/r/20241016202814.4061541-2-samuel.holland@sifive.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-6.12
commit 51624dd
category: feature
bugzilla: RVCK-Project#304

--------------------------------

Add description for the Zabha ISA extension which was ratified in April
2024.

Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Reviewed-by: Guo Ren <guoren@kernel.org>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Reviewed-by: Andrew Jones <ajones@ventanamicro.com>
Reviewed-by: Andrea Parri <parri.andrea@gmail.com>
Link: https://lore.kernel.org/r/20241103145153.105097-5-alexghiti@rivosinc.com
Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-6.14
commit a65e0f6
category: feature
bugzilla: RVCK-Project#304

--------------------------------

Add description for the Zaamo and Zalrsc ISA extension[1].

Link: https://github.com/riscv/riscv-zaamo-zalrsc [1]
Signed-off-by: Clément Léger <cleger@rivosinc.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20240619153913.867263-2-cleger@rivosinc.com
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>

Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-6.15-rc1
commit 534d813
category: feature
bugzilla: RVCK-Project#304

--------------------------------

Per the specifications, the d extension for double-precision floating
point operations depends on the f extension for single-precision floating
point. Add that requirement to the bindings. This differs from the
Linux implementation, where single-precious only is not supported.

Reviewed-by: Clément Léger <cleger@rivosinc.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20250312-perpetual-daunting-ad489c9a857a@spud
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-6.15-rc1
commit e9f1d61
category: feature
bugzilla: RVCK-Project#304

--------------------------------
Section 33.18.2. Zve*: Vector Extensions for Embedded Processors
in [1] says:
| The Zve32f and Zve64x extensions depend on the Zve32x extension. The Zve64f extension depends
| on the Zve32f and Zve64x extensions. The Zve64d extension depends on the Zve64f extension

| The Zve32x extension depends on the Zicsr extension. The Zve32f and Zve64f extensions depend
| upon the F extension

| The Zve64d extension depends upon the D extension

Apply these rules to the bindings to help prevent invalid combinations.

Link: https://github.com/riscv/riscv-isa-manual/releases/tag/riscv-isa-release-698e64a-2024-09-09 [1]
Reviewed-by: Clément Léger <cleger@rivosinc.com>
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20250312-banking-crestless-58f3259a5018@spud
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-6.15-rc1
commit a0d8572
category: feature
bugzilla: RVCK-Project#304

--------------------------------

The Unpriv spec states:
| The Zvknhb and Zvbc Vector Crypto Extensions --and accordingly the
| composite extensions Zvkn, Zvknc, Zvkng, and Zvksc-- require a Zve64x
| base, or application ("V") base Vector Extension. All of the other
| Vector Crypto Extensions can be built on any embedded (Zve*) or
| application ("V") base Vector Extension.

Enforce the minimum requirement via schema.

Link: https://github.com/riscv/riscv-isa-manual/blob/main/src/vector-crypto.adoc#extensions-overview
Acked-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Signed-off-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20250312-flask-relay-b36ee622b2c8@spud
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-6.19-rc2
commit 4115155
category: feature
bugzilla: RVCK-Project#304

--------------------------------

Add descriptions for the Zilsd (Load/Store pair instructions) and
Zclsd (Compressed Load/Store pair instructions) ISA extensions
which were ratified in commit f88abf1 ("Integrating load/store
pair for RV32 with the main manual") of the riscv-isa-manual.

Signed-off-by: Pincheng Wang <pincheng.plct@isrc.iscas.ac.cn>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Acked-by: Conor Dooley <conor.dooley@microchip.com>
Link: https://patch.msgid.link/20250826162939.1494021-2-pincheng.plct@isrc.iscas.ac.cn
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-6.19-rc2
commit 3f0cbfb
category: feature
bugzilla: RVCK-Project#304

--------------------------------

Add parsing for Zilsd and Zclsd ISA extensions which were ratified in
commit f88abf1 ("Integrating load/store pair for RV32 with the
main manual") of the riscv-isa-manual.

Signed-off-by: Pincheng Wang <pincheng.plct@isrc.iscas.ac.cn>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Link: https://patch.msgid.link/20250826162939.1494021-3-pincheng.plct@isrc.iscas.ac.cn
[pjw@kernel.org: cleaned up checkpatch issues, whitespace; updated to apply]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-6.19-rc2
commit 6118ebe
category: feature
bugzilla: RVCK-Project#304

--------------------------------

Export Zilsd and Zclsd ISA extensions through hwprobe.

Signed-off-by: Pincheng Wang <pincheng.plct@isrc.iscas.ac.cn>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Link: https://patch.msgid.link/20250826162939.1494021-4-pincheng.plct@isrc.iscas.ac.cn
[pjw@kernel.org: fixed whitespace; updated to apply]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
mainline inclusion
from mainline-6.19-rc2
commit f326e84
category: feature
bugzilla: RVCK-Project#304

--------------------------------

Extend the KVM ISA extension ONE_REG interface to allow KVM user space
to detect and enable Zilsd and Zclsd extensions for Guest/VM.

Signed-off-by: Pincheng Wang <pincheng.plct@isrc.iscas.ac.cn>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20250826162939.1494021-5-pincheng.plct@isrc.iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
…test

mainline inclusion
from mainline-6.19-rc2
commit ab2a7b7
category: feature
bugzilla: RVCK-Project#304

--------------------------------

The KVM RISC-V allows Zilsd and Zclsd extensions for Guest/VM so add
this extension to get-reg-list test.

Signed-off-by: Pincheng Wang <pincheng.plct@isrc.iscas.ac.cn>
Reviewed-by: Nutty Liu <nutty.liu@hotmail.com>
Reviewed-by: Anup Patel <anup@brainfault.org>
Link: https://lore.kernel.org/r/20250826162939.1494021-6-pincheng.plct@isrc.iscas.ac.cn
Signed-off-by: Anup Patel <anup@brainfault.org>
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
driver inclusion
category other
Link: RVCK-Project#315

-------------------------------------------------

Correct register names, descriptions, and definitions
in JSON config files to match the latest hardware spec;
remove deprecated registers and obsolete files.
Metadata/documentation changes only. No functional
logic modified. Ensure downstream tools handle the
removed file and updated definitions.

Signed-off-by: heyilin <he.yilin@zte.com.cn>
Signed-off-by: liuqingtao <liu.qingtao2@zte.com.cn>
mainline inclusion
from mainline-v7.1-rc1
commit 382cf7b ("riscv: vdso_cfi: Add clean rule for copied sources")
category: bugfix
bugzilla: RVCK-Project#328

--------------------------------

When building VDSO with CFI support, source files are copied from the main
VDSO directory to the CFI build directory as part of the build process.
However, these copied source files were not removed during 'make clean',
leaving temporary files in the build directory.

Add the clean-files variable to ensure that these copied .c and .S files
are properly cleaned up. The notdir() function is used to strip the path
prefix, as clean-files expects relative file names without directory
components.

This ensures the build directory is left in a clean state after make clean.

Signed-off-by: Chen Pei <cp0613@linux.alibaba.com>
Link: https://patch.msgid.link/20260320021850.1877-2-cp0613@linux.alibaba.com
Signed-off-by: Paul Walmsley <pjw@kernel.org>
Signed-off-by: Chen Wang <wangchen20@iscas.ac.cn>
driver inclusion
category: bugfix
Link: RVCK-Project#308

--------------------------------

When using NVMe for PCIe peripherals on an RV multi-core CPU with IOMMU
enabled, the command `fio --filename=/dev/nvme0n1 --ioengine=libaio
--direct=1 --iodepth=256 --numjobs=8 --group_reporting=1 --bs=1M
--time_based=1 --runtime=2 --rw=read --name=test_read_8 --thread=1`
resulted a fault 15 exception during IOMMU testing.

When multiple cores modify iommu page talbe simultaneously, executing
riscv_iommu_map_pages or riscv_iommu_pte_alloc, an out-of-order iommu
page table clearing problem can occur due to a memory barrier missing.
It caused PTE being incorrectly cleared.

Setting dma_wmb ensures that all previous DMA write operations have
been completed before cmpxchg_relaxed.

This issue is relatively rare and may only occur during stress testing.

Signed-off-by: bailu <bai.lu5@zte.com.cn>
Signed-off-by: liuqingtao <liu.qingtao2@zte.com.cn>
iommu/riscv: add dma_wmb before cmpxchg_relaxed
Add Zilsd/Zclsd support in hwprobe and KVM
riscv: vdso_cfi: Add clean rule for copied sources
driver inclusion
category: bugfix
bugzilla: RVCK-Project#339

--------------------------------

This patch improves the RISC-V strnlen implementation:

- Add explicit fallback to generic path when count == SIZE_MAX,
  avoiding minu instruction misbehavior.
- Add overflow check for (s + count), ensuring safe fallback
  when address addition wraps around.
- Refactor aligned boundary calculation to use (s + count - 1),
  preventing word loads beyond the valid range.
- Add fast exit when all remaining bytes are within the first word.
- Simplify generic path loop with clearer pointer/count handling.

These changes fix potential off-by-one, overflow, and extreme
input bugs, while keeping ZBB optimization for normal cases.

Fixes: 5ba15d4 ("riscv: lib: add strnlen() implementation")
Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
driver inclusion
category: bugfix
bugzilla: RVCK-Project#339

--------------------------------

Extend string_test_strnlen to validate strnlen behavior with
SIZE_MAX input:

- Add explicit test case for strnlen(s, SIZE_MAX).
- Ensure fallback to generic path returns correct length when
  string has no NUL terminator.
- Complements existing tests for non-terminated strings and
  boundary conditions.

This improves KUnit coverage for extreme inputs and verifies
the correctness of the new fallback logic in strnlen.S.

Signed-off-by: Gao Rui <gao.rui@zte.com.cn>
@github-actions

github-actions Bot commented Jul 22, 2026

Copy link
Copy Markdown

开始测试 log: https://github.com/RVCK-Project/rvck/actions/runs/29883038080

参数解析结果
args value
repository RVCK-Project/rvck
head ref pull/340/head
base ref rvck-6.6
LAVA repo RVCK-Project/lavaci
LAVA hardware ['qemu']
LAVA Testcase path lava-testcases/common-test/ltp/ltp.yaml
need run job kunit-test,kernel-build,check-patch,lava-trigger

测试完成

详细结果:
check result
kunit-test success
kernel-build success
check-patch success
lava-trigger-qemu success
lava-trigger-sg2042 skipped
lava-trigger-k1 skipped
lava-trigger-lpi4a skipped

Kunit Test Result

[01:29:44] Testing complete. Ran 482 tests: passed: 465, skipped: 17

Kernel Build Result

Check Patch Result

Total Errors 0
Total Warnings 2

LAVA Check (qemu)

args value
testcase_repo RVCK-Project/lavaci
lava_template lava-job-template/qemu/qemu-ltp.yaml
testcase_path lava-testcases/common-test/ltp/ltp.yaml
kernel_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck/340_29883038080_1/Image
initramfs_download_url http://10.30.190.110/openEuler-RISC-V/RVCK/OERV-RVCI/RVCK-Project/rvck/340_29883038080_1/initramfs.img
rootfs_download_url https://fast-mirror.isrc.ac.cn/openeuler-sig-riscv/openEuler-RISC-V/RVCK/openEuler24.03-LTS-SP1/openeuler-rootfs.img.zst
testcase_ref main
testitem_name RVCK-Project_rvck_pull_request_target_340__common-test_qemu

result: Lava check done!

@uestc-gr

Copy link
Copy Markdown
Contributor Author

PR已完成请老师评审

@unicornx

Copy link
Copy Markdown

这是 rvck 独有的问题还是主线也存在的问题,如果主线也存在的话,我建议先提交给主线合入后再 pick 到这里,这样可以请上游的 maintainer 协助更详细的审查。@uestc-gr

@unicornx unicornx added the ZTE label Jul 22, 2026
@uestc-gr

Copy link
Copy Markdown
Contributor Author

这是 rvck 独有的问题还是主线也存在的问题,如果主线也存在的话,我建议先提交给主线合入后再 pick 到这里,这样可以请上游的 maintainer 协助更详细的审查。@uestc-gr

主线也存在问题,这个问题比较紧急且重要,会导致系统找不到lvm磁盘设备,进而安装失败或启动失败,主线修改周期较长,我测试过这个修改性能上可能差一点,但至少功能应该没有问题,我想先合入rvck解决启动问题,后面再回合主线的正式修改@unicornx

@sterling-teng

Copy link
Copy Markdown
Contributor

这是 rvck 独有的问题还是主线也存在的问题,如果主线也存在的话,我建议先提交给主线合入后再 pick 到这里,这样可以请上游的 maintainer 协助更详细的审查。@uestc-gr

主线也存在问题,这个问题比较紧急且重要,会导致系统找不到lvm磁盘设备,进而安装失败或启动失败,主线修改周期较长,我测试过这个修改性能上可能差一点,但至少功能应该没有问题,我想先合入rvck解决启动问题,后面再回合主线的正式修改@unicornx

你的补丁改了nolibc,代码影响范围比较大。这种情况,我建议同时提交邮件列表,我们想了解下上游社区维护该子系统maintainer的看法,以此来评估是否合入。

BTW,这个pr要不先进openruyi内核集成测试下? @RevySR

@unicornx

unicornx commented Jul 22, 2026

Copy link
Copy Markdown

你的补丁改了nolibc,代码影响范围比较大。这种情况,我建议同时提交邮件列表,我们想了解下上游社区维护该子系统maintainer的看法,以此来评估是否合入。

我也赞成同时提交上游,如果上游 maintainer 一接受,我们这可以提前就合入 rvck,不用等上游的 master pick。这样也快。而且这个改动我看本身改动不大,如果没啥问题,上游 review 也快的,你觉得如何? @uestc-gr

我同时也想到的是,如果我们提前合入了,等上游 master 正式 pick 了,为了让 rvck 看得更好,我们或许可以再做一次 revert + repick(上游master 版本)的操作,这样会更完美些。

@uestc-gr

Copy link
Copy Markdown
Contributor Author

你的补丁改了nolibc,代码影响范围比较大。这种情况,我建议同时提交邮件列表,我们想了解下上游社区维护该子系统maintainer的看法,以此来评估是否合入。

我也赞成同时提交上游,如果上游 maintainer 一接受,我们这可以提前就合入 rvck,不用等上游的 master pick。这样也快。而且这个改动我看本身改动不大,如果没啥问题,上游 review 也快的,你觉得如何? @uestc-gr

我同时也想到的是,如果我们提前合入了,等上游 master 正式 pick 了,为了让 rvck 看得更好,我们或许可以再做一次 revert + repick(上游master 版本)的操作,这样会更完美些。

好的,我们先推L0看看

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

riscv: strnlen: fix ZBB path overflow and SIZE_MAX fallback