It turns out that our big real mode implementation was based on a miconception: I believed that loading a segment register in real mode causes the limit to be reset to 0xffff (thus undoing the effect), while in reality, the limit is preserved across segment changes. This bug was hidden by another bug: we didn't do limit checks in real mode. So even though segment loads corrupted the limit, the guest still functioned because that limit isn't checked. This patchset fixes both bugs, and introduces an optimization: we can now use vm86 mode to virtualize big real mode (under usually-met conditions). This both speeds up big real mode, and makes it more robust, since fewer instructions need to be emulated. I think this patchset means we can remove emulate_invalid_guest_state=0, since it offers no advantages now. Avi Kivity (13): KVM: VMX: Separate saving pre-realmode state from setting segments KVM: VMX: Fix incorrect lookup of segment S flag in fix_pmode_dataseg() KVM: VMX: Use kvm_segment to save protected-mode segments when entering realmode KVM: VMX: Retain limit and attributes when entering protected mode KVM: VMX: Allow real mode emulation using vm86 with dpl=0 KVM: VMX: Allow vm86 virtualization of big real mode KVM: x86 emulator: Leave segment limit and attributs alone in real mode KVM: x86 emulator: Check segment limits in real mode too KVM: x86 emulator: Fix #GP error code during linearization KVM: VMX: Return real real-mode segment data even if emulate_invalid_guest_state=1 KVM: VMX: Preserve segment limit and access rights in real mode KVM: VMX: Save all segment data in real mode KVM: VMX: Ignore segment G and D bits when considering whether we can virtualize arch/x86/kvm/emulate.c | 19 ++++------ arch/x86/kvm/vmx.c | 100 ++++++++++++++++++------------------------------- 2 files changed, 44 insertions(+), 75 deletions(-) -- 1.7.11.3 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html