Re: [patch 3/3] KVM: move postcommit flush to x86, as mmio sptes are x86 specific

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

 



On Mon, Aug 27, 2012 at 11:41:08PM +0900, Takuya Yoshikawa wrote:
> On Fri, 24 Aug 2012 15:54:59 -0300
> Marcelo Tosatti <mtosatti@xxxxxxxxxx> wrote:
> 
> > Other arches do not need this.
> > 
> > Signed-off-by: Marcelo Tosatti <mtosatti@xxxxxxxxxx>
> > 
> > Index: kvm/arch/x86/kvm/x86.c
> > ===================================================================
> > --- kvm.orig/arch/x86/kvm/x86.c
> > +++ kvm/arch/x86/kvm/x86.c
> > @@ -6455,6 +6455,14 @@ void kvm_arch_commit_memory_region(struc
> >  		kvm_mmu_change_mmu_pages(kvm, nr_mmu_pages);
> >  	kvm_mmu_slot_remove_write_access(kvm, mem->slot);
> >  	spin_unlock(&kvm->mmu_lock);
> > +	/*
> > +	 * If the new memory slot is created, we need to clear all
> > +	 * mmio sptes.
> > +	 */
> > +	if (old.npages == 0 && npages) {
> > +		kvm_mmu_zap_all(kvm);
> > +		kvm_reload_remote_mmus(kvm);
> > +	}
> >  }
> 
> Any explanation why (old.base_gfn != new.base_gfn) case can be
> omitted?

(old.base_gfn != new.base_gfn) check covers the cases

1. old.base_gfn = 0, new.base_gfn = !0 (slot creation)

and

x != 0, y != 0, x != y.
2. old.base_gfn = x, new.base_gfn = y (gpa base change)

Patch 2 covers case 2, so its only necessary to cover case
1 here.

Makes sense?

> Takuya
> 
> >  
> >  void kvm_arch_flush_shadow_all(struct kvm *kvm)
> > Index: kvm/virt/kvm/kvm_main.c
> > ===================================================================
> > --- kvm.orig/virt/kvm/kvm_main.c
> > +++ kvm/virt/kvm/kvm_main.c
> > @@ -849,13 +849,6 @@ int __kvm_set_memory_region(struct kvm *
> >  
> >  	kvm_arch_commit_memory_region(kvm, mem, old, user_alloc);
> >  
> > -	/*
> > -	 * If the new memory slot is created, we need to clear all
> > -	 * mmio sptes.
> > -	 */
> > -	if (npages && old.base_gfn != mem->guest_phys_addr >> PAGE_SHIFT)
> > -		kvm_arch_flush_shadow_all(kvm);
> > -
> >  	kvm_free_physmem_slot(&old, &new);
> >  	kfree(old_memslots);
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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