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

From: Drew Fustini

Date: Wed Nov 25 2026 - 12:35:19 EST


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@xxxxxxxx>
> Reviewed-by: Alexandre Ghiti <alexghiti@xxxxxxxxxxxx>
> Reviewed-by: Leonardo Bras <leobras@xxxxxxxxxx>
> Reviewed-by: Inochi Amaoto <inochiama@xxxxxxxxx>
> Tested-by: Han Gao <gaohan@xxxxxxxxxxx>
> Tested-by: Yao Zi <me@xxxxxxxx>
> Cc: Chen Wang <unicorn_wang@xxxxxxxxxxx>
> Cc: Xiaoguang Xing <xiaoguang.xing@xxxxxxxxxx>
> Cc: Paul Walmsley <pjw@xxxxxxxxxx>
> Cc: Drew Fustini <fustini@xxxxxxxxxx>
> Co-developed-by: Han Gao <gaohan@xxxxxxxxxxx>
> Signed-off-by: Han Gao <gaohan@xxxxxxxxxxx>
> Signed-off-by: GUO Ren (XuanTie) <guoren@xxxxxxxxxx>
> ---
> 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@xxxxxxxxxxx/
> - 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@xxxxxxxxxx>

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