From: Alistair Francis <alistair23@gmail.com>
To: Nicholas Piggin <npiggin@gmail.com>
Cc: qemu-riscv@nongnu.org, qemu-devel@nongnu.org,
Laurent Vivier <laurent@vivier.eu>,
Pierrick Bouvier <pierrick.bouvier@linaro.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <alistair.francis@wdc.com>,
Weiwei Li <liwei1518@gmail.com>,
Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
Richard Henderson <richard.henderson@linaro.org>,
Joel Stanley <joel@jms.id.au>
Subject: Re: [PATCH v3 2/5] linux-user/riscv: Allow restore_sigcontext to return error
Date: Wed, 25 Mar 2026 13:07:50 +1000 [thread overview]
Message-ID: <CAKmqyKPzEpAT_4gOJBfamV_7m4uVCR5681Lb9GiQYur+hqQLZA@mail.gmail.com> (raw)
In-Reply-To: <20260321141345.599105-3-npiggin@gmail.com>
On Sun, Mar 22, 2026 at 12:16 AM Nicholas Piggin <npiggin@gmail.com> wrote:
>
> Linux can return error from restore_sigcontext in some conditions, which
> forces a SIGSEGV. Plumb through this error handling which will be used
> by the next change.
>
> Suggested-by: Richard Henderson <richard.henderson@linaro.org>
> Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> linux-user/riscv/signal.c | 13 +++++++++----
> 1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/linux-user/riscv/signal.c b/linux-user/riscv/signal.c
> index 22b1b8149f..ece276f85f 100644
> --- a/linux-user/riscv/signal.c
> +++ b/linux-user/riscv/signal.c
> @@ -145,7 +145,7 @@ badframe:
> force_sig(TARGET_SIGSEGV);
> }
>
> -static void restore_sigcontext(CPURISCVState *env, struct target_sigcontext *sc)
> +static bool restore_sigcontext(CPURISCVState *env, struct target_sigcontext *sc)
> {
> int i;
>
> @@ -161,9 +161,11 @@ static void restore_sigcontext(CPURISCVState *env, struct target_sigcontext *sc)
> uint32_t fcsr;
> __get_user(fcsr, &sc->fcsr);
> riscv_csr_write(env, CSR_FCSR, fcsr);
> +
> + return true;
> }
>
> -static void restore_ucontext(CPURISCVState *env, struct target_ucontext *uc)
> +static bool restore_ucontext(CPURISCVState *env, struct target_ucontext *uc)
> {
> sigset_t blocked;
> target_sigset_t target_set;
> @@ -177,7 +179,7 @@ static void restore_ucontext(CPURISCVState *env, struct target_ucontext *uc)
> target_to_host_sigset_internal(&blocked, &target_set);
> set_sigmask(&blocked);
>
> - restore_sigcontext(env, &uc->uc_mcontext);
> + return restore_sigcontext(env, &uc->uc_mcontext);
> }
>
> long do_rt_sigreturn(CPURISCVState *env)
> @@ -191,7 +193,10 @@ long do_rt_sigreturn(CPURISCVState *env)
> goto badframe;
> }
>
> - restore_ucontext(env, &frame->uc);
> + if (!restore_ucontext(env, &frame->uc)) {
> + goto badframe;
> + }
> +
> target_restore_altstack(&frame->uc.uc_stack, env);
>
> unlock_user_struct(frame, frame_addr, 0);
> --
> 2.51.0
>
>
next prev parent reply other threads:[~2026-03-25 3:08 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-21 14:13 [PATCH v3 0/5] linux-user/riscv: add vector state to signal context Nicholas Piggin
2026-03-21 14:13 ` [PATCH v3 1/5] tests/tcg/riscv64: Add a user signal handling test Nicholas Piggin
2026-03-25 3:07 ` Alistair Francis
2026-03-21 14:13 ` [PATCH v3 2/5] linux-user/riscv: Allow restore_sigcontext to return error Nicholas Piggin
2026-03-25 3:07 ` Alistair Francis [this message]
2026-03-21 14:13 ` [PATCH v3 3/5] linux-user/riscv: Add extended state to sigcontext Nicholas Piggin
2026-03-25 3:14 ` Alistair Francis
2026-03-21 14:13 ` [PATCH v3 4/5] linux-user/riscv: Add vector state to signal context Nicholas Piggin
2026-03-25 3:45 ` Alistair Francis
2026-03-21 14:13 ` [PATCH v3 5/5] tests/tcg/riscv64: Add vector state to signal test Nicholas Piggin
2026-03-25 3:49 ` Alistair Francis
2026-03-25 4:45 ` [PATCH v3 0/5] linux-user/riscv: add vector state to signal context Alistair Francis
2026-03-26 6:22 ` Nicholas Piggin
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=CAKmqyKPzEpAT_4gOJBfamV_7m4uVCR5681Lb9GiQYur+hqQLZA@mail.gmail.com \
--to=alistair23@gmail.com \
--cc=alistair.francis@wdc.com \
--cc=dbarboza@ventanamicro.com \
--cc=joel@jms.id.au \
--cc=laurent@vivier.eu \
--cc=liwei1518@gmail.com \
--cc=npiggin@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pierrick.bouvier@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=zhiwei_liu@linux.alibaba.com \
/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