From: Sheng Yang Subject: Re: [PATCH 2/4] KVM: Add accessor for reading cr4 (or some bits of cr4) Date: Tue, 8 Dec 2009 22:40:14 +0800 Message-ID: <20091208144014.GA15355@syang10-desktop> References: <1260182832-3974-1-git-send-email-avi@redhat.com> <1260182832-3974-3-git-send-email-avi@redhat.com> <200912081557.42822.sheng@linux.intel.com> <4B1E1E3B.3020704@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Marcelo Tosatti , kvm@vger.kernel.org To: Avi Kivity Return-path: Received: from mga01.intel.com ([192.55.52.88]:6492 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755415AbZLHOkL (ORCPT ); Tue, 8 Dec 2009 09:40:11 -0500 Content-Disposition: inline In-Reply-To: <4B1E1E3B.3020704@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: On Tue, Dec 08, 2009 at 11:36:59AM +0200, Avi Kivity wrote: > On 12/08/2009 09:57 AM, Sheng Yang wrote: > >vcpu->arch.cr0 = cr0; > >>- vmx_set_cr4(vcpu, vcpu->arch.cr4); > >>+ vmx_set_cr4(vcpu, kvm_read_cr4(vcpu)); > >> } > >Another place accessed cr4 directly, in ept_update_paging_mode_cr4() > > > > That one is called from vmx_set_cr4(); at that time CR4_READ_SHADOW > is not up-to-date and vmx_decache_cr4_guest_bits() will actually > corrupt vcpu->arch.cr4 (except it won't be called, since cr4.pae is > never guest owned). Yes, you are right... > > But you are right, I should have placed a comment. I'll add a patch > that inlines ept_update_paging_mode_cr4 into its caller so it can > access the cr4 parameter directly instead of vcpu->arch.cr4. Just notice another thing, seems the cr4_guest_owned_bits' initial value is wrong. It should be ~KVM_GUEST_CR4_MASK rather than KVM_GUEST_CR4_MASK in this patch IIUC. -- regards Yang, Sheng