From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marcelo Tosatti Subject: Re: [PATCH 00/13] Big real mode fixes Date: Mon, 27 Aug 2012 21:08:34 -0300 Message-ID: <20120828000834.GA22742@amt.cnet> References: <1345558030-29370-1-git-send-email-avi@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mx1.redhat.com ([209.132.183.28]:28495 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753140Ab2H1QZj (ORCPT ); Tue, 28 Aug 2012 12:25:39 -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 q7SGPd0w021046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Tue, 28 Aug 2012 12:25:39 -0400 Content-Disposition: inline In-Reply-To: <1345558030-29370-1-git-send-email-avi@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Aug 21, 2012 at 05:06:57PM +0300, Avi Kivity wrote: > 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(-) Applied, thanks.