Commit 3f14a89d authored by David Rientjes's avatar David Rientjes Committed by Radim Krčmář

kvm: sev: Fail KVM_SEV_INIT if already initialized

By code inspection, it was found that multiple calls to KVM_SEV_INIT
could deplete asid bits and overwrite kvm_sev_info's regions_list.

Multiple calls to KVM_SVM_INIT is not likely to occur with QEMU, but this
should likely be fixed anyway.

This code is serialized by kvm->lock.

Fixes: 1654efcb ("KVM: SVM: Add KVM_SEV_INIT command")
Reported-by: default avatarCfir Cohen <cfir@google.com>
Signed-off-by: default avatarDavid Rientjes <rientjes@google.com>
Signed-off-by: default avatarRadim Krčmář <rkrcmar@redhat.com>
parent 98938aa8
...@@ -6278,6 +6278,9 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp) ...@@ -6278,6 +6278,9 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
int asid, ret; int asid, ret;
ret = -EBUSY; ret = -EBUSY;
if (unlikely(sev->active))
return ret;
asid = sev_asid_new(); asid = sev_asid_new();
if (asid < 0) if (asid < 0)
return ret; return ret;
......
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