Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * fault.c:  Page fault handlers for the Sparc.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 1995 David S. Miller (davem@caip.rutgers.edu)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Copyright (C) 1996 Eddie C. Dost (ecd@skynet.be)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * Copyright (C) 1997 Jakub Jelinek (jj@sunsite.mff.cuni.cz)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <asm/head.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/string.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/types.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/mman.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/threads.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <linux/perf_event.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include <linux/interrupt.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include <linux/kdebug.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #include <asm/openprom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) #include <asm/oplib.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) #include <asm/setup.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) #include <asm/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) #include <asm/traps.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) #include "mm_32.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) int show_unhandled_signals = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) static void __noreturn unhandled_fault(unsigned long address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 				       struct task_struct *tsk,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 				       struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	if ((unsigned long) address < PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 		printk(KERN_ALERT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 		    "Unable to handle kernel NULL pointer dereference\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 		printk(KERN_ALERT "Unable to handle kernel paging request at virtual address %08lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 		       address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	printk(KERN_ALERT "tsk->{mm,active_mm}->context = %08lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		(tsk->mm ? tsk->mm->context : tsk->active_mm->context));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	printk(KERN_ALERT "tsk->{mm,active_mm}->pgd = %08lx\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 		(tsk->mm ? (unsigned long) tsk->mm->pgd :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 			(unsigned long) tsk->active_mm->pgd));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 	die_if_kernel("Oops", regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) asmlinkage int lookup_fault(unsigned long pc, unsigned long ret_pc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 			    unsigned long address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 	struct pt_regs regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	unsigned long g2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 	unsigned int insn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 	i = search_extables_range(ret_pc, &g2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 	switch (i) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 	case 3:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 		/* load & store will be handled by fixup */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		return 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	case 1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		/* store will be handled by fixup, load will bump out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		/* for _to_ macros */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 		insn = *((unsigned int *) pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		if ((insn >> 21) & 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 			return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	case 2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		/* load will be handled by fixup, store will bump out */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		/* for _from_ macros */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 		insn = *((unsigned int *) pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		if (!((insn >> 21) & 1) || ((insn>>19)&0x3f) == 15)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 			return 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	memset(&regs, 0, sizeof(regs));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	regs.pc = pc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	regs.npc = pc + 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 	__asm__ __volatile__(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		"rd %%psr, %0\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		"nop\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 		"nop\n\t"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		"nop\n" : "=r" (regs.psr));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	unhandled_fault(address, current, &regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 	/* Not reached */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) show_signal_msg(struct pt_regs *regs, int sig, int code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 		unsigned long address, struct task_struct *tsk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 	if (!unhandled_signal(tsk, sig))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	if (!printk_ratelimit())
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	printk("%s%s[%d]: segfault at %lx ip %px (rpc %px) sp %px error %x",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 	       task_pid_nr(tsk) > 1 ? KERN_INFO : KERN_EMERG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 	       tsk->comm, task_pid_nr(tsk), address,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	       (void *)regs->pc, (void *)regs->u_regs[UREG_I7],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 	       (void *)regs->u_regs[UREG_FP], code);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	print_vma_addr(KERN_CONT " in ", regs->pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	printk(KERN_CONT "\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static void __do_fault_siginfo(int code, int sig, struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 			       unsigned long addr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	if (unlikely(show_unhandled_signals))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 		show_signal_msg(regs, sig, code,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 				addr, current);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 	force_sig_fault(sig, code, (void __user *) addr, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) static unsigned long compute_si_addr(struct pt_regs *regs, int text_fault)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	unsigned int insn;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	if (text_fault)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		return regs->pc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	if (regs->psr & PSR_PS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		insn = *(unsigned int *) regs->pc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 		__get_user(insn, (unsigned int *) regs->pc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 	return safe_compute_effective_address(regs, insn);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static noinline void do_fault_siginfo(int code, int sig, struct pt_regs *regs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 				      int text_fault)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	unsigned long addr = compute_si_addr(regs, text_fault);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 	__do_fault_siginfo(code, sig, regs, addr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) asmlinkage void do_sparc_fault(struct pt_regs *regs, int text_fault, int write,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 			       unsigned long address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	struct vm_area_struct *vma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	struct task_struct *tsk = current;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	struct mm_struct *mm = tsk->mm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 	unsigned int fixup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 	unsigned long g2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	int from_user = !(regs->psr & PSR_PS);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	int code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	vm_fault_t fault;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	unsigned int flags = FAULT_FLAG_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	if (text_fault)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		address = regs->pc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 	 * We fault-in kernel-space virtual memory on-demand. The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	 * 'reference' page table is init_mm.pgd.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 	 * NOTE! We MUST NOT take any locks for this case. We may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 	 * be in an interrupt or a critical region, and should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	 * only copy the information from the master page table,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 	 * nothing more.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	code = SEGV_MAPERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	if (address >= TASK_SIZE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 		goto vmalloc_fault;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	 * If we're in an interrupt or have no user
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	 * context, we must not take the fault..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 	if (pagefault_disabled() || !mm)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 		goto no_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 	perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) retry:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 	mmap_read_lock(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	if (!from_user && address >= PAGE_OFFSET)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		goto bad_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	vma = find_vma(mm, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	if (!vma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 		goto bad_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	if (vma->vm_start <= address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 		goto good_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 	if (!(vma->vm_flags & VM_GROWSDOWN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 		goto bad_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 	if (expand_stack(vma, address))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 		goto bad_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 	 * Ok, we have a good vm_area for this memory access, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 	 * we can handle it..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) good_area:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	code = SEGV_ACCERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 	if (write) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 		if (!(vma->vm_flags & VM_WRITE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			goto bad_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 		/* Allow reads even for write-only mappings */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 			goto bad_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	if (from_user)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 		flags |= FAULT_FLAG_USER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	if (write)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		flags |= FAULT_FLAG_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 	 * If for any reason at all we couldn't handle the fault,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 	 * make sure we exit gracefully rather than endlessly redo
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 	 * the fault.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 	fault = handle_mm_fault(vma, address, flags, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	if (fault_signal_pending(fault, regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	if (unlikely(fault & VM_FAULT_ERROR)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 		if (fault & VM_FAULT_OOM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 			goto out_of_memory;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		else if (fault & VM_FAULT_SIGSEGV)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 			goto bad_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		else if (fault & VM_FAULT_SIGBUS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 			goto do_sigbus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 		BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 	if (flags & FAULT_FLAG_ALLOW_RETRY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 		if (fault & VM_FAULT_RETRY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 			flags |= FAULT_FLAG_TRIED;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 			/* No need to mmap_read_unlock(mm) as we would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			 * have already released it in __lock_page_or_retry
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 			 * in mm/filemap.c.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 			goto retry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	mmap_read_unlock(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 	 * Something tried to access memory that isn't in our memory map..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	 * Fix it, but check if it's kernel or user first..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) bad_area:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) 	mmap_read_unlock(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) bad_area_nosemaphore:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	/* User mode accesses just cause a SIGSEGV */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	if (from_user) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 		do_fault_siginfo(code, SIGSEGV, regs, text_fault);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 	/* Is this in ex_table? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) no_context:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 	g2 = regs->u_regs[UREG_G2];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 	if (!from_user) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 		fixup = search_extables_range(regs->pc, &g2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 		/* Values below 10 are reserved for other things */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 		if (fixup > 10) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 			extern const unsigned int __memset_start[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 			extern const unsigned int __memset_end[];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) #ifdef DEBUG_EXCEPTIONS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 			printk("Exception: PC<%08lx> faddr<%08lx>\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 			       regs->pc, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 			printk("EX_TABLE: insn<%08lx> fixup<%08x> g2<%08lx>\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 				regs->pc, fixup, g2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 			if ((regs->pc >= (unsigned long)__memset_start &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 			     regs->pc < (unsigned long)__memset_end)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 				regs->u_regs[UREG_I4] = address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 				regs->u_regs[UREG_I5] = regs->pc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 			regs->u_regs[UREG_G2] = g2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 			regs->pc = fixup;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 			regs->npc = regs->pc + 4;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 	unhandled_fault(address, tsk, regs);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	do_exit(SIGKILL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314)  * We ran out of memory, or some other thing happened to us that made
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315)  * us unable to handle the page fault gracefully.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) out_of_memory:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 	mmap_read_unlock(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 	if (from_user) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		pagefault_out_of_memory();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 	goto no_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) do_sigbus:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 	mmap_read_unlock(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 	do_fault_siginfo(BUS_ADRERR, SIGBUS, regs, text_fault);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 	if (!from_user)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 		goto no_context;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) vmalloc_fault:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 		 * Synchronize this task's top level page-table
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 		 * with the 'reference' page table.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		int offset = pgd_index(address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		pgd_t *pgd, *pgd_k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 		p4d_t *p4d, *p4d_k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 		pud_t *pud, *pud_k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 		pmd_t *pmd, *pmd_k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		pgd = tsk->active_mm->pgd + offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 		pgd_k = init_mm.pgd + offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 		if (!pgd_present(*pgd)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 			if (!pgd_present(*pgd_k))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) 				goto bad_area_nosemaphore;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 			pgd_val(*pgd) = pgd_val(*pgd_k);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) 			return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 		p4d = p4d_offset(pgd, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) 		pud = pud_offset(p4d, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 		pmd = pmd_offset(pud, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 		p4d_k = p4d_offset(pgd_k, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		pud_k = pud_offset(p4d_k, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 		pmd_k = pmd_offset(pud_k, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 		if (pmd_present(*pmd) || !pmd_present(*pmd_k))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 			goto bad_area_nosemaphore;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 		*pmd = *pmd_k;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) /* This always deals with user addresses. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) static void force_user_fault(unsigned long address, int write)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	struct vm_area_struct *vma;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	struct task_struct *tsk = current;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 	struct mm_struct *mm = tsk->mm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	unsigned int flags = FAULT_FLAG_USER;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 	int code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	code = SEGV_MAPERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	mmap_read_lock(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	vma = find_vma(mm, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 	if (!vma)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 		goto bad_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	if (vma->vm_start <= address)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		goto good_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	if (!(vma->vm_flags & VM_GROWSDOWN))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 		goto bad_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	if (expand_stack(vma, address))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 		goto bad_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) good_area:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	code = SEGV_ACCERR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	if (write) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 		if (!(vma->vm_flags & VM_WRITE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 			goto bad_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 		flags |= FAULT_FLAG_WRITE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 		if (!(vma->vm_flags & (VM_READ | VM_EXEC)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 			goto bad_area;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	switch (handle_mm_fault(vma, address, flags, NULL)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	case VM_FAULT_SIGBUS:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 	case VM_FAULT_OOM:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		goto do_sigbus;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 	mmap_read_unlock(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) bad_area:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 	mmap_read_unlock(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 	__do_fault_siginfo(code, SIGSEGV, tsk->thread.kregs, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) do_sigbus:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	mmap_read_unlock(mm);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 	__do_fault_siginfo(BUS_ADRERR, SIGBUS, tsk->thread.kregs, address);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) static void check_stack_aligned(unsigned long sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	if (sp & 0x7UL)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 		force_sig(SIGILL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) void window_overflow_fault(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) 	unsigned long sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) 	sp = current_thread_info()->rwbuf_stkptrs[0];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) 	if (((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 		force_user_fault(sp + 0x38, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 	force_user_fault(sp, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 	check_stack_aligned(sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) void window_underflow_fault(unsigned long sp)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	if (((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		force_user_fault(sp + 0x38, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 	force_user_fault(sp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 	check_stack_aligned(sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) void window_ret_fault(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	unsigned long sp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 	sp = regs->u_regs[UREG_FP];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) 	if (((sp + 0x38) & PAGE_MASK) != (sp & PAGE_MASK))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) 		force_user_fault(sp + 0x38, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	force_user_fault(sp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	check_stack_aligned(sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }