| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: fault.c,v 1.102 2014/10/25 10:58:12 skrll Exp $ */ | | 1 | /* $NetBSD: fault.c,v 1.103 2015/03/02 13:36:36 martin Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright 2003 Wasabi Systems, Inc. | | 4 | * Copyright 2003 Wasabi Systems, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Written by Steve C. Woodford for Wasabi Systems, Inc. | | 7 | * Written by Steve C. Woodford for Wasabi Systems, Inc. |
8 | * | | 8 | * |
9 | * Redistribution and use in source and binary forms, with or without | | 9 | * Redistribution and use in source and binary forms, with or without |
10 | * modification, are permitted provided that the following conditions | | 10 | * modification, are permitted provided that the following conditions |
11 | * are met: | | 11 | * are met: |
12 | * 1. Redistributions of source code must retain the above copyright | | 12 | * 1. Redistributions of source code must retain the above copyright |
13 | * notice, this list of conditions and the following disclaimer. | | 13 | * notice, this list of conditions and the following disclaimer. |
14 | * 2. Redistributions in binary form must reproduce the above copyright | | 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| @@ -71,27 +71,27 @@ | | | @@ -71,27 +71,27 @@ |
71 | * RiscBSD kernel project | | 71 | * RiscBSD kernel project |
72 | * | | 72 | * |
73 | * fault.c | | 73 | * fault.c |
74 | * | | 74 | * |
75 | * Fault handlers | | 75 | * Fault handlers |
76 | * | | 76 | * |
77 | * Created : 28/11/94 | | 77 | * Created : 28/11/94 |
78 | */ | | 78 | */ |
79 | | | 79 | |
80 | #include "opt_ddb.h" | | 80 | #include "opt_ddb.h" |
81 | #include "opt_kgdb.h" | | 81 | #include "opt_kgdb.h" |
82 | | | 82 | |
83 | #include <sys/types.h> | | 83 | #include <sys/types.h> |
84 | __KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.102 2014/10/25 10:58:12 skrll Exp $"); | | 84 | __KERNEL_RCSID(0, "$NetBSD: fault.c,v 1.103 2015/03/02 13:36:36 martin Exp $"); |
85 | | | 85 | |
86 | #include <sys/param.h> | | 86 | #include <sys/param.h> |
87 | #include <sys/systm.h> | | 87 | #include <sys/systm.h> |
88 | #include <sys/proc.h> | | 88 | #include <sys/proc.h> |
89 | #include <sys/kernel.h> | | 89 | #include <sys/kernel.h> |
90 | #include <sys/kauth.h> | | 90 | #include <sys/kauth.h> |
91 | #include <sys/cpu.h> | | 91 | #include <sys/cpu.h> |
92 | #include <sys/intr.h> | | 92 | #include <sys/intr.h> |
93 | | | 93 | |
94 | #include <uvm/uvm_extern.h> | | 94 | #include <uvm/uvm_extern.h> |
95 | #include <uvm/uvm_stat.h> | | 95 | #include <uvm/uvm_stat.h> |
96 | #ifdef UVMHIST | | 96 | #ifdef UVMHIST |
97 | #include <uvm/uvm.h> | | 97 | #include <uvm/uvm.h> |
| @@ -497,35 +497,46 @@ data_abort_handler(trapframe_t *tf) | | | @@ -497,35 +497,46 @@ data_abort_handler(trapframe_t *tf) |
497 | if (pcb->pcb_onfault) { | | 497 | if (pcb->pcb_onfault) { |
498 | tf->tf_r0 = error; | | 498 | tf->tf_r0 = error; |
499 | tf->tf_pc = (register_t)(intptr_t) pcb->pcb_onfault; | | 499 | tf->tf_pc = (register_t)(intptr_t) pcb->pcb_onfault; |
500 | return; | | 500 | return; |
501 | } | | 501 | } |
502 | | | 502 | |
503 | printf("\nuvm_fault(%p, %lx, %x) -> %x\n", map, va, ftype, | | 503 | printf("\nuvm_fault(%p, %lx, %x) -> %x\n", map, va, ftype, |
504 | error); | | 504 | error); |
505 | dab_fatal(tf, fsr, far, l, NULL); | | 505 | dab_fatal(tf, fsr, far, l, NULL); |
506 | } | | 506 | } |
507 | | | 507 | |
508 | KSI_INIT_TRAP(&ksi); | | 508 | KSI_INIT_TRAP(&ksi); |
509 | | | 509 | |
510 | if (error == ENOMEM) { | | 510 | switch (error) { |
| | | 511 | case ENOMEM: |
511 | printf("UVM: pid %d (%s), uid %d killed: " | | 512 | printf("UVM: pid %d (%s), uid %d killed: " |
512 | "out of swap\n", l->l_proc->p_pid, l->l_proc->p_comm, | | 513 | "out of swap\n", l->l_proc->p_pid, l->l_proc->p_comm, |
513 | l->l_cred ? kauth_cred_geteuid(l->l_cred) : -1); | | 514 | l->l_cred ? kauth_cred_geteuid(l->l_cred) : -1); |
514 | ksi.ksi_signo = SIGKILL; | | 515 | ksi.ksi_signo = SIGKILL; |
515 | } else | | 516 | break; |
| | | 517 | case EACCES: |
516 | ksi.ksi_signo = SIGSEGV; | | 518 | ksi.ksi_signo = SIGSEGV; |
517 | | | 519 | ksi.ksi_code = SEGV_ACCERR; |
518 | ksi.ksi_code = (error == EACCES) ? SEGV_ACCERR : SEGV_MAPERR; | | 520 | break; |
| | | 521 | case EINVAL: |
| | | 522 | ksi.ksi_signo = SIGBUS; |
| | | 523 | ksi.ksi_code = BUS_ADRERR; |
| | | 524 | break; |
| | | 525 | default: |
| | | 526 | ksi.ksi_signo = SIGSEGV; |
| | | 527 | ksi.ksi_code = SEGV_MAPERR; |
| | | 528 | break; |
| | | 529 | } |
519 | ksi.ksi_addr = (uint32_t *)(intptr_t) far; | | 530 | ksi.ksi_addr = (uint32_t *)(intptr_t) far; |
520 | ksi.ksi_trap = fsr; | | 531 | ksi.ksi_trap = fsr; |
521 | UVMHIST_LOG(maphist, " <- error (%d)", error, 0, 0, 0); | | 532 | UVMHIST_LOG(maphist, " <- error (%d)", error, 0, 0, 0); |
522 | | | 533 | |
523 | do_trapsignal: | | 534 | do_trapsignal: |
524 | call_trapsignal(l, tf, &ksi); | | 535 | call_trapsignal(l, tf, &ksi); |
525 | out: | | 536 | out: |
526 | /* If returning to user mode, make sure to invoke userret() */ | | 537 | /* If returning to user mode, make sure to invoke userret() */ |
527 | if (user) | | 538 | if (user) |
528 | userret(l); | | 539 | userret(l); |
529 | } | | 540 | } |
530 | | | 541 | |
531 | /* | | 542 | /* |