Skip to content

Commit 094d00f

Browse files
author
Marc Zyngier
committed
KVM: arm64: pkvm: Use the mm_ops indirection for cache maintenance
CMOs issued from EL2 cannot directly use the kernel helpers, as EL2 doesn't have a mapping of the guest pages. Oops. Instead, use the mm_ops indirection to use helpers that will perform a mapping at EL2 and allow the CMO to be effective. Fixes: 25aa286 ("KVM: arm64: Move guest CMOs to the fault handlers") Reviewed-by: Quentin Perret <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1c53a1a commit 094d00f

File tree

1 file changed

+6
-12
lines changed

1 file changed

+6
-12
lines changed

arch/arm64/kvm/hyp/pgtable.c

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -983,13 +983,9 @@ static int stage2_unmap_walker(u64 addr, u64 end, u32 level, kvm_pte_t *ptep,
983983
*/
984984
stage2_put_pte(ptep, mmu, addr, level, mm_ops);
985985

986-
if (need_flush) {
987-
kvm_pte_t *pte_follow = kvm_pte_follow(pte, mm_ops);
988-
989-
dcache_clean_inval_poc((unsigned long)pte_follow,
990-
(unsigned long)pte_follow +
991-
kvm_granule_size(level));
992-
}
986+
if (need_flush && mm_ops->dcache_clean_inval_poc)
987+
mm_ops->dcache_clean_inval_poc(kvm_pte_follow(pte, mm_ops),
988+
kvm_granule_size(level));
993989

994990
if (childp)
995991
mm_ops->put_page(childp);
@@ -1151,15 +1147,13 @@ static int stage2_flush_walker(u64 addr, u64 end, u32 level, kvm_pte_t *ptep,
11511147
struct kvm_pgtable *pgt = arg;
11521148
struct kvm_pgtable_mm_ops *mm_ops = pgt->mm_ops;
11531149
kvm_pte_t pte = *ptep;
1154-
kvm_pte_t *pte_follow;
11551150

11561151
if (!kvm_pte_valid(pte) || !stage2_pte_cacheable(pgt, pte))
11571152
return 0;
11581153

1159-
pte_follow = kvm_pte_follow(pte, mm_ops);
1160-
dcache_clean_inval_poc((unsigned long)pte_follow,
1161-
(unsigned long)pte_follow +
1162-
kvm_granule_size(level));
1154+
if (mm_ops->dcache_clean_inval_poc)
1155+
mm_ops->dcache_clean_inval_poc(kvm_pte_follow(pte, mm_ops),
1156+
kvm_granule_size(level));
11631157
return 0;
11641158
}
11651159

0 commit comments

Comments
 (0)