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

Bug #883136 reported by Peter Maydell on 2011-10-28
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Linaro QEMU
Fix Released
Ken Werner

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.

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.

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)

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".


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).


Michael Hope (michaelh1) on 2012-01-05
Changed in qemu-linaro:
status: New → In Progress
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
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)
Peter Maydell (pmaydell) wrote :

(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)

Peter Maydell (pmaydell) wrote :

David Gilbert's post to upstream eglibc, and a reply from Joseph Myers with some review comments:

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.

Peter Maydell (pmaydell) wrote :


-- 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.

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) on 2012-03-15
Changed in qemu-linaro:
status: Fix Committed → Fix Released
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  Edit
Everyone can see this information.

Other bug subscribers