• Sean Christopherson's avatar
    KVM: x86/mmu: Use synthetic page fault error code to indicate private faults · b3d5dc62
    Sean Christopherson authored
    Add and use a synthetic, KVM-defined page fault error code to indicate
    whether a fault is to private vs. shared memory.  TDX and SNP have
    different mechanisms for reporting private vs. shared, and KVM's
    software-protected VMs have no mechanism at all.  Usurp an error code
    flag to avoid having to plumb another parameter to kvm_mmu_page_fault()
    and friends.
    
    Alternatively, KVM could borrow AMD's PFERR_GUEST_ENC_MASK, i.e. set it
    for TDX and software-protected VMs as appropriate, but that would require
    *clearing* the flag for SEV and SEV-ES VMs, which support encrypted
    memory at the hardware layer, but don't utilize private memory at the
    KVM layer.
    
    Opportunistically add a comment to call out that the logic for software-
    protected VMs is (and was before this commit) broken for nested MMUs, i.e.
    for nested TDP, as the GPA is an L2 GPA.  Punt on trying to play nice with
    nested MMUs as there is a _lot_ of functionality that simply doesn't work
    for software-protected VMs, e.g. all of the paths where KVM accesses guest
    memory need to be updated to be aware of private vs. shared memory.
    Signed-off-by: default avatarSean Christopherson <seanjc@google.com>
    Message-Id: <20240228024147.41573-6-seanjc@google.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    b3d5dc62
kvm_host.h 71 KB