]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
RISC-V: vDSO: Correct inline assembly constraints in the getrandom syscall wrapper
authorXi Ruoyao <xry111@xry111.site>
Fri, 6 Jun 2025 09:24:44 +0000 (17:24 +0800)
committerPalmer Dabbelt <palmer@dabbelt.com>
Thu, 12 Jun 2025 19:13:57 +0000 (12:13 -0700)
commit2b9518684f8558cd61a7c608cc03a27822cf7b03
tree202541799c0991c1551b8ce071baa08b4d12a5bf
parent4262bd0d9cc704ea1365ac00afc1272400c2cbef
RISC-V: vDSO: Correct inline assembly constraints in the getrandom syscall wrapper

As recently pointed out by Thomas, if a register is forced for two
different register variables, among them one is used as "+" (both input
and output) and another is only used as input, Clang would treat the
conflicting input parameters as undefined behaviour and optimize away
the argument assignment.

Instead use "=r" (only output) for the output parameter and "r" (only
input) for the input parameter.
While the example from the GCC documentation uses "0" for the input
parameter, this is not necessary as confirmed by the GCC developers and "r"
matches what the other architectures' vDSO implementations are using.

[ alex: Update log to match v2 (Thomas) ]

Link: https://lore.kernel.org/all/20250603-loongarch-vdso-syscall-v1-1-6d12d6dfbdd0@linutronix.de/
Link: https://gcc.gnu.org/onlinedocs/gcc-15.1.0/gcc/Local-Register-Variables.html
Link: https://gcc.gnu.org/pipermail/gcc-help/2025-June/144266.html
Cc: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Cc: Nathan Chancellor <nathan@kernel.org>
Signed-off-by: Xi Ruoyao <xry111@xry111.site>
Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Fixes: ee0d03053e70 ("RISC-V: vDSO: Wire up getrandom() vDSO")
Link: https://lore.kernel.org/r/20250606092443.73650-2-xry111@xry111.site
Signed-off-by: Alexandre Ghiti <alexghiti@rivosinc.com>
Signed-off-by: Palmer Dabbelt <palmer@dabbelt.com>
arch/riscv/include/asm/vdso/getrandom.h