From: Ram Pai Date: Wed, 03 Jun 2020 13:25:16 +0000 Subject: Re: [PATCH v1 4/4] KVM: PPC: Book3S HV: migrate hot plugged memory Message-Id: <20200603132516.GA5423@oc0525413822.ibm.com> List-Id: References: <1590892071-25549-1-git-send-email-linuxram@us.ibm.com> <1590892071-25549-5-git-send-email-linuxram@us.ibm.com> <1df25542-1977-fad4-c56d-b6b2c40a6852@linux.ibm.com> In-Reply-To: <1df25542-1977-fad4-c56d-b6b2c40a6852@linux.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable To: Laurent Dufour Cc: cclaudio@linux.ibm.com, kvm-ppc@vger.kernel.org, bharata@linux.ibm.com, aneesh.kumar@linux.ibm.com, sukadev@linux.vnet.ibm.com, linuxppc-dev@lists.ozlabs.org, bauerman@linux.ibm.com, david@gibson.dropbear.id.au On Tue, Jun 02, 2020 at 10:31:32AM +0200, Laurent Dufour wrote: > Le 31/05/2020 =E0 04:27, Ram Pai a =E9crit=A0: > >From: Laurent Dufour > > > >When a memory slot is hot plugged to a SVM, GFNs associated with that > >memory slot automatically default to secure GFN. Hence migrate the > >PFNs associated with these GFNs to device-PFNs. > > > >uv_migrate_mem_slot() is called to achieve that. It will not call > >UV_PAGE_IN since this request is ignored by the Ultravisor. > >NOTE: Ultravisor does not trust any page content provided by > >the Hypervisor, ones the VM turns secure. > > > >Cc: Paul Mackerras > >Cc: Benjamin Herrenschmidt > >Cc: Michael Ellerman > >Cc: Bharata B Rao > >Cc: Aneesh Kumar K.V > >Cc: Sukadev Bhattiprolu > >Cc: Laurent Dufour > >Cc: Thiago Jung Bauermann > >Cc: David Gibson > >Cc: Claudio Carvalho > >Cc: kvm-ppc@vger.kernel.org > >Cc: linuxppc-dev@lists.ozlabs.org > >Signed-off-by: Ram Pai > > (fixed merge conflicts. Modified the commit message) > >Signed-off-by: Laurent Dufour > >--- > > arch/powerpc/include/asm/kvm_book3s_uvmem.h | 4 ++++ > > arch/powerpc/kvm/book3s_hv.c | 11 +++++++---- > > arch/powerpc/kvm/book3s_hv_uvmem.c | 3 +-- > > 3 files changed, 12 insertions(+), 6 deletions(-) > > > >diff --git a/arch/powerpc/include/asm/kvm_book3s_uvmem.h b/arch/powerpc/= include/asm/kvm_book3s_uvmem.h > >index f0c5708..2ec2e5afb 100644 > >--- a/arch/powerpc/include/asm/kvm_book3s_uvmem.h > >+++ b/arch/powerpc/include/asm/kvm_book3s_uvmem.h > >@@ -23,6 +23,7 @@ unsigned long kvmppc_h_svm_page_out(struct kvm *kvm, > > void kvmppc_uvmem_drop_pages(const struct kvm_memory_slot *free, > > struct kvm *kvm, bool skip_page_out, > > bool purge_gfn); > >+int uv_migrate_mem_slot(struct kvm *kvm, const struct kvm_memory_slot *= memslot); > > #else > > static inline int kvmppc_uvmem_init(void) > > { > >@@ -78,5 +79,8 @@ static inline int kvmppc_send_page_to_uv(struct kvm *k= vm, unsigned long gfn) > > kvmppc_uvmem_drop_pages(const struct kvm_memory_slot *free, > > struct kvm *kvm, bool skip_page_out, > > bool purge_gfn) { } > >+ > >+static int uv_migrate_mem_slot(struct kvm *kvm, > >+ const struct kvm_memory_slot *memslot); >=20 > That line was not part of the patch I sent to you! Your patch is rebased on top of my patches. This prototype declaration is for the ifndef CONFIG_PPC_UV case. >=20 >=20 > > #endif /* CONFIG_PPC_UV */ > > #endif /* __ASM_KVM_BOOK3S_UVMEM_H__ */ > >diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > >index 4c62bfe..604d062 100644 > >--- a/arch/powerpc/kvm/book3s_hv.c > >+++ b/arch/powerpc/kvm/book3s_hv.c > >@@ -4516,13 +4516,16 @@ static void kvmppc_core_commit_memory_region_hv(= struct kvm *kvm, > > case KVM_MR_CREATE: > > if (kvmppc_uvmem_slot_init(kvm, new)) > > return; > >- uv_register_mem_slot(kvm->arch.lpid, > >- new->base_gfn << PAGE_SHIFT, > >- new->npages * PAGE_SIZE, > >- 0, new->id); > >+ if (uv_register_mem_slot(kvm->arch.lpid, > >+ new->base_gfn << PAGE_SHIFT, > >+ new->npages * PAGE_SIZE, > >+ 0, new->id)) > >+ return; > >+ uv_migrate_mem_slot(kvm, new); > > break; > > case KVM_MR_DELETE: > > uv_unregister_mem_slot(kvm->arch.lpid, old->id); > >+ kvmppc_uvmem_drop_pages(old, kvm, true, true); >=20 > Again that line has been changed from the patch I sent to you. The > last 'true' argument has nothing to do here. yes. i did add another parameter to kvmppc_uvmem_drop_pages() in my patch series. So had to adapt your patch to operate on top my mine. >=20 > Is that series really building? yes. it built for me. RP