KVM: SVM: Treat SVM as unsupported when running as an SEV guest
authorSean Christopherson <seanjc@google.com>
Tue, 2 Feb 2021 21:20:17 +0000 (13:20 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 3 Feb 2021 09:30:37 +0000 (04:30 -0500)
commitccd85d90ce092bdb047a7f6580f3955393833b22
treefe14a57ed7ad132c093fbc8909b534ed26ca82c2
parent943dea8af21bd896e0d6c30ea221203fb3cd3265
KVM: SVM: Treat SVM as unsupported when running as an SEV guest

Don't let KVM load when running as an SEV guest, regardless of what
CPUID says.  Memory is encrypted with a key that is not accessible to
the host (L0), thus it's impossible for L0 to emulate SVM, e.g. it'll
see garbage when reading the VMCB.

Technically, KVM could decrypt all memory that needs to be accessible to
the L0 and use shadow paging so that L0 does not need to shadow NPT, but
exposing such information to L0 largely defeats the purpose of running as
an SEV guest.  This can always be revisited if someone comes up with a
use case for running VMs inside SEV guests.

Note, VMLOAD, VMRUN, etc... will also #GP on GPAs with C-bit set, i.e. KVM
is doomed even if the SEV guest is debuggable and the hypervisor is willing
to decrypt the VMCB.  This may or may not be fixed on CPUs that have the
SVME_ADDR_CHK fix.

Cc: stable@vger.kernel.org
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210202212017.2486595-1-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/svm/svm.c
arch/x86/mm/mem_encrypt.c