Skip to content

[PW_SID:986268] [v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot - #702

Closed
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw986268
Closed

[PW_SID:986268] [v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot#702
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw986268

Conversation

@linux-riscv-bot

Copy link
Copy Markdown

PR for series 986268 applied to workflow__riscv__fixes

Name: [v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot
URL: https://patchwork.kernel.org/project/linux-riscv/list/?series=986268
Version: 7

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 late_initcall. 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: e7c9d66 ("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

Co-developed-by: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Jingwei Wang <wangjingwei@iscas.ac.cn>
Signed-off-by: Linux RISC-V bot <linux.riscv.bot@gmail.com>
@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 107.46 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
build-rv64-clang-allmodconfig
Desc: Builds riscv64 allmodconfig with Clang, and checks for errors and added warnings
Duration: 1116.38 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
build-rv64-gcc-allmodconfig
Desc: Builds riscv64 allmodconfig with GCC, and checks for errors and added warnings
Duration: 1709.45 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
build-rv64-nommu-k210-defconfig
Desc: Builds riscv64 defconfig with NOMMU for K210
Duration: 21.29 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
build-rv64-nommu-k210-virt
Desc: Builds riscv64 defconfig with NOMMU for the virt platform
Duration: 22.79 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 2.50 seconds
Result: WARNING
Output:

WARNING: Co-developed-by and Signed-off-by: name/email do not match
#28: 
Co-developed-by: Palmer Dabbelt <palmer@dabbelt.com>
Signed-off-by: Jingwei Wang <wangjingwei@iscas.ac.cn>

CHECK: Alignment should match open parenthesis
#168: FILE: arch/riscv/kernel/sys_hwprobe.c:543:
+static int do_riscv_hwprobe(struct riscv_hwprobe __user *pairs,
+			     size_t pair_count, size_t cpusetsize,

CHECK: Alignment should match open parenthesis
#205: FILE: arch/riscv/kernel/unaligned_access_speed.c:479:
+		if (IS_ERR(kthread_run(vec_check_unaligned_access_speed_all_cpus,
+			   NULL, "vec_check_unaligned_access_speed_all_cpus"))) {

CHECK: Unnecessary parentheses around 'flags != 0'
#221: FILE: arch/riscv/kernel/vdso/hwprobe.c:30:
+	if ((flags != 0) || (!all_cpus && !avd->homogeneous_cpus) || unlikely(!avd->ready))

total: 0 errors, 1 warnings, 3 checks, 158 lines checked

NOTE: For some of the reported defects, checkpatch may be able to
      mechanically convert to the typical style using --fix or --fix-inplace.

Commit 19d44c55c121 ("riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot") has style problems, please review.

NOTE: Ignored message types: ALLOC_SIZEOF_STRUCT CAMELCASE COMMIT_LOG_LONG_LINE GIT_COMMIT_ID MACRO_ARG_REUSE NO_AUTHOR_SIGN_OFF

NOTE: If any of the errors are false positives, please report
      them to the maintainer, see CHECKPATCH in MAINTAINERS.
total: 0 errors, 1 warnings, 3 checks, 158 lines checked
CHECK: Alignment should match open parenthesis
CHECK: Unnecessary parentheses around 'flags != 0'
WARNING: Co-developed-by and Signed-off-by: name/email do not match


@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 72.81 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
header-inline
Desc: Detects static functions without inline keyword in header files
Duration: 0.24 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
kdoc
Desc: Detects for kdoc errors
Duration: 0.82 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
module-param
Desc: Detect module_param changes
Duration: 0.26 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
verify-fixes
Desc: Verifies that the Fixes: tags exist
Duration: 0.29 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v7] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
verify-signedoff
Desc: Verifies that Signed-off-by: tags are correct
Duration: 0.30 seconds
Result: PASS

@linux-riscv-bot
linux-riscv-bot deleted the pw986268 branch August 5, 2025 01:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants