Alexander Graf wrote: > Real mode segments are mere offsets. They get lshifted by 4 (as far as > I remember) and just added to the offset. SS is on some value here >
Yes, this is correct. > 0x0000000000046e60: and $0xffff,%esp > 0x0000000000046e66: shl $0x4,%eax > 0x0000000000046e69: add %eax,%esp > 0x0000000000046e6b: mov $0x8,%ax > 0x0000000000046e6f: mov %eax,%ss > 0x0000000000046e71: mov %eax,%es > 0x0000000000046e73: mov %eax,%fs > 0x0000000000046e75: mov %eax,%gs > > set the segments to the selector we just calculated > > [...] > > So what could be the problem with this code? It looks slightly hacky, > but works on most x86 computers (some VIAs choke here too). > > After the vmexit on writing cr0, we are in a somewhat undefined state. > For most of it, we are in protected mode by now. But the segments have > not been set to something meaningful in protected mode, so they still > are on their old values. > > Unfortunately VMX does a lot of sanity checks, if the virtual machine > is actually valid and can be entered into, when trying to do so. One > of these checks is 'CS.RPL == SS.RPL'. The RPL are lowest 2 bits (I am > not too sure about this, read in the manuals if you really need to > know) of the selector. We don't have a real selector in this > transitioning phase though, but instead have real mode offsets in > them. This means, if CS was on 0x0 and SS on 0x1235, there is no way > the RPL equals condition can be met. > Keep in mind, this is not big real mode. The gfxboot code here was actually rewritten to not use big real mode so that it worked with Xen. It works with Xen because Xen uses vm86 mode within the host whereas KVM uses vm86 mode in the guest's VT context. An alternative approach to fixing this problem (but in a less hackish way) would be to simply use the host's vm86 mode instead of vm86 mode within the guest's VT context. However, this does not fix big real mode. For that, you need to do proper 16-bit instruction emulation. Regards, Anthony Liguori ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ kvm-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/kvm-devel
