summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Deacon <will@kernel.org>2026-03-31 18:50:55 +0300
committerMarc Zyngier <maz@kernel.org>2026-04-01 16:29:06 +0300
commitbc20692f528b2ac8226bafe5b1db9a1f8be96dbf (patch)
tree76f025d890b464c399261c616cda1dcc289d14e3
parent2400696883870ec3fb0fb9925426c62a3383ca36 (diff)
downloadlinux-bc20692f528b2ac8226bafe5b1db9a1f8be96dbf.tar.xz
KVM: arm64: Don't hold 'vm_table_lock' across guest page reclaim
Now that the teardown of a VM cannot be finalised as long as a reference is held on the VM, rework __pkvm_reclaim_dying_guest_page() to hold a reference to the dying VM rather than take the global 'vm_table_lock' during the reclaim operation. Signed-off-by: Will Deacon <will@kernel.org> Link: https://patch.msgid.link/20260331155056.28220-4-will@kernel.org Signed-off-by: Marc Zyngier <maz@kernel.org>
-rw-r--r--arch/arm64/kvm/hyp/nvhe/pkvm.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/arch/arm64/kvm/hyp/nvhe/pkvm.c b/arch/arm64/kvm/hyp/nvhe/pkvm.c
index b955da0e50bc..7ed96d64d611 100644
--- a/arch/arm64/kvm/hyp/nvhe/pkvm.c
+++ b/arch/arm64/kvm/hyp/nvhe/pkvm.c
@@ -918,15 +918,16 @@ teardown_donated_memory(struct kvm_hyp_memcache *mc, void *addr, size_t size)
int __pkvm_reclaim_dying_guest_page(pkvm_handle_t handle, u64 gfn)
{
- struct pkvm_hyp_vm *hyp_vm;
+ struct pkvm_hyp_vm *hyp_vm = get_pkvm_hyp_vm(handle);
int ret = -EINVAL;
- hyp_spin_lock(&vm_table_lock);
- hyp_vm = get_vm_by_handle(handle);
- if (hyp_vm && hyp_vm->kvm.arch.pkvm.is_dying)
+ if (!hyp_vm)
+ return ret;
+
+ if (hyp_vm->kvm.arch.pkvm.is_dying)
ret = __pkvm_host_reclaim_page_guest(gfn, hyp_vm);
- hyp_spin_unlock(&vm_table_lock);
+ put_pkvm_hyp_vm(hyp_vm);
return ret;
}