fault.c 17 KB

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