Re: [PATCH v4 01/19] KVM: x86: Allocate new rmap and large page tracking when moving memslot
From: Peter Xu
Date: Tue Dec 17 2019 - 17:37:41 EST
On Tue, Dec 17, 2019 at 02:20:59PM -0800, Sean Christopherson wrote:
> > For example, I see PPC has this:
> >
> > struct kvm_arch_memory_slot {
> > #ifdef CONFIG_KVM_BOOK3S_HV_POSSIBLE
> > unsigned long *rmap;
> > #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */
> > };
> >
> > I started to look into HV code of it a bit, then I see...
> >
> > - kvm_arch_create_memslot(kvmppc_core_create_memslot_hv) init slot->arch.rmap,
> > - kvm_arch_flush_shadow_memslot(kvmppc_core_flush_memslot_hv) didn't free it,
> > - kvm_arch_prepare_memory_region(kvmppc_core_prepare_memory_region_hv) is nop.
> >
> > So Does it have similar issue?
>
> No, KVM doesn't allow a memslot's size to be changed, and PPC's rmap
> allocation is directly tied to the size of the memslot. The x86 bug exists
> because the size of its metadata arrays varies based on the alignment of
> the base gfn.
Yes, I was actually thinking those rmap would be invalid rather than
the size after the move. But I think kvm_arch_flush_shadow_memslot()
will flush all of them anyways... So yes it seems fine.
Thanks,
--
Peter Xu