mirror-linux/arch/riscv/include/asm
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 <research_trasio@irq.a4lg.com>
Closes: https://lore.kernel.org/linux-riscv/760d637b-b13b-4518-b6bf-883d55d44e7f@irq.a4lg.com/
Fixes: e7c9d66e31 ("RISC-V: Report vector unaligned access speed hwprobe")
Cc: Palmer Dabbelt <palmer@dabbelt.com>
Cc: Alexandre Ghiti <alexghiti@rivosinc.com>
Cc: Olof Johansson <olof@lixom.net>
Cc: stable@vger.kernel.org
Reviewed-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Co-developed-by: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Jingwei Wang <wangjingwei@iscas.ac.cn>
Link: https://lore.kernel.org/r/20250811142035.105820-1-wangjingwei@iscas.ac.cn
[pjw@kernel.org: fix checkpatch issues]
Signed-off-by: Paul Walmsley <pjw@kernel.org>
2025-10-17 22:23:11 -06:00
..
vdso riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot 2025-10-17 22:23:11 -06:00
vendor_extensions riscv: hwprobe: Add MIPS vendor extension probing 2025-09-19 10:33:56 -06:00
Kbuild fprobe: Add fprobe_header encoding feature 2024-12-26 10:50:05 -05:00
acenv.h
acpi.h ACPI: RISCV: Make acpi_numa_get_nid() to be static 2024-09-17 12:02:48 -07:00
alternative-macros.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
alternative.h riscv: errata: Fix the PAUSE Opcode for MIPS P8700 2025-09-19 10:33:56 -06:00
arch_hweight.h RISC-V: separate Zbb optimisations requiring and not requiring toolchain support 2025-03-18 08:53:02 +00:00
archrandom.h
asm-extable.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
asm-offsets.h
asm-prototypes.h RISC-V Patches for the 6.16 Merge Window, Part 1 2025-06-06 18:05:18 -07:00
asm.h riscv: Remove the PER_CPU_OFFSET_SHIFT macro 2025-10-17 22:00:29 -06:00
assembler.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
atomic.h Merge patch series "Rework & improve riscv cmpxchg.h and atomic.h" 2024-04-28 14:50:33 -07:00
barrier.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
bitops.h riscv: Add __attribute_const__ to ffs()-family implementations 2025-09-08 14:58:51 -07:00
bug.h riscv/bug: Add ARCH_WARN_ASM macro for BUG/WARN asm code sharing with Rust 2025-07-23 00:04:53 +02:00
bugs.h riscv: Add ghostwrite vulnerability 2025-01-18 12:33:39 -08:00
cache.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
cacheflush.h mm: introduce memdesc_flags_t 2025-09-13 16:55:07 -07:00
cacheinfo.h
cfi.h kcfi: Rename CONFIG_CFI_CLANG to CONFIG_CFI 2025-09-24 14:29:14 -07:00
checksum.h RISC-V: separate Zbb optimisations requiring and not requiring toolchain support 2025-03-18 08:53:02 +00:00
clint.h
clocksource.h
cmpxchg.h bpf-next-6.18 2025-09-30 17:58:11 -07:00
compat.h RISC-V: Remove unnecessary include from compat.h 2024-11-26 11:48:53 -08:00
cpu.h
cpu_ops.h
cpu_ops_sbi.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
cpufeature-macros.h riscv: Move cpufeature.h macros into their own header 2024-11-11 07:33:08 -08:00
cpufeature.h riscv: add a forward declaration for cpuinfo_op 2025-10-17 22:10:01 -06:00
cpuidle.h
crash_reserve.h
csr.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
current.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
delay.h
dma-noncoherent.h
dmi.h riscv: dmi: Add SMBIOS/DMI support 2024-06-26 08:02:33 -07:00
efi.h
elf.h riscv: Introduce set_compat_task() in asm/compat.h 2024-03-19 16:39:40 -07:00
entry-common.h riscv: Fix default misaligned access trap 2024-11-12 14:45:26 -08:00
errata_list.h riscv: errata: Fix the PAUSE Opcode for MIPS P8700 2025-09-19 10:33:56 -06:00
errata_list_vendors.h riscv: errata: Fix the PAUSE Opcode for MIPS P8700 2025-09-19 10:33:56 -06:00
exec.h riscv: Randomize lower bits of stack address 2024-09-17 08:05:10 -07:00
extable.h
fence.h riscv: Add license to fence.h 2024-09-03 07:18:33 -07:00
fixmap.h
fpu.h riscv: add support for kernel-mode FPU 2024-05-19 14:36:19 -07:00
ftrace.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
futex.h riscv/futex: sign extend compare value in atomic cmpxchg 2025-02-14 13:06:31 -08:00
gdb_xml.h
gpr-num.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
hugetlb.h mm: introduce memdesc_flags_t 2025-09-13 16:55:07 -07:00
hwcap.h riscv: Add support for Zicbop 2025-06-05 11:09:37 -07:00
hwprobe.h riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot 2025-10-17 22:23:11 -06:00
image.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
insn-def.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
insn.h riscv: kprobes: Move branch_funct3 to insn.h 2025-09-16 18:46:43 -06:00
io.h riscv: introduce ioremap_wc() 2025-09-16 16:24:27 -06:00
irq.h ACPI: RISC-V: Add RPMI System MSI to GSI mapping 2025-09-25 19:49:09 -06:00
irq_stack.h
irq_work.h
irqflags.h riscv: Remove unnecessary irqflags processor.h include 2024-04-16 18:50:52 -07:00
jump_label.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
kasan.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
kdebug.h
kexec.h riscv: kexec_file: Support loading Image binary file 2025-06-05 11:09:34 -07:00
kfence.h riscv: Fix IPIs usage in kfence_protect_page() 2024-12-11 11:44:03 -08:00
kgdb.h riscv: kgdb: Ensure that BUFMAX > NUMREGBYTES 2025-10-09 19:36:45 -06:00
kprobes.h
kvm_aia.h RISC-V: KVM: Drop the return value of kvm_riscv_vcpu_aia_init() 2025-07-28 22:27:07 +05:30
kvm_gstage.h RISC-V: KVM: Factor-out g-stage page table management 2025-07-28 22:27:30 +05:30
kvm_host.h RISC-V: KVM: add support for FWFT SBI extension 2025-09-08 09:52:57 +05:30
kvm_mmu.h RISC-V: KVM: Factor-out g-stage page table management 2025-07-28 22:27:30 +05:30
kvm_nacl.h RISC-V: KVM: Use SBI sync SRET call when available 2024-10-28 16:44:03 +05:30
kvm_tlb.h RISC-V: KVM: Pass VMID as parameter to kvm_riscv_hfence_xyz() APIs 2025-07-28 22:27:32 +05:30
kvm_types.h
kvm_vcpu_fp.h
kvm_vcpu_insn.h
kvm_vcpu_pmu.h RISC-V: KVM: Implement get event info function 2025-09-16 11:49:31 +05:30
kvm_vcpu_sbi.h RISC-V: KVM: Upgrade the supported SBI version to 3.0 2025-09-16 11:49:31 +05:30
kvm_vcpu_sbi_fwft.h RISC-V: KVM: Implement ONE_REG interface for SBI FWFT state 2025-09-16 10:54:21 +05:30
kvm_vcpu_timer.h
kvm_vcpu_vector.h KVM: RISC-V: refactor vector state reset 2025-05-21 09:34:46 +05:30
kvm_vmid.h RISC-V: KVM: Factor-out MMU related declarations into separate headers 2025-07-28 22:27:23 +05:30
linkage.h
membarrier.h
mmio.h riscv/barrier: Consolidate fence definitions 2024-03-19 18:52:24 -07:00
mmiowb.h riscv/barrier: Consolidate fence definitions 2024-03-19 18:52:24 -07:00
mmu.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
mmu_context.h riscv: Add support for the tagged address ABI 2024-10-24 14:12:56 -07:00
module.h
module.lds.h
numa.h
page.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
paravirt.h
paravirt_api_clock.h
pci.h
perf_event.h The biggest change here is eliminating the awful idea that KVM had, of 2024-11-23 16:00:50 -08:00
pgalloc.h riscv: pgtable: unconditionally use tlb_remove_ptdesc() 2025-04-01 15:17:14 -07:00
pgtable-32.h
pgtable-64.h riscv: mm: Define MAX_POSSIBLE_PHYSMEM_BITS for zsmalloc 2025-10-17 22:00:29 -06:00
pgtable-bits.h mm: remove devmap related functions and page table bits 2025-07-09 22:42:18 -07:00
pgtable.h RISC-V: Define pgprot_dmacoherent() for non-coherent devices 2025-10-17 21:30:05 -06:00
probes.h
processor.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
ptrace.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
runtime-const.h riscv: fix runtime constant support for nommu kernels 2025-06-10 18:19:33 -07:00
sbi.h RISC-V updates for the v6.18 merge window (part two) 2025-10-04 10:36:22 -07:00
scs.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
seccomp.h
sections.h
semihost.h
set_memory.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
signal32.h
simd.h riscv: vector: Fix a typo of preempt_v 2024-03-15 10:17:38 -07:00
smp.h riscv: Use IPIs for remote cache/TLB flushes by default 2024-04-29 10:49:26 -07:00
soc.h
sparsemem.h RISC-V: Don't have MAX_PHYSMEM_BITS exceed phys_addr_t 2024-09-20 01:32:39 -07:00
spinlock.h riscv: qspinlock: Fixup _Q_PENDING_LOOPS definition 2025-01-08 10:46:01 -08:00
stackprotector.h
stacktrace.h
string.h riscv: Omit optimized string routines when using KASAN 2024-09-19 01:10:00 -07:00
suspend.h riscv: Add stimecmp save and restore 2025-03-18 12:59:03 +00:00
swab.h riscv: introduce asm/swab.h 2025-09-18 08:20:25 -06:00
switch_to.h riscv: vector: Support xtheadvector save/restore 2025-01-18 12:33:33 -08:00
sync_core.h
syscall.h syscall.h: introduce syscall_set_nr() 2025-05-11 17:48:15 -07:00
syscall_table.h riscv: convert to generic syscall table 2024-07-10 14:23:38 +02:00
syscall_wrapper.h riscv: Mark __se_sys_* functions __used 2024-03-26 14:11:03 -07:00
text-patching.h asm-generic: introduce text-patching.h 2024-11-07 14:25:15 -08:00
thread_info.h A set of changes to consolidate the generic TIF bits accross architectures 2025-09-30 14:36:20 -07:00
timex.h
tlb.h mm: pgtable: introduce generic __tlb_remove_table() 2025-01-25 20:22:23 -08:00
tlbbatch.h
tlbflush.h mm: remove arch_flush_tlb_batched_pending() arch helper 2025-07-24 19:12:32 -07:00
topology.h arch, mm: move definition of node_data to generic code 2024-09-03 21:15:28 -07:00
trace.h riscv: Add tracepoints for SBI calls and returns 2024-07-10 13:23:09 -07:00
uaccess.h riscv: Fix sparse warning about different address spaces 2025-09-05 15:33:52 -06:00
unistd.h riscv: convert to generic syscall table 2024-07-10 14:23:38 +02:00
uprobes.h asm-generic: introduce text-patching.h 2024-11-07 14:25:15 -08:00
vdso.h riscv: Replace __ASSEMBLY__ with __ASSEMBLER__ in non-uapi headers 2025-09-16 16:25:30 -06:00
vector.h riscv: vector: Fix context save/restore with xtheadvector 2025-06-12 12:13:47 -07:00
vendor_extensions.h riscv: cpufeature: Extract common elements from extension checking 2024-07-22 15:36:57 -07:00
vendorid_list.h riscv: Add xmipsexectl as a vendor extension 2025-09-18 20:36:00 -06:00
vermagic.h
vmalloc.h riscv: Add license to vmalloc.h 2024-09-03 07:18:34 -07:00
word-at-a-time.h
xip_fixup.h riscv: drop the use of XIP_OFFSET in XIP_FIXUP_FLASH_OFFSET 2024-09-12 07:22:59 -07:00
xor.h