Re: [PATCH v3] KVM: x86: don't reset root in kvm_mmu_setup()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 07/09/2018 13:59, Wei Yang wrote:
> Here is the code path which shows kvm_mmu_setup() is invoked after
> kvm_mmu_create(). Since kvm_mmu_setup() is only invoked in this code path,
> this means the root_hpa and prev_roots are guaranteed to be invalid. And
> it is not necessary to reset it again.
> 
>     kvm_vm_ioctl_create_vcpu()
>         kvm_arch_vcpu_create()
>             vmx_create_vcpu()
>                 kvm_vcpu_init()
>                     kvm_arch_vcpu_init()
>                         kvm_mmu_create()
>         kvm_arch_vcpu_setup()
>             kvm_mmu_setup()
>                 kvm_init_mmu()
> 
> This patch set reset_roots to false in kmv_mmu_setup().
> 
> Signed-off-by: Wei Yang <richard.weiyang@xxxxxxxxx>
> Reviewed-by: Liran Alon <liran.alon@xxxxxxxxxx>
> 
> ---
> v3: add a comment in code based on Liran comment.
> v2: adjust changelog based on Sean Christopherson comment
> ---
>  arch/x86/kvm/mmu.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c
> index b2b88454b1d8..899c029cff0d 100644
> --- a/arch/x86/kvm/mmu.c
> +++ b/arch/x86/kvm/mmu.c
> @@ -5413,7 +5413,12 @@ void kvm_mmu_setup(struct kvm_vcpu *vcpu)
>  {
>  	MMU_WARN_ON(VALID_PAGE(vcpu->arch.mmu.root_hpa));
>  
> -	kvm_init_mmu(vcpu, true);
> +	/*
> +	 * kvm_mmu_setup() is called only on vCPU initialization.  
> +	 * Therefore, no need to reset mmu roots as they are not yet
> +	 * initialized.
> +	 */
> +	kvm_init_mmu(vcpu, false);
>  }
>  
>  static void kvm_mmu_invalidate_zap_pages_in_memslot(struct kvm *kvm,
> 

Queued, thanks.

Paolo



[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux