riscv: signal: fix the FP state restore in rt_sigreturn()
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest2 patches 0 repliesNew
- v22 patches 2 repliesSuperseded
- v11 patch 2 repliesSuperseded
Changes in v3 from the cover letter
- selftest: load the tgkill() arguments inside the asm statement. v2 bound them to local register variables, which GCC does not keep across the sigaltstack() call before the asm, so the signal was never sent and the test failed with or without patch 1 (Andy Chiu).
- Rebased onto v7.4-rc3.
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/2 | riscv: signal: mark the FP state clean before restoring it from the framearch/ | +7 | 0 replies | |
| 2/2 | selftests: riscv: test FP state restore when rt_sigreturn() faultstools/ tools/ tools/ | +152 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH v3 0/2] riscv: signal: fix the FP state restore in rt_sigreturn()
If rt_sigreturn() is preempted or sleeps on a page fault while it copies the FP registers from the signal frame, the interrupted code resumes with the signal handler's FP registers. Patch 1 fixes this, patch 2 adds a selftest that reproduces it with userfaultfd.
Tested under QEMU with riscv64 defconfig plus CONFIG_USERFAULTFD: the new test, built with GCC 15 through the kselftest Makefile and with clang 21, fails 10 of 10 runs without patch 1 and passes 10 of 10 with it.
This series was prepared with the help of an AI tool.
Changes in v3:
- selftest: load the tgkill() arguments inside the asm statement. v2 bound them to local register variables, which GCC does not keep across the sigaltstack() call before the asm, so the signal was never sent and the test failed with or without patch 1 (Andy Chiu).
- Rebased onto v7.4-rc3.
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/
Nickolai Zeldovich (2):
riscv: signal: mark the FP state clean before restoring it from the
frame
selftests: riscv: test FP state restore when rt_sigreturn() faults
arch/riscv/kernel/signal.c | 7 + .../selftests/riscv/sigreturn/.gitignore | 1 + .../selftests/riscv/sigreturn/Makefile | 5 +- .../selftests/riscv/sigreturn/fp_restore.c | 147 ++++++++++++++++++ 4 files changed, 159 insertions(+), 1 deletion(-) create mode 100644 tools/testing/selftests/riscv/sigreturn/fp_restore.c
base-commit: aebb7274476403040d582c61478df8f4a7bf9cd3
Signature · 1 line
2.53.0