]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
KVM: arm64: Move handle check into pkvm_pgtable_stage2_destroy_range()
authorWill Deacon <will@kernel.org>
Mon, 30 Mar 2026 14:48:04 +0000 (15:48 +0100)
committerMarc Zyngier <maz@kernel.org>
Mon, 30 Mar 2026 15:58:07 +0000 (16:58 +0100)
commit9f02deef471e1b6637a6641ce6bf9e2a1dd7d2c1
tree2a6fcbc5c1280d6bdf80bb065969777d4ce210f7
parent5e66f723d4de432a5acb481293d81dc88c7f61a4
KVM: arm64: Move handle check into pkvm_pgtable_stage2_destroy_range()

When pKVM is enabled, a VM has a 'handle' allocated by the hypervisor
in kvm_arch_init_vm() and released later by kvm_arch_destroy_vm().

Consequently, the only time __pkvm_pgtable_stage2_unmap() can run into
an uninitialised 'handle' is on the kvm_arch_init_vm() failure path,
where we destroy the empty stage-2 page-table if we fail to allocate a
handle.

Move the handle check into pkvm_pgtable_stage2_destroy_range(), which
will additionally handle protected VMs in subsequent patches.

Reviewed-by: Fuad Tabba <tabba@google.com>
Tested-by: Fuad Tabba <tabba@google.com>
Tested-by: Mostafa Saleh <smostafa@google.com>
Signed-off-by: Will Deacon <will@kernel.org>
Link: https://patch.msgid.link/20260330144841.26181-4-will@kernel.org
Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/kvm/pkvm.c