[RFC PATCH 2/7] ARM: KVM: introduce stage2_set_pte_at

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

 



As we carry on deconstructing stage2_set_pte(), introduce a method
to write a pte at a given location.

Make the prototype similar to the kernel set_pte_at(), so the properties
are not completely surprising. Convert stage2_set_pte() to make use
of stage_set_pte_at().

Signed-off-by: Marc Zyngier <marc.zyngier@xxxxxxx>
---
 arch/arm/kvm/mmu.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/arch/arm/kvm/mmu.c b/arch/arm/kvm/mmu.c
index cb2b42e..ab35906 100644
--- a/arch/arm/kvm/mmu.c
+++ b/arch/arm/kvm/mmu.c
@@ -444,10 +444,24 @@ static pte_t *stage2_get_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache
 	return pte_offset_kernel(pmd, addr);
 }
 
+static void stage2_set_pte_at(struct kvm *kvm, phys_addr_t addr,
+			      pte_t *pte, const pte_t pteval)
+{
+	pte_t old_pte;
+
+	/* Create 2nd stage page table mapping - Level 3 */
+	old_pte = *pte;
+	kvm_set_pte(pte, pteval);
+	if (pte_present(old_pte))
+		kvm_tlb_flush_vmid_ipa(kvm, addr);
+	else
+		get_page(virt_to_page(pte));
+}
+
 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)
 {
-	pte_t *pte, old_pte;
+	pte_t *pte;
 
 	pte = stage2_get_pte(kvm, cache, addr);
 	if (!pte)
@@ -456,13 +470,7 @@ static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
 	if (iomap && pte_present(*pte))
 		return -EFAULT;
 
-	/* Create 2nd stage page table mapping - Level 3 */
-	old_pte = *pte;
-	kvm_set_pte(pte, *new_pte);
-	if (pte_present(old_pte))
-		kvm_tlb_flush_vmid_ipa(kvm, addr);
-	else
-		get_page(virt_to_page(pte));
+	stage2_set_pte_at(kvm, addr, pte, *new_pte);
 
 	return 0;
 }
-- 
1.8.1.2



_______________________________________________
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