ANDROID: KVM: Don't release the VM memory after it is given to the hyp

Prevent the kernel from freeing the VM memory protected by the
hypervisor after a failed attempt to send VM availability messages
to Trustzone.

Bug: 424713496
Bug: 278749606
Test: start a pVM with FF-A and send a kill signal immediately
Change-Id: I6d262e0a018fe4a7f4bbb86b7fa73bd4fd730551
Signed-off-by: Sebastian Ene <sebastianene@google.com>
This commit is contained in:
Sebastian Ene
2025-06-13 10:01:01 +00:00
committed by Keir Fraser
parent df79f04f71
commit c4de34084f

View File

@@ -550,11 +550,8 @@ static int __pkvm_create_hyp_vm(struct kvm *host_kvm)
WRITE_ONCE(host_kvm->arch.pkvm.handle, ret);
kvm_account_pgtable_pages(pgd, pgd_sz >> PAGE_SHIFT);
ret = __pkvm_notify_guest_vm_avail_retry(host_kvm, FFA_VM_CREATION_MSG);
if (ret)
goto free_pgd;
return ret;
return __pkvm_notify_guest_vm_avail_retry(host_kvm, FFA_VM_CREATION_MSG);
free_pgd:
free_pages_exact(pgd, pgd_sz);
atomic64_sub(pgd_sz, &host_kvm->stat.protected_hyp_mem);