qemu on ARM hosts aborts on startup because makecontext() always fails

Bug #883136 reported by Peter Maydell
14
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Linaro QEMU
Fix Released
Medium
Ken Werner
QEMU
Fix Released
Undecided
Unassigned

Bug Description

qemu has recently grown a coroutines implementation. There are two versions, one using the makecontext/setcontext/swapcontext functions from ucontext.h, and one falling back to implementing coroutines as separate glib threads. configure chooses the former if the platform has a makecontext().

Unfortunately ARM eglibc provides a makecontext() which always fails ENOSYS, which means the configure check passes but when qemu starts it abort()s.

The best fix for this is probably going to involve making the coroutine implementation runtime-selectable.

Revision history for this message
Peter Maydell (pmaydell) wrote :

I have temporarily added a patch to qemu-linaro ("configure: Force ucontext check to fail on ARM") to work around this in the configure script. However this is only a stopgap to let us get on with KVM development and won't be going upstream.

Revision history for this message
Dr. David Alan Gilbert (davidgil-uk) wrote :

Attached is a 1st cut of a makecontext/setcontext/getcontext/swapcontext set for ARM - not ready to go into libc yet;
currently it builds standalone and links (and passes) with a test of mine. Next stop libc and a lot of cleanup.

Changed in qemu-linaro:
assignee: nobody → Dr. David Alan Gilbert (davidgil-uk)
Revision history for this message
Stefan Hajnoczi (stefanha) wrote : Re: [Qemu-devel] [Bug 883136] Re: qemu on ARM hosts aborts on startup because makecontext() always fails

On Wed, Dec 21, 2011 at 5:42 PM, Dr. David Alan Gilbert
<email address hidden> wrote:
> Attached is a 1st cut of a makecontext/setcontext/getcontext/swapcontext set for ARM - not ready to go into libc yet;
> currently it builds standalone and links (and passes) with a test of mine.  Next stop libc and a lot of cleanup.

Excellent. There is a stand-alone QEMU coroutine test which you can
build with "make test-coroutine".

Stefan

Revision history for this message
Dr. David Alan Gilbert (davidgil-uk) wrote :

OK, here is a eglibc patch that adds the context routines; seems to pass Stefan's magic coroutine test, pass all the context specific tests in eglibc and boots a debian image on qemu. (Not run a full eglibc test run yet).

Dave

Michael Hope (michaelh1)
Changed in qemu-linaro:
status: New → In Progress
Revision history for this message
Michael Hope (michaelh1) wrote :

Removing Dave as he's done most of the work but can't complete it.

Changed in qemu-linaro:
importance: Undecided → Medium
assignee: Dr. David Alan Gilbert (davidgil-uk) → nobody
Revision history for this message
Michael Hope (michaelh1) wrote :

Consider putting this in 2.15 as well. Talk with Matthias re: getting it into Ubuntu Precise either through a 2.13 backport or as part of a 2.15 update.

Changed in qemu-linaro:
assignee: nobody → Ken Werner (kwerner)
Revision history for this message
Peter Maydell (pmaydell) wrote :

Plan:
(a) get makecontext added to eglibc
(b) see if upstream eglibc are open to the idea of some sort of #define for MAKECONTEXT_ACTUALLY_IMPLEMENTED_NOW so we can detect it at compile time
(c) otherwise, work around in qemu (probably by adding another layer of indirection)

Revision history for this message
Peter Maydell (pmaydell) wrote :

David Gilbert's post to upstream eglibc, and a reply from Joseph Myers with some review comments:
http://comments.gmane.org/gmane.comp.lib.glibc.ports/1187

Revision history for this message
Peter Maydell (pmaydell) wrote :

Michael Hope pointed out that glibc defines a macro __stub_makecontext when the makecontext() implementation is a stub, so we can just add this to the qemu configure test to make it automatically fall back to the pthreads version as required.

Revision history for this message
Peter Maydell (pmaydell) wrote :

http://comments.gmane.org/gmane.comp.lib.glibc.ports/1325

-- Michael's version of the makecontext patches has been committed to glibc-ports and should be available in glibc 2.16.

Upstream qemu (and thus qemu-linaro) now have a version of the configure check which tests for __stub_makecontext, so qemu will just automatically pick up the makecontext implementation when compiled against a glibc which supports it. So I think the only remaining thing is to decide whether Linaro and/or Ubuntu want to backport this.

Revision history for this message
Peter Maydell (pmaydell) wrote :

...and I think that backporting would be a bug against some other package, not qemu, so we can close this bug.

Changed in qemu-linaro:
status: In Progress → Fix Committed
Changed in qemu:
status: New → Fix Committed
Peter Maydell (pmaydell)
Changed in qemu-linaro:
status: Fix Committed → Fix Released
Revision history for this message
Peter Maydell (pmaydell) wrote :

Fix released in upstream QEMU 1.1.

Changed in qemu:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.