fault.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676
  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. if (notify_page_fault(regs))
  256. return 0;
  257. tsk = current;
  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 (access == VM_WRITE || (trans_exc_code & store_indication) == 0x400)
  272. flags |= FAULT_FLAG_WRITE;
  273. down_read(&mm->mmap_sem);
  274. #ifdef CONFIG_PGSTE
  275. if ((current->flags & PF_VCPU) && S390_lowcore.gmap) {
  276. address = __gmap_fault(address,
  277. (struct gmap *) S390_lowcore.gmap);
  278. if (address == -EFAULT) {
  279. fault = VM_FAULT_BADMAP;
  280. goto out_up;
  281. }
  282. if (address == -ENOMEM) {
  283. fault = VM_FAULT_OOM;
  284. goto out_up;
  285. }
  286. }
  287. #endif
  288. retry:
  289. fault = VM_FAULT_BADMAP;
  290. vma = find_vma(mm, address);
  291. if (!vma)
  292. goto out_up;
  293. if (unlikely(vma->vm_start > address)) {
  294. if (!(vma->vm_flags & VM_GROWSDOWN))
  295. goto out_up;
  296. if (expand_stack(vma, address))
  297. goto out_up;
  298. }
  299. /*
  300. * Ok, we have a good vm_area for this memory access, so
  301. * we can handle it..
  302. */
  303. fault = VM_FAULT_BADACCESS;
  304. if (unlikely(!(vma->vm_flags & access)))
  305. goto out_up;
  306. if (is_vm_hugetlb_page(vma))
  307. address &= HPAGE_MASK;
  308. /*
  309. * If for any reason at all we couldn't handle the fault,
  310. * make sure we exit gracefully rather than endlessly redo
  311. * the fault.
  312. */
  313. fault = handle_mm_fault(mm, vma, address, flags);
  314. /* No reason to continue if interrupted by SIGKILL. */
  315. if ((fault & VM_FAULT_RETRY) && fatal_signal_pending(current)) {
  316. fault = VM_FAULT_SIGNAL;
  317. goto out;
  318. }
  319. if (unlikely(fault & VM_FAULT_ERROR))
  320. goto out_up;
  321. /*
  322. * Major/minor page fault accounting is only done on the
  323. * initial attempt. If we go through a retry, it is extremely
  324. * likely that the page will be found in page cache at that point.
  325. */
  326. if (flags & FAULT_FLAG_ALLOW_RETRY) {
  327. if (fault & VM_FAULT_MAJOR) {
  328. tsk->maj_flt++;
  329. perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1,
  330. regs, address);
  331. } else {
  332. tsk->min_flt++;
  333. perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1,
  334. regs, address);
  335. }
  336. if (fault & VM_FAULT_RETRY) {
  337. /* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
  338. * of starvation. */
  339. flags &= ~FAULT_FLAG_ALLOW_RETRY;
  340. flags |= FAULT_FLAG_TRIED;
  341. down_read(&mm->mmap_sem);
  342. goto retry;
  343. }
  344. }
  345. /*
  346. * The instruction that caused the program check will
  347. * be repeated. Don't signal single step via SIGTRAP.
  348. */
  349. clear_tsk_thread_flag(tsk, TIF_PER_TRAP);
  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. trans_exc_code = regs->int_parm_long;
  391. if (unlikely(!user_space_fault(trans_exc_code) || in_atomic() || !mm))
  392. goto no_context;
  393. down_read(&mm->mmap_sem);
  394. vma = find_vma(mm, trans_exc_code & __FAIL_ADDR_MASK);
  395. up_read(&mm->mmap_sem);
  396. if (vma) {
  397. update_mm(mm, current);
  398. return;
  399. }
  400. /* User mode accesses just cause a SIGSEGV */
  401. if (user_mode(regs)) {
  402. do_sigsegv(regs, SEGV_MAPERR);
  403. return;
  404. }
  405. no_context:
  406. do_no_context(regs);
  407. }
  408. #endif
  409. int __handle_fault(unsigned long uaddr, unsigned long pgm_int_code, int write)
  410. {
  411. struct pt_regs regs;
  412. int access, fault;
  413. /* Emulate a uaccess fault from kernel mode. */
  414. regs.psw.mask = psw_kernel_bits | PSW_MASK_DAT | PSW_MASK_MCHECK;
  415. if (!irqs_disabled())
  416. regs.psw.mask |= PSW_MASK_IO | PSW_MASK_EXT;
  417. regs.psw.addr = (unsigned long) __builtin_return_address(0);
  418. regs.psw.addr |= PSW_ADDR_AMODE;
  419. regs.int_code = pgm_int_code;
  420. regs.int_parm_long = (uaddr & PAGE_MASK) | 2;
  421. access = write ? VM_WRITE : VM_READ;
  422. fault = do_exception(&regs, access);
  423. /*
  424. * Since the fault happened in kernel mode while performing a uaccess
  425. * all we need to do now is emulating a fixup in case "fault" is not
  426. * zero.
  427. * For the calling uaccess functions this results always in -EFAULT.
  428. */
  429. return fault ? -EFAULT : 0;
  430. }
  431. #ifdef CONFIG_PFAULT
  432. /*
  433. * 'pfault' pseudo page faults routines.
  434. */
  435. static int pfault_disable;
  436. static int __init nopfault(char *str)
  437. {
  438. pfault_disable = 1;
  439. return 1;
  440. }
  441. __setup("nopfault", nopfault);
  442. struct pfault_refbk {
  443. u16 refdiagc;
  444. u16 reffcode;
  445. u16 refdwlen;
  446. u16 refversn;
  447. u64 refgaddr;
  448. u64 refselmk;
  449. u64 refcmpmk;
  450. u64 reserved;
  451. } __attribute__ ((packed, aligned(8)));
  452. int pfault_init(void)
  453. {
  454. struct pfault_refbk refbk = {
  455. .refdiagc = 0x258,
  456. .reffcode = 0,
  457. .refdwlen = 5,
  458. .refversn = 2,
  459. .refgaddr = __LC_CURRENT_PID,
  460. .refselmk = 1ULL << 48,
  461. .refcmpmk = 1ULL << 48,
  462. .reserved = __PF_RES_FIELD };
  463. int rc;
  464. if (pfault_disable)
  465. return -1;
  466. asm volatile(
  467. " diag %1,%0,0x258\n"
  468. "0: j 2f\n"
  469. "1: la %0,8\n"
  470. "2:\n"
  471. EX_TABLE(0b,1b)
  472. : "=d" (rc) : "a" (&refbk), "m" (refbk) : "cc");
  473. return rc;
  474. }
  475. void pfault_fini(void)
  476. {
  477. struct pfault_refbk refbk = {
  478. .refdiagc = 0x258,
  479. .reffcode = 1,
  480. .refdwlen = 5,
  481. .refversn = 2,
  482. };
  483. if (pfault_disable)
  484. return;
  485. asm volatile(
  486. " diag %0,0,0x258\n"
  487. "0:\n"
  488. EX_TABLE(0b,0b)
  489. : : "a" (&refbk), "m" (refbk) : "cc");
  490. }
  491. static DEFINE_SPINLOCK(pfault_lock);
  492. static LIST_HEAD(pfault_list);
  493. static void pfault_interrupt(struct ext_code ext_code,
  494. unsigned int param32, unsigned long param64)
  495. {
  496. struct task_struct *tsk;
  497. __u16 subcode;
  498. pid_t pid;
  499. /*
  500. * Get the external interruption subcode & pfault
  501. * initial/completion signal bit. VM stores this
  502. * in the 'cpu address' field associated with the
  503. * external interrupt.
  504. */
  505. subcode = ext_code.subcode;
  506. if ((subcode & 0xff00) != __SUBCODE_MASK)
  507. return;
  508. kstat_cpu(smp_processor_id()).irqs[EXTINT_PFL]++;
  509. /* Get the token (= pid of the affected task). */
  510. pid = sizeof(void *) == 4 ? param32 : param64;
  511. rcu_read_lock();
  512. tsk = find_task_by_pid_ns(pid, &init_pid_ns);
  513. if (tsk)
  514. get_task_struct(tsk);
  515. rcu_read_unlock();
  516. if (!tsk)
  517. return;
  518. spin_lock(&pfault_lock);
  519. if (subcode & 0x0080) {
  520. /* signal bit is set -> a page has been swapped in by VM */
  521. if (tsk->thread.pfault_wait == 1) {
  522. /* Initial interrupt was faster than the completion
  523. * interrupt. pfault_wait is valid. Set pfault_wait
  524. * back to zero and wake up the process. This can
  525. * safely be done because the task is still sleeping
  526. * and can't produce new pfaults. */
  527. tsk->thread.pfault_wait = 0;
  528. list_del(&tsk->thread.list);
  529. wake_up_process(tsk);
  530. put_task_struct(tsk);
  531. } else {
  532. /* Completion interrupt was faster than initial
  533. * interrupt. Set pfault_wait to -1 so the initial
  534. * interrupt doesn't put the task to sleep.
  535. * If the task is not running, ignore the completion
  536. * interrupt since it must be a leftover of a PFAULT
  537. * CANCEL operation which didn't remove all pending
  538. * completion interrupts. */
  539. if (tsk->state == TASK_RUNNING)
  540. tsk->thread.pfault_wait = -1;
  541. }
  542. } else {
  543. /* signal bit not set -> a real page is missing. */
  544. if (WARN_ON_ONCE(tsk != current))
  545. goto out;
  546. if (tsk->thread.pfault_wait == 1) {
  547. /* Already on the list with a reference: put to sleep */
  548. __set_task_state(tsk, TASK_UNINTERRUPTIBLE);
  549. set_tsk_need_resched(tsk);
  550. } else if (tsk->thread.pfault_wait == -1) {
  551. /* Completion interrupt was faster than the initial
  552. * interrupt (pfault_wait == -1). Set pfault_wait
  553. * back to zero and exit. */
  554. tsk->thread.pfault_wait = 0;
  555. } else {
  556. /* Initial interrupt arrived before completion
  557. * interrupt. Let the task sleep.
  558. * An extra task reference is needed since a different
  559. * cpu may set the task state to TASK_RUNNING again
  560. * before the scheduler is reached. */
  561. get_task_struct(tsk);
  562. tsk->thread.pfault_wait = 1;
  563. list_add(&tsk->thread.list, &pfault_list);
  564. __set_task_state(tsk, TASK_UNINTERRUPTIBLE);
  565. set_tsk_need_resched(tsk);
  566. }
  567. }
  568. out:
  569. spin_unlock(&pfault_lock);
  570. put_task_struct(tsk);
  571. }
  572. static int __cpuinit pfault_cpu_notify(struct notifier_block *self,
  573. unsigned long action, void *hcpu)
  574. {
  575. struct thread_struct *thread, *next;
  576. struct task_struct *tsk;
  577. switch (action & ~CPU_TASKS_FROZEN) {
  578. case CPU_DEAD:
  579. spin_lock_irq(&pfault_lock);
  580. list_for_each_entry_safe(thread, next, &pfault_list, list) {
  581. thread->pfault_wait = 0;
  582. list_del(&thread->list);
  583. tsk = container_of(thread, struct task_struct, thread);
  584. wake_up_process(tsk);
  585. put_task_struct(tsk);
  586. }
  587. spin_unlock_irq(&pfault_lock);
  588. break;
  589. default:
  590. break;
  591. }
  592. return NOTIFY_OK;
  593. }
  594. static int __init pfault_irq_init(void)
  595. {
  596. int rc;
  597. rc = register_external_interrupt(0x2603, pfault_interrupt);
  598. if (rc)
  599. goto out_extint;
  600. rc = pfault_init() == 0 ? 0 : -EOPNOTSUPP;
  601. if (rc)
  602. goto out_pfault;
  603. service_subclass_irq_register();
  604. hotcpu_notifier(pfault_cpu_notify, 0);
  605. return 0;
  606. out_pfault:
  607. unregister_external_interrupt(0x2603, pfault_interrupt);
  608. out_extint:
  609. pfault_disable = 1;
  610. return rc;
  611. }
  612. early_initcall(pfault_irq_init);
  613. #endif /* CONFIG_PFAULT */