fault.c 17 KB

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