ANDROID: KVM: arm64: Fix pKVM VM teardown leak

Somehow, commit 144a77d178 ("Merge 6.12.2 into android16-6.12") has
removed the stage2_mc free for pKVM. That creates a leak after VM
teardown.

Bug: 357781595
Bug: 385687347
Change-Id: I6381cafc8fdf3706a3c469cd2c871cff3a589ea3
Signed-off-by: Vincent Donnefort <vdonnefort@google.com>
This commit is contained in:
Vincent Donnefort
2024-12-23 15:17:44 +00:00
parent 9c760a21bb
commit bdf9b0a641
+8 -1
View File
@@ -528,7 +528,14 @@ void kvm_arch_vcpu_postcreate(struct kvm_vcpu *vcpu)
void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)
{
kvm_mmu_free_memory_cache(&vcpu->arch.mmu_page_cache);
if (is_protected_kvm_enabled()) {
atomic64_sub(vcpu->arch.stage2_mc.nr_pages << PAGE_SHIFT,
&vcpu->kvm->stat.protected_hyp_mem);
free_hyp_memcache(&vcpu->arch.stage2_mc);
} else {
kvm_mmu_free_memory_cache(&vcpu->arch.mmu_page_cache);
}
kvm_timer_vcpu_terminate(vcpu);
kvm_pmu_vcpu_destroy(vcpu);
kvm_vgic_vcpu_destroy(vcpu);