aboutsummaryrefslogtreecommitdiffstats
path: root/virt/kvm
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2018-06-27 10:51:05 -0400
committerMarc Zyngier <marc.zyngier@arm.com>2018-07-09 06:37:42 -0400
commit0db9dd8a0fbd5c861737bf2a8a2852e56dbd7ceb (patch)
tree0af37b0db4492e510c9366f9f3c8c7b16920c680 /virt/kvm
parent88dc25e8ea7c968bbf76d033431e2d7e1418bcd7 (diff)
KVM: arm/arm64: Stop using the kernel's {pmd,pud,pgd}_populate helpers
The {pmd,pud,pgd}_populate accessors usage have always been a bit weird in KVM. We don't have a struct mm to pass (and neither does the kernel most of the time, but still...), and the 32bit code has all kind of cache maintenance that doesn't make sense on ARMv7+ when MP extensions are mandatory (which is the case when the VEs are present). Let's bite the bullet and provide our own implementations. The only bit of architectural code left has to do with building the table entry itself (arm64 having up to 52bit PA, arm lacking PUD level). Acked-by: Mark Rutland <mark.rutland@arm.com> Acked-by: Christoffer Dall <christoffer.dall@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Diffstat (limited to 'virt/kvm')
-rw-r--r--virt/kvm/arm/mmu.c25
1 files changed, 21 insertions, 4 deletions
diff --git a/virt/kvm/arm/mmu.c b/virt/kvm/arm/mmu.c
index a6bdbed1903a..eade30caaa3c 100644
--- a/virt/kvm/arm/mmu.c
+++ b/virt/kvm/arm/mmu.c
@@ -189,6 +189,23 @@ static inline void kvm_set_pmd(pmd_t *pmdp, pmd_t new_pmd)
189 dsb(ishst); 189 dsb(ishst);
190} 190}
191 191
192static inline void kvm_pmd_populate(pmd_t *pmdp, pte_t *ptep)
193{
194 kvm_set_pmd(pmdp, kvm_mk_pmd(ptep));
195}
196
197static inline void kvm_pud_populate(pud_t *pudp, pmd_t *pmdp)
198{
199 WRITE_ONCE(*pudp, kvm_mk_pud(pmdp));
200 dsb(ishst);
201}
202
203static inline void kvm_pgd_populate(pgd_t *pgdp, pud_t *pudp)
204{
205 WRITE_ONCE(*pgdp, kvm_mk_pgd(pudp));
206 dsb(ishst);
207}
208
192/* 209/*
193 * Unmapping vs dcache management: 210 * Unmapping vs dcache management:
194 * 211 *
@@ -617,7 +634,7 @@ static int create_hyp_pmd_mappings(pud_t *pud, unsigned long start,
617 kvm_err("Cannot allocate Hyp pte\n"); 634 kvm_err("Cannot allocate Hyp pte\n");
618 return -ENOMEM; 635 return -ENOMEM;
619 } 636 }
620 pmd_populate_kernel(NULL, pmd, pte); 637 kvm_pmd_populate(pmd, pte);
621 get_page(virt_to_page(pmd)); 638 get_page(virt_to_page(pmd));
622 kvm_flush_dcache_to_poc(pmd, sizeof(*pmd)); 639 kvm_flush_dcache_to_poc(pmd, sizeof(*pmd));
623 } 640 }
@@ -650,7 +667,7 @@ static int create_hyp_pud_mappings(pgd_t *pgd, unsigned long start,
650 kvm_err("Cannot allocate Hyp pmd\n"); 667 kvm_err("Cannot allocate Hyp pmd\n");
651 return -ENOMEM; 668 return -ENOMEM;
652 } 669 }
653 pud_populate(NULL, pud, pmd); 670 kvm_pud_populate(pud, pmd);
654 get_page(virt_to_page(pud)); 671 get_page(virt_to_page(pud));
655 kvm_flush_dcache_to_poc(pud, sizeof(*pud)); 672 kvm_flush_dcache_to_poc(pud, sizeof(*pud));
656 } 673 }
@@ -687,7 +704,7 @@ static int __create_hyp_mappings(pgd_t *pgdp, unsigned long ptrs_per_pgd,
687 err = -ENOMEM; 704 err = -ENOMEM;
688 goto out; 705 goto out;
689 } 706 }
690 pgd_populate(NULL, pgd, pud); 707 kvm_pgd_populate(pgd, pud);
691 get_page(virt_to_page(pgd)); 708 get_page(virt_to_page(pgd));
692 kvm_flush_dcache_to_poc(pgd, sizeof(*pgd)); 709 kvm_flush_dcache_to_poc(pgd, sizeof(*pgd));
693 } 710 }
@@ -1106,7 +1123,7 @@ static int stage2_set_pte(struct kvm *kvm, struct kvm_mmu_memory_cache *cache,
1106 if (!cache) 1123 if (!cache)
1107 return 0; /* ignore calls from kvm_set_spte_hva */ 1124 return 0; /* ignore calls from kvm_set_spte_hva */
1108 pte = mmu_memory_cache_alloc(cache); 1125 pte = mmu_memory_cache_alloc(cache);
1109 pmd_populate_kernel(NULL, pmd, pte); 1126 kvm_pmd_populate(pmd, pte);
1110 get_page(virt_to_page(pmd)); 1127 get_page(virt_to_page(pmd));
1111 } 1128 }
1112 1129