From patchwork Mon Oct 26 18:48:33 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcelo Tosatti X-Patchwork-Id: 55956 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n9QIpuFj020749 for ; Mon, 26 Oct 2009 18:51:57 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754297AbZJZSvf (ORCPT ); Mon, 26 Oct 2009 14:51:35 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754296AbZJZSvf (ORCPT ); Mon, 26 Oct 2009 14:51:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:58581 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754292AbZJZSvd (ORCPT ); Mon, 26 Oct 2009 14:51:33 -0400 Received: from int-mx08.intmail.prod.int.phx2.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id n9QIpcW2008346; Mon, 26 Oct 2009 14:51:38 -0400 Received: from ns3.rdu.redhat.com (ns3.rdu.redhat.com [10.11.255.199]) by int-mx08.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id n9QIpbYp016994; Mon, 26 Oct 2009 14:51:38 -0400 Received: from amt.cnet (vpn-10-126.str.redhat.com [10.32.10.126]) by ns3.rdu.redhat.com (8.13.8/8.13.8) with ESMTP id n9QIpZ5a018663; Mon, 26 Oct 2009 14:51:37 -0400 Received: from amt.cnet (amt.cnet [127.0.0.1]) by amt.cnet (Postfix) with ESMTP id 6CBEC682A79; Mon, 26 Oct 2009 16:48:46 -0200 (BRST) Received: (from marcelo@localhost) by amt.cnet (8.14.3/8.14.3/Submit) id n9QImXO8006618; Mon, 26 Oct 2009 16:48:33 -0200 Date: Mon, 26 Oct 2009 16:48:33 -0200 From: Marcelo Tosatti To: Avi Kivity Cc: kvm , "Yang, Sheng" Subject: KVM: VMX: move CR3/PDPTR update to vmx_set_cr3 Message-ID: <20091026184833.GD6016@amt.cnet> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Scanned-By: MIMEDefang 2.67 on 10.5.11.21 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Index: b/arch/x86/kvm/vmx.c =================================================================== --- a/arch/x86/kvm/vmx.c +++ b/arch/x86/kvm/vmx.c @@ -1748,6 +1748,7 @@ static void vmx_set_cr3(struct kvm_vcpu vmcs_write64(EPT_POINTER, eptp); guest_cr3 = is_paging(vcpu) ? vcpu->arch.cr3 : vcpu->kvm->arch.ept_identity_map_addr; + ept_load_pdptrs(vcpu); } vmx_flush_tlb(vcpu); @@ -3638,10 +3639,6 @@ static void vmx_vcpu_run(struct kvm_vcpu { struct vcpu_vmx *vmx = to_vmx(vcpu); - if (enable_ept && is_paging(vcpu)) { - vmcs_writel(GUEST_CR3, vcpu->arch.cr3); - ept_load_pdptrs(vcpu); - } /* Record the guest's net vcpu time for enforced NMI injections. */ if (unlikely(!cpu_has_virtual_nmis() && vmx->soft_vnmi_blocked)) vmx->entry_time = ktime_get(); Index: b/arch/x86/kvm/x86.c =================================================================== --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -4517,8 +4517,10 @@ int kvm_arch_vcpu_ioctl_set_sregs(struct mmu_reset_needed |= vcpu->arch.cr4 != sregs->cr4; kvm_x86_ops->set_cr4(vcpu, sregs->cr4); - if (!is_long_mode(vcpu) && is_pae(vcpu)) + if (!is_long_mode(vcpu) && is_pae(vcpu)) { load_pdptrs(vcpu, vcpu->arch.cr3); + mmu_reset_needed = 1; + } if (mmu_reset_needed) kvm_mmu_reset_context(vcpu);