summaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorDavid Rientjes <rientjes@google.com>2019-01-02 12:56:33 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-02-20 10:25:43 +0100
commit6804b3ecbe20654891324ef82f840ba02d642d6c (patch)
tree995bfd6917dfc5436ce1ac17d0b1ef14a01b3bc0 /arch
parent63715c1f0a67a1e92631fca7f4b4dff89eb6be23 (diff)
kvm: sev: Fail KVM_SEV_INIT if already initialized
[ Upstream commit 3f14a89d1132dcae3c8ce6721c6ef51f6e6d9b5f ] 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: 1654efcbc431 ("KVM: SVM: Add KVM_SEV_INIT command") Reported-by: Cfir Cohen <cfir@google.com> Signed-off-by: David Rientjes <rientjes@google.com> Signed-off-by: Radim Krčmář <rkrcmar@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/kvm/svm.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c
index 02ac8fa0cd6d..ee8f8d70b98a 100644
--- a/arch/x86/kvm/svm.c
+++ b/arch/x86/kvm/svm.c
@@ -6256,6 +6256,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;