All of lore.kernel.org
 help / color / mirror / Atom feed
From: Warner Losh <imp@bsdimp.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Kyle Evans <kevans@freebsd.org>, Stacey Son <sson@freebsd.org>,
	QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [PATCH 16/30] bsd-user/signal.c: host_to_target_siginfo_noswap
Date: Fri, 14 Jan 2022 23:19:27 -0700	[thread overview]
Message-ID: <CANCZdfroBqUPuu8SU5-WzbFP25ansqgmf==XTcoMRsRGim5WJw@mail.gmail.com> (raw)
In-Reply-To: <CAFEAcA9ikK-GV6fy35wZHpTKZkQ8jD8=xm1z+25OdPG56yS=Ow@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 4358 bytes --]

On Thu, Jan 13, 2022 at 12:43 PM Peter Maydell <peter.maydell@linaro.org>
wrote:

> On Sun, 9 Jan 2022 at 16:41, Warner Losh <imp@bsdimp.com> wrote:
> >
> > Implement conversion of host to target siginfo.
> >
> > Signed-off-by: Stacey Son <sson@FreeBSD.org>
> > Signed-off-by: Kyle Evans <kevans@freebsd.org>
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> >  bsd-user/signal.c | 37 +++++++++++++++++++++++++++++++++++++
> >  1 file changed, 37 insertions(+)
> >
> > diff --git a/bsd-user/signal.c b/bsd-user/signal.c
> > index 7168d851be8..3fe8b2d9898 100644
> > --- a/bsd-user/signal.c
> > +++ b/bsd-user/signal.c
> > @@ -43,6 +43,43 @@ int target_to_host_signal(int sig)
> >      return sig;
> >  }
> >
> > +/* Siginfo conversion. */
> > +static inline void host_to_target_siginfo_noswap(target_siginfo_t
> *tinfo,
> > +        const siginfo_t *info)
> > +{
> > +    int sig, code;
> > +
> > +    sig = host_to_target_signal(info->si_signo);
> > +    /* XXX should have host_to_target_si_code() */
> > +    code = tswap32(info->si_code);
> > +    tinfo->si_signo = sig;
> > +    tinfo->si_errno = info->si_errno;
> > +    tinfo->si_code = info->si_code;
> > +    tinfo->si_pid = info->si_pid;
> > +    tinfo->si_uid = info->si_uid;
> > +    tinfo->si_status = info->si_status;
> > +    tinfo->si_addr = (abi_ulong)(unsigned long)info->si_addr;
> > +    /* si_value is opaque to kernel */
> > +    tinfo->si_value.sival_ptr =
> > +        (abi_ulong)(unsigned long)info->si_value.sival_ptr;
> > +    if (SIGILL == sig || SIGFPE == sig || SIGSEGV == sig || SIGBUS ==
> sig ||
>
> Don't use yoda-conditions, please. sig == SIGILL, etc.
>
> > +            SIGTRAP == sig) {
> > +        tinfo->_reason._fault._trapno = info->_reason._fault._trapno;
> > +    }
> > +#ifdef SIGPOLL
> > +    if (SIGPOLL == sig) {
> > +        tinfo->_reason._poll._band = info->_reason._poll._band;
> > +    }
> > +#endif
> > +    if (SI_TIMER == code) {
> > +        int timerid;
> > +
> > +        timerid = info->_reason._timer._timerid;
> > +        tinfo->_reason._timer._timerid = timerid;
> > +        tinfo->_reason._timer._overrun = info->_reason._timer._overrun;
> > +    }
> > +}
>
> I think this will only compile on FreeBSD (the other BSDs having
> notably different target_siginfo_t structs); I guess we're OK
> with that ?
>

Yes. bsd-user fork does not compile on the other BSDs. There's too many
things missing, and too few places where specific code is in place. I'm
thinking
that it won't be possible to implement running NetBSD binaries on FreeBSD
or vice versa since they are so different. OpenBSD and NetBSD are a lot
closer to each other, with fewer critical differences in areas like
threads, so
it may be possible there. There's a lot of rework that's needed in this area
to take what's even in bsd-user fork and make it work on NetBSD or
OpenBSD, exactly for reasons like this. I've been ignoring the elephant
in the room for a while now, ever since I realized this fundamental
shift.


> I also commented on the general setup linux-user has for this
> function back in patch 2; I'll let you figure out whether what
> you have here is the right thing for BSD.
>

Yea. I'm still thinking through what you said there (and elsewhere). These
issues may be the root cause of some regressions in arm binaries between
6.1 and 6.2 as I tried to adopt the sigsegv/sigbus changes.

