From mboxrd@z Thu Jan 1 00:00:00 1970 From: Paolo Bonzini Subject: Re: Calling to kvm_mmu_load Date: Wed, 23 Oct 2013 07:21:40 +0100 Message-ID: <52676AF4.4080906@redhat.com> References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Cc: kvm , Jan Kiszka To: Arthur Chunqi Li Return-path: Received: from mail-wi0-f171.google.com ([209.85.212.171]:33286 "EHLO mail-wi0-f171.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751161Ab3JWGVo (ORCPT ); Wed, 23 Oct 2013 02:21:44 -0400 Received: by mail-wi0-f171.google.com with SMTP id h11so6804022wiv.16 for ; Tue, 22 Oct 2013 23:21:43 -0700 (PDT) In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: Il 21/10/2013 08:56, Arthur Chunqi Li ha scritto: > Hi there, > > I noticed that kvm_mmu_reload() is called every time in vcpu enter, > and kvm_mmu_load() is called in this function when root_hpa is > INVALID_PAGE. I get confused why and when root_hpa can be set to > INVALID_PAGE? I find one condition that if vcpu get request > KVM_REQ_MMU_RELOAD, kvm_mmu_unload() is called to invalid root_hpa, > but this condition cannot cover all occasions. Look also at mmu_free_roots, kvm_mmu_unload and kvm_mmu_reset_context. In "normal" cases and without EPT, it should be called when CR3 changes or when the paging mode changes (32-bit, PAE, 64-bit, no paging). With EPT, this kind of change won't reset the MMU (CR3 changes won't cause a vmexit at all, in fact). With nested virtualization, roots are invalidated whenever kvm->arch.mmu changes meaning from L1->L0 or L2->L0 or vice versa (in the special case where EPT is disabled on L0, this is trivially because vmentry loads CR3 from the vmcs02). Paolo