Subject: [PATCH 0/3] KVM: arm64: Fix teardown of non-protected VMs with pKVM

From: Will Deacon <[email-masked]>
Date: Tue, 31 Mar 2026 16:50:52 +0100

Hi folks,

Sashiko continues to throw rocks at me.

This time, it spotted that my fix (introduced in v5 [1] of the pKVM
series) to prevent taking a reference on a VM in the 'is_dying' state
also prevents unsharing of pages shared with a non-protected VM if that
VM is torn down by its VM fd being destroyed, rather than the usual path
via the MMU notifiers.

Rather than send a v6 of the whole series, here are three patches that
apply on top of v5 and fix the issue by (a) preventing teardown of a
referenced VM and (b) allowing some references to be taken on a dying
VM. As an added bonus, this simplifies the locking on the reclaim path
because now a VM reference is enough to stop the page-tables from going
away.

Cheers,

Will

[1] https://lore.kernel.org/kvmarm/[email-masked]

Cc: Marc Zyngier <[email-masked]>
Cc: Oliver Upton <[email-masked]>
Cc: Joey Gouly <[email-masked]>
Cc: Suzuki K Poulose <[email-masked]>
Cc: Zenghui Yu <[email-masked]>
Cc: Catalin Marinas <[email-masked]>
Cc: Quentin Perret <[email-masked]>
Cc: Fuad Tabba <[email-masked]>
Cc: Vincent Donnefort <[email-masked]>
Cc: Mostafa Saleh <[email-masked]>
Cc: Alexandru Elisei <[email-masked]>

--->8

Will Deacon (3):
  KVM: arm64: Prevent teardown finalisation of referenced 'hyp_vm'
  KVM: arm64: Allow get_pkvm_hyp_vm() to take a reference to a dying VM
  KVM: arm64: Don't hold 'vm_table_lock' across guest page reclaim

 arch/arm64/kvm/hyp/nvhe/pkvm.c | 53 +++++++++++++++++-----------------
 1 file changed, 26 insertions(+), 27 deletions(-)

-- 
2.53.0.1118.gaef5881109-goog