I need to work through those things in our development branch before trying
to fold them into this series. And I'm not yet sure the right way to do
that because
many of the things are likely to be largish changes that may be tough to
manage
keeping this patch series in sync. So I'm going to do all the trivial style
and
tiny bug things first, then tackle this more fundamental issue. I've thought
about it enough to understand that the code in this patch series has some
conceptual mistakes that must be addressed. Having this very detailed
feedback
is quite helpful in laying out the path for me to fix these issues (even if
I don't
ultimately do everything like linux-user, I'll know why it's different
rather than
the current situation where there's much inherited code and the best answer
I could give is 'well linux-user was like that 5 years ago and we needed to
make
these hacks to make things work' which is completely unsatisfying to give
and
to hear.

Warner

[-- Attachment #2: Type: text/html, Size: 5919 bytes --]

  reply	other threads:[~2022-01-15  6:22 UTC|newest]

Thread overview: 105+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-09 16:18 [PATCH 00/30] bsd-user: upstream our signal implementation Warner Losh
2022-01-09 16:18 ` [PATCH 01/30] bsd-user/arm/target_arch_cpu.h: Move EXCP_ATOMIC to match linux-user Warner Losh
2022-01-13 15:47   ` Peter Maydell
2022-01-23 21:30   ` Richard Henderson
2022-01-09 16:18 ` [PATCH 02/30] bsd-user/signal.c: implement force_sig_fault Warner Losh
2022-01-13 16:43   ` Peter Maydell
2022-01-23 21:36   ` Richard Henderson
2022-01-09 16:18 ` [PATCH 03/30] bsd-user/signal.c: Implement cpu_loop_exit_sigsegv Warner Losh
2022-01-13 17:00   ` Peter Maydell
2022-01-23 21:38   ` Richard Henderson
2022-01-09 16:18 ` [PATCH 04/30] bsd-user/signal.c: implement cpu_loop_exit_sigbus Warner Losh
2022-01-13 17:00   ` Peter Maydell
2022-01-23 21:38   ` Richard Henderson
2022-01-09 16:18 ` [PATCH 05/30] bsd-user/arm/arget_arch_cpu.h: Move EXCP_DEBUG and EXCP_BKPT together Warner Losh
2022-01-13 17:13   ` Peter Maydell
2022-01-14  6:33     ` Warner Losh
2022-01-23 21:40   ` Richard Henderson
2022-01-09 16:18 ` [PATCH 06/30] bsd-user/arm/target_arch_cpu.h: Correct code pointer Warner Losh
2022-01-13 17:15   ` Peter Maydell
2022-01-14  6:38     ` Warner Losh
2022-01-14 10:22       ` Peter Maydell
2022-01-17  4:12         ` Warner Losh
2022-01-23 21:43   ` Richard Henderson
2022-01-09 16:19 ` [PATCH 07/30] bsd-user/arm/target_arch_cpu.h: Use force_sig_fault for EXCP_UDEF Warner Losh
2022-01-13 17:19   ` Peter Maydell
2022-01-23 22:07     ` Richard Henderson
2022-01-09 16:19 ` [PATCH 08/30] bsd-user/arm/target_arch_cpu.h: Implement data faults Warner Losh
2022-01-13 17:40   ` Peter Maydell
2022-01-14 18:13     ` Warner Losh
2022-01-14 18:21       ` Peter Maydell
2022-01-24  1:12   ` Richard Henderson
2022-01-09 16:19 ` [PATCH 09/30] bsd-user/signal.c: implement abstract target / host signal translation Warner Losh
2022-01-13 17:44   ` Peter Maydell
2022-01-14 18:27     ` Warner Losh
2022-01-09 16:19 ` [PATCH 10/30] bsd-user/signal.c: Implement signal_init() Warner Losh
2022-01-13 19:28   ` Peter Maydell
2022-01-14 18:51     ` Warner Losh
2022-01-24  1:38   ` Richard Henderson
2022-01-24 21:35     ` Warner Losh
2022-01-09 16:19 ` [PATCH 11/30] bsd-user/host/arm/host-signal.h: Implement host_signal_* Warner Losh
2022-01-13 19:32   ` Peter Maydell
2022-01-17  3:53     ` Warner Losh
2022-01-09 16:19 ` [PATCH 12/30] bsd-user/host/i386/host-signal.h: " Warner Losh
2022-01-13 19:33   ` Peter Maydell
2022-01-24  1:49   ` Richard Henderson
2022-01-09 16:19 ` [PATCH 13/30] bsd-user/host/x86_64/host-signal.h: " Warner Losh
2022-01-13 19:33   ` Peter Maydell
2022-01-24  1:52   ` Richard Henderson
2022-01-09 16:19 ` [PATCH 14/30] bsd-user: Add host signals to the build Warner Losh
2022-01-13 19:35   ` Peter Maydell
2022-01-24  1:56   ` Richard Henderson
2022-01-09 16:19 ` [PATCH 15/30] bsd-user: Add trace events for bsd-usr Warner Losh
2022-01-13 19:37   ` Peter Maydell
2022-01-24  1:57   ` Richard Henderson
2022-01-09 16:19 ` [PATCH 16/30] bsd-user/signal.c: host_to_target_siginfo_noswap Warner Losh
2022-01-13 19:43   ` Peter Maydell
2022-01-15  6:19     ` Warner Losh [this message]
2022-01-15 11:08       ` Peter Maydell
2022-01-24  2:05   ` Richard Henderson
2022-01-24 21:45     ` Warner Losh
2022-01-09 16:19 ` [PATCH 17/30] bsd-user/signal.c: Implement rewind_if_in_safe_syscall Warner Losh
2022-01-13 19:44   ` Peter Maydell
2022-01-24  2:09   ` Richard Henderson
2022-01-09 16:19 ` [PATCH 18/30] bsd-user/signal.c: Implement host_signal_handler Warner Losh
2022-01-13 20:17   ` Peter Maydell
2022-01-16 20:52     ` Warner Losh
2022-01-09 16:19 ` [PATCH 19/30] bsd-user/strace.c: print_taken_signal Warner Losh
2022-01-13 20:20   ` Peter Maydell
2022-01-24  2:45   ` Richard Henderson
2022-01-09 16:19 ` [PATCH 20/30] bsd-user/signal.c: core_dump_signal Warner Losh
2022-01-13 20:22   ` Peter Maydell
2022-01-13 20:28     ` Warner Losh
2022-01-13 20:40       ` Peter Maydell
2022-01-24  3:01   ` Richard Henderson
2022-01-09 16:19 ` [PATCH 21/30] bsd-user/signal.c: force_sig Warner Losh
2022-01-13 20:29   ` Peter Maydell
2022-01-13 20:53     ` Peter Maydell
2022-01-13 23:04       ` Kyle Evans
2022-01-18 22:27         ` Warner Losh
2022-01-09 16:19 ` [PATCH 22/30] bsd-user/signal.c: Fill in queue_signal Warner Losh
2022-01-13 20:37   ` Peter Maydell
2022-01-17 16:22     ` Warner Losh
2022-01-17 16:33       ` Peter Maydell
2022-01-09 16:19 ` [PATCH 23/30] bsd-user/signal.c: sigset manipulation routines Warner Losh
2022-01-14 11:13   ` Peter Maydell
2022-01-22 16:44     ` Warner Losh
2022-01-22 18:00       ` Kyle Evans
2022-01-09 16:19 ` [PATCH 24/30] bsd-user/signal.c: setup_frame Warner Losh
2022-01-14 11:40   ` Peter Maydell
2022-01-17  6:58     ` Warner Losh
2022-01-17  7:24       ` Warner Losh
2022-01-09 16:19 ` [PATCH 25/30] bsd-user/signal.c: handle_pending_signal Warner Losh
2022-01-14 11:50   ` Peter Maydell
2022-01-09 16:19 ` [PATCH 26/30] bsd-user/signal.c: tswap_siginfo Warner Losh
2022-01-14 11:54   ` Peter Maydell
2022-01-09 16:19 ` [PATCH 27/30] bsd-user/signal.c: process_pending_signals Warner Losh
2022-01-14 11:55   ` Peter Maydell
2022-01-17  2:09     ` Warner Losh
2022-01-09 16:19 ` [PATCH 28/30] bsd-user/signal.c: implement do_sigreturn Warner Losh
2022-01-14 12:12   ` Peter Maydell
2022-01-09 16:19 ` [PATCH 29/30] bsd-user/signal.c: implement do_sigaction Warner Losh
2022-01-14 13:13   ` Peter Maydell
2022-01-09 16:19 ` [PATCH 30/30] bsd-user/signal.c: do_sigaltstack Warner Losh
2022-01-14 13:18   ` Peter Maydell
2022-01-22 22:20     ` Warner Losh

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='CANCZdfroBqUPuu8SU5-WzbFP25ansqgmf==XTcoMRsRGim5WJw@mail.gmail.com' \
    --to=imp@bsdimp.com \
    --cc=kevans@freebsd.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=sson@freebsd.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.