[PATCH v2 06/13] KVM: arm64: Size the stage-2 memcache from the fault MMU
From: Lorenzo Stoakes (ARM)
Date: Mon Sep 14 2026 - 09:14:57 EST
topup_mmu_memcache() sizes the page-table cache from
vcpu->arch.hw_mmu, which is the MMU that faulted.
Pass the target s2fd->mmu instead, so the mmu used can be controlled by the
caller.
For a guest abort this is vcpu->arch.hw_mmu, so this commit introduces no
functional change in practice.
However, it's necessary for a future change which introduces stage 2
pre-faulting which must always target the canonical MMU regardless of the
vCPU's last-run context.
No functional change intended.
Signed-off-by: Lorenzo Stoakes (ARM) <ljs@xxxxxxxxxx>
---
arch/arm64/kvm/mmu.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/arch/arm64/kvm/mmu.c b/arch/arm64/kvm/mmu.c
index 13541218cadb..8c23fef4ecf8 100644
--- a/arch/arm64/kvm/mmu.c
+++ b/arch/arm64/kvm/mmu.c
@@ -1554,9 +1554,9 @@ static void *get_mmu_memcache(struct kvm_vcpu *vcpu)
return &vcpu->arch.pkvm_memcache;
}
-static int topup_mmu_memcache(struct kvm_vcpu *vcpu, void *memcache)
+static int topup_mmu_memcache(struct kvm_s2_mmu *mmu, void *memcache)
{
- int min_pages = kvm_mmu_cache_min_pages(vcpu->arch.hw_mmu);
+ int min_pages = kvm_mmu_cache_min_pages(mmu);
if (!is_protected_kvm_enabled())
return kvm_mmu_topup_memory_cache(memcache, min_pages);
@@ -1654,7 +1654,7 @@ static int gmem_abort(const struct kvm_s2_fault_desc *s2fd,
if (!perm_fault) {
memcache = get_mmu_memcache(s2fd->vcpu);
- ret = topup_mmu_memcache(s2fd->vcpu, memcache);
+ ret = topup_mmu_memcache(s2fd->mmu, memcache);
if (ret)
return ret;
}
@@ -1755,7 +1755,7 @@ static int pkvm_mem_abort(const struct kvm_s2_fault_desc *s2fd)
int ret;
hyp_memcache = get_mmu_memcache(vcpu);
- ret = topup_mmu_memcache(vcpu, hyp_memcache);
+ ret = topup_mmu_memcache(s2fd->mmu, hyp_memcache);
if (ret)
return -ENOMEM;
@@ -2159,7 +2159,7 @@ static int user_mem_abort(const struct kvm_s2_fault_desc *s2fd,
memcache = get_mmu_memcache(s2fd->vcpu);
if (!perm_fault || memslot_is_logging(s2fd->memslot) ||
is_protected_kvm_enabled()) {
- ret = topup_mmu_memcache(s2fd->vcpu, memcache);
+ ret = topup_mmu_memcache(s2fd->mmu, memcache);
if (ret)
return ret;
}
--
2.55.0