> -----Original Message----- > From: kvm-ppc-owner@xxxxxxxxxxxxxxx [mailto:kvm-ppc- > owner@xxxxxxxxxxxxxxx] On Behalf Of Alexander Graf > Sent: Thursday, March 21, 2013 12:07 PM > To: Caraman Mihai Claudiu-B02008 > Cc: kvm-ppc@xxxxxxxxxxxxxxx; kvm@xxxxxxxxxxxxxxx; linuxppc- > dev@xxxxxxxxxxxxxxxx > Subject: Re: [PATCH] KVM: PPC: e500: Add separate functions for vcpu's > MMU configuration > > > On 19.03.2013, at 18:16, Mihai Caraman wrote: > > > Move vcpu's MMU default configuration and geometry update into their > own > > functions. > > Mind to explain why? You requested a separate function for clearing TLBnCFG_IND bit (E.PT removal) to self-document the code. The existing logic (that TLBnCFG_IND relies on) was buried in a chunk of code and I thought this will add more clarity. If you don't agree I would document the code at least. -Mike > > > Alex > > > > > Signed-off-by: Mihai Caraman <mihai.caraman@xxxxxxxxxxxxx> > > --- > > arch/powerpc/kvm/e500_mmu.c | 59 +++++++++++++++++++++++++++--------- > ------- > > 1 files changed, 37 insertions(+), 22 deletions(-) > > > > diff --git a/arch/powerpc/kvm/e500_mmu.c b/arch/powerpc/kvm/e500_mmu.c > > index 5c44759..66b6e31 100644 > > --- a/arch/powerpc/kvm/e500_mmu.c > > +++ b/arch/powerpc/kvm/e500_mmu.c > > @@ -596,6 +596,20 @@ int kvmppc_set_sregs_e500_tlb(struct kvm_vcpu > *vcpu, struct kvm_sregs *sregs) > > return 0; > > } > > > > +static int vcpu_mmu_geometry_update(struct kvm_vcpu *vcpu, > > + struct kvm_book3e_206_tlb_params *params) > > +{ > > + vcpu->arch.tlbcfg[0] &= ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC); > > + if (params->tlb_sizes[0] <= 2048) > > + vcpu->arch.tlbcfg[0] |= params->tlb_sizes[0]; > > + vcpu->arch.tlbcfg[0] |= params->tlb_ways[0] << TLBnCFG_ASSOC_SHIFT; > > + > > + vcpu->arch.tlbcfg[1] &= ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC); > > + vcpu->arch.tlbcfg[1] |= params->tlb_sizes[1]; > > + vcpu->arch.tlbcfg[1] |= params->tlb_ways[1] << TLBnCFG_ASSOC_SHIFT; > > + return 0; > > +} > > + > > int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu *vcpu, > > struct kvm_config_tlb *cfg) > > { > > @@ -692,16 +706,8 @@ int kvm_vcpu_ioctl_config_tlb(struct kvm_vcpu > *vcpu, > > vcpu_e500->gtlb_offset[0] = 0; > > vcpu_e500->gtlb_offset[1] = params.tlb_sizes[0]; > > > > - vcpu->arch.mmucfg = mfspr(SPRN_MMUCFG) & ~MMUCFG_LPIDSIZE; > > - > > - vcpu->arch.tlbcfg[0] &= ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC); > > - if (params.tlb_sizes[0] <= 2048) > > - vcpu->arch.tlbcfg[0] |= params.tlb_sizes[0]; > > - vcpu->arch.tlbcfg[0] |= params.tlb_ways[0] << TLBnCFG_ASSOC_SHIFT; > > - > > - vcpu->arch.tlbcfg[1] &= ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC); > > - vcpu->arch.tlbcfg[1] |= params.tlb_sizes[1]; > > - vcpu->arch.tlbcfg[1] |= params.tlb_ways[1] << TLBnCFG_ASSOC_SHIFT; > > + /* Update vcpu's MMU geometry based on SW_TLB input */ > > + vcpu_mmu_geometry_update(vcpu, ¶ms); > > > > vcpu_e500->shared_tlb_pages = pages; > > vcpu_e500->num_shared_tlb_pages = num_pages; > > @@ -737,6 +743,26 @@ int kvm_vcpu_ioctl_dirty_tlb(struct kvm_vcpu > *vcpu, > > return 0; > > } > > > > +/* vcpu's MMU default configuration */ > > +static int vcpu_mmu_init(struct kvm_vcpu *vcpu, > > + struct kvmppc_e500_tlb_params *params) > > +{ > > + /* Initialize RASIZE, PIDSIZE, NTLBS and MAVN fields with host > values*/ > > + vcpu->arch.mmucfg = mfspr(SPRN_MMUCFG) & ~MMUCFG_LPIDSIZE; > > + > > + /* Initialize IPROT field with host value*/ > > + vcpu->arch.tlbcfg[0] = mfspr(SPRN_TLB0CFG) & > > + ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC); > > + vcpu->arch.tlbcfg[0] |= params[0].entries; > > + vcpu->arch.tlbcfg[0] |= params[0].ways << TLBnCFG_ASSOC_SHIFT; > > + > > + vcpu->arch.tlbcfg[1] = mfspr(SPRN_TLB1CFG) & > > + ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC); > > + vcpu->arch.tlbcfg[1] |= params[1].entries; > > + vcpu->arch.tlbcfg[1] |= params[1].ways << TLBnCFG_ASSOC_SHIFT; > > + return 0; > > +} > > + > > int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 *vcpu_e500) > > { > > struct kvm_vcpu *vcpu = &vcpu_e500->vcpu; > > @@ -781,18 +807,7 @@ int kvmppc_e500_tlb_init(struct kvmppc_vcpu_e500 > *vcpu_e500) > > if (!vcpu_e500->g2h_tlb1_map) > > goto err; > > > > - /* Init TLB configuration register */ > > - vcpu->arch.tlbcfg[0] = mfspr(SPRN_TLB0CFG) & > > - ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC); > > - vcpu->arch.tlbcfg[0] |= vcpu_e500->gtlb_params[0].entries; > > - vcpu->arch.tlbcfg[0] |= > > - vcpu_e500->gtlb_params[0].ways << TLBnCFG_ASSOC_SHIFT; > > - > > - vcpu->arch.tlbcfg[1] = mfspr(SPRN_TLB1CFG) & > > - ~(TLBnCFG_N_ENTRY | TLBnCFG_ASSOC); > > - vcpu->arch.tlbcfg[1] |= vcpu_e500->gtlb_params[1].entries; > > - vcpu->arch.tlbcfg[1] |= > > - vcpu_e500->gtlb_params[1].ways << TLBnCFG_ASSOC_SHIFT; > > + vcpu_mmu_init(vcpu, vcpu_e500->gtlb_params); > > > > kvmppc_recalc_tlb1map_range(vcpu_e500); > > return 0; > > -- > > 1.7.4.1 > > > > > > -- > > To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in > > the body of a message to majordomo@xxxxxxxxxxxxxxx > > More majordomo info at http://vger.kernel.org/majordomo-info.html > > -- > To unsubscribe from this list: send the line "unsubscribe kvm-ppc" in > the body of a message to majordomo@xxxxxxxxxxxxxxx > More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html