Skip to content

Commit bc3d7c5

Browse files
pgondasean-jc
authored andcommitted
KVM: SVM: Update SEV-ES shutdown intercepts with more metadata
Currently if an SEV-ES VM shuts down userspace sees KVM_RUN struct with only errno=EINVAL. This is a very limited amount of information to debug the situation. Instead return KVM_EXIT_SHUTDOWN to alert userspace the VM is shutting down and is not usable any further. Signed-off-by: Peter Gonda <[email protected]> Suggested-by: Sean Christopherson <[email protected]> Suggested-by: Tom Lendacky <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Tom Lendacky <[email protected]> Cc: Joerg Roedel <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Reviewed-by: Tom Lendacky <[email protected]> Link: https://lore.kernel.org/r/[email protected] [sean: tweak changelog] Signed-off-by: Sean Christopherson <[email protected]>
1 parent 5804c19 commit bc3d7c5

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2203,12 +2203,6 @@ static int shutdown_interception(struct kvm_vcpu *vcpu)
22032203
struct kvm_run *kvm_run = vcpu->run;
22042204
struct vcpu_svm *svm = to_svm(vcpu);
22052205

2206-
/*
2207-
* The VM save area has already been encrypted so it
2208-
* cannot be reinitialized - just terminate.
2209-
*/
2210-
if (sev_es_guest(vcpu->kvm))
2211-
return -EINVAL;
22122206

22132207
/*
22142208
* VMCB is undefined after a SHUTDOWN intercept. INIT the vCPU to put
@@ -2217,9 +2211,14 @@ static int shutdown_interception(struct kvm_vcpu *vcpu)
22172211
* userspace. At a platform view, INIT is acceptable behavior as
22182212
* there exist bare metal platforms that automatically INIT the CPU
22192213
* in response to shutdown.
2214+
*
2215+
* The VM save area for SEV-ES guests has already been encrypted so it
2216+
* cannot be reinitialized, i.e. synthesizing INIT is futile.
22202217
*/
2221-
clear_page(svm->vmcb);
2222-
kvm_vcpu_reset(vcpu, true);
2218+
if (!sev_es_guest(vcpu->kvm)) {
2219+
clear_page(svm->vmcb);
2220+
kvm_vcpu_reset(vcpu, true);
2221+
}
22232222

22242223
kvm_run->exit_reason = KVM_EXIT_SHUTDOWN;
22252224
return 0;

0 commit comments

Comments
 (0)