Skip to content

Commit

Permalink
Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm
Browse files Browse the repository at this point in the history
Pull ARM fix from Russell King:
 "One further ARM fix for 6.1 from Wang Kefeng, fixing up the handling
  for kfence faults"

* tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm:
  ARM: 9278/1: kfence: only handle translation faults
  • Loading branch information
torvalds committed Dec 10, 2022
2 parents 3ecc379 + 73a0b6e commit 296a7b7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 5 deletions.
18 changes: 16 additions & 2 deletions arch/arm/mm/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,19 @@ static inline bool is_write_fault(unsigned int fsr)
return (fsr & FSR_WRITE) && !(fsr & FSR_CM);
}

static inline bool is_translation_fault(unsigned int fsr)
{
int fs = fsr_fs(fsr);
#ifdef CONFIG_ARM_LPAE
if ((fs & FS_MMU_NOLL_MASK) == FS_TRANS_NOLL)
return true;
#else
if (fs == FS_L1_TRANS || fs == FS_L2_TRANS)
return true;
#endif
return false;
}

static void die_kernel_fault(const char *msg, struct mm_struct *mm,
unsigned long addr, unsigned int fsr,
struct pt_regs *regs)
Expand Down Expand Up @@ -140,7 +153,8 @@ __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
if (addr < PAGE_SIZE) {
msg = "NULL pointer dereference";
} else {
if (kfence_handle_page_fault(addr, is_write_fault(fsr), regs))
if (is_translation_fault(fsr) &&
kfence_handle_page_fault(addr, is_write_fault(fsr), regs))
return;

msg = "paging request";
Expand Down Expand Up @@ -208,7 +222,7 @@ static inline bool is_permission_fault(unsigned int fsr)
{
int fs = fsr_fs(fsr);
#ifdef CONFIG_ARM_LPAE
if ((fs & FS_PERM_NOLL_MASK) == FS_PERM_NOLL)
if ((fs & FS_MMU_NOLL_MASK) == FS_PERM_NOLL)
return true;
#else
if (fs == FS_L1_PERM || fs == FS_L2_PERM)
Expand Down
9 changes: 6 additions & 3 deletions arch/arm/mm/fault.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,20 @@

#ifdef CONFIG_ARM_LPAE
#define FSR_FS_AEA 17
#define FS_TRANS_NOLL 0x4
#define FS_PERM_NOLL 0xC
#define FS_PERM_NOLL_MASK 0x3C
#define FS_MMU_NOLL_MASK 0x3C

static inline int fsr_fs(unsigned int fsr)
{
return fsr & FSR_FS5_0;
}
#else
#define FSR_FS_AEA 22
#define FS_L1_PERM 0xD
#define FS_L2_PERM 0xF
#define FS_L1_TRANS 0x5
#define FS_L2_TRANS 0x7
#define FS_L1_PERM 0xD
#define FS_L2_PERM 0xF

static inline int fsr_fs(unsigned int fsr)
{
Expand Down

0 comments on commit 296a7b7

Please sign in to comment.