• Sean Christopherson's avatar
    KVM: nSVM: Don't strip host's C-bit from guest's CR3 when reading PDPTRs · 2732be90
    Sean Christopherson authored
    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: d0ec49d4 ("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: default avatarSean Christopherson <seanjc@google.com>
    Message-Id: <20210204000117.3303214-3-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    2732be90
nested.c 32.9 KB