fault.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688
  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. /*
  362. * Protection exceptions are suppressing, decrement psw address.
  363. * The exception to this rule are aborted transactions, for these
  364. * the PSW already points to the correct location.
  365. */
  366. if (!(regs->int_code & 0x200))
  367. regs->psw.addr = __rewind_psw(regs->psw, regs->int_code >> 16);
  368. /*
  369. * Check for low-address protection. This needs to be treated
  370. * as a special case because the translation exception code
  371. * field is not guaranteed to contain valid data in this case.
  372. */
  373. if (unlikely(!(trans_exc_code & 4))) {
  374. do_low_address(regs);
  375. return;
  376. }
  377. fault = do_exception(regs, VM_WRITE);
  378. if (unlikely(fault))
  379. do_fault_error(regs, fault);
  380. }
  381. void __kprobes do_dat_exception(struct pt_regs *regs)
  382. {
  383. int access, fault;
  384. access = VM_READ | VM_EXEC | VM_WRITE;
  385. fault = do_exception(regs, access);
  386. if (unlikely(fault))
  387. do_fault_error(regs, fault);
  388. }
  389. #ifdef CONFIG_64BIT
  390. void __kprobes do_asce_exception(struct pt_regs *regs)
  391. {
  392. struct mm_struct *mm = current->mm;
  393. struct vm_area_struct *vma;
  394. unsigned long trans_exc_code;
  395. /*
  396. * The instruction that caused the program check has
  397. * been nullified. Don't signal single step via SIGTRAP.
  398. */
  399. clear_tsk_thread_flag(current, TIF_PER_TRAP);
  400. trans_exc_code = regs->int_parm_long;
  401. if (unlikely(!user_space_fault(trans_exc_code) || in_atomic() || !mm))
  402. goto no_context;
  403. down_read(&mm->mmap_sem);
  404. vma = find_vma(mm, trans_exc_code & __FAIL_ADDR_MASK);
  405. up_read(&mm->mmap_sem);
  406. if (vma) {
  407. update_mm(mm, current);
  408. return;
  409. }
  410. /* User mode accesses just cause a SIGSEGV */
  411. if (user_mode(regs)) {
  412. do_sigsegv(regs, SEGV_MAPERR);
  413. return;
  414. }
  415. no_context:
  416. do_no_context(regs);
  417. }
  418. #endif
  419. int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write)
  420. {
  421. struct pt_regs regs;
  422. int access, fault;
  423. /* Emulate a uaccess fault from kernel mode. */
  424. regs.psw.mask = psw_kernel_bits | PSW_MASK_DAT | PSW_MASK_MCHECK;
  425. if (!irqs_disabled())
  426. regs.psw.mask |= PSW_MASK_IO | PSW_MASK_EXT;
  427. regs.psw.addr = (unsigned long) __builtin_return_address(0);
  428. regs.psw.addr |= PSW_ADDR_AMODE;
  429. regs.int_code = pgm_int_code;
  430. regs.int_parm_long = (uaddr & PAGE_MASK) | 2;
  431. access = write ? VM_WRITE : VM_READ;
  432. fault = do_exception(&regs, access);
  433. /*
  434. * Since the fault happened in kernel mode while performing a uaccess
  435. * all we need to do now is emulating a fixup in case "fault" is not
  436. * zero.
  437. * For the calling uaccess functions this results always in -EFAULT.
  438. */
  439. return fault ? -EFAULT : 0;
  440. }
  441. #ifdef CONFIG_PFAULT
  442. /*
  443. * 'pfault' pseudo page faults routines.
  444. */
  445. static int pfault_disable;
  446. static int __init nopfault(char *str)
  447. {
  448. pfault_disable = 1;
  449. return 1;
  450. }
  451. __setup("nopfault", nopfault);
  452. struct pfault_refbk {
  453. u16 refdiagc;
  454. u16 reffcode;
  455. u16 refdwlen;
  456. u16 refversn;
  457. u64 refgaddr;
  458. u64 refselmk;
  459. u64 refcmpmk;
  460. u64 reserved;
  461. } __attribute__ ((packed, aligned(8)));
  462. int pfault_init(void)
  463. {
  464. struct pfault_refbk refbk = {
  465. .refdiagc = 0x258,
  466. .reffcode = 0,
  467. .refdwlen = 5,
  468. .refversn = 2,
  469. .refgaddr = __LC_CURRENT_PID,
  470. .refselmk = 1ULL << 48,
  471. .refcmpmk = 1ULL << 48,
  472. .reserved = __PF_RES_FIELD };
  473. int rc;
  474. if (pfault_disable)
  475. return -1;
  476. asm volatile(
  477. " diag %1,%0,0x258\n"
  478. "0: j 2f\n"
  479. "1: la %0,8\n"
  480. "2:\n"
  481. EX_TABLE(0b,1b)
  482. : "=d" (rc) : "a" (&refbk), "m" (refbk) : "cc");
  483. return rc;
  484. }
  485. void pfault_fini(void)
  486. {
  487. struct pfault_refbk refbk = {
  488. .refdiagc = 0x258,
  489. .reffcode = 1,
  490. .refdwlen = 5,
  491. .refversn = 2,
  492. };
  493. if (pfault_disable)
  494. return;
  495. asm volatile(
  496. " diag %0,0,0x258\n"
  497. "0:\n"
  498. EX_TABLE(0b,0b)
  499. : : "a" (&refbk), "m" (refbk) : "cc");
  500. }
  501. static DEFINE_SPINLOCK(pfault_lock);
  502. static LIST_HEAD(pfault_list);
  503. static void pfault_interrupt(struct ext_code ext_code,
  504. unsigned int param32, unsigned long param64)
  505. {
  506. struct task_struct *tsk;
  507. __u16 subcode;
  508. pid_t pid;
  509. /*
  510. * Get the external interruption subcode & pfault
  511. * initial/completion signal bit. VM stores this
  512. * in the 'cpu address' field associated with the
  513. * external interrupt.
  514. */
  515. subcode = ext_code.subcode;
  516. if ((subcode & 0xff00) != __SUBCODE_MASK)
  517. return;
  518. inc_irq_stat(IRQEXT_PFL);
  519. /* Get the token (= pid of the affected task). */
  520. pid = sizeof(void *) == 4 ? param32 : param64;
  521. rcu_read_lock();
  522. tsk = find_task_by_pid_ns(pid, &init_pid_ns);
  523. if (tsk)
  524. get_task_struct(tsk);
  525. rcu_read_unlock();
  526. if (!tsk)
  527. return;
  528. spin_lock(&pfault_lock);
  529. if (subcode & 0x0080) {
  530. /* signal bit is set -> a page has been swapped in by VM */
  531. if (tsk->thread.pfault_wait == 1) {
  532. /* Initial interrupt was faster than the completion
  533. * interrupt. pfault_wait is valid. Set pfault_wait
  534. * back to zero and wake up the process. This can
  535. * safely be done because the task is still sleeping
  536. * and can't produce new pfaults. */
  537. tsk->thread.pfault_wait = 0;
  538. list_del(&tsk->thread.list);
  539. wake_up_process(tsk);
  540. put_task_struct(tsk);
  541. } else {
  542. /* Completion interrupt was faster than initial
  543. * interrupt. Set pfault_wait to -1 so the initial
  544. * interrupt doesn't put the task to sleep.
  545. * If the task is not running, ignore the completion
  546. * interrupt since it must be a leftover of a PFAULT
  547. * CANCEL operation which didn't remove all pending
  548. * completion interrupts. */
  549. if (tsk->state == TASK_RUNNING)
  550. tsk->thread.pfault_wait = -1;
  551. }
  552. } else {
  553. /* signal bit not set -> a real page is missing. */
  554. if (WARN_ON_ONCE(tsk != current))
  555. goto out;
  556. if (tsk->thread.pfault_wait == 1) {
  557. /* Already on the list with a reference: put to sleep */
  558. __set_task_state(tsk, TASK_UNINTERRUPTIBLE);
  559. set_tsk_need_resched(tsk);
  560. } else if (tsk->thread.pfault_wait == -1) {
  561. /* Completion interrupt was faster than the initial
  562. * interrupt (pfault_wait == -1). Set pfault_wait
  563. * back to zero and exit. */
  564. tsk->thread.pfault_wait = 0;
  565. } else {
  566. /* Initial interrupt arrived before completion
  567. * interrupt. Let the task sleep.
  568. * An extra task reference is needed since a different
  569. * cpu may set the task state to TASK_RUNNING again
  570. * before the scheduler is reached. */
  571. get_task_struct(tsk);
  572. tsk->thread.pfault_wait = 1;
  573. list_add(&tsk->thread.list, &pfault_list);
  574. __set_task_state(tsk, TASK_UNINTERRUPTIBLE);
  575. set_tsk_need_resched(tsk);
  576. }
  577. }
  578. out:
  579. spin_unlock(&pfault_lock);
  580. put_task_struct(tsk);
  581. }
  582. static int __cpuinit pfault_cpu_notify(struct notifier_block *self,
  583. unsigned long action, void *hcpu)
  584. {
  585. struct thread_struct *thread, *next;
  586. struct task_struct *tsk;
  587. switch (action & ~CPU_TASKS_FROZEN) {
  588. case CPU_DEAD:
  589. spin_lock_irq(&pfault_lock);
  590. list_for_each_entry_safe(thread, next, &pfault_list, list) {
  591. thread->pfault_wait = 0;
  592. list_del(&thread->list);
  593. tsk = container_of(thread, struct task_struct, thread);
  594. wake_up_process(tsk);
  595. put_task_struct(tsk);
  596. }
  597. spin_unlock_irq(&pfault_lock);
  598. break;
  599. default:
  600. break;
  601. }
  602. return NOTIFY_OK;
  603. }
  604. static int __init pfault_irq_init(void)
  605. {
  606. int rc;
  607. rc = register_external_interrupt(0x2603, pfault_interrupt);
  608. if (rc)
  609. goto out_extint;
  610. rc = pfault_init() == 0 ? 0 : -EOPNOTSUPP;
  611. if (rc)
  612. goto out_pfault;
  613. service_subclass_irq_register();
  614. hotcpu_notifier(pfault_cpu_notify, 0);
  615. return 0;
  616. out_pfault:
  617. unregister_external_interrupt(0x2603, pfault_interrupt);
  618. out_extint:
  619. pfault_disable = 1;
  620. return rc;
  621. }
  622. early_initcall(pfault_irq_init);
  623. #endif /* CONFIG_PFAULT */