[PATCH v7] riscv: errata: Add ERRATA WRITE_ONCE fixup

Drew Fustini fustini at kernel.org
Wed Nov 25 09:35:13 PST 2026


On Tue, Nov 24, 2026 at 08:35:04AM +0000, GUO Ren (XuanTie) wrote:
> The early version of XuanTie C910 core has a store merge buffer
> delay problem. The store merge buffer could improve the store queue
> performance by merging multi-store requests, but when there are not
> continued store requests, the prior single store request would be
> waiting in the store queue for a long time. That would cause
> significant problems for communication between multi-cores. This
> problem was found on sg2042 platform with the qspinlock lock torture
> test.
> 
> So appending a fence w.o could immediately flush the store merge
> buffer and let other cores see the write result.
> 
> This will apply the WRITE_ONCE errata to handle the non-standard
> behavior via appending a fence w.o instruction for WRITE_ONCE().
> 
> This problem is only observed on the sg2042 hardware platform: it
> takes hours of locktorture stress testing to trigger the livelock
> once, and an interrupt can break the livelock. No user space
> application has been observed to hit this problem, so there is no
> need to modify user space WRITE_ONCE(). The vDSO code runs in user
> space context as well, so its WRITE_ONCE() does not need the errata
> fence either.
> 
> Acked-by: Arnd Bergmann <arnd at arndb.de>
> Reviewed-by: Alexandre Ghiti <alexghiti at rivosinc.com>
> Reviewed-by: Leonardo Bras <leobras at redhat.com>
> Reviewed-by: Inochi Amaoto <inochiama at gmail.com>
> Tested-by: Han Gao <gaohan at iscas.ac.cn>
> Tested-by: Yao Zi <me at ziyao.cc>
> Cc: Chen Wang <unicorn_wang at outlook.com>
> Cc: Xiaoguang Xing <xiaoguang.xing at sophgo.com>
> Cc: Paul Walmsley <pjw at kernel.org>
> Cc: Drew Fustini <fustini at kernel.org>
> Co-developed-by: Han Gao <gaohan at iscas.ac.cn>
> Signed-off-by: Han Gao <gaohan at iscas.ac.cn>
> Signed-off-by: GUO Ren (XuanTie) <guoren at kernel.org>
> ---
> Changelog
> 
> v7:
>  - Define BUILD_VDSO for the riscv vDSO build (as arm64, powerpc and
>    others do) and use it to keep the WRITE_ONCE errata alternative out
>    of the vDSO. The vdso getrandom code uses WRITE_ONCE(), so v6 added
>    .alternative entries to the vDSO and booting with
>    CONFIG_DEBUG_VIRTUAL=y hit VIRTUAL_BUG_ON() in vmalloc_to_page(),
>    as reported by Drew Fustini:
>    https://lore.kernel.org/linux-riscv/awPgjwuswbjeDftg@thelio/
>    Fold in Han Gao's "riscv: vdso: Define BUILD_VDSO" patch:
>    https://lore.kernel.org/linux-riscv/20261124-riscv-vdso-build-vdso-v1-1-c52b0b3592dc@iscas.ac.cn/
>  - Clarify in the commit message why user space and the vDSO are not
>    affected by the livelock.
>  - Rebase on v7.4-rc4.

Reviewed-by: Drew Fustini <fustini at kernel.org>

I tried v7 in qemu with -cpu thead-c906 and CONFIG_DEBUG_VIRTUAL=y. It
boots okay and the vdso has no entries in .alternative.

Thanks,
Drew



More information about the linux-riscv mailing list