| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: trap.c,v 1.146 2012/02/19 21:06:15 rmind Exp $ */ | | 1 | /* $NetBSD: trap.c,v 1.147 2015/03/03 20:36:31 martin Exp $ */ |
2 | | | 2 | |
3 | /* | | 3 | /* |
4 | * Copyright (c) 1988 University of Utah. | | 4 | * Copyright (c) 1988 University of Utah. |
5 | * Copyright (c) 1982, 1986, 1990, 1993 | | 5 | * Copyright (c) 1982, 1986, 1990, 1993 |
6 | * The Regents of the University of California. All rights reserved. | | 6 | * The Regents of the University of California. All rights reserved. |
7 | * | | 7 | * |
8 | * This code is derived from software contributed to Berkeley by | | 8 | * This code is derived from software contributed to Berkeley by |
9 | * the Systems Programming Group of the University of Utah Computer | | 9 | * the Systems Programming Group of the University of Utah Computer |
10 | * Science Department. | | 10 | * Science Department. |
11 | * | | 11 | * |
12 | * Redistribution and use in source and binary forms, with or without | | 12 | * Redistribution and use in source and binary forms, with or without |
13 | * modification, are permitted provided that the following conditions | | 13 | * modification, are permitted provided that the following conditions |
14 | * are met: | | 14 | * are met: |
| @@ -29,27 +29,27 @@ | | | @@ -29,27 +29,27 @@ |
29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 30 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 32 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 33 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
34 | * SUCH DAMAGE. | | 34 | * SUCH DAMAGE. |
35 | * | | 35 | * |
36 | * from: Utah $Hdr: trap.c 1.37 92/12/20$ | | 36 | * from: Utah $Hdr: trap.c 1.37 92/12/20$ |
37 | * | | 37 | * |
38 | * @(#)trap.c 8.5 (Berkeley) 1/4/94 | | 38 | * @(#)trap.c 8.5 (Berkeley) 1/4/94 |
39 | */ | | 39 | */ |
40 | | | 40 | |
41 | #include <sys/cdefs.h> | | 41 | #include <sys/cdefs.h> |
42 | __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.146 2012/02/19 21:06:15 rmind Exp $"); | | 42 | __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.147 2015/03/03 20:36:31 martin Exp $"); |
43 | | | 43 | |
44 | #include "opt_ddb.h" | | 44 | #include "opt_ddb.h" |
45 | #include "opt_execfmt.h" | | 45 | #include "opt_execfmt.h" |
46 | #include "opt_fpu_emulate.h" | | 46 | #include "opt_fpu_emulate.h" |
47 | #include "opt_kgdb.h" | | 47 | #include "opt_kgdb.h" |
48 | #include "opt_compat_sunos.h" | | 48 | #include "opt_compat_sunos.h" |
49 | #include "opt_m68k_arch.h" | | 49 | #include "opt_m68k_arch.h" |
50 | | | 50 | |
51 | #include <sys/param.h> | | 51 | #include <sys/param.h> |
52 | #include <sys/systm.h> | | 52 | #include <sys/systm.h> |
53 | #include <sys/proc.h> | | 53 | #include <sys/proc.h> |
54 | #include <sys/acct.h> | | 54 | #include <sys/acct.h> |
55 | #include <sys/kernel.h> | | 55 | #include <sys/kernel.h> |
| @@ -575,49 +575,56 @@ copyfault: | | | @@ -575,49 +575,56 @@ copyfault: |
575 | | | 575 | |
576 | if (type == T_MMUFLT) { | | 576 | if (type == T_MMUFLT) { |
577 | if (ucas_ras_check(&fp->F_t)) { | | 577 | if (ucas_ras_check(&fp->F_t)) { |
578 | return; | | 578 | return; |
579 | } | | 579 | } |
580 | #if defined(M68040) | | 580 | #if defined(M68040) |
581 | if (mmutype == MMU_68040) | | 581 | if (mmutype == MMU_68040) |
582 | (void)writeback(fp, 1); | | 582 | (void)writeback(fp, 1); |
583 | #endif | | 583 | #endif |
584 | return; | | 584 | return; |
585 | } | | 585 | } |
586 | goto out; | | 586 | goto out; |
587 | } | | 587 | } |
588 | if (rv == EACCES) { | | | |
589 | ksi.ksi_code = SEGV_ACCERR; | | | |
590 | rv = EFAULT; | | | |
591 | } else | | | |
592 | ksi.ksi_code = SEGV_MAPERR; | | | |
593 | if (type == T_MMUFLT) { | | 588 | if (type == T_MMUFLT) { |
594 | if (onfault) | | 589 | if (onfault) |
595 | goto copyfault; | | 590 | goto copyfault; |
596 | printf("uvm_fault(%p, 0x%lx, 0x%x) -> 0x%x\n", | | 591 | printf("uvm_fault(%p, 0x%lx, 0x%x) -> 0x%x\n", |
597 | map, va, ftype, rv); | | 592 | map, va, ftype, rv); |
598 | printf(" type %x, code [mmu,,ssw]: %x\n", | | 593 | printf(" type %x, code [mmu,,ssw]: %x\n", |
599 | type, code); | | 594 | type, code); |
600 | goto dopanic; | | 595 | goto dopanic; |
601 | } | | 596 | } |
602 | ksi.ksi_addr = (void *)v; | | 597 | ksi.ksi_addr = (void *)v; |
603 | if (rv == ENOMEM) { | | 598 | switch (rv) { |
| | | 599 | case ENOMEM: |
604 | printf("UVM: pid %d (%s), uid %d killed: out of swap\n", | | 600 | printf("UVM: pid %d (%s), uid %d killed: out of swap\n", |
605 | p->p_pid, p->p_comm, | | 601 | p->p_pid, p->p_comm, |
606 | l->l_cred ? | | 602 | l->l_cred ? |
607 | kauth_cred_geteuid(l->l_cred) : -1); | | 603 | kauth_cred_geteuid(l->l_cred) : -1); |
608 | ksi.ksi_signo = SIGKILL; | | 604 | ksi.ksi_signo = SIGKILL; |
609 | } else { | | 605 | break; |
| | | 606 | case EINVAL: |
| | | 607 | ksi.ksi_signo = SIGBUS; |
| | | 608 | ksi.ksi_code = BUS_ADRERR; |
| | | 609 | break; |
| | | 610 | case EACCES: |
610 | ksi.ksi_signo = SIGSEGV; | | 611 | ksi.ksi_signo = SIGSEGV; |
| | | 612 | ksi.ksi_code = SEGV_ACCERR; |
| | | 613 | break; |
| | | 614 | default: |
| | | 615 | ksi.ksi_signo = SIGSEGV; |
| | | 616 | ksi.ksi_code = SEGV_MAPERR; |
| | | 617 | break; |
611 | } | | 618 | } |
612 | break; | | 619 | break; |
613 | } | | 620 | } |
614 | } | | 621 | } |
615 | if (ksi.ksi_signo) | | 622 | if (ksi.ksi_signo) |
616 | trapsignal(l, &ksi); | | 623 | trapsignal(l, &ksi); |
617 | if ((type & T_USER) == 0) | | 624 | if ((type & T_USER) == 0) |
618 | return; | | 625 | return; |
619 | out: | | 626 | out: |
620 | userret(l, fp, sticks, v, 1); | | 627 | userret(l, fp, sticks, v, 1); |
621 | } | | 628 | } |
622 | | | 629 | |
623 | #if defined(M68040) | | 630 | #if defined(M68040) |