From: Warner Losh <imp@bsdimp.com>
To: Richard Henderson <richard.henderson@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: Question about atomics
Date: Tue, 8 Mar 2022 07:09:55 -0700 [thread overview]
Message-ID: <CANCZdfqwA8HbxYhud8pKxF_f=BMoMtrO+R=zg7GiKesz8_YZvg@mail.gmail.com> (raw)
In-Reply-To: <5bb620d4-96f0-cf7f-5530-af529a32c78d@linaro.org>
[-- Attachment #1: Type: text/plain, Size: 2392 bytes --]
On Mon, Mar 7, 2022 at 10:00 PM Richard Henderson <
richard.henderson@linaro.org> wrote:
> On 3/7/22 18:18, Warner Losh wrote:
> > I have a question related to the user-mode emulation and atomics. I
> asked on IRC, but
> > thinking about it, I think it may be too complex to discuss in that
> medium...
> >
> > In FreeBSD we have a system call that uses host atomic operations to
> interact memory that
> > userland also interacts with using atomic operations.
> >
> > In bsd-user we call the kernel with a special flag for dealing with
> 32-bit processes
> > running on a 64-bit kernel. In this case, we use 32-bit-sized atomics to
> set variables in
> > the address space of the bsd-user guest. This is used when running armv7
> binaries on amd64
> > hosts.
> >
> > First question: Is this expected to work? I know I'm a bit vague, so as
> a followup
> > question: If there's restrictions on this, what might they be? Do some
> classes of atomic
> > operations work, while others may fail or need additional cooperation?
> Are there any
> > conformance tests I could compile for FreeBSD/armv7 to test the
> hypothesis that atomic
> > operations are misbehaving?
>
> Yes, qatomic_foo is expected to work. It's what we use across threads,
> and it is expected
> to work "in kernel mode", i.e. within cpu_loop().
>
Even when the writers are done in the context of system calls to the kernel?
> There are compile-time restrictions on the set of atomic operations,
> mostly based on what
> the host supports. But anything that actually compiles is expected to
> work (there are a
> set of ifdefs if you need something more than the default).
>
> Beyond that, there is start_exclusive() / end_exclusive() which will
> stop-the-world and
> make sure that the current thread is the only one running.
>
So anything that happens in the BSD host kernel would need to be confined
to the one
and only on running thread? It also assumes only one thread is scheduled
and running
and that might be a source of 'brokeness' if there's an issue in the BSD
implementation
of the mechanisms that are used for that. And if the system call does this
w/o using
the start_exclusive/end_exclusive stuff, is that a problem?
> > Thanks for any help you might be able to give.
>
> Show the code in question?
>
Which code? The test cases that are failing, or the bsd-user code in the
branch I suspect?
Warner
[-- Attachment #2: Type: text/html, Size: 3289 bytes --]
next prev parent reply other threads:[~2022-03-08 14:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-08 4:18 Question about atomics Warner Losh
2022-03-08 5:00 ` Richard Henderson
2022-03-08 14:09 ` Warner Losh [this message]
2022-03-08 14:26 ` Paolo Bonzini
2022-03-08 16:29 ` Warner Losh
2022-03-13 4:59 ` Warner Losh
2022-03-13 16:47 ` Richard Henderson
2022-03-13 16:57 ` Warner Losh
2022-03-13 17:03 ` Richard Henderson
2022-03-13 18:29 ` Warner Losh
2022-03-13 20:19 ` Richard Henderson
2022-03-14 4:09 ` Warner Losh
2022-03-14 4:36 ` Richard Henderson
2022-03-14 5:42 ` Warner Losh
2022-03-14 4:43 ` Richard Henderson
2022-03-14 5:34 ` 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='CANCZdfqwA8HbxYhud8pKxF_f=BMoMtrO+R=zg7GiKesz8_YZvg@mail.gmail.com' \
--to=imp@bsdimp.com \
--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).