From mboxrd@z Thu Jan 1 00:00:00 1970 From: Avi Kivity Subject: Re: KVM call minutes for Nov 30 Date: Tue, 07 Dec 2010 15:10:03 +0200 Message-ID: <4CFE322B.4080004@redhat.com> References: <20101130155355.GJ24841@x200.localdomain> <20101201092730.GB29486@fermat.math.technion.ac.il> <20101206193919.GA1999@fermat.math.technion.ac.il> <4CFDF19D.70505@redhat.com> <20101207124907.GA25485@fermat.math.technion.ac.il> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Chris Wright , kvm@vger.kernel.org To: "Nadav Har'El" Return-path: Received: from mx1.redhat.com ([209.132.183.28]:2965 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753681Ab0LGNKN (ORCPT ); Tue, 7 Dec 2010 08:10:13 -0500 In-Reply-To: <20101207124907.GA25485@fermat.math.technion.ac.il> Sender: kvm-owner@vger.kernel.org List-ID: On 12/07/2010 02:49 PM, Nadav Har'El wrote: > On Tue, Dec 07, 2010, Avi Kivity wrote about "Re: KVM call minutes for Nov 30": > >... > > All it requires is a > > kvm_set_cr3() which will load the PDPTEs into the PDPTRs if PAE is > > enabled. You may need to order the loading of CR0, CR3, CR4, and EFER > > to achieve the desired effect. > > I did this more explicitly as: > > vmcs_writel(GUEST_CR3, get_vmcs12_fields(vcpu)->guest_cr3); > vcpu->arch.cr3 = get_vmcs12_fields(vcpu)->guest_cr3; > load_pdptrs(vcpu, vcpu->arch.walk_mmu, vcpu->arch.cr3); > vmcs_write64(GUEST_PDPTR0, vcpu->arch.mmu.pdptrs[0]); > vmcs_write64(GUEST_PDPTR1, vcpu->arch.mmu.pdptrs[1]); > vmcs_write64(GUEST_PDPTR2, vcpu->arch.mmu.pdptrs[2]); > vmcs_write64(GUEST_PDPTR3, vcpu->arch.mmu.pdptrs[3]); > > I'm still working on trying to simplify this code - I'll indeed try to see if > I can use kvm_set_cr3 instead. Thanks for the suggestion. > However, Even if it works, I have a concern on how nested vmx might brake in > the future if kvm_set_cr3 is changed in some way that is irrelevant to nested. It's more correct to use kvm_set_cr3(), since that accounts for all side effects. For example unsynchronized shadow mmu pages need to be synced. If there are new side effects that we don't want in nesting, then we'll add a flag to avoid them. Also need to do the same on the vmexit path (kvm_set_cr3(HOST_CR3)). This is what svm does (though only for !npt; but it should also work unconditionally). -- error compiling committee.c: too many arguments to function