• Mohammed Gamal's avatar
    KVM: VMX: Add guest physical address check in EPT violation and misconfig · 1dbf5d68
    Mohammed Gamal authored
    Check guest physical address against its maximum, which depends on the
    guest MAXPHYADDR. If the guest's physical address exceeds the
    maximum (i.e. has reserved bits set), inject a guest page fault with
    PFERR_RSVD_MASK set.
    
    This has to be done both in the EPT violation and page fault paths, as
    there are complications in both cases with respect to the computation
    of the correct error code.
    
    For EPT violations, unfortunately the only possibility is to emulate,
    because the access type in the exit qualification might refer to an
    access to a paging structure, rather than to the access performed by
    the program.
    
    Trapping page faults instead is needed in order to correct the error code,
    but the access type can be obtained from the original error code and
    passed to gva_to_gpa.  The corrections required in the error code are
    subtle. For example, imagine that a PTE for a supervisor page has a reserved
    bit set.  On a supervisor-mode access, the EPT violation path would trigger.
    However, on a user-mode access, the processor will not notice the reserved
    bit and not include PFERR_RSVD_MASK in the error code.
    Co-developed-by: default avatarMohammed Gamal <mgamal@redhat.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Message-Id: <20200710154811.418214-8-mgamal@redhat.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    1dbf5d68
vmx.h 14.7 KB