Re: [RFC PATCH 3/7] ARM: KVM: remove handling of IO mapping from stage2_set_pte

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

 



On Wed, Feb 13, 2013 at 03:47:00PM +0000, Marc Zyngier wrote:
> Simplify stage2_set_pte() by removing the IO mapping handling.
> kvm_phys_addr_ioremap() now directly calls stage2_get_pte() and
> stage2_set_pte_at().
> 
> This allows for the removal of the iomap flag in stage2_set_pte()
> prototype.
> 
> Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx>
> ---
>  arch/arm/kvm/mmu.c | 22 +++++++++++-----------
>  1 file changed, 11 insertions(+), 11 deletions(-)
> 
> diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
> index ab35906..8fde75b 100644
> --- a/arch/arm/kvm/mmu.c
> +++ b/arch/arm/kvm/mmu.c
> @@ -459,18 +459,13 @@ static void stage2_set_pte_at(struct kvm *kvm, phys_addr_t addr,
>  }
>  
>  static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
> -			  phys_addr_t addr, const pte_t *new_pte, bool iomap)
> +			  phys_addr_t addr, const pte_t *new_pte)
>  {
>  	pte_t *pte;
>  
>  	pte = stage2_get_pte(kvm, cache, addr);
> -	if (!pte)
> -		return 0;
> -
> -	if (iomap && pte_present(*pte))
> -		return -EFAULT;
> -
> -	stage2_set_pte_at(kvm, addr, pte, *new_pte);
> +	if (pte)
> +		stage2_set_pte_at(kvm, addr, pte, *new_pte);

this should never happen now right? I think we can get rid of this
function (but I think stage2_set_pte_at should be named stage2_set_pte).

>  
>  	return 0;
>  }
> @@ -495,6 +490,7 @@ int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa,
>  	pfn = __phys_to_pfn(pa);
>  
>  	for (addr = guest_ipa; addr < end; addr += PAGE_SIZE) {
> +		pte_t *ptep;
>  		pte_t pte = pfn_pte(pfn, PAGE_S2_DEVICE);
>  		kvm_set_s2pte_writable(&pte);
>  
> @@ -502,7 +498,11 @@ int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa,
>  		if (ret)
>  			goto out;
>  		spin_lock(&kvm->mmu_lock);
> -		ret = stage2_set_pte(kvm, &cache, addr, &pte, true);
> +		ptep = stage2_get_pte(kvm, &cache, addr);
> +		if (pte_present(*ptep))
> +			ret = -EFAULT;
> +		else
> +			stage2_set_pte_at(kvm, addr, ptep, pte);
>  		spin_unlock(&kvm->mmu_lock);
>  		if (ret)
>  			goto out;
> @@ -563,7 +563,7 @@ static int user_mem_abort(struct kvm_vcpu *vcpu, phys_addr_t fault_ipa,
>  		kvm_set_s2pte_writable(&new_pte);
>  		kvm_set_pfn_dirty(pfn);
>  	}
> -	stage2_set_pte(vcpu->kvm, memcache, fault_ipa, &new_pte, false);
> +	stage2_set_pte(vcpu->kvm, memcache, fault_ipa, &new_pte);
>  
>  out_unlock:
>  	spin_unlock(&vcpu->kvm->mmu_lock);
> @@ -720,7 +720,7 @@ static void kvm_set_spte_handler(struct kvm *kvm, gpa_t gpa, void *data)
>  {
>  	pte_t *pte = (pte_t *)data;
>  
> -	stage2_set_pte(kvm, NULL, gpa, pte, false);
> +	stage2_set_pte(kvm, NULL, gpa, pte);
>  }
>  
>  
> -- 
> 1.8.1.2
> 
> 
> 
> _______________________________________________
> kvmarm mailing list
> kvmarm@xxxxxxxxxxxxxxxxxxxxx
> https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/cucslists/listinfo/kvmarm


[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux