From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 51EF3C433EF for ; Sat, 22 Jan 2022 22:22:03 +0000 (UTC) Received: from localhost ([::1]:48284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nBOlm-00009E-0Y for qemu-devel@archiver.kernel.org; Sat, 22 Jan 2022 17:22:02 -0500 Received: from eggs.gnu.org ([209.51.188.92]:39458) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nBOk9-0007oL-0Y for qemu-devel@nongnu.org; Sat, 22 Jan 2022 17:20:21 -0500 Received: from [2607:f8b0:4864:20::932] (port=45898 helo=mail-ua1-x932.google.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nBOk6-0000j8-E4 for qemu-devel@nongnu.org; Sat, 22 Jan 2022 17:20:20 -0500 Received: by mail-ua1-x932.google.com with SMTP id b37so6028569uad.12 for ; Sat, 22 Jan 2022 14:20:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20210112.gappssmtp.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=juBjm1na1Gh03Xtp1LqMDrCiDLQ/pgKM5SI5sB+EhEc=; b=uqOfP4g2eY96+c31BTGcb6nlC35tSXN7RiCCskIToii7xPZWwTeciGyfK/bYWYDHzz huDnzygZhyO8L5dKXAajlt6vPrRTArq8aFBS3Gp3B8GNurIyayQ4PDs918Zb0Johie2U Svxqhcp2NHO8ExIQqx3PHGFnULHxIhxm3SOBUBroy7A5G/MQaYkQUULzG3SoZoLMteKl Jg86dgOTBPe6TTV85/0g4SU47WsCQe/Wvd/A2FSni7iER6zTuPzC5zc2+ihYcQWyQM8G uZ2YnlGL/Pev0pPAb9cTkbeih0CrKzE5XbVGZhw0t4NiNG2cR+iH49jU12ZhQwZvVVq7 7RTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=juBjm1na1Gh03Xtp1LqMDrCiDLQ/pgKM5SI5sB+EhEc=; b=iq44ohGhSxd/hJiEQNCge1SvdgJlYzWDuHwFI84gs4/yXO9ll1Vm6eByUXBMf8IDwr Wbp0ZaIgTB1JDuRwhEigBC/TkjOcAcClE8GR6Hxrxz8hVmXEBQPphWw0wCdA8NVnLtE9 uxw4FxZV7gG5VcAYsPYop3umHLdm46qWSGoLgVv3OlqbrrnAfS+Rmgs4a8aQWX46fTsN Udr/GRUiLFNPHK3boY2W+Jo+E7d5Xd4FrC029zD6dPWI5gzRGpFFfcaFsZm46CCflnMM +OrjorOSOGZ1gwWUI7vjU3VR+3qYts8LM6wUnDGjwo11P0Z+h19PBGOcOJaHWz2Pr2nE iOBw== X-Gm-Message-State: AOAM530unJQlSQcoQ0n9TsKI19PUcfCvzYGpPPFh0ksDPXvp0JCgEoe0 zGDfajwtvCW+4Xw7xhlNAGb//YtVo/SsR93g9m4lrA== X-Google-Smtp-Source: ABdhPJz8VZnIm6dxWdh9KaVNW4ckwmCjV4i9IDXmwrKMBxa0ilgZhmmFB8m2RllJeMo6NOPCHHqzTPvUB/yJKy/KVZ8= X-Received: by 2002:a9f:2a8e:: with SMTP id z14mr3752027uai.85.1642890016828; Sat, 22 Jan 2022 14:20:16 -0800 (PST) MIME-Version: 1.0 References: <20220109161923.85683-1-imp@bsdimp.com> <20220109161923.85683-31-imp@bsdimp.com> In-Reply-To: From: Warner Losh Date: Sat, 22 Jan 2022 15:20:05 -0700 Message-ID: Subject: Re: [PATCH 30/30] bsd-user/signal.c: do_sigaltstack To: Peter Maydell Content-Type: multipart/alternative; boundary="000000000000dbc30605d63323ee" X-Host-Lookup-Failed: Reverse DNS lookup failed for 2607:f8b0:4864:20::932 (failed) Received-SPF: none client-ip=2607:f8b0:4864:20::932; envelope-from=wlosh@bsdimp.com; helo=mail-ua1-x932.google.com X-Spam_score_int: -10 X-Spam_score: -1.1 X-Spam_bar: - X-Spam_report: (-1.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, HTML_MESSAGE=0.001, PDS_HP_HELO_NORDNS=0.001, RCVD_IN_DNSWL_NONE=-0.0001, RDNS_NONE=0.793, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kyle Evans , Stacey Son , QEMU Developers Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" --000000000000dbc30605d63323ee Content-Type: text/plain; charset="UTF-8" On Fri, Jan 14, 2022 at 6:18 AM Peter Maydell wrote: > On Sun, 9 Jan 2022 at 17:08, Warner Losh wrote: > > > > Implement the meat of the sigaltstack(2) system call with do_sigaltstack. > > > > Signed-off-by: Stacey Son > > Signed-off-by: Kyle Evans > > Signed-off-by: Warner Losh > > --- > > bsd-user/qemu.h | 1 + > > bsd-user/signal.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++ > > 2 files changed, 67 insertions(+) > > > > diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h > > index c643d6ba246..fcdea460ed2 100644 > > --- a/bsd-user/qemu.h > > +++ b/bsd-user/qemu.h > > @@ -226,6 +226,7 @@ int host_to_target_signal(int sig); > > void host_to_target_sigset(target_sigset_t *d, const sigset_t *s); > > void target_to_host_sigset(sigset_t *d, const target_sigset_t *s); > > long do_sigreturn(CPUArchState *regs, abi_ulong addr); > > +abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, > abi_ulong sp); > > int do_sigaction(int sig, const struct target_sigaction *act, > > struct target_sigaction *oact); > > void QEMU_NORETURN force_sig(int target_sig); > > diff --git a/bsd-user/signal.c b/bsd-user/signal.c > > index f055d1db407..e5e5e28c60c 100644 > > --- a/bsd-user/signal.c > > +++ b/bsd-user/signal.c > > @@ -528,6 +528,72 @@ static void host_signal_handler(int host_sig, > siginfo_t *info, void *puc) > > cpu_exit(thread_cpu); > > } > > > > +/* do_sigaltstack() returns target values and errnos. */ > > +/* compare to kern/kern_sig.c sys_sigaltstack() and kern_sigaltstack() > */ > > +abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, > abi_ulong sp) > > +{ > > + int ret; > > + target_stack_t oss; > > + > > + if (uoss_addr) { > > + /* Save current signal stack params */ > > + oss.ss_sp = tswapl(target_sigaltstack_used.ss_sp); > > + oss.ss_size = tswapl(target_sigaltstack_used.ss_size); > > + oss.ss_flags = tswapl(sas_ss_flags(sp)); > > + } > > This will need some minor changes to work with the sigaltstack > info being per-thread and in the TaskState struct. > Yes. Moving it into the TaskState was easy and got rid if the global. Thanks for that suggestion earlier in the patch series. Warrner --000000000000dbc30605d63323ee Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable


=
On Fri, Jan 14, 2022 at 6:18 AM Peter= Maydell <peter.maydell@lina= ro.org> wrote:
On Sun, 9 Jan 2022 at 17:08, Warner Losh <imp@bsdimp.com> wrote:
>
> Implement the meat of the sigaltstack(2) system call with do_sigaltsta= ck.
>
> Signed-off-by: Stacey Son <sson@FreeBSD.org>
> Signed-off-by: Kyle Evans <kevans@freebsd.org>
> Signed-off-by: Warner Losh <imp@bsdimp.com>
> ---
>=C2=A0 bsd-user/qemu.h=C2=A0 =C2=A0|=C2=A0 1 +
>=C2=A0 bsd-user/signal.c | 66 +++++++++++++++++++++++++++++++++++++++++= ++++++
>=C2=A0 2 files changed, 67 insertions(+)
>
> diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
> index c643d6ba246..fcdea460ed2 100644
> --- a/bsd-user/qemu.h
> +++ b/bsd-user/qemu.h
> @@ -226,6 +226,7 @@ int host_to_target_signal(int sig);
>=C2=A0 void host_to_target_sigset(target_sigset_t *d, const sigset_t *s= );
>=C2=A0 void target_to_host_sigset(sigset_t *d, const target_sigset_t *s= );
>=C2=A0 long do_sigreturn(CPUArchState *regs, abi_ulong addr);
> +abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_= ulong sp);
>=C2=A0 int do_sigaction(int sig, const struct target_sigaction *act, >=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 struct t= arget_sigaction *oact);
>=C2=A0 void QEMU_NORETURN force_sig(int target_sig);
> diff --git a/bsd-user/signal.c b/bsd-user/signal.c
> index f055d1db407..e5e5e28c60c 100644
> --- a/bsd-user/signal.c
> +++ b/bsd-user/signal.c
> @@ -528,6 +528,72 @@ static void host_signal_handler(int host_sig, sig= info_t *info, void *puc)
>=C2=A0 =C2=A0 =C2=A0 cpu_exit(thread_cpu);
>=C2=A0 }
>
> +/* do_sigaltstack() returns target values and errnos. */
> +/* compare to kern/kern_sig.c sys_sigaltstack() and kern_sigaltstack(= ) */
> +abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_= ulong sp)
> +{
> +=C2=A0 =C2=A0 int ret;
> +=C2=A0 =C2=A0 target_stack_t oss;
> +
> +=C2=A0 =C2=A0 if (uoss_addr) {
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* Save current signal stack params */ > +=C2=A0 =C2=A0 =C2=A0 =C2=A0 oss.ss_sp =3D tswapl(target_sigaltstack_u= sed.ss_sp);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 oss.ss_size =3D tswapl(target_sigaltstack= _used.ss_size);
> +=C2=A0 =C2=A0 =C2=A0 =C2=A0 oss.ss_flags =3D tswapl(sas_ss_flags(sp))= ;
> +=C2=A0 =C2=A0 }

This will need some minor changes to work with the sigaltstack
info being per-thread and in the TaskState struct.
Yes. Moving it into the TaskState was easy and got rid if the g= lobal.
Thanks for that suggestion earlier in the patch series.

Warrner=C2=A0
--000000000000dbc30605d63323ee--