225
225
force_sig_info(SIGBUS, &si, tsk);
228
#ifdef CONFIG_S390_EXEC_PROTECT
229
static noinline int signal_return(struct pt_regs *regs, long int_code,
230
unsigned long trans_exc_code)
235
rc = __get_user(instruction, (u16 __user *) regs->psw.addr);
237
if (!rc && instruction == 0x0a77) {
238
clear_tsk_thread_flag(current, TIF_PER_TRAP);
239
if (is_compat_task())
243
} else if (!rc && instruction == 0x0aad) {
244
clear_tsk_thread_flag(current, TIF_PER_TRAP);
245
if (is_compat_task())
246
sys32_rt_sigreturn();
250
do_sigsegv(regs, int_code, SEGV_MAPERR, trans_exc_code);
253
#endif /* CONFIG_S390_EXEC_PROTECT */
255
228
static noinline void do_fault_error(struct pt_regs *regs, long int_code,
256
229
unsigned long trans_exc_code, int fault)
279
245
do_no_context(regs, int_code, trans_exc_code);
281
247
default: /* fault & VM_FAULT_ERROR */
282
if (fault & VM_FAULT_OOM)
283
pagefault_out_of_memory();
284
else if (fault & VM_FAULT_SIGBUS) {
248
if (fault & VM_FAULT_OOM) {
249
if (!(regs->psw.mask & PSW_MASK_PSTATE))
250
do_no_context(regs, int_code, trans_exc_code);
252
pagefault_out_of_memory();
253
} else if (fault & VM_FAULT_SIGBUS) {
285
254
/* Kernel mode? Handle exceptions or die */
286
255
if (!(regs->psw.mask & PSW_MASK_PSTATE))
287
256
do_no_context(regs, int_code, trans_exc_code);
359
333
* make sure we exit gracefully rather than endlessly redo
362
write = (access == VM_WRITE ||
363
(trans_exc_code & store_indication) == 0x400) ?
364
FAULT_FLAG_WRITE : 0;
365
fault = handle_mm_fault(mm, vma, address, write);
336
fault = handle_mm_fault(mm, vma, address, flags);
366
337
if (unlikely(fault & VM_FAULT_ERROR))
369
if (fault & VM_FAULT_MAJOR) {
371
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, 0,
375
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, 0,
341
* Major/minor page fault accounting is only done on the
342
* initial attempt. If we go through a retry, it is extremely
343
* likely that the page will be found in page cache at that point.
345
if (flags & FAULT_FLAG_ALLOW_RETRY) {
346
if (fault & VM_FAULT_MAJOR) {
348
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, 0,
352
perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, 0,
355
if (fault & VM_FAULT_RETRY) {
356
/* Clear FAULT_FLAG_ALLOW_RETRY to avoid any risk
358
flags &= ~FAULT_FLAG_ALLOW_RETRY;
379
363
* The instruction that caused the program check will
414
398
int access, fault;
416
400
access = VM_READ | VM_EXEC | VM_WRITE;
417
#ifdef CONFIG_S390_EXEC_PROTECT
418
if ((regs->psw.mask & PSW_MASK_ASC) == PSW_ASC_SECONDARY &&
419
(trans_exc_code & 3) == 0)
422
401
fault = do_exception(regs, access, trans_exc_code);
423
402
if (unlikely(fault))
424
403
do_fault_error(regs, pgm_int_code & 255, trans_exc_code, fault);
468
447
access = write ? VM_WRITE : VM_READ;
469
448
fault = do_exception(®s, access, uaddr | 2);
470
449
if (unlikely(fault)) {
471
if (fault & VM_FAULT_OOM) {
472
pagefault_out_of_memory();
474
} else if (fault & VM_FAULT_SIGBUS)
450
if (fault & VM_FAULT_OOM)
452
else if (fault & VM_FAULT_SIGBUS)
475
453
do_sigbus(®s, pgm_int_code, uaddr);
477
455
return fault ? -EFAULT : 0;
492
470
__setup("nopfault", nopfault);
503
} __attribute__ ((packed, aligned(8))) pfault_refbk_t;
472
struct pfault_refbk {
481
} __attribute__ ((packed, aligned(8)));
505
483
int pfault_init(void)
507
pfault_refbk_t refbk =
508
{ 0x258, 0, 5, 2, __LC_CURRENT, 1ULL << 48, 1ULL << 48,
485
struct pfault_refbk refbk = {
490
.refgaddr = __LC_CURRENT_PID,
491
.refselmk = 1ULL << 48,
492
.refcmpmk = 1ULL << 48,
493
.reserved = __PF_RES_FIELD };
512
496
if (!MACHINE_IS_VM || pfault_disable)
553
543
if ((subcode & 0xff00) != __SUBCODE_MASK)
555
545
kstat_cpu(smp_processor_id()).irqs[EXTINT_PFL]++;
558
* Get the token (= address of the task structure of the affected task).
561
tsk = (struct task_struct *) param64;
563
tsk = (struct task_struct *) param32;
546
if (subcode & 0x0080) {
547
/* Get the token (= pid of the affected task). */
548
pid = sizeof(void *) == 4 ? param32 : param64;
550
tsk = find_task_by_pid_ns(pid, &init_pid_ns);
552
get_task_struct(tsk);
559
spin_lock(&pfault_lock);
566
560
if (subcode & 0x0080) {
567
561
/* signal bit is set -> a page has been swapped in by VM */
568
if (xchg(&tsk->thread.pfault_wait, -1) != 0) {
562
if (tsk->thread.pfault_wait == 1) {
569
563
/* Initial interrupt was faster than the completion
570
564
* interrupt. pfault_wait is valid. Set pfault_wait
571
565
* back to zero and wake up the process. This can
572
566
* safely be done because the task is still sleeping
573
567
* and can't produce new pfaults. */
574
568
tsk->thread.pfault_wait = 0;
569
list_del(&tsk->thread.list);
575
570
wake_up_process(tsk);
576
put_task_struct(tsk);
572
/* Completion interrupt was faster than initial
573
* interrupt. Set pfault_wait to -1 so the initial
574
* interrupt doesn't put the task to sleep. */
575
tsk->thread.pfault_wait = -1;
577
put_task_struct(tsk);
579
579
/* signal bit not set -> a real page is missing. */
580
get_task_struct(tsk);
581
set_task_state(tsk, TASK_UNINTERRUPTIBLE);
582
if (xchg(&tsk->thread.pfault_wait, 1) != 0) {
580
if (tsk->thread.pfault_wait == -1) {
583
581
/* Completion interrupt was faster than the initial
584
* interrupt (swapped in a -1 for pfault_wait). Set
585
* pfault_wait back to zero and exit. This can be
586
* done safely because tsk is running in kernel
587
* mode and can't produce new pfaults. */
582
* interrupt (pfault_wait == -1). Set pfault_wait
583
* back to zero and exit. */
588
584
tsk->thread.pfault_wait = 0;
589
set_task_state(tsk, TASK_RUNNING);
590
put_task_struct(tsk);
586
/* Initial interrupt arrived before completion
587
* interrupt. Let the task sleep. */
588
tsk->thread.pfault_wait = 1;
589
list_add(&tsk->thread.list, &pfault_list);
590
set_task_state(tsk, TASK_UNINTERRUPTIBLE);
592
591
set_tsk_need_resched(tsk);
594
spin_unlock(&pfault_lock);
597
static int __cpuinit pfault_cpu_notify(struct notifier_block *self,
598
unsigned long action, void *hcpu)
600
struct thread_struct *thread, *next;
601
struct task_struct *tsk;
605
case CPU_DEAD_FROZEN:
606
spin_lock_irq(&pfault_lock);
607
list_for_each_entry_safe(thread, next, &pfault_list, list) {
608
thread->pfault_wait = 0;
609
list_del(&thread->list);
610
tsk = container_of(thread, struct task_struct, thread);
611
wake_up_process(tsk);
613
spin_unlock_irq(&pfault_lock);
596
621
static int __init pfault_irq_init(void)
600
625
if (!MACHINE_IS_VM)
603
* Try to get pfault pseudo page faults going.
605
627
rc = register_external_interrupt(0x2603, pfault_interrupt);
610
if (pfault_init() == 0)
630
rc = pfault_init() == 0 ? 0 : -EOPNOTSUPP;
633
service_subclass_irq_register();
634
hotcpu_notifier(pfault_cpu_notify, 0);
613
/* Tough luck, no pfault. */
615
638
unregister_external_interrupt(0x2603, pfault_interrupt);
618
643
early_initcall(pfault_irq_init);
645
#endif /* CONFIG_PFAULT */