]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: SVM: Do not set sev->es_active until KVM_SEV_ES_INIT completes
authorSean Christopherson <seanjc@google.com>
Wed, 31 Mar 2021 03:19:35 +0000 (20:19 -0700)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 17 Apr 2021 12:30:57 +0000 (08:30 -0400)
commit774fc364a20ab704f83cf16fed45e3fb0fd5c573
tree31e977ffdfd344f680a9dfd6c2e8f8a4e0d1e753
parent818f6d50f2cb38c1a54a3a7e427ffbc29b28bfa6
KVM: SVM: Do not set sev->es_active until KVM_SEV_ES_INIT completes

Set sev->es_active only after the guts of KVM_SEV_ES_INIT succeeds.  If
the command fails, e.g. because SEV is already active or there are no
available ASIDs, then es_active will be left set even though the VM is
not fully SEV-ES capable.

Refactor the code so that "es_active" is passed on the stack instead of
being prematurely shoved into sev_info, both to avoid having to unwind
sev_info and so that it's more obvious what actually consumes es_active
in sev_guest_init() and its helpers.

Fixes: e1b32015dde6 ("KVM: SVM: Provide support to launch and run an SEV-ES guest")
Cc: stable@vger.kernel.org
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210331031936.2495277-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/sev.c