On Thu, Nov 01, 2018 at 09:49:26PM +1100, Balbir Singh wrote: > On Mon, Oct 22, 2018 at 10:48:36AM +0530, Bharata B Rao wrote: > > H_SVM_INIT_START: Initiate securing a VM > > H_SVM_INIT_DONE: Conclude securing a VM > > > > During early guest init, these hcalls will be issued by UV. > > As part of these hcalls, [un]register memslots with UV. > > > > Signed-off-by: Bharata B Rao <bharata@xxxxxxxxxxxxx> > > --- > > arch/powerpc/include/asm/hvcall.h | 4 ++- > > arch/powerpc/include/asm/kvm_host.h | 1 + > > arch/powerpc/include/asm/ucall-api.h | 6 ++++ > > arch/powerpc/kvm/book3s_hv.c | 54 ++++++++++++++++++++++++++++ > > 4 files changed, 64 insertions(+), 1 deletion(-) > > > > diff --git a/arch/powerpc/include/asm/hvcall.h b/arch/powerpc/include/asm/hvcall.h > > index 89e6b70c1857..6091276fef07 100644 > > --- a/arch/powerpc/include/asm/hvcall.h > > +++ b/arch/powerpc/include/asm/hvcall.h > > @@ -300,7 +300,9 @@ > > #define H_INT_RESET 0x3D0 > > #define H_SVM_PAGE_IN 0x3D4 > > #define H_SVM_PAGE_OUT 0x3D8 > > -#define MAX_HCALL_OPCODE H_SVM_PAGE_OUT > > +#define H_SVM_INIT_START 0x3DC > > +#define H_SVM_INIT_DONE 0x3E0 > > +#define MAX_HCALL_OPCODE H_SVM_INIT_DONE > > > > /* H_VIOCTL functions */ > > #define H_GET_VIOA_DUMP_SIZE 0x01 > > diff --git a/arch/powerpc/include/asm/kvm_host.h b/arch/powerpc/include/asm/kvm_host.h > > index 194e6e0ff239..267f8c568bc3 100644 > > --- a/arch/powerpc/include/asm/kvm_host.h > > +++ b/arch/powerpc/include/asm/kvm_host.h > > @@ -292,6 +292,7 @@ struct kvm_arch { > > struct dentry *debugfs_dir; > > struct dentry *htab_dentry; > > struct kvm_resize_hpt *resize_hpt; /* protected by kvm->lock */ > > + bool svm_init_start; /* Indicates H_SVM_INIT_START has been called */ > > #endif /* CONFIG_KVM_BOOK3S_HV_POSSIBLE */ > > #ifdef CONFIG_KVM_BOOK3S_PR_POSSIBLE > > struct mutex hpt_mutex; > > diff --git a/arch/powerpc/include/asm/ucall-api.h b/arch/powerpc/include/asm/ucall-api.h > > index 2c12f514f8ab..9ddfcf541211 100644 > > --- a/arch/powerpc/include/asm/ucall-api.h > > +++ b/arch/powerpc/include/asm/ucall-api.h > > @@ -17,4 +17,10 @@ static inline int uv_page_out(u64 lpid, u64 dw0, u64 dw1, u64 dw2, u64 dw3) > > return U_SUCCESS; > > } > > > > +static inline int uv_register_mem_slot(u64 lpid, u64 dw0, u64 dw1, u64 dw2, > > + u64 dw3) > > +{ > > + return 0; > > +} > > + > > #endif /* _ASM_POWERPC_UCALL_API_H */ > > diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c > > index 05084eb8aadd..47f366f634fd 100644 > > --- a/arch/powerpc/kvm/book3s_hv.c > > +++ b/arch/powerpc/kvm/book3s_hv.c > > @@ -819,6 +819,50 @@ static int kvmppc_get_yield_count(struct kvm_vcpu *vcpu) > > return yield_count; > > } > > > > +#ifdef CONFIG_PPC_SVM > > +#include <asm/ucall-api.h> > > +/* > > + * TODO: Check if memslots related calls here need to be called > > + * under any lock. > > + */ > > +static unsigned long kvmppc_h_svm_init_start(struct kvm *kvm) > > +{ > > + struct kvm_memslots *slots; > > + struct kvm_memory_slot *memslot; > > + int ret; > > + > > + slots = kvm_memslots(kvm); > > + kvm_for_each_memslot(memslot, slots) { > > + ret = uv_register_mem_slot(kvm->arch.lpid, > > + memslot->base_gfn << PAGE_SHIFT, > > + memslot->npages * PAGE_SIZE, > > + 0, memslot->id); > > For every memslot their is a corresponding registration in the ultravisor? > Is there a corresponding teardown? Yes, uv_unregister_mem_slot(), called during memory unplug time. Regards, Bharata.