Skip to content

Commit 78fee41

Browse files
vdonnefortMarc Zyngier
authored andcommitted
KVM: arm64: Fix __pkvm_init_vcpu cptr_el2 error path
On an error, hyp_vcpu will be accessed while this memory has already been relinquished to the host and unmapped from the hypervisor. Protect the CPTR assignment with an early return. Fixes: b5b9955 ("KVM: arm64: Eagerly restore host fpsimd/sve state in pKVM") Reviewed-by: Oliver Upton <oliver.upton@linux.dev> Signed-off-by: Vincent Donnefort <vdonnefort@google.com> Link: https://lore.kernel.org/r/20240919110500.2345927-1-vdonnefort@google.com Signed-off-by: Marc Zyngier <maz@kernel.org>
1 parent 9852d85 commit 78fee41

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

arch/arm64/kvm/hyp/nvhe/pkvm.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -574,12 +574,14 @@ int __pkvm_init_vcpu(pkvm_handle_t handle, struct kvm_vcpu *host_vcpu,
574574
unlock:
575575
hyp_spin_unlock(&vm_table_lock);
576576

577-
if (ret)
577+
if (ret) {
578578
unmap_donated_memory(hyp_vcpu, sizeof(*hyp_vcpu));
579+
return ret;
580+
}
579581

580582
hyp_vcpu->vcpu.arch.cptr_el2 = kvm_get_reset_cptr_el2(&hyp_vcpu->vcpu);
581583

582-
return ret;
584+
return 0;
583585
}
584586

585587
static void

0 commit comments

Comments
 (0)