| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: trap.c,v 1.131 2014/05/16 06:11:21 martin Exp $ */ | | 1 | /* $NetBSD: trap.c,v 1.132 2015/03/02 11:07:16 martin Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2000, 2001 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, | | 8 | * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, |
9 | * NASA Ames Research Center, by Charles M. Hannum, and by Ross Harvey. | | 9 | * NASA Ames Research Center, by Charles M. Hannum, and by Ross Harvey. |
10 | * | | 10 | * |
11 | * Redistribution and use in source and binary forms, with or without | | 11 | * Redistribution and use in source and binary forms, with or without |
12 | * modification, are permitted provided that the following conditions | | 12 | * modification, are permitted provided that the following conditions |
13 | * are met: | | 13 | * are met: |
14 | * 1. Redistributions of source code must retain the above copyright | | 14 | * 1. Redistributions of source code must retain the above copyright |
| @@ -83,27 +83,27 @@ | | | @@ -83,27 +83,27 @@ |
83 | * Carnegie Mellon University | | 83 | * Carnegie Mellon University |
84 | * Pittsburgh PA 15213-3890 | | 84 | * Pittsburgh PA 15213-3890 |
85 | * | | 85 | * |
86 | * any improvements or extensions that they make and grant Carnegie the | | 86 | * any improvements or extensions that they make and grant Carnegie the |
87 | * rights to redistribute these changes. | | 87 | * rights to redistribute these changes. |
88 | */ | | 88 | */ |
89 | | | 89 | |
90 | #include "opt_fix_unaligned_vax_fp.h" | | 90 | #include "opt_fix_unaligned_vax_fp.h" |
91 | #include "opt_ddb.h" | | 91 | #include "opt_ddb.h" |
92 | #include "opt_multiprocessor.h" | | 92 | #include "opt_multiprocessor.h" |
93 | | | 93 | |
94 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ | | 94 | #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ |
95 | | | 95 | |
96 | __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.131 2014/05/16 06:11:21 martin Exp $"); | | 96 | __KERNEL_RCSID(0, "$NetBSD: trap.c,v 1.132 2015/03/02 11:07:16 martin Exp $"); |
97 | | | 97 | |
98 | #include <sys/param.h> | | 98 | #include <sys/param.h> |
99 | #include <sys/systm.h> | | 99 | #include <sys/systm.h> |
100 | #include <sys/proc.h> | | 100 | #include <sys/proc.h> |
101 | #include <sys/syscall.h> | | 101 | #include <sys/syscall.h> |
102 | #include <sys/buf.h> | | 102 | #include <sys/buf.h> |
103 | #include <sys/kauth.h> | | 103 | #include <sys/kauth.h> |
104 | #include <sys/kmem.h> | | 104 | #include <sys/kmem.h> |
105 | #include <sys/cpu.h> | | 105 | #include <sys/cpu.h> |
106 | #include <sys/atomic.h> | | 106 | #include <sys/atomic.h> |
107 | | | 107 | |
108 | #include <uvm/uvm_extern.h> | | 108 | #include <uvm/uvm_extern.h> |
109 | | | 109 | |
| @@ -486,39 +486,48 @@ do_fault: | | | @@ -486,39 +486,48 @@ do_fault: |
486 | | | 486 | |
487 | if (user == 0) { | | 487 | if (user == 0) { |
488 | /* Check for copyin/copyout fault */ | | 488 | /* Check for copyin/copyout fault */ |
489 | if (onfault != 0) { | | 489 | if (onfault != 0) { |
490 | framep->tf_regs[FRAME_PC] = onfault; | | 490 | framep->tf_regs[FRAME_PC] = onfault; |
491 | framep->tf_regs[FRAME_V0] = rv; | | 491 | framep->tf_regs[FRAME_V0] = rv; |
492 | goto out; | | 492 | goto out; |
493 | } | | 493 | } |
494 | goto dopanic; | | 494 | goto dopanic; |
495 | } | | 495 | } |
496 | KSI_INIT_TRAP(&ksi); | | 496 | KSI_INIT_TRAP(&ksi); |
497 | ksi.ksi_addr = (void *)a0; | | 497 | ksi.ksi_addr = (void *)a0; |
498 | ksi.ksi_trap = a1; /* MMCSR VALUE */ | | 498 | ksi.ksi_trap = a1; /* MMCSR VALUE */ |
499 | if (rv == ENOMEM) { | | 499 | switch (rv) { |
| | | 500 | case ENOMEM: |
500 | printf("UVM: pid %d (%s), uid %d killed: " | | 501 | printf("UVM: pid %d (%s), uid %d killed: " |
501 | "out of swap\n", l->l_proc->p_pid, | | 502 | "out of swap\n", l->l_proc->p_pid, |
502 | l->l_proc->p_comm, | | 503 | l->l_proc->p_comm, |
503 | l->l_cred ? | | 504 | l->l_cred ? |
504 | kauth_cred_geteuid(l->l_cred) : -1); | | 505 | kauth_cred_geteuid(l->l_cred) : -1); |
505 | ksi.ksi_signo = SIGKILL; | | 506 | ksi.ksi_signo = SIGKILL; |
506 | } else | | 507 | break; |
| | | 508 | case EINVAL: |
| | | 509 | ksi.ksi_signo = SIGBUS; |
| | | 510 | ksi.ksi_code = BUS_ADRERR; |
| | | 511 | break; |
| | | 512 | case EACCES: |
507 | ksi.ksi_signo = SIGSEGV; | | 513 | ksi.ksi_signo = SIGSEGV; |
508 | if (rv == EACCES) | | | |
509 | ksi.ksi_code = SEGV_ACCERR; | | 514 | ksi.ksi_code = SEGV_ACCERR; |
510 | else | | 515 | break; |
| | | 516 | default: |
| | | 517 | ksi.ksi_signo = SIGSEGV; |
511 | ksi.ksi_code = SEGV_MAPERR; | | 518 | ksi.ksi_code = SEGV_MAPERR; |
| | | 519 | break; |
| | | 520 | } |
512 | break; | | 521 | break; |
513 | } | | 522 | } |
514 | | | 523 | |
515 | default: | | 524 | default: |
516 | printf("trap: unknown MMCSR value 0x%lx\n", a1); | | 525 | printf("trap: unknown MMCSR value 0x%lx\n", a1); |
517 | goto dopanic; | | 526 | goto dopanic; |
518 | } | | 527 | } |
519 | break; | | 528 | break; |
520 | | | 529 | |
521 | default: | | 530 | default: |
522 | goto dopanic; | | 531 | goto dopanic; |
523 | } | | 532 | } |
524 | | | 533 | |