From: Warner Losh <imp@bsdimp.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: Laurent Vivier <laurent@vivier.eu>,
QEMU Developers <qemu-devel@nongnu.org>,
Philippe Mathieu-Daude <f4bug@amsat.org>
Subject: Re: [RFC v2 4/6] common-user: Adjust system call return on FreeBSD
Date: Wed, 10 Nov 2021 15:53:54 -0700 [thread overview]
Message-ID: <CANCZdfotsf8j4wpNwaWYiuoAW+c_wf-qbo3aLbmKdQjebFphcA@mail.gmail.com> (raw)
In-Reply-To: <c9e84889-e365-6277-3a62-3a76c05075db@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 2201 bytes --]
On Wed, Nov 10, 2021 at 9:59 AM Richard Henderson <
richard.henderson@linaro.org> wrote:
> On 11/10/21 5:31 PM, Warner Losh wrote:
> > All the *-users generally use the Linux style of negative return codes
> > for errno. FreeBSD returns errno, not -errno. Add ifdefs for FreeBSD to
> > make the adjustment on the 4 hosts that we have support for.
> >
> > Signed-off-by: Warner Losh <imp@bsdimp.com>
> > ---
> > common-user/host/aarch64/safe-syscall.inc.S | 5 +++++
> > common-user/host/arm/safe-syscall.inc.S | 5 +++++
> > common-user/host/i386/safe-syscall.inc.S | 5 +++++
> > common-user/host/x86_64/safe-syscall.inc.S | 5 +++++
> > 4 files changed, 20 insertions(+)
> >
> > diff --git a/common-user/host/aarch64/safe-syscall.inc.S
> b/common-user/host/aarch64/safe-syscall.inc.S
> > index bc1f5a9792..6584950ccf 100644
> > --- a/common-user/host/aarch64/safe-syscall.inc.S
> > +++ b/common-user/host/aarch64/safe-syscall.inc.S
> > @@ -64,6 +64,11 @@ safe_syscall_start:
> > svc 0x0
> > safe_syscall_end:
> > /* code path for having successfully executed the syscall */
> > +#ifdef __FreeBSD__
> > + b.cc 2f /* Convert to Linux -ERRNO convention */
> > + neg x0, x0
> > +2:
> > +#endif
>
> I think it should be a little odd to mention Linux.
>
Yea, from my view of hacking on Unix and Unix-derived systems for the
last 30 years, Linux is the outlier in returning -errno. However, the
'norms'
have shifted, I guess, so I'm happy with your suggestion...
> How about
>
> /*
> * FreeBSD kernel returns C bit set with positive errno.
> * Encode this for use in bsd-user as -errno:
> * x0 = !c ? x0 : -x0
> */
> csneg x0, x0, x0, cc
>
Ah, better assembler. Good!
>
> > +++ b/common-user/host/arm/safe-syscall.inc.S
> > @@ -78,6 +78,11 @@ safe_syscall_start:
> > swi 0
> > safe_syscall_end:
> > /* code path for having successfully executed the syscall */
> > +#ifdef __FreeBSD__
> > + bcc 2f
> > + neg r0, r0
>
> negcs r0, r0
>
> I just can't help myself. :-)
I can relate... Really :)
I'll rework and resend in the next round.
Warner
[-- Attachment #2: Type: text/html, Size: 3367 bytes --]
next prev parent reply other threads:[~2021-11-10 22:55 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-10 16:31 [RFC v2 0/6] linux-user: simplify safe signal handling Warner Losh
2021-11-10 16:31 ` [RFC v2 1/6] linux-user: Add host_signal_set_pc to set pc in mcontext Warner Losh
2021-11-10 16:42 ` Richard Henderson
2021-11-10 22:46 ` Warner Losh
2021-11-10 16:31 ` [RFC v2 2/6] linux-user/signal.c: Create a common rewind_if_in_safe_syscall Warner Losh
2021-11-10 16:31 ` [RFC v2 3/6] linux-user/safe-syscall.inc.S: Move to common-user Warner Losh
2021-11-10 16:43 ` Richard Henderson
2021-11-10 16:31 ` [RFC v2 4/6] common-user: Adjust system call return on FreeBSD Warner Losh
2021-11-10 16:59 ` Richard Henderson
2021-11-10 22:53 ` Warner Losh [this message]
2021-11-10 16:31 ` [RFC v2 5/6] common-user/host/mips: create, though mips hosts likely don't work reliably Warner Losh
2021-11-10 17:00 ` Richard Henderson
2021-11-10 22:58 ` Warner Losh
2021-11-10 16:31 ` [RFC v2 6/6] *-user: move safe-syscall.* to common-user Warner Losh
2021-11-10 17:04 ` Richard Henderson
2021-11-10 23:02 ` 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=CANCZdfotsf8j4wpNwaWYiuoAW+c_wf-qbo3aLbmKdQjebFphcA@mail.gmail.com \
--to=imp@bsdimp.com \
--cc=f4bug@amsat.org \
--cc=laurent@vivier.eu \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.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;
as well as URLs for NNTP newsgroup(s).