mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nickolai Zeldovich <nickolai@csail.mit.edu>
To: Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>
Cc: Alexandre Ghiti <alex@ghiti.fr>, Andy Chiu <andybnac@gmail.com>,
	Guobin Zhang <guobin.zhang@intel.com>,
	Deepak Gupta <debug@rivosinc.com>, Shuah Khan <shuah@kernel.org>,
	linux-riscv@lists.infradead.org, linux-kselftest@vger.kernel.org,
	linux-kernel@vger.kernel.org,
	Nickolai Zeldovich <nickolai@csail.mit.edu>
Subject: [PATCH v3 0/2] riscv: signal: fix the FP state restore in rt_sigreturn()
Date: Sun, 15 Nov 2026 21:35:32 -0500	[thread overview]
Message-ID: <20261116023534.50074-1-nickolai@csail.mit.edu> (raw)

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/20261031161826.858908-1-nickolai@csail.mit.edu/
v1: https://lore.kernel.org/all/20261016160708.790397-1-nickolai@csail.mit.edu/

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
-- 
2.53.0


             reply	other threads:[~2026-11-16  2:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-16  2:35 Nickolai Zeldovich [this message]
2026-11-16  2:35 ` [PATCH v3 1/2] riscv: signal: mark the FP state clean before restoring it from the frame Nickolai Zeldovich
2026-11-16  2:35 ` [PATCH v3 2/2] selftests: riscv: test FP state restore when rt_sigreturn() faults Nickolai Zeldovich

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261116023534.50074-1-nickolai@csail.mit.edu \
    --to=nickolai@csail.mit.edu \
    --cc=alex@ghiti.fr \
    --cc=andybnac@gmail.com \
    --cc=aou@eecs.berkeley.edu \
    --cc=debug@rivosinc.com \
    --cc=guobin.zhang@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-kselftest@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=shuah@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®