Ramon van Handel <[EMAIL PROTECTED]> wrote:
> Done. I use the VIF and VIP flags in eflags in order to
> do this, like described in the Intel manual part 3,
> paragraph 15.4. As a matter of fact, turning on PVM
> should work fine now (I didn't try it), but it is
> emulated as well.
Hmmm. It seems we have again a guest flags vs. monitor flags
problem here (remember the discussion about the trap flag?).
As with the TF, we can for now gloss over that distinction
in the case of the VIF/VIP, but definitely *not* in the case
of the IF; for example, you have added this piece of code:
+ /* Copy eflags.vif to eflags.if; iret will restore it later */
+ if (context->eflags & (1<<19))
+ context->eflags |= (1<<9);
+ else
+ context->eflags &= ~(1<<9);
which means that you sometimes execute guest code with *IF clear*!
This in turn allows guest code to deadlock the system by simply
entering an infinite loop, which is not good :-/
Instead, the *monitor* IF setting, i.e. the IF active on the real
processor while it executes *any* part of guest code, must always
be 'set'. (This means we need to virtualize guest access to the
EFLAGS, and replace the real value --always set-- with the value
the guest expects at this point, when it does a PUSHF for example.)
B.t.w. there's another problem with the CLI/STI code: you need to
check the current guest CPL; if it is greater than the guest IOPL,
CLI/STI should trap to the guest GPF handler (unless the guest has
activated PVI if we want to support that ...). But this is probably
not critical for now.
Bye,
Ulrich