···225225 mod->arch.init.plt = s;226226 else if (s->sh_type == SHT_SYMTAB)227227 syms = (Elf32_Sym *)s->sh_addr;228228+#if defined(CONFIG_ARM_UNWIND) && !defined(CONFIG_VMSPLIT_3G)229229+ else if (s->sh_type == ELF_SECTION_UNWIND ||230230+ (strncmp(".ARM.extab", secstrings + s->sh_name, 10) == 0)) {231231+ /*232232+ * To avoid the possible relocation out of range issue for233233+ * R_ARM_PREL31, mark unwind section .ARM.extab and .ARM.exidx as234234+ * executable so they will be allocated along with .text section to235235+ * meet +/-1GB range requirement of the R_ARM_PREL31 relocation236236+ */237237+ s->sh_flags |= SHF_EXECINSTR;238238+ }239239+#endif228240 }229241230242 if (!mod->arch.core.plt || !mod->arch.init.plt) {
+73-85
arch/arm/mm/fault.c
···115115 return (fsr & FSR_WRITE) && !(fsr & FSR_CM);116116}117117118118-static inline bool is_translation_fault(unsigned int fsr)119119-{120120- int fs = fsr_fs(fsr);121121-#ifdef CONFIG_ARM_LPAE122122- if ((fs & FS_MMU_NOLL_MASK) == FS_TRANS_NOLL)123123- return true;124124-#else125125- if (fs == FS_L1_TRANS || fs == FS_L2_TRANS)126126- return true;127127-#endif128128- return false;129129-}130130-131131-static inline bool is_permission_fault(unsigned int fsr)132132-{133133- int fs = fsr_fs(fsr);134134-#ifdef CONFIG_ARM_LPAE135135- if ((fs & FS_MMU_NOLL_MASK) == FS_PERM_NOLL)136136- return true;137137-#else138138- if (fs == FS_L1_PERM || fs == FS_L2_PERM)139139- return true;140140-#endif141141- return false;142142-}143143-144118static void die_kernel_fault(const char *msg, struct mm_struct *mm,145119 unsigned long addr, unsigned int fsr,146120 struct pt_regs *regs)···164190165191/*166192 * Something tried to access memory that isn't in our memory map..167167- * User mode accesses just cause a SIGSEGV193193+ * User mode accesses just cause a SIGSEGV. Ensure interrupts are enabled194194+ * for preempt RT.168195 */169196static void170197__do_user_fault(unsigned long addr, unsigned int fsr, unsigned int sig,171198 int code, struct pt_regs *regs)172199{173200 struct task_struct *tsk = current;201201+202202+ local_irq_enable();174203175204#ifdef CONFIG_DEBUG_USER176205 if (((user_debug & UDBG_SEGV) && (sig == SIGSEGV)) ||···235258}236259#endif237260261261+/*262262+ * Handle a vmalloc fault, copying the non-leaf page table entries from263263+ * init_mm.pgd. Any kernel context can trigger this, so we must not sleep264264+ * or enable interrupts. Having two CPUs execute this for the same page is265265+ * no problem, we'll just copy the same data twice.266266+ *267267+ * Returns false on failure.268268+ */269269+static bool __kprobes __maybe_unused vmalloc_fault(unsigned long addr)270270+{271271+ unsigned int index;272272+ pgd_t *pgd, *pgd_k;273273+ p4d_t *p4d, *p4d_k;274274+ pud_t *pud, *pud_k;275275+ pmd_t *pmd, *pmd_k;276276+277277+ index = pgd_index(addr);278278+279279+ pgd = cpu_get_pgd() + index;280280+ pgd_k = init_mm.pgd + index;281281+282282+ p4d = p4d_offset(pgd, addr);283283+ p4d_k = p4d_offset(pgd_k, addr);284284+285285+ if (p4d_none(*p4d_k))286286+ return false;287287+ if (!p4d_present(*p4d))288288+ set_p4d(p4d, *p4d_k);289289+290290+ pud = pud_offset(p4d, addr);291291+ pud_k = pud_offset(p4d_k, addr);292292+293293+ if (pud_none(*pud_k))294294+ return false;295295+ if (!pud_present(*pud))296296+ set_pud(pud, *pud_k);297297+298298+ pmd = pmd_offset(pud, addr);299299+ pmd_k = pmd_offset(pud_k, addr);300300+301301+#ifdef CONFIG_ARM_LPAE302302+ /*303303+ * Only one hardware entry per PMD with LPAE.304304+ */305305+ index = 0;306306+#else307307+ /*308308+ * On ARM one Linux PGD entry contains two hardware entries (see page309309+ * tables layout in pgtable.h). We normally guarantee that we always310310+ * fill both L1 entries. But create_mapping() doesn't follow the rule.311311+ * It can create inidividual L1 entries, so here we have to call312312+ * pmd_none() check for the entry really corresponded to address, not313313+ * for the first of pair.314314+ */315315+ index = (addr >> SECTION_SHIFT) & 1;316316+#endif317317+ if (pmd_none(pmd_k[index]))318318+ return false;319319+320320+ copy_pmd(pmd, pmd_k);321321+322322+ return true;323323+}324324+238325static int __kprobes239326do_kernel_address_page_fault(struct mm_struct *mm, unsigned long addr,240327 unsigned int fsr, struct pt_regs *regs)···309268 * should not be faulting in kernel space, which includes the310269 * vector/khelper page. Handle the branch predictor hardening311270 * while interrupts are still disabled, then send a SIGSEGV.271271+ * Note that __do_user_fault() will enable interrupts.312272 */313273 harden_branch_predictor();314274 __do_user_fault(addr, fsr, SIGSEGV, SEGV_MAPERR, regs);···534492 * directly to do_kernel_address_page_fault() to handle.535493 *536494 * Otherwise, we're probably faulting in the vmalloc() area, so try to fix537537- * that up. Note that we must not take any locks or enable interrupts in538538- * this case.495495+ * that up via vmalloc_fault().539496 *540540- * If vmalloc() fixup fails, that means the non-leaf page tables did not497497+ * If vmalloc_fault() fails, that means the non-leaf page tables did not541498 * contain an entry for this address, so handle this via542499 * do_kernel_address_page_fault().543500 */···545504do_translation_fault(unsigned long addr, unsigned int fsr,546505 struct pt_regs *regs)547506{548548- unsigned int index;549549- pgd_t *pgd, *pgd_k;550550- p4d_t *p4d, *p4d_k;551551- pud_t *pud, *pud_k;552552- pmd_t *pmd, *pmd_k;553553-554507 if (addr < TASK_SIZE)555508 return do_page_fault(addr, fsr, regs);556509557557- if (user_mode(regs))558558- goto bad_area;510510+ if (!user_mode(regs) && vmalloc_fault(addr))511511+ return 0;559512560560- index = pgd_index(addr);561561-562562- pgd = cpu_get_pgd() + index;563563- pgd_k = init_mm.pgd + index;564564-565565- p4d = p4d_offset(pgd, addr);566566- p4d_k = p4d_offset(pgd_k, addr);567567-568568- if (p4d_none(*p4d_k))569569- goto bad_area;570570- if (!p4d_present(*p4d))571571- set_p4d(p4d, *p4d_k);572572-573573- pud = pud_offset(p4d, addr);574574- pud_k = pud_offset(p4d_k, addr);575575-576576- if (pud_none(*pud_k))577577- goto bad_area;578578- if (!pud_present(*pud))579579- set_pud(pud, *pud_k);580580-581581- pmd = pmd_offset(pud, addr);582582- pmd_k = pmd_offset(pud_k, addr);583583-584584-#ifdef CONFIG_ARM_LPAE585585- /*586586- * Only one hardware entry per PMD with LPAE.587587- */588588- index = 0;589589-#else590590- /*591591- * On ARM one Linux PGD entry contains two hardware entries (see page592592- * tables layout in pgtable.h). We normally guarantee that we always593593- * fill both L1 entries. But create_mapping() doesn't follow the rule.594594- * It can create inidividual L1 entries, so here we have to call595595- * pmd_none() check for the entry really corresponded to address, not596596- * for the first of pair.597597- */598598- index = (addr >> SECTION_SHIFT) & 1;599599-#endif600600- if (pmd_none(pmd_k[index]))601601- goto bad_area;602602-603603- copy_pmd(pmd, pmd_k);604604- return 0;605605-606606-bad_area:607513 do_kernel_address_page_fault(current->mm, addr, fsr, regs);608514609515 return 0;
+36-6
arch/arm/mm/fault.h
···55/*66 * Fault status register encodings. We steal bit 31 for our own purposes.77 */88-#define FSR_LNX_PF (1 << 31)99-#define FSR_CM (1 << 13)1010-#define FSR_WRITE (1 << 11)1111-#define FSR_FS4 (1 << 10)1212-#define FSR_FS3_0 (15)1313-#define FSR_FS5_0 (0x3f)88+#define FSR_LNX_PF BIT(31)99+#define FSR_CM BIT(13)1010+#define FSR_WRITE BIT(11)14111512#ifdef CONFIG_ARM_LPAE1613#define FSR_FS_AEA 17···1518#define FS_PERM_NOLL 0xC1619#define FS_MMU_NOLL_MASK 0x3C17202121+#define FSR_FS5_0 GENMASK(5, 0)2222+1823static inline int fsr_fs(unsigned int fsr)1924{2025 return fsr & FSR_FS5_0;2626+}2727+2828+static inline bool is_translation_fault(unsigned int fsr)2929+{3030+ int fs = fsr_fs(fsr);3131+3232+ return (fs & FS_MMU_NOLL_MASK) == FS_TRANS_NOLL;3333+}3434+3535+static inline bool is_permission_fault(unsigned int fsr)3636+{3737+ int fs = fsr_fs(fsr);3838+3939+ return (fs & FS_MMU_NOLL_MASK) == FS_PERM_NOLL;2140}2241#else2342#define FSR_FS_AEA 22···4229#define FS_L1_PERM 0xD4330#define FS_L2_PERM 0xF44313232+#define FSR_FS4 BIT(10)3333+#define FSR_FS3_0 GENMASK(3, 0)3434+4535static inline int fsr_fs(unsigned int fsr)4636{4737 return (fsr & FSR_FS3_0) | (fsr & FSR_FS4) >> 6;3838+}3939+4040+static inline bool is_translation_fault(unsigned int fsr)4141+{4242+ int fs = fsr_fs(fsr);4343+4444+ return fs == FS_L1_TRANS || fs == FS_L2_TRANS;4545+}4646+4747+static inline bool is_permission_fault(unsigned int fsr)4848+{4949+ int fs = fsr_fs(fsr);5050+5151+ return fs == FS_L1_PERM || fs == FS_L2_PERM;4852}4953#endif5054
+3-1
arch/arm/mm/flush.c
···304304 else305305 mapping = NULL;306306307307- if (!test_and_set_bit(PG_dcache_clean, &folio->flags.f))307307+ if (!test_bit(PG_dcache_clean, &folio->flags.f)) {308308 __flush_dcache_folio(mapping, folio);309309+ set_bit(PG_dcache_clean, &folio->flags.f);310310+ }309311310312 if (pte_exec(pteval))311313 __flush_icache_all();