Files
linux/arch/riscv/include/asm/vdso
Jingwei Wang 5d15d2ad36 riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot
The hwprobe vDSO data for some keys, like MISALIGNED_VECTOR_PERF,
is determined by an asynchronous kthread. This can create a race
condition where the kthread finishes after the vDSO data has
already been populated, causing userspace to read stale values.

To fix this race, a new 'ready' flag is added to the vDSO data,
initialized to 'false' during arch_initcall_sync. This flag is
checked by both the vDSO's user-space code and the riscv_hwprobe
syscall. The syscall serves as a one-time gate, using a completion
to wait for any pending probes before populating the data and
setting the flag to 'true', thus ensuring userspace reads fresh
values on its first request.

Reported-by: Tsukasa OI <[email protected]>
Closes: https://lore.kernel.org/linux-riscv/[email protected]/
Fixes: e7c9d66e31 ("RISC-V: Report vector unaligned access speed hwprobe")
Cc: Palmer Dabbelt <[email protected]>
Cc: Alexandre Ghiti <[email protected]>
Cc: Olof Johansson <[email protected]>
Cc: [email protected]
Reviewed-by: Alexandre Ghiti <[email protected]>
Co-developed-by: Palmer Dabbelt <[email protected]>
Signed-off-by: Palmer Dabbelt <[email protected]>
Signed-off-by: Jingwei Wang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
[[email protected]: fix checkpatch issues]
Signed-off-by: Paul Walmsley <[email protected]>
2025-10-17 22:23:11 -06:00
..