• S
    x86/mm: Signal SIGSEGV with PF_SGX · 84ddf6b0
    Sean Christopherson 提交于
    mainline inclusion
    from mainline-5.11
    commit 74faeee0
    category: feature
    bugzilla: https://gitee.com/openeuler/intel-kernel/issues/I5EZEK
    CVE: NA
    
    Intel-SIG: commit 74faeee0 x86/mm: Signal SIGSEGV with PF_SGX.
    Backport for SGX Foundations support
    
    --------------------------------
    
    The x86 architecture has a set of page fault error codes.  These indicate
    things like whether the fault occurred from a write, or whether it
    originated in userspace.
    
    The SGX hardware architecture has its own per-page memory management
    metadata (EPCM) [*] and hardware which is separate from the normal x86 MMU.
    The architecture has a new page fault error code: PF_SGX.  This new error
    code bit is set whenever a page fault occurs as the result of the SGX MMU.
    
    These faults occur for a variety of reasons.  For instance, an access
    attempt to enclave memory from outside the enclave causes a PF_SGX fault.
    PF_SGX would also be set for permission conflicts, such as if a write to an
    enclave page occurs and the page is marked read-write in the x86 page
    tables but is read-only in the EPCM.
    
    These faults do not always indicate errors, though.  SGX pages are
    encrypted with a key that is destroyed at hardware reset, including
    suspend. Throwing a SIGSEGV allows user space software to react and recover
    when these events occur.
    
    Include PF_SGX in the PF error codes list and throw SIGSEGV when it is
    encountered.
    
    [*] Intel SDM: 36.5.1 Enclave Page Cache Map (EPCM)
    
     [ bp: Add bit 15 to the comment above enum x86_pf_error_code too. ]
    Signed-off-by: NSean Christopherson <sean.j.christopherson@intel.com>
    Signed-off-by: NJarkko Sakkinen <jarkko@kernel.org>
    Signed-off-by: NBorislav Petkov <bp@suse.de>
    Acked-by: NJethro Beekman <jethro@fortanix.com>
    Link: https://lkml.kernel.org/r/20201112220135.165028-7-jarkko@kernel.orgSigned-off-by: NFan Du <fan.du@intel.com>
    Signed-off-by: NZhiquan Li <zhiquan1.li@intel.com>
    84ddf6b0
fault.c 40.8 KB