Re: [PATCH] KVM: SEV: Update SEV-ES shutdown intercepts with more metadata

From: Sean Christopherson
Date: Tue Sep 05 2023 - 17:09:31 EST


On Tue, Sep 05, 2023, Peter Gonda wrote:
> Currently if an SEV-ES VM shuts down userspace sees KVM_RUN struct with
> only the INVALID_ARGUMENT. This is a very limited amount of information
> to debug the situation. Instead KVM can return a
> KVM_SYSTEM_EVENT_SEV_TERM to alert userspace the VM is shutting down and
> is not usable any further. This latter point can be enforced using the
> kvm_vm_dead() functionality.

Add the kvm_vm_dead() thing in a separate patch. If we want to actually harden
KVM against consuming a garbage VMSA then we do need to mark the VM dead, but on
the other hand that will block _all_ KVM ioctls(), which will make debug even
harder.

> Signed-off-by: Peter Gonda <pgonda@xxxxxxxxxx>
> Cc: Paolo Bonzini <pbonzini@xxxxxxxxxx>
> Cc: Sean Christopherson <seanjc@xxxxxxxxxx>
> Cc: Tom Lendacky <thomas.lendacky@xxxxxxx>
> Cc: Joerg Roedel <joro@xxxxxxxxxx>
> Cc: Borislav Petkov <bp@xxxxxxxxx>
> Cc: x86@xxxxxxxxxx
> Cc: kvm@xxxxxxxxxxxxxxx
> Cc: linux-kernel@xxxxxxxxxxxxxxx
>
> ---
>
> I am not sure if this is the right path forward maybe just returning
> KVM_EXIT_SHUTDOWN is better. But the current behavior is very unhelpful.

Ya, KVM_EXIT_SHUTDOWN is better, we should leave KVM_SYSTEM_EVENT_SEV_TERM to
explicit "requests" from the guest.