Re: use of setjmp/longjmp in x86 emulator.

From: Avi Kivity
Date: Sun Mar 07 2010 - 04:01:24 EST

On 03/02/2010 09:28 AM, Gleb Natapov wrote:
On Mon, Mar 01, 2010 at 02:13:32PM -0500, john cooper wrote:
Gleb Natapov wrote:

Think about what happens if in the middle of
instruction emulation some data from device emulated in userspace is
needed. Emulator should be able to tell KVM that exit to userspace is
needed and restart instruction emulation when data is available.
setjmp/longjmp are useful constructs in general but
IME are better suited for infrequent exceptions vs.
routine usage.
Exception condition during instruction emulation _is_

Well, with mmio you'd expect it to happen every read access.

Although setjmp/longjmp that I know about
are routine usage. See QEMU TCG main loop or userspace
thread libraries.

Agreed, nothing magical about it.

If the issue is finding some clean and regular way
to back out from (and possibly reeneter) logic
expressed within nested function invocations, have
you considered turning the problem inside out and
using a state machine approach?
I don't see how state machine will help. But the goal
is not to rewrite emulator.c (this will no be excepted
by kvm maintainers), but improve it gradually.

That is orthogonal. If we decide a state machine is the best implementation, then we'll find a way to move over to that. However, I don't think a state machine is a good representation considering some of the code paths are very complicated and depend on a many memory accesses (e.g. hardware task switches).

error compiling committee.c: too many arguments to function

To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at
Please read the FAQ at