From: Jamie Lokier <jamie@shareable.org>
To: qemu-devel@nongnu.org
Cc: Paul Brook <paul@codesourcery.com>
Subject: Re: [Qemu-devel] [PATCH]ish NPTL support.
Date: Sat, 16 Dec 2006 18:48:22 +0000 [thread overview]
Message-ID: <20061216184822.GA1245@mail.shareable.org> (raw)
In-Reply-To: <1166275574.5253.1196.camel@pmac.infradead.org>
David Woodhouse wrote:
> > However, it is probably easier to use the host's, than to write the
> > equivalent (basically duplicating the kernel's futex code in qemu, the
> > hashed locks and wait queues etc.).
>
> The kernel's implementation is a _whole_ lot more complicated than ours
> needs to be in qemu, because of the security implications of dealing
> with arbitrary pointers in userspace. I think it's reasonable enough for
> qemu to do its own.
Although there are security issues, things like page table walking and
address hashing would need to be implemented in qemu too, if the
emulated program is allowed to fork.
> > On the other hand, using the host's makes it hard to run Linux guest
> > binaries on non-Linux hosts (those which don't have futex), or newer
> > Linux guest binaries on older Linux hosts which have fewer futex ops,
> > or none at all.
>
> I don't think we care. You can't run qemu-i386 on a non-Linux box
> _anyway_, can you? And having some syscalls return -ENOSYS if you run on
> a prehistoric kernel is perfectly normal.
If we want non-Linux hosts to behave as prehistoric kernels, that's
fine. If you want non-Linux hosts to run current Linux binaries, I
guess that's not enough.
> I did briefly think about implementing threading entirely within qemu
> _without_ using threads on the host -- having the qemu process itself
> schedule between the different CPU contexts. That would make the GDB
> stub a whole lot saner for debugging multi-threaded guest programs. But
> I don't think it's workable -- the whole point in NPTL was that you
> _can't_ emulate proper POSIX-compliant threading with hacks in
> userspace; especially the details of signal delivery.
NPTL is a number of changes from LinuxThreads, some for performance
and some for POSIXness.
What you can't sanely do is implement POSIX-thread signals when using
the old style of clone()'d kernel threads which LinuxThreads uses.
That was due to a kernel limitation.
But you can implement POSIX-thread signals them when all threads run
within a single POSIX process, and are all scheduled in userspace.
AFAIK, POSIX thread signals are specified the way they are
specifically to allow that kind of implementation.
See GNU Pth for a fairly portable implementation of POSIX threads
entirely in a userspace library, using a single kernel thread.
You might be able to adapt Pth to implement your single process idea
for Qemu.
What's much more difficult is providing Linux thread semantics for
non-POSIX things, particularly blocking operations on devices and
files, and tid-specific things like queued SIGIO delivery.
But any emulation which doesn't simply map those things to the host
Linux kernel will have trouble getting those right.
-- Jamie
next prev parent reply other threads:[~2006-12-16 18:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-09 22:38 [Qemu-devel] [PATCH]ish NPTL support David Woodhouse
2006-12-13 16:02 ` Mulyadi Santosa
2006-12-13 17:01 ` David Woodhouse
2006-12-13 17:22 ` Paul Brook
2006-12-13 17:32 ` David Woodhouse
2006-12-13 17:42 ` Paul Brook
2006-12-13 17:50 ` David Woodhouse
2006-12-13 18:07 ` Paul Brook
2006-12-13 18:44 ` Fabrice Bellard
2006-12-14 2:16 ` Jamie Lokier
2006-12-16 13:26 ` David Woodhouse
2006-12-16 15:17 ` Paul Brook
2006-12-16 18:48 ` Jamie Lokier [this message]
2006-12-13 17:35 ` Thiemo Seufer
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=20061216184822.GA1245@mail.shareable.org \
--to=jamie@shareable.org \
--cc=paul@codesourcery.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).