fault.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685
  1. /*
  2. * S390 version
  3. * Copyright IBM Corp. 1999
  4. * Author(s): Hartmut Penner (hp@de.ibm.com)
  5. * Ulrich Weigand (uweigand@de.ibm.com)
  6. *
  7. * Derived from "arch/i386/mm/fault.c"
  8. * Copyright (C) 1995 Linus Torvalds
  9. */
  10. #include <linux/kernel_stat.h>
  11. #include <linux/perf_event.h>
  12. #include <linux/signal.h>
  13. #include <linux/sched.h>
  14. #include <linux/kernel.h>
  15. #include <linux/errno.h>
  16. #include <linux/string.h>
  17. #include <linux/types.h>
  18. #include <linux/ptrace.h>
  19. #include <linux/mman.h>
  20. #include <linux/mm.h>
  21. #include <linux/compat.h>
  22. #include <linux/smp.h>
  23. #include <linux/kdebug.h>
  24. #include <linux/init.h>
  25. #include <linux/console.h>
  26. #include <linux/module.h>
  27. #include <linux/hardirq.h>
  28. #include <linux/kprobes.h>
  29. #include <linux/uaccess.h>
  30. #include <linux/hugetlb.h>
  31. #include <asm/asm-offsets.h>
  32. #include <asm/pgtable.h>
  33. #include <asm/irq.h>
  34. #include <asm/mmu_context.h>
  35. #include <asm/facility.h>
  36. #include "../kernel/entry.h"
  37. #ifndef CONFIG_64BIT
  38. #define __FAIL_ADDR_MASK 0x7ffff000
  39. #define __SUBCODE_MASK 0x0200
  40. #define __PF_RES_FIELD 0ULL
  41. #else /* CONFIG_64BIT */
  42. #define __FAIL_ADDR_MASK -4096L
  43. #define __SUBCODE_MASK 0x0600
  44. #define __PF_RES_FIELD 0x8000000000000000ULL
  45. #endif /* CONFIG_64BIT */
  46. #define VM_FAULT_BADCONTEXT 0x010000
  47. #define VM_FAULT_BADMAP 0x020000
  48. #define VM_FAULT_BADACCESS 0x040000
  49. #define VM_FAULT_SIGNAL 0x080000
  50. static unsigned long store_indication __read_mostly;
  51. #ifdef CONFIG_64BIT
  52. static int __init fault_init(void)
  53. {
  54. if (test_facility(75))
  55. store_indication = 0xc00;
  56. return 0;
  57. }
  58. early_initcall(fault_init);
  59. #endif
  60. static inline int notify_page_fault(struct pt_regs *regs)
  61. {
  62. int ret = 0;
  63. /* kprobe_running() needs smp_processor_id() */
  64. if (kprobes_built_in() && !user_mode(regs)) {
  65. preempt_disable();
  66. if (kprobe_running() && kprobe_fault_handler(regs, 14))
  67. ret = 1;
  68. preempt_enable();
  69. }
  70. return ret;
  71. }
  72. /*
  73. * Unlock any spinlocks which will prevent us from getting the
  74. * message out.
  75. */
  76. void bust_spinlocks(int yes)
  77. {
  78. if (yes) {
  79. oops_in_progress = 1;
  80. } else {
  81. int loglevel_save = console_loglevel;
  82. console_unblank();
  83. oops_in_progress = 0;
  84. /*
  85. * OK, the message is on the console. Now we call printk()
  86. * without oops_in_progress set so that printk will give klogd
  87. * a poke. Hold onto your hats...
  88. */
  89. console_loglevel = 15;
  90. printk(" ");
  91. console_loglevel = loglevel_save;
  92. }
  93. }
  94. /*
  95. * Returns the address space associated with the fault.
  96. * Returns 0 for kernel space and 1 for user space.
  97. */
  98. static inline int user_space_fault(unsigned long trans_exc_code)
  99. {
  100. /*
  101. * The lowest two bits of the translation exception
  102. * identification indicate which paging table was used.
  103. */
  104. trans_exc_code &= 3;
  105. if (trans_exc_code == 2)
  106. /* Access via secondary space, set_fs setting decides */
  107. return current->thread.mm_segment.ar4;
  108. /*
  109. * Access via primary space or access register is from user space
  110. * and access via home space is from the kernel.
  111. */
  112. return trans_exc_code != 3;
  113. }
  114. static inline void report_user_fault(struct pt_regs *regs, long signr)
  115. {
  116. if ((task_pid_nr(current) > 1) && !show_unhandled_signals)
  117. return;
  118. if (!unhandled_signal(current, signr))
  119. return;
  120. if (!printk_ratelimit())
  121. return;
  122. printk(KERN_ALERT "User process fault: interruption code 0x%X ",
  123. regs->int_code);
  124. print_vma_addr(KERN_CONT "in ", regs->psw.addr & PSW_ADDR_INSN);
  125. printk(KERN_CONT "\n");
  126. printk(KERN_ALERT "failing address: %lX\n",
  127. regs->int_parm_long & __FAIL_ADDR_MASK);
  128. show_regs(regs);
  129. }
  130. /*
  131. * Send SIGSEGV to task. This is an external routine
  132. * to keep the stack usage of do_page_fault small.
  133. */
  134. static noinline void do_sigsegv(struct pt_regs *regs, int si_code)
  135. {
  136. struct siginfo si;
  137. report_user_fault(regs, SIGSEGV);
  138. si.si_signo = SIGSEGV;
  139. si.si_code = si_code;
  140. si.si_addr = (void __user *)(regs->int_parm_long & __FAIL_ADDR_MASK);
  141. force_sig_info(SIGSEGV, &si, current);
  142. }
  143. static noinline void do_no_context(struct pt_regs *regs)
  144. {
  145. const struct exception_table_entry *fixup;
  146. unsigned long address;
  147. /* Are we prepared to handle this kernel fault? */
  148. fixup = search_exception_tables(regs->psw.addr & PSW_ADDR_INSN);
  149. if (fixup) {
  150. regs->psw.addr = extable_fixup(fixup) | PSW_ADDR_AMODE;
  151. return;
  152. }
  153. /*
  154. * Oops. The kernel tried to access some bad page. We'll have to
  155. * terminate things with extreme prejudice.
  156. */
  157. address = regs->int_parm_long & __FAIL_ADDR_MASK;
  158. if (!user_space_fault(regs->int_parm_long))
  159. printk(KERN_ALERT "Unable to handle kernel pointer dereference"
  160. " at virtual kernel address %p\n", (void *)address);
  161. else
  162. printk(KERN_ALERT "Unable to handle kernel paging request"
  163. " at virtual user address %p\n", (void *)address);
  164. die(regs, "Oops");
  165. do_exit(SIGKILL);
  166. }
  167. static noinline void do_low_address(struct pt_regs *regs)
  168. {
  169. /* Low-address protection hit in kernel mode means
  170. NULL pointer write access in kernel mode. */
  171. if (regs->psw.mask & PSW_MASK_PSTATE) {
  172. /* Low-address protection hit in user mode 'cannot happen'. */
  173. die (regs, "Low-address protection");
  174. do_exit(SIGKILL);
  175. }
  176. do_no_context(regs);
  177. }
  178. static noinline void do_sigbus(struct pt_regs *regs)
  179. {
  180. struct task_struct *tsk = current;
  181. struct siginfo si;
  182. /*
  183. * Send a sigbus, regardless of whether we were in kernel
  184. * or user mode.
  185. */
  186. si.si_signo = SIGBUS;
  187. si.si_errno = 0;
  188. si.si_code = BUS_ADRERR;
  189. si.si_addr = (void __user *)(regs->int_parm_long & __FAIL_ADDR_MASK);
  190. force_sig_info(SIGBUS, &si, tsk);
  191. }
  192. static noinline void do_fault_error(struct pt_regs *regs, int fault)
  193. {
  194. int si_code;
  195. switch (fault) {
  196. case VM_FAULT_BADACCESS:
  197. case VM_FAULT_BADMAP:
  198. /* Bad memory access. Check if it is kernel or user space. */
  199. if (user_mode(regs)) {
  200. /* User mode accesses just cause a SIGSEGV */
  201. si_code = (fault == VM_FAULT_BADMAP) ?
  202. SEGV_MAPERR : SEGV_ACCERR;
  203. do_sigsegv(regs, si_code);
  204. return;
  205. }
  206. case VM_FAULT_BADCONTEXT:
  207. do_no_context(regs);
  208. break;
  209. case VM_FAULT_SIGNAL:
  210. if (!user_mode(regs))
  211. do_no_context(regs);
  212. break;
  213. default: /* fault & VM_FAULT_ERROR */
  214. if (fault & VM_FAULT_OOM) {
  215. if (!user_mode(regs))
  216. do_no_context(regs);
  217. else
  218. pagefault_out_of_memory();
  219. } else if (fault & VM_FAULT_SIGBUS) {
  220. /* Kernel mode? Handle exceptions or die */
  221. if (!user_mode(regs))
  222. do_no_context(regs);
  223. else
  224. do_sigbus(regs);
  225. } else
  226. BUG();
  227. break;
  228. }
  229. }
  230. /*
  231. * This routine handles page faults. It determines the address,
  232. * and the problem, and then passes it off to one of the appropriate
  233. * routines.
  234. *
  235. * interruption code (int_code):
  236. * 04 Protection -> Write-Protection (suprression)
  237. * 10 Segment translation -> Not present (nullification)
  238. * 11 Page translation -> Not present (nullification)
  239. * 3b Region third trans. -> Not present (nullification)
  240. */
  241. static inline int do_exception(struct pt_regs *regs, int access)
  242. {
  243. struct task_struct *tsk;
  244. struct mm_struct *mm;
  245. struct vm_area_struct *vma;
  246. unsigned long trans_exc_code;
  247. unsigned long address;
  248. unsigned int flags;
  249. int fault;
  250. tsk = current;
  251. /*
  252. * The instruction that caused the program check has
  253. * been nullified. Don't signal single step via SIGTRAP.
  254. */
  255. clear_tsk_thread_flag(tsk, TIF_PER_TRAP);
  256. if (notify_page_fault(regs))
  257. return 0;
  258. mm = tsk->mm;
  259. trans_exc_code = regs->int_parm_long;
  260. /*
  261. * Verify that the fault happened in user space, that
  262. * we are not in an interrupt and that there is a
  263. * user context.
  264. */
  265. fault = VM_FAULT_BADCONTEXT;
  266. if (unlikely(!user_space_fault(trans_exc_code) || in_atomic() || !mm))
  267. goto out;
  268. address = trans_exc_code & __FAIL_ADDR_MASK;
  269. perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, regs, address);
  270. flags = FAULT_FLAG_ALLOW_RETRY | FAULT_FLAG_KILLABLE;
  271. if (user_mode(regs))
  272. flags |= FAULT_FLAG_USER;
  273. if (access == VM_WRITE || (trans_exc_code & store_indication) == 0x400)
  274. flags |= FAULT_FLAG_WRITE;
  275. down_read(&mm->mmap_sem);
  276. #ifdef CONFIG_PGSTE
  277. if ((current->flags & PF_VCPU) && S390_lowcore.gmap) {
  278. address = __gmap_fault(address,
  279. (struct gmap *) S390_lowcore.gmap);
  280. if (address == -EFAULT) {
  281. fault = VM_FAULT_BADMAP;
  282. goto out_up;
  283. }
  284. if (address == -ENOMEM) {
  285. fault = VM_FAULT_OOM;
  286. goto out_up;
  287. }
  288. }
  289. #endif
  290. retry:
  291. fault = VM_FAULT_BADMAP;
  292. vma = find_vma(mm, address);
  293. if (!vma)
  294. goto out_up;
  295. if (unlikely(vma->vm_start > address)) {
  296. if (!(vma->vm_flags & VM_GROWSDOWN))
  297. goto out_up;
  298. if (expand_stack(vma, address))
  299. goto out_up;
  300. }
  301. /*
  302. * Ok, we have a good vm_area for this memory access, so
  303. * we can handle it..
  304. */
  305. fault = VM_FAULT_BADACCESS;
  306. if (unlikely(!(vma->vm_flags & access)))
  307. goto out_up;
  308. if (is_vm_hugetlb_page(vma))
  309. address &= HPAGE_MASK;
  310. /*
  311. * If for any reason at all we couldn't handle the fault,
  312. * make sure we exit gracefully rather than endlessly redo
  313. * the fault.
  314. */
  315. fault = handle_mm_fault(mm, vma, address, flags);
  316. /* No reason to continue if interrupted by SIGKILL. */
  317. if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) {
  318. fault = VM_FAULT_SIGNAL;
  319. goto out;
  320. }
  321. if (unlikely(fault & VM_FAULT_ERROR))
  322. goto out_up;
  323. /*
  324. * Major/minor page fault accounting is only done on the
  325. * initial attempt. If we go through a retry, it is extremely
  326. * likely that the page will be found in page cache at that point.
  327. */
  328. if (flags & FAULT_FLAG_ALLOW_RETRY) {
  329. if (fault & VM_FAULT_MAJOR) {
  330. tsk->maj_flt++;
  331. perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1,
  332. regs, address);
  333. } else {
  334. tsk->min_flt++;
  335. perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1,
  336. regs, address);
  337. }
  338. if (fault & VM_FAULT_RETRY) {
  339. /* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
  340. * of starvation. */
  341. flags &= ~FAULT_FLAG_ALLOW_RETRY;
  342. flags |= FAULT_FLAG_TRIED;
  343. down_read(&mm->mmap_sem);
  344. goto retry;
  345. }
  346. }
  347. fault = 0;
  348. out_up:
  349. up_read(&mm->mmap_sem);
  350. out:
  351. return fault;
  352. }
  353. void __kprobes do_protection_exception(struct pt_regs *regs)
  354. {
  355. unsigned long trans_exc_code;
  356. int fault;
  357. trans_exc_code = regs->int_parm_long;
  358. /*
  359. * Protection exceptions are suppressing, decrement psw address.
  360. * The exception to this rule are aborted transactions, for these
  361. * the PSW already points to the correct location.
  362. */
  363. if (!(regs->int_code & 0x200))
  364. regs->psw.addr = __rewind_psw(regs->psw, regs->int_code >> 16);
  365. /*
  366. * Check for low-address protection. This needs to be treated
  367. * as a special case because the translation exception code
  368. * field is not guaranteed to contain valid data in this case.
  369. */
  370. if (unlikely(!(trans_exc_code & 4))) {
  371. do_low_address(regs);
  372. return;
  373. }
  374. fault = do_exception(regs, VM_WRITE);
  375. if (unlikely(fault))
  376. do_fault_error(regs, fault);
  377. }
  378. void __kprobes do_dat_exception(struct pt_regs *regs)
  379. {
  380. int access, fault;
  381. access = VM_READ | VM_EXEC | VM_WRITE;
  382. fault = do_exception(regs, access);
  383. if (unlikely(fault))
  384. do_fault_error(regs, fault);
  385. }
  386. #ifdef CONFIG_64BIT
  387. void __kprobes do_asce_exception(struct pt_regs *regs)
  388. {
  389. struct mm_struct *mm = current->mm;
  390. struct vm_area_struct *vma;
  391. unsigned long trans_exc_code;
  392. /*
  393. * The instruction that caused the program check has
  394. * been nullified. Don't signal single step via SIGTRAP.
  395. */
  396. clear_tsk_thread_flag(current, TIF_PER_TRAP);
  397. trans_exc_code = regs->int_parm_long;
  398. if (unlikely(!user_space_fault(trans_exc_code) || in_atomic() || !mm))
  399. goto no_context;
  400. down_read(&mm->mmap_sem);
  401. vma = find_vma(mm, trans_exc_code & __FAIL_ADDR_MASK);
  402. up_read(&mm->mmap_sem);
  403. if (vma) {
  404. update_mm(mm, current);
  405. return;
  406. }
  407. /* User mode accesses just cause a SIGSEGV */
  408. if (user_mode(regs)) {
  409. do_sigsegv(regs, SEGV_MAPERR);
  410. return;
  411. }
  412. no_context:
  413. do_no_context(regs);
  414. }
  415. #endif
  416. int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write)
  417. {
  418. struct pt_regs regs;
  419. int access, fault;
  420. /* Emulate a uaccess fault from kernel mode. */
  421. regs.psw.mask = PSW_KERNEL_BITS | PSW_MASK_DAT | PSW_MASK_MCHECK;
  422. if (!irqs_disabled())
  423. regs.psw.mask |= PSW_MASK_IO | PSW_MASK_EXT;
  424. regs.psw.addr = (unsigned long) __builtin_return_address(0);
  425. regs.psw.addr |= PSW_ADDR_AMODE;
  426. regs.int_code = pgm_int_code;
  427. regs.int_parm_long = (uaddr & PAGE_MASK) | 2;
  428. access = write ? VM_WRITE : VM_READ;
  429. fault = do_exception(&regs, access);
  430. /*
  431. * Since the fault happened in kernel mode while performing a uaccess
  432. * all we need to do now is emulating a fixup in case "fault" is not
  433. * zero.
  434. * For the calling uaccess functions this results always in -EFAULT.
  435. */
  436. return fault ? -EFAULT : 0;
  437. }
  438. #ifdef CONFIG_PFAULT
  439. /*
  440. * 'pfault' pseudo page faults routines.
  441. */
  442. static int pfault_disable;
  443. static int __init nopfault(char *str)
  444. {
  445. pfault_disable = 1;
  446. return 1;
  447. }
  448. __setup("nopfault", nopfault);
  449. struct pfault_refbk {
  450. u16 refdiagc;
  451. u16 reffcode;
  452. u16 refdwlen;
  453. u16 refversn;
  454. u64 refgaddr;
  455. u64 refselmk;
  456. u64 refcmpmk;
  457. u64 reserved;
  458. } __attribute__ ((packed, aligned(8)));
  459. int pfault_init(void)
  460. {
  461. struct pfault_refbk refbk = {
  462. .refdiagc = 0x258,
  463. .reffcode = 0,
  464. .refdwlen = 5,
  465. .refversn = 2,
  466. .refgaddr = __LC_CURRENT_PID,
  467. .refselmk = 1ULL << 48,
  468. .refcmpmk = 1ULL << 48,
  469. .reserved = __PF_RES_FIELD };
  470. int rc;
  471. if (pfault_disable)
  472. return -1;
  473. asm volatile(
  474. " diag %1,%0,0x258\n"
  475. "0: j 2f\n"
  476. "1: la %0,8\n"
  477. "2:\n"
  478. EX_TABLE(0b,1b)
  479. : "=d" (rc) : "a" (&refbk), "m" (refbk) : "cc");
  480. return rc;
  481. }
  482. void pfault_fini(void)
  483. {
  484. struct pfault_refbk refbk = {
  485. .refdiagc = 0x258,
  486. .reffcode = 1,
  487. .refdwlen = 5,
  488. .refversn = 2,
  489. };
  490. if (pfault_disable)
  491. return;
  492. asm volatile(
  493. " diag %0,0,0x258\n"
  494. "0:\n"
  495. EX_TABLE(0b,0b)
  496. : : "a" (&refbk), "m" (refbk) : "cc");
  497. }
  498. static DEFINE_SPINLOCK(pfault_lock);
  499. static LIST_HEAD(pfault_list);
  500. static void pfault_interrupt(struct ext_code ext_code,
  501. unsigned int param32, unsigned long param64)
  502. {
  503. struct task_struct *tsk;
  504. __u16 subcode;
  505. pid_t pid;
  506. /*
  507. * Get the external interruption subcode & pfault
  508. * initial/completion signal bit. VM stores this
  509. * in the 'cpu address' field associated with the
  510. * external interrupt.
  511. */
  512. subcode = ext_code.subcode;
  513. if ((subcode & 0xff00) != __SUBCODE_MASK)
  514. return;
  515. inc_irq_stat(IRQEXT_PFL);
  516. /* Get the token (= pid of the affected task). */
  517. pid = sizeof(void *) == 4 ? param32 : param64;
  518. rcu_read_lock();
  519. tsk = find_task_by_pid_ns(pid, &init_pid_ns);
  520. if (tsk)
  521. get_task_struct(tsk);
  522. rcu_read_unlock();
  523. if (!tsk)
  524. return;
  525. spin_lock(&pfault_lock);
  526. if (subcode & 0x0080) {
  527. /* signal bit is set -> a page has been swapped in by VM */
  528. if (tsk->thread.pfault_wait == 1) {
  529. /* Initial interrupt was faster than the completion
  530. * interrupt. pfault_wait is valid. Set pfault_wait
  531. * back to zero and wake up the process. This can
  532. * safely be done because the task is still sleeping
  533. * and can't produce new pfaults. */
  534. tsk->thread.pfault_wait = 0;
  535. list_del(&tsk->thread.list);
  536. wake_up_process(tsk);
  537. put_task_struct(tsk);
  538. } else {
  539. /* Completion interrupt was faster than initial
  540. * interrupt. Set pfault_wait to -1 so the initial
  541. * interrupt doesn't put the task to sleep.
  542. * If the task is not running, ignore the completion
  543. * interrupt since it must be a leftover of a PFAULT
  544. * CANCEL operation which didn't remove all pending
  545. * completion interrupts. */
  546. if (tsk->state == TASK_RUNNING)
  547. tsk->thread.pfault_wait = -1;
  548. }
  549. } else {
  550. /* signal bit not set -> a real page is missing. */
  551. if (WARN_ON_ONCE(tsk != current))
  552. goto out;
  553. if (tsk->thread.pfault_wait == 1) {
  554. /* Already on the list with a reference: put to sleep */
  555. __set_task_state(tsk, TASK_UNINTERRUPTIBLE);
  556. set_tsk_need_resched(tsk);
  557. } else if (tsk->thread.pfault_wait == -1) {
  558. /* Completion interrupt was faster than the initial
  559. * interrupt (pfault_wait == -1). Set pfault_wait
  560. * back to zero and exit. */
  561. tsk->thread.pfault_wait = 0;
  562. } else {
  563. /* Initial interrupt arrived before completion
  564. * interrupt. Let the task sleep.
  565. * An extra task reference is needed since a different
  566. * cpu may set the task state to TASK_RUNNING again
  567. * before the scheduler is reached. */
  568. get_task_struct(tsk);
  569. tsk->thread.pfault_wait = 1;
  570. list_add(&tsk->thread.list, &pfault_list);
  571. __set_task_state(tsk, TASK_UNINTERRUPTIBLE);
  572. set_tsk_need_resched(tsk);
  573. }
  574. }
  575. out:
  576. spin_unlock(&pfault_lock);
  577. put_task_struct(tsk);
  578. }
  579. static int pfault_cpu_notify(struct notifier_block *self, unsigned long action,
  580. void *hcpu)
  581. {
  582. struct thread_struct *thread, *next;
  583. struct task_struct *tsk;
  584. switch (action & ~CPU_TASKS_FROZEN) {
  585. case CPU_DEAD:
  586. spin_lock_irq(&pfault_lock);
  587. list_for_each_entry_safe(thread, next, &pfault_list, list) {
  588. thread->pfault_wait = 0;
  589. list_del(&thread->list);
  590. tsk = container_of(thread, struct task_struct, thread);
  591. wake_up_process(tsk);
  592. put_task_struct(tsk);
  593. }
  594. spin_unlock_irq(&pfault_lock);
  595. break;
  596. default:
  597. break;
  598. }
  599. return NOTIFY_OK;
  600. }
  601. static int __init pfault_irq_init(void)
  602. {
  603. int rc;
  604. rc = register_external_interrupt(0x2603, pfault_interrupt);
  605. if (rc)
  606. goto out_extint;
  607. rc = pfault_init() == 0 ? 0 : -EOPNOTSUPP;
  608. if (rc)
  609. goto out_pfault;
  610. irq_subclass_register(IRQ_SUBCLASS_SERVICE_SIGNAL);
  611. hotcpu_notifier(pfault_cpu_notify, 0);
  612. return 0;
  613. out_pfault:
  614. unregister_external_interrupt(0x2603, pfault_interrupt);
  615. out_extint:
  616. pfault_disable = 1;
  617. return rc;
  618. }
  619. early_initcall(pfault_irq_init);
  620. #endif /* CONFIG_PFAULT */