From: Richard Henderson <richard.henderson@linaro.org>
To: Warner Losh <imp@bsdimp.com>, QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: Question about atomics
Date: Mon, 7 Mar 2022 19:00:11 -1000 [thread overview]
Message-ID: <5bb620d4-96f0-cf7f-5530-af529a32c78d@linaro.org> (raw)
In-Reply-To: <CANCZdfpJVWFjrQDiYJy8xiw-THF8_3GNcu=0Pmbvp_6zAJbfHA@mail.gmail.com>
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().
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.
> Thanks for any help you might be able to give.
Show the code in question?
r~
next prev parent reply other threads:[~2022-03-08 5:01 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 [this message]
2022-03-08 14:09 ` Warner Losh
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=5bb620d4-96f0-cf7f-5530-af529a32c78d@linaro.org \
--to=richard.henderson@linaro.org \
--cc=imp@bsdimp.com \
--cc=qemu-devel@nongnu.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).