Re: [PATCH] KVM: PPC: e500: Add separate functions for vcpu's MMU configuration

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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?


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, &params);
> 
> 	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" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux