Commit 78fee419 authored by Vincent Donnefort's avatar Vincent Donnefort Committed by Marc Zyngier

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: b5b99556 ("KVM: arm64: Eagerly restore host fpsimd/sve state in pKVM")
Reviewed-by: default avatarOliver Upton <oliver.upton@linux.dev>
Signed-off-by: default avatarVincent Donnefort <vdonnefort@google.com>
Link: https://lore.kernel.org/r/20240919110500.2345927-1-vdonnefort@google.comSigned-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent 9852d85e
......@@ -574,12 +574,14 @@ int __pkvm_init_vcpu(pkvm_handle_t handle, struct kvm_vcpu *host_vcpu,
unlock:
hyp_spin_unlock(&vm_table_lock);
if (ret)
if (ret) {
unmap_donated_memory(hyp_vcpu, sizeof(*hyp_vcpu));
return ret;
}
hyp_vcpu->vcpu.arch.cptr_el2 = kvm_get_reset_cptr_el2(&hyp_vcpu->vcpu);
return ret;
return 0;
}
static void
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment