Skip to content

Commit

Permalink
kvm: sev: Fail KVM_SEV_INIT if already initialized
Browse files Browse the repository at this point in the history
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: 1654efc ("KVM: SVM: Add KVM_SEV_INIT command")
Reported-by: Cfir Cohen <[email protected]>
Signed-off-by: David Rientjes <[email protected]>
Signed-off-by: Radim Krčmář <[email protected]>
  • Loading branch information
rientjes authored and rkrcmar committed Jan 11, 2019
1 parent 98938aa commit 3f14a89
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/x86/kvm/svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -6278,6 +6278,9 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
int asid, ret;

ret = -EBUSY;
if (unlikely(sev->active))
return ret;

asid = sev_asid_new();
if (asid < 0)
return ret;
Expand Down

0 comments on commit 3f14a89

Please sign in to comment.