lkml.org 
[lkml]   [2022]   [Jan]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH V8 08/44] x86/fault: Adjust WARN_ON for PKey fault
    Date
    From: Ira Weiny <ira.weiny@intel.com>

    Previously if a Protection key fault occurred it indicated something
    very wrong because user page mappings are not supposed to be in the
    kernel address space.

    Now PKey faults may happen on kernel mappings if the feature is enabled.

    If PKS is enabled, avoid the warning in the fault path.

    Cc: Sean Christopherson <seanjc@google.com>
    Cc: Dan Williams <dan.j.williams@intel.com>
    Signed-off-by: Ira Weiny <ira.weiny@intel.com>
    ---
    arch/x86/mm/fault.c | 12 ++++++++----
    1 file changed, 8 insertions(+), 4 deletions(-)

    diff --git a/arch/x86/mm/fault.c b/arch/x86/mm/fault.c
    index d0074c6ed31a..6ed91b632eac 100644
    --- a/arch/x86/mm/fault.c
    +++ b/arch/x86/mm/fault.c
    @@ -1148,11 +1148,15 @@ do_kern_addr_fault(struct pt_regs *regs, unsigned long hw_error_code,
    unsigned long address)
    {
    /*
    - * Protection keys exceptions only happen on user pages. We
    - * have no user pages in the kernel portion of the address
    - * space, so do not expect them here.
    + * X86_PF_PK (Protection key exceptions) may occur on kernel addresses
    + * when PKS (PKeys Supervisor) is enabled.
    + *
    + * However, if PKS is not enabled WARN if this exception is seen
    + * because there are no user pages in the kernel portion of the address
    + * space.
    */
    - WARN_ON_ONCE(hw_error_code & X86_PF_PK);
    + WARN_ON_ONCE(!cpu_feature_enabled(X86_FEATURE_PKS) &&
    + (hw_error_code & X86_PF_PK));

    #ifdef CONFIG_X86_32
    /*
    --
    2.31.1
    \
     
     \ /
      Last update: 2022-01-27 18:56    [W:4.029 / U:0.020 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site