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~

Reply via email to