Re: [PATCH v5 04/19] KVM: PPC: Move memslot memory allocation into prepare_memory_region()

From: Peter Xu
Date: Wed Feb 05 2020 - 17:42:03 EST


On Tue, Jan 21, 2020 at 02:31:42PM -0800, Sean Christopherson wrote:
> static int kvmppc_core_prepare_memory_region_hv(struct kvm *kvm,
> - struct kvm_memory_slot *memslot,
> - const struct kvm_userspace_memory_region *mem)
> + struct kvm_memory_slot *slot,
> + const struct kvm_userspace_memory_region *mem,
> + enum kvm_mr_change change)
> {
> + unsigned long npages = mem->memory_size >> PAGE_SHIFT;

Only in case if this patch still needs a respin: IIUC we can directly
use slot->npages below. No matter what:

Reviewed-by: Peter Xu <peterx@xxxxxxxxxx>

> +
> + if (change == KVM_MR_CREATE) {
> + slot->arch.rmap = vzalloc(array_size(npages,
> + sizeof(*slot->arch.rmap)));
> + if (!slot->arch.rmap)
> + return -ENOMEM;
> + }
> +
> return 0;
> }

--
Peter Xu