mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-09 22:50:41 +00:00
KVM: SEV: Set sev_info.active after initial checks in sev_guest_init()
Set sev_info.active during SEV/SEV-ES activation before calling any code that can potentially consume sev_info.es_active, e.g. set "active" and "es_active" as a pair immediately after the initial sanity checks. KVM generally expects that es_active can be true if and only if active is true, e.g. sev_asid_new() deliberately avoids sev_es_guest() so that it doesn't get a false negative. This will allow WARNing in sev_es_guest() if the VM is tagged as SEV-ES but not SEV. Signed-off-by: Sean Christopherson <seanjc@google.com> Message-Id: <20211109215101.2211373-4-seanjc@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
79b1114276
commit
a41fb26e61
@ -229,7 +229,6 @@ static void sev_unbind_asid(struct kvm *kvm, unsigned int handle)
|
|||||||
static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
|
static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
|
||||||
{
|
{
|
||||||
struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
|
struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info;
|
||||||
bool es_active = argp->id == KVM_SEV_ES_INIT;
|
|
||||||
int asid, ret;
|
int asid, ret;
|
||||||
|
|
||||||
if (kvm->created_vcpus)
|
if (kvm->created_vcpus)
|
||||||
@ -239,7 +238,8 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
|
|||||||
if (unlikely(sev->active))
|
if (unlikely(sev->active))
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
sev->es_active = es_active;
|
sev->active = true;
|
||||||
|
sev->es_active = argp->id == KVM_SEV_ES_INIT;
|
||||||
asid = sev_asid_new(sev);
|
asid = sev_asid_new(sev);
|
||||||
if (asid < 0)
|
if (asid < 0)
|
||||||
goto e_no_asid;
|
goto e_no_asid;
|
||||||
@ -249,7 +249,6 @@ static int sev_guest_init(struct kvm *kvm, struct kvm_sev_cmd *argp)
|
|||||||
if (ret)
|
if (ret)
|
||||||
goto e_free;
|
goto e_free;
|
||||||
|
|
||||||
sev->active = true;
|
|
||||||
sev->asid = asid;
|
sev->asid = asid;
|
||||||
INIT_LIST_HEAD(&sev->regions_list);
|
INIT_LIST_HEAD(&sev->regions_list);
|
||||||
|
|
||||||
@ -260,6 +259,7 @@ e_free:
|
|||||||
sev->asid = 0;
|
sev->asid = 0;
|
||||||
e_no_asid:
|
e_no_asid:
|
||||||
sev->es_active = false;
|
sev->es_active = false;
|
||||||
|
sev->active = false;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user