Skip to content

[PW_SID:986134] [v6] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot - #701

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

[PW_SID:986134] [v6] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot#701
linux-riscv-bot wants to merge 1 commit into
workflow__riscv__fixesfrom
pw986134

Conversation

@linux-riscv-bot

Copy link
Copy Markdown

PR for series 986134 applied to workflow__riscv__fixes

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

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: "[v6] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
build-rv32-defconfig
Desc: Builds riscv32 defconfig
Duration: 102.22 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v6] 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: 1059.28 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v6] 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: 1546.37 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v6] 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: 18.30 seconds
Result: ERROR
Output:

Full log:
W: Support for running offline not available (unshare: unshare failed: Operation not permitted)
I: config: PASS in 0:00:03.373935
I: default: FAIL in 0:00:10.890111
I: kernel: SKIP in 0:00:00.000008
I: xipkernel: SKIP in 0:00:00.000004
I: modules: SKIP in 0:00:00.001602
I: dtbs: PASS in 0:00:00.756643
I: dtbs-legacy: SKIP in 0:00:00.003336
I: debugkernel: SKIP in 0:00:00.000004
I: headers: PASS in 0:00:01.087693
I: build output in /build/tmp.kapYUvc6RT
tuxmake --download-all-korg-gcc-toolchains --target-arch=riscv --kconfig=nommu_k210_defconfig --toolchain=gcc --wrapper=ccache --environment=KBUILD_BUILD_TIMESTAMP=@1621270510 --environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake --environment=KCFLAGS=-ffile-prefix-map=/build/tmp.kapYUvc6RT/build/= --runtime=null --image=docker.io/tuxmake/riscv_gcc CROSS_COMPILE=riscv64-linux- config default kernel xipkernel modules dtbs dtbs-legacy debugkernel headers
make --silent --keep-going --jobs=48 O=/build/tmp.kapYUvc6RT/build ARCH=riscv CROSS_COMPILE=riscv64-linux- 'CC=ccache riscv64-linux-gcc' 'HOSTCC=ccache gcc' nommu_k210_defconfig
make --silent --keep-going --jobs=48 O=/build/tmp.kapYUvc6RT/build ARCH=riscv CROSS_COMPILE=riscv64-linux- 'CC=ccache riscv64-linux-gcc' 'HOSTCC=ccache gcc'
/build/tmpvc7ujwht/arch/riscv/kernel/sys_hwprobe.c: In function 'do_riscv_hwprobe':
/build/tmpvc7ujwht/arch/riscv/kernel/sys_hwprobe.c:546:9: error: implicit declaration of function 'complete_hwprobe_vdso_data' [-Wimplicit-function-declaration]
  546 |         complete_hwprobe_vdso_data();
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
make[5]: *** [/build/tmpvc7ujwht/scripts/Makefile.build:287: arch/riscv/kernel/sys_hwprobe.o] Error 1
make[5]: Target 'arch/riscv/kernel/' not remade because of errors.
make[4]: *** [/build/tmpvc7ujwht/scripts/Makefile.build:554: arch/riscv/kernel] Error 2
make[4]: Target 'arch/riscv/' not remade because of errors.
make[3]: *** [/build/tmpvc7ujwht/scripts/Makefile.build:554: arch/riscv] Error 2
make[3]: Target './' not remade because of errors.
make[2]: *** [/build/tmpvc7ujwht/Makefile:2003: .] Error 2
make[2]: Target '__all' not remade because of errors.
make[1]: *** [/build/tmpvc7ujwht/Makefile:248: __sub-make] Error 2
make[1]: Target '__all' not remade because of errors.
make: *** [Makefile:248: __sub-make] Error 2
make: Target '__all' not remade because of errors.
make --silent --keep-going --jobs=48 O=/build/tmp.kapYUvc6RT/build INSTALL_DTBS_PATH=/build/tmp.kapYUvc6RT/build/dtbsinstall/dtbs ARCH=riscv CROSS_COMPILE=riscv64-linux- 'CC=ccache riscv64-linux-gcc' 'HOSTCC=ccache gcc' dtbs
rm -rf /build/tmp.kapYUvc6RT/build/dtbsinstall
mkdir -p /build/tmp.kapYUvc6RT/build/dtbsinstall/dtbs
make --silent --keep-going --jobs=48 O=/build/tmp.kapYUvc6RT/build INSTALL_DTBS_PATH=/build/tmp.kapYUvc6RT/build/dtbsinstall/dtbs ARCH=riscv CROSS_COMPILE=riscv64-linux- 'CC=ccache riscv64-linux-gcc' 'HOSTCC=ccache gcc' dtbs_install
tar --sort=name --owner=tuxmake:1000 --group=tuxmake:1000 --mtime=@1753554247 --clamp-mtime -caf /build/tmp.kapYUvc6RT/build/dtbs.tar -C /build/tmp.kapYUvc6RT/build/dtbsinstall dtbs
rm -rf /build/tmp.kapYUvc6RT/build/install_hdr
make --silent --keep-going --jobs=48 O=/build/tmp.kapYUvc6RT/build INSTALL_HDR_PATH=/build/tmp.kapYUvc6RT/build/install_hdr/ ARCH=riscv CROSS_COMPILE=riscv64-linux- 'CC=ccache riscv64-linux-gcc' 'HOSTCC=ccache gcc' headers_install
tar --sort=name --owner=tuxmake:1000 --group=tuxmake:1000 --mtime=@1753554247 --clamp-mtime -caf /build/tmp.kapYUvc6RT/build/headers.tar -C /build/tmp.kapYUvc6RT/build/install_hdr .
warnings/errors:
/build/tmpvc7ujwht/arch/riscv/kernel/sys_hwprobe.c:546:9: error: implicit declaration of function 'complete_hwprobe_vdso_data' [-Wimplicit-function-declaration]


@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v6] 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: 19.85 seconds
Result: ERROR
Output:

Full log:
W: Support for running offline not available (unshare: unshare failed: Operation not permitted)
I: config: PASS in 0:00:03.407358
I: default: FAIL in 0:00:12.146526
I: kernel: SKIP in 0:00:00.000008
I: xipkernel: SKIP in 0:00:00.000005
I: modules: SKIP in 0:00:00.002694
I: dtbs: PASS in 0:00:00.827735
I: dtbs-legacy: SKIP in 0:00:00.004892
I: debugkernel: SKIP in 0:00:00.000004
I: headers: PASS in 0:00:01.125493
I: build output in /build/tmp.tNhaSY5fcZ
tuxmake --download-all-korg-gcc-toolchains --target-arch=riscv --kconfig=nommu_virt_defconfig --toolchain=gcc --wrapper=ccache --environment=KBUILD_BUILD_TIMESTAMP=@1621270510 --environment=KBUILD_BUILD_USER=tuxmake --environment=KBUILD_BUILD_HOST=tuxmake --environment=KCFLAGS=-ffile-prefix-map=/build/tmp.tNhaSY5fcZ/build/= --runtime=null --image=docker.io/tuxmake/riscv_gcc CROSS_COMPILE=riscv64-linux- config default kernel xipkernel modules dtbs dtbs-legacy debugkernel headers
make --silent --keep-going --jobs=48 O=/build/tmp.tNhaSY5fcZ/build ARCH=riscv CROSS_COMPILE=riscv64-linux- 'CC=ccache riscv64-linux-gcc' 'HOSTCC=ccache gcc' nommu_virt_defconfig
make --silent --keep-going --jobs=48 O=/build/tmp.tNhaSY5fcZ/build ARCH=riscv CROSS_COMPILE=riscv64-linux- 'CC=ccache riscv64-linux-gcc' 'HOSTCC=ccache gcc'
/build/tmpvc7ujwht/arch/riscv/kernel/sys_hwprobe.c: In function 'do_riscv_hwprobe':
/build/tmpvc7ujwht/arch/riscv/kernel/sys_hwprobe.c:546:9: error: implicit declaration of function 'complete_hwprobe_vdso_data' [-Wimplicit-function-declaration]
  546 |         complete_hwprobe_vdso_data();
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~
make[5]: *** [/build/tmpvc7ujwht/scripts/Makefile.build:287: arch/riscv/kernel/sys_hwprobe.o] Error 1
make[5]: Target 'arch/riscv/kernel/' not remade because of errors.
make[4]: *** [/build/tmpvc7ujwht/scripts/Makefile.build:554: arch/riscv/kernel] Error 2
make[4]: Target 'arch/riscv/' not remade because of errors.
make[3]: *** [/build/tmpvc7ujwht/scripts/Makefile.build:554: arch/riscv] Error 2
make[3]: Target './' not remade because of errors.
make[2]: *** [/build/tmpvc7ujwht/Makefile:2003: .] Error 2
make[2]: Target '__all' not remade because of errors.
make[1]: *** [/build/tmpvc7ujwht/Makefile:248: __sub-make] Error 2
make[1]: Target '__all' not remade because of errors.
make: *** [Makefile:248: __sub-make] Error 2
make: Target '__all' not remade because of errors.
make --silent --keep-going --jobs=48 O=/build/tmp.tNhaSY5fcZ/build INSTALL_DTBS_PATH=/build/tmp.tNhaSY5fcZ/build/dtbsinstall/dtbs ARCH=riscv CROSS_COMPILE=riscv64-linux- 'CC=ccache riscv64-linux-gcc' 'HOSTCC=ccache gcc' dtbs
rm -rf /build/tmp.tNhaSY5fcZ/build/dtbsinstall
mkdir -p /build/tmp.tNhaSY5fcZ/build/dtbsinstall/dtbs
make --silent --keep-going --jobs=48 O=/build/tmp.tNhaSY5fcZ/build INSTALL_DTBS_PATH=/build/tmp.tNhaSY5fcZ/build/dtbsinstall/dtbs ARCH=riscv CROSS_COMPILE=riscv64-linux- 'CC=ccache riscv64-linux-gcc' 'HOSTCC=ccache gcc' dtbs_install
tar --sort=name --owner=tuxmake:1000 --group=tuxmake:1000 --mtime=@1753554247 --clamp-mtime -caf /build/tmp.tNhaSY5fcZ/build/dtbs.tar -C /build/tmp.tNhaSY5fcZ/build/dtbsinstall dtbs
rm -rf /build/tmp.tNhaSY5fcZ/build/install_hdr
make --silent --keep-going --jobs=48 O=/build/tmp.tNhaSY5fcZ/build INSTALL_HDR_PATH=/build/tmp.tNhaSY5fcZ/build/install_hdr/ ARCH=riscv CROSS_COMPILE=riscv64-linux- 'CC=ccache riscv64-linux-gcc' 'HOSTCC=ccache gcc' headers_install
tar --sort=name --owner=tuxmake:1000 --group=tuxmake:1000 --mtime=@1753554247 --clamp-mtime -caf /build/tmp.tNhaSY5fcZ/build/headers.tar -C /build/tmp.tNhaSY5fcZ/build/install_hdr .
warnings/errors:
/build/tmpvc7ujwht/arch/riscv/kernel/sys_hwprobe.c:546:9: error: implicit declaration of function 'complete_hwprobe_vdso_data' [-Wimplicit-function-declaration]


@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v6] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
checkpatch
Desc: Runs checkpatch.pl on the patch
Duration: 2.49 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: Please use a blank line after function/struct/union/enum declarations
#48: FILE: arch/riscv/include/asm/hwprobe.h:43:
 }
+#ifdef CONFIG_MMU

CHECK: Alignment should match open parenthesis
#168: FILE: arch/riscv/kernel/sys_hwprobe.c:542:
+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, 4 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 e19e3a016fdf ("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, 4 checks, 158 lines checked
CHECK: Alignment should match open parenthesis
CHECK: Please use a blank line after function/struct/union/enum declarations
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: "[v6] riscv: hwprobe: Fix stale vDSO data for late-initialized keys at boot"
dtb-warn-rv64
Desc: Checks for Device Tree warnings/errors
Duration: 71.32 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v6] 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.41 seconds
Result: PASS

@linux-riscv-bot

Copy link
Copy Markdown
Author

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

@linux-riscv-bot

Copy link
Copy Markdown
Author

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

@linux-riscv-bot

Copy link
Copy Markdown
Author

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

@linux-riscv-bot

Copy link
Copy Markdown
Author

Patch 1: "[v6] 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 pw986134 branch July 28, 2025 01:13
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