Skip to contentSkip to conversation

FAILED: patch "[PATCH] KVM: SVM: Do not allow SEV/SEV-ES initialization after vCPUs" failed to apply to 4.19-stable tree

PATCH [email protected] 1 participant 1 message May 12, 2021

Subsystems (3)
lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

The patch below does not apply to the 4.19-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.

thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 8727906fde6ea665b52e68ddc58833772537f40a Mon Sep 17 00:00:00 2001
From: Sean Christopherson <[email protected]>
Date: Tue, 30 Mar 2021 20:19:36 -0700
Subject: [PATCH] KVM: SVM: Do not allow SEV/SEV-ES initialization after vCPUs
are created

Reject KVM_SEV_INIT and KVM_SEV_ES_INIT if they are attempted after one or more vCPUs have been created. KVM assumes a VM is tagged SEV/SEV-ES prior to vCPU creation, e.g. init_vmcb() needs to mark the VMCB as SEV enabled, and svm_create_vcpu() needs to allocate the VMSA. At best, creating vCPUs before SEV/SEV-ES init will lead to unexpected errors and/or behavior, and at worst it will crash the host, e.g. sev_launch_update_vmsa() will dereference a null svm->vmsa pointer.

Fixes 1654efcbc431 ("KVM: SVM: Add KVM_SEV_INIT command")
Fixes ad73109ae7ec ("KVM: SVM: Provide support to launch and run an SEV-ES guest")
Cc Brijesh Singh <[email protected]>
Cc Tom Lendacky <[email protected]>

Message-Id: <[email protected]>

arch/x86/kvm/svm/sev.c +3 -0
index 97d42a007b86..824bc7d22e77 100644
@@ -182,6 +182,9 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
 	bool es_active = argp->id == KVM_SEV_ES_INIT;
 	int asid, ret;
 
+	if (kvm->created_vcpus)
+		return -EINVAL;
+
 	ret = -EBUSY;
 	if (unlikely(sev->active))
 		return ret;