• Huacai Chen's avatar
    LoongArch: Add ARCH_HAS_SET_DIRECT_MAP support · f04de6d8
    Huacai Chen authored
    Add set_direct_map_*() functions for setting the direct map alias for
    the page to its default permissions and to an invalid state that cannot
    be cached in a TLB. (See d253ca0c ("x86/mm/cpa: Add set_direct_map_*()
    functions")) Add a similar implementation for LoongArch.
    
    This fixes the KFENCE warnings during hibernation:
    
     ==================================================================
     BUG: KFENCE: invalid read in swsusp_save+0x368/0x4d8
    
     Invalid read at 0x00000000f7b89a3c:
      swsusp_save+0x368/0x4d8
      hibernation_snapshot+0x3f0/0x4e0
      hibernate+0x20c/0x440
      state_store+0x128/0x140
      kernfs_fop_write_iter+0x160/0x260
      vfs_write+0x2c0/0x520
      ksys_write+0x74/0x160
      do_syscall+0xb0/0x160
    
     CPU: 0 UID: 0 PID: 812 Comm: bash Tainted: G    B              6.11.0-rc1+ #1566
     Tainted: [B]=BAD_PAGE
     Hardware name: Loongson-LS3A5000-7A1000-1w-CRB, BIOS vUDK2018-LoongArch-V2.0.0 10/21/2022
     ==================================================================
    
    Note: We can only set permissions for KVRANGE/XKVRANGE kernel addresses.
    Signed-off-by: default avatarHuacai Chen <chenhuacai@loongson.cn>
    f04de6d8
set_memory.h 645 Bytes