linux/arch/x86/kvm/svm
Sean Christopherson 2732be9023 KVM: nSVM: Don't strip host's C-bit from guest's CR3 when reading PDPTRs
Don't clear the SME C-bit when reading a guest PDPTR, as the GPA (CR3) is
in the guest domain.

Barring a bizarre paravirtual use case, this is likely a benign bug.  SME
is not emulated by KVM, loading SEV guest PDPTRs is doomed as KVM can't
use the correct key to read guest memory, and setting guest MAXPHYADDR
higher than the host, i.e. overlapping the C-bit, would cause faults in
the guest.

Note, for SEV guests, stripping the C-bit is technically aligned with CPU
behavior, but for KVM it's the greater of two evils.  Because KVM doesn't
have access to the guest's encryption key, ignoring the C-bit would at
best result in KVM reading garbage.  By keeping the C-bit, KVM will
fail its read (unless userspace creates a memslot with the C-bit set).
The guest will still undoubtedly die, as KVM will use '0' for the PDPTR
value, but that's preferable to interpreting encrypted data as a PDPTR.

Fixes: d0ec49d4de ("kvm/x86/svm: Support Secure Memory Encryption within KVM")
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20210204000117.3303214-3-seanjc@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2021-02-04 09:27:27 -05:00
..
avic.c KVM: X86: Don't track dirty for KVM_SET_[TSS_ADDR|IDENTITY_MAP_ADDR] 2020-11-15 09:49:12 -05:00
nested.c KVM: nSVM: Don't strip host's C-bit from guest's CR3 when reading PDPTRs 2021-02-04 09:27:27 -05:00
pmu.c KVM: x86/pmu: Tweak kvm_pmu_get_msr to pass 'struct msr_data' in 2020-06-01 04:26:08 -04:00
sev.c KVM: SVM: use .prepare_guest_switch() to handle CPU register save/setup 2021-02-04 05:27:35 -05:00
svm_ops.h KVM: SVM: use vmsave/vmload for saving/restoring additional host state 2021-02-04 05:27:34 -05:00
svm.c KVM: x86: move kvm_inject_gp up from kvm_set_xcr to callers 2021-02-04 05:27:37 -05:00
svm.h KVM: SVM: use .prepare_guest_switch() to handle CPU register save/setup 2021-02-04 05:27:35 -05:00
vmenter.S KVM: SVM: Provide an updated VMRUN invocation for SEV-ES guests 2020-12-15 05:20:59 -05:00