@@ -421,8 +421,8 @@ static void stage2_clear_pte(struct kvm *kvm, phys_addr_t addr)
kvm_tlb_flush_vmid(kvm);
}
-static void stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
- phys_addr_t addr, const pte_t *new_pte, bool iomap)
+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)
{
pgd_t *pgd;
pud_t *pud;
@@ -434,7 +434,7 @@ static void stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
pud = pud_offset(pgd, addr);
if (pud_none(*pud)) {
if (!cache)
- return; /* ignore calls from kvm_set_spte_hva */
+ return 0; /* ignore calls from kvm_set_spte_hva */
pmd = mmu_memory_cache_alloc(cache);
pud_populate(NULL, pud, pmd);
pmd += pmd_index(addr);
@@ -445,7 +445,7 @@ static void stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
/* Create 2nd stage page table mapping - Level 2 */
if (pmd_none(*pmd)) {
if (!cache)
- return; /* ignore calls from kvm_set_spte_hva */
+ return 0; /* ignore calls from kvm_set_spte_hva */
pte = mmu_memory_cache_alloc(cache);
clean_pte_table(pte);
pmd_populate_kernel(NULL, pmd, pte);
@@ -454,7 +454,7 @@ static void stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
} else
pte = pte_offset_kernel(pmd, addr);
- if (iomap && pte_present(old_pte))
+ if (iomap && pte_present(*pte))
return -EFAULT;
/* Create 2nd stage page table mapping - Level 3 */
@@ -464,6 +464,8 @@ static void stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
kvm_tlb_flush_vmid(kvm);
else
get_page(virt_to_page(pte));
+
+ return 0;
}
/**
@@ -492,8 +494,10 @@ int kvm_phys_addr_ioremap(struct kvm *kvm, phys_addr_t guest_ipa,
if (ret)
goto out;
spin_lock(&kvm->mmu_lock);
- stage2_set_pte(kvm, &cache, addr, &pte, true);
+ ret = stage2_set_pte(kvm, &cache, addr, &pte, true);
spin_unlock(&kvm->mmu_lock);
+ if (ret)
+ goto out;
pfn++;
}
Missed a commit of my working tree, so accidentally sent out the wrong patch. This fixes it. Signed-off-by: Christoffer Dall <c.dall@virtualopensystems.com> --- arch/arm/kvm/mmu.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)