ARM fixes for 6.1

One further ARM fix for 6.1 from Wang Kefeng, fixing up the handling
 for kfence faults.
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEuNNh8scc2k/wOAE+9OeQG+StrGQFAmOUtTQACgkQ9OeQG+St
 rGSo7RAAigvanMYnpBUeyncAkWTUuym4N+ghlVRsmBtKZDlPTajwIj27LEKIgdAf
 yKBvMWgeN/+1K4XwEEon7n1OXfLmFfWiMoMhUj+R9Us32wTsnPzj922hPkuEp3s+
 MCQP3McP+tfwdbQiMUwtGfEjtIzoCDQ5fh3XoHqW5RK/mHpvf0W+Xniw58RcrFjd
 rnbMUqCwo+KTfIddUkN2+bVLoxgLgAmTqJ4hzAtnEjxA4zCCxujk4KoVpk4Ov7FF
 ovsvQeA/zuwMKf7cT/FG8xNSsGZKuo+LhAv8KsB1LmV9nAh71Mq/LHgc2dZ0KKsO
 XGMuWeEqxr3luUEXi84J9AGLTtROKGdsraYcLxCeyOSt5UWirCuLbPTxltEXscTQ
 ADF11j/FwVzUnJxtRm8mwWM8SgAWbTcenZSRRuN+tDSoCmW+tjnXlgoG9Fu3WFXc
 T7luJOxAcu8P7wvejhsVliY3dS/6Sywrnrn84Kp7ayJcNZriMssMLooPwoib9Tw/
 9zDPrUnoka54dhr/etFKtybvRhTr0i7HO1OAVlAUSNLT5K2ZN5ER2s87tRREgq7Q
 98oKH7+3QuRRO/302VVGtnUqvdelJEXeymTlDUpxNhKAeJN0Z0OFHhsUVXmlOqWc
 21e2ge8FFoOIL/fJMPfrFq+qpOB5M2SlN0/4W62kNUzdRrI9WN4=
 =PqxP
 -----END PGP SIGNATURE-----

Merge tag 'for-linus' of git://git.armlinux.org.uk/~rmk/linux-arm

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
This commit is contained in:
Linus Torvalds 2022-12-10 10:14:52 -08:00
commit 296a7b7eb7
2 changed files with 22 additions and 5 deletions

View File

@ -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)
@ -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";
@ -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)

View File

@ -14,8 +14,9 @@
#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)
{
@ -23,8 +24,10 @@ static inline int fsr_fs(unsigned int fsr)
}
#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)
{