KVM: arm64: Mark freed S2 MMUs as invalid
Marc Zyngier
maintainerPATCH 1/1 KVM: arm64: Mark freed S2 MMUs as invalid
When freeing an S2 MMU, we free the associated pgd, but omit to mark the structure as invalid. Subsequently, a call to kvm_nested_s2_unmap() would pick these invalid S2 MMUs and pass them down the teardown path.
This ends up with a nasty warning as we try to unmap an unallocated set of page tables.
Fix this by making the S2 MMU invalid on freeing the pgd by calling kvm_init_nested_s2_mmu().
--- arch/arm64/kvm/mmu.c | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm64/kvm/mmu.c +4 -0
@@ -1074,6 +1074,10 @@ void kvm_free_stage2_pgd(struct kvm_s2_mmu *mmu) mmu->pgt =NULL ;free_percpu (mmu->last_vcpu_ran); } + +if (kvm_is_nested_s2_mmu (kvm, mmu)) +kvm_init_nested_s2_mmu (mmu); +write_unlock (&kvm->mmu_lock);if (pgt) {
Signature · 1 line
2.47.2
Oliver Upton
AppliedQuoted 9 lines · Marc Zyngier
When freeing an S2 MMU, we free the associated pgd, but omit to mark the structure as invalid. Subsequently, a call to
kvm_nested_s2_unmap()would pick these invalid S2 MMUs and pass them down the teardown path.This ends up with a nasty warning as we try to unmap an unallocated set of page tables.
[...]
Applied to fixes, thanks!
[1/1] KVM: arm64: Mark freed S2 MMUs as invalid
https://git.kernel.org/kvmarm/kvmarm/c/34b8f4adedd5
--
Best,
Oliver