From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: [PATCH 00/13] Big real mode fixes Date: Tue, 21 Aug 2012 17:06:57 +0300 Message-ID: <1345558030-29370-1-git-send-email-avi@redhat.com> Cc: kvm@vger.kernel.org To: Marcelo Tosatti Return-path: Received: from mx1.redhat.com ([209.132.183.28]:22078 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753162Ab2HUOHW (ORCPT ); Tue, 21 Aug 2012 10:07:22 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q7LE7MYd008130 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 21 Aug 2012 10:07:22 -0400 Sender: kvm-owner@vger.kernel.org List-ID: 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