fault.c 17 KB

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