Re: [RFC PATCH v0 2/2] KVM: PPC: Book3S HV: Use H_RPT_INVALIDATE in nested KVM
On Thu, Jul 09, 2020 at 08:07:11PM +1000, Paul Mackerras wrote: > On Thu, Jul 09, 2020 at 02:38:51PM +0530, Bharata B Rao wrote: > > On Thu, Jul 09, 2020 at 03:18:03PM +1000, Paul Mackerras wrote: > > > On Fri, Jul 03, 2020 at 04:14:20PM +0530, Bharata B Rao wrote: > > > > In the nested KVM case, replace H_TLB_INVALIDATE by the new hcall > > > > H_RPT_INVALIDATE if available. The availability of this hcall > > > > is determined from "hcall-rpt-invalidate" string in > > > > ibm,hypertas-functions > > > > DT property. > > > > > > What are we going to use when nested KVM supports HPT guests at L2? > > > L1 will need to do partition-scoped tlbies with R=0 via a hypercall, > > > but H_RPT_INVALIDATE says in its name that it only handles radix > > > page tables (i.e. R=1). > > > > For L2 HPT guests, the old hcall is expected to work after it adds > > support for R=0 case? > > That was the plan. > > > The new hcall should be advertised via ibm,hypertas-functions only > > for radix guests I suppose. > > Well, the L1 hypervisor is a radix guest of L0, so it would have > H_RPT_INVALIDATE available to it? > > I guess the question is whether H_RPT_INVALIDATE is supposed to do > everything, that is, radix process-scoped invalidations, radix > partition-scoped invalidations, and HPT partition-scoped > invalidations. If that is the plan then we should call it something > different. Guess we are bit late now to rename it and include HPT in the scope. > > This patchset seems to imply that H_RPT_INVALIDATE is at least going > to be used for radix partition-scoped invalidations as well as radix > process-scoped invalidations. If you are thinking that in future when > we need HPT partition-scoped invalidations for a radix L1 hypervisor > running a HPT L2 guest, we are going to define a new hypercall for > that, I suppose that is OK, though it doesn't really seem necessary. Guess a new hcall would be the way forward to cover the HPT L2 guest requirements. Thanks for pointing this out. Regards, Bharata.
Re: [RFC PATCH v0 2/2] KVM: PPC: Book3S HV: Use H_RPT_INVALIDATE in nested KVM
On Thu, Jul 09, 2020 at 02:38:51PM +0530, Bharata B Rao wrote: > On Thu, Jul 09, 2020 at 03:18:03PM +1000, Paul Mackerras wrote: > > On Fri, Jul 03, 2020 at 04:14:20PM +0530, Bharata B Rao wrote: > > > In the nested KVM case, replace H_TLB_INVALIDATE by the new hcall > > > H_RPT_INVALIDATE if available. The availability of this hcall > > > is determined from "hcall-rpt-invalidate" string in ibm,hypertas-functions > > > DT property. > > > > What are we going to use when nested KVM supports HPT guests at L2? > > L1 will need to do partition-scoped tlbies with R=0 via a hypercall, > > but H_RPT_INVALIDATE says in its name that it only handles radix > > page tables (i.e. R=1). > > For L2 HPT guests, the old hcall is expected to work after it adds > support for R=0 case? That was the plan. > The new hcall should be advertised via ibm,hypertas-functions only > for radix guests I suppose. Well, the L1 hypervisor is a radix guest of L0, so it would have H_RPT_INVALIDATE available to it? I guess the question is whether H_RPT_INVALIDATE is supposed to do everything, that is, radix process-scoped invalidations, radix partition-scoped invalidations, and HPT partition-scoped invalidations. If that is the plan then we should call it something different. This patchset seems to imply that H_RPT_INVALIDATE is at least going to be used for radix partition-scoped invalidations as well as radix process-scoped invalidations. If you are thinking that in future when we need HPT partition-scoped invalidations for a radix L1 hypervisor running a HPT L2 guest, we are going to define a new hypercall for that, I suppose that is OK, though it doesn't really seem necessary. Paul.
Re: [RFC PATCH v0 2/2] KVM: PPC: Book3S HV: Use H_RPT_INVALIDATE in nested KVM
On Thu, Jul 09, 2020 at 03:18:03PM +1000, Paul Mackerras wrote: > On Fri, Jul 03, 2020 at 04:14:20PM +0530, Bharata B Rao wrote: > > In the nested KVM case, replace H_TLB_INVALIDATE by the new hcall > > H_RPT_INVALIDATE if available. The availability of this hcall > > is determined from "hcall-rpt-invalidate" string in ibm,hypertas-functions > > DT property. > > What are we going to use when nested KVM supports HPT guests at L2? > L1 will need to do partition-scoped tlbies with R=0 via a hypercall, > but H_RPT_INVALIDATE says in its name that it only handles radix > page tables (i.e. R=1). For L2 HPT guests, the old hcall is expected to work after it adds support for R=0 case? The new hcall should be advertised via ibm,hypertas-functions only for radix guests I suppose. Regards, Bharata.
Re: [RFC PATCH v0 2/2] KVM: PPC: Book3S HV: Use H_RPT_INVALIDATE in nested KVM
On Fri, Jul 03, 2020 at 04:14:20PM +0530, Bharata B Rao wrote: > In the nested KVM case, replace H_TLB_INVALIDATE by the new hcall > H_RPT_INVALIDATE if available. The availability of this hcall > is determined from "hcall-rpt-invalidate" string in ibm,hypertas-functions > DT property. What are we going to use when nested KVM supports HPT guests at L2? L1 will need to do partition-scoped tlbies with R=0 via a hypercall, but H_RPT_INVALIDATE says in its name that it only handles radix page tables (i.e. R=1). Paul.
[RFC PATCH v0 2/2] KVM: PPC: Book3S HV: Use H_RPT_INVALIDATE in nested KVM
In the nested KVM case, replace H_TLB_INVALIDATE by the new hcall H_RPT_INVALIDATE if available. The availability of this hcall is determined from "hcall-rpt-invalidate" string in ibm,hypertas-functions DT property. Signed-off-by: Bharata B Rao --- arch/powerpc/include/asm/firmware.h | 4 +++- arch/powerpc/kvm/book3s_64_mmu_radix.c| 26 ++- arch/powerpc/kvm/book3s_hv_nested.c | 13 ++-- arch/powerpc/platforms/pseries/firmware.c | 1 + 4 files changed, 36 insertions(+), 8 deletions(-) diff --git a/arch/powerpc/include/asm/firmware.h b/arch/powerpc/include/asm/firmware.h index 6003c2e533a0..aa6a5ef5d483 100644 --- a/arch/powerpc/include/asm/firmware.h +++ b/arch/powerpc/include/asm/firmware.h @@ -52,6 +52,7 @@ #define FW_FEATURE_PAPR_SCMASM_CONST(0x0020) #define FW_FEATURE_ULTRAVISOR ASM_CONST(0x0040) #define FW_FEATURE_STUFF_TCE ASM_CONST(0x0080) +#define FW_FEATURE_RPT_INVALIDATE ASM_CONST(0x0100) #ifndef __ASSEMBLY__ @@ -71,7 +72,8 @@ enum { FW_FEATURE_TYPE1_AFFINITY | FW_FEATURE_PRRN | FW_FEATURE_HPT_RESIZE | FW_FEATURE_DRMEM_V2 | FW_FEATURE_DRC_INFO | FW_FEATURE_BLOCK_REMOVE | - FW_FEATURE_PAPR_SCM | FW_FEATURE_ULTRAVISOR, + FW_FEATURE_PAPR_SCM | FW_FEATURE_ULTRAVISOR | + FW_FEATURE_RPT_INVALIDATE, FW_FEATURE_PSERIES_ALWAYS = 0, FW_FEATURE_POWERNV_POSSIBLE = FW_FEATURE_OPAL | FW_FEATURE_ULTRAVISOR, FW_FEATURE_POWERNV_ALWAYS = 0, diff --git a/arch/powerpc/kvm/book3s_64_mmu_radix.c b/arch/powerpc/kvm/book3s_64_mmu_radix.c index e738ea652192..8411e42eedbd 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_radix.c +++ b/arch/powerpc/kvm/book3s_64_mmu_radix.c @@ -21,6 +21,7 @@ #include #include #include +#include /* * Supported radix tree geometry. @@ -313,9 +314,17 @@ void kvmppc_radix_tlbie_page(struct kvm *kvm, unsigned long addr, } psi = shift_to_mmu_psize(pshift); - rb = addr | (mmu_get_ap(psi) << PPC_BITLSHIFT(58)); - rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(0, 0, 1), - lpid, rb); + if (!firmware_has_feature(FW_FEATURE_RPT_INVALIDATE)) { + rb = addr | (mmu_get_ap(psi) << PPC_BITLSHIFT(58)); + rc = plpar_hcall_norets(H_TLB_INVALIDATE, + H_TLBIE_P1_ENC(0, 0, 1), lpid, rb); + } else { + rc = pseries_rpt_invalidate(lpid, H_RPTI_TARGET_CMMU, + H_RPTI_TYPE_NESTED | + H_RPTI_TYPE_TLB, + psize_to_rpti_pgsize(psi), + addr, addr + psize); + } if (rc) pr_err("KVM: TLB page invalidation hcall failed, rc=%ld\n", rc); } @@ -329,8 +338,15 @@ static void kvmppc_radix_flush_pwc(struct kvm *kvm, unsigned int lpid) return; } - rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(1, 0, 1), - lpid, TLBIEL_INVAL_SET_LPID); + if (!firmware_has_feature(FW_FEATURE_RPT_INVALIDATE)) + rc = plpar_hcall_norets(H_TLB_INVALIDATE, + H_TLBIE_P1_ENC(1, 0, 1), + lpid, TLBIEL_INVAL_SET_LPID); + else + rc = pseries_rpt_invalidate(lpid, H_RPTI_TARGET_CMMU, + H_RPTI_TYPE_NESTED | + H_RPTI_TYPE_PWC, H_RPTI_PAGE_ALL, + 0, -1UL); if (rc) pr_err("KVM: TLB PWC invalidation hcall failed, rc=%ld\n", rc); } diff --git a/arch/powerpc/kvm/book3s_hv_nested.c b/arch/powerpc/kvm/book3s_hv_nested.c index efb78d37f29a..4d023c451be4 100644 --- a/arch/powerpc/kvm/book3s_hv_nested.c +++ b/arch/powerpc/kvm/book3s_hv_nested.c @@ -19,6 +19,7 @@ #include #include #include +#include static struct patb_entry *pseries_partition_tb; @@ -401,8 +402,16 @@ static void kvmhv_flush_lpid(unsigned int lpid) return; } - rc = plpar_hcall_norets(H_TLB_INVALIDATE, H_TLBIE_P1_ENC(2, 0, 1), - lpid, TLBIEL_INVAL_SET_LPID); + if (!firmware_has_feature(FW_FEATURE_RPT_INVALIDATE)) + rc = plpar_hcall_norets(H_TLB_INVALIDATE, + H_TLBIE_P1_ENC(2, 0, 1), + lpid, TLBIEL_INVAL_SET_LPID); + else + rc = pseries_rpt_invalidate(lpid, H_RPTI_TARGET_CMMU, + H_RPTI_TYPE_NESTED | + H_RPTI_TYPE_TLB | H_RPTI_TYPE_PWC | + H_RPTI_TYPE_PAT, +