> Date: Thu, 20 Jul 2017 18:18:58 +0200 > From: Alexander Bluhm <alexander.bl...@gmx.net> > > On Thu, Jul 20, 2017 at 02:03:10PM +0200, Mark Kettenis wrote: > > If you can make the BUS_ADRERR -> BUS_OBJERR change (both here and in > > the regress test), this is ok kettenis@ > > This passes on amd64 and i386. > > ok?
ok kettenis@ The man page will need some further tweaking once other architectures catch up. > Index: sys/arch/amd64/amd64/trap.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/arch/amd64/amd64/trap.c,v > retrieving revision 1.55 > diff -u -p -r1.55 trap.c > --- sys/arch/amd64/amd64/trap.c 14 Jul 2017 12:20:32 -0000 1.55 > +++ sys/arch/amd64/amd64/trap.c 20 Jul 2017 15:59:37 -0000 > @@ -306,6 +306,7 @@ copyfault: > struct vm_map *map; > vm_prot_t ftype; > extern struct vm_map *kernel_map; > + int signal, sicode; > > cr2 = rcr2(); > KERNEL_LOCK(); > @@ -372,12 +373,14 @@ faultcommon: > map, fa, ftype, error); > goto we_re_toast; > } > + > + signal = SIGSEGV; > + sicode = SEGV_MAPERR; > if (error == ENOMEM) { > printf("UVM: pid %d (%s), uid %d killed:" > " out of swap\n", p->p_p->ps_pid, p->p_p->ps_comm, > p->p_ucred ? (int)p->p_ucred->cr_uid : -1); > - sv.sival_ptr = (void *)fa; > - trapsignal(p, SIGKILL, T_PAGEFLT, SEGV_MAPERR, sv); > + signal = SIGKILL; > } else { > #ifdef TRAP_SIGDEBUG > printf("pid %d (%s): %s at rip %llx addr %llx\n", > @@ -385,10 +388,15 @@ faultcommon: > frame->tf_rip, rcr2()); > frame_dump(frame); > #endif > - sv.sival_ptr = (void *)fa; > - trapsignal(p, SIGSEGV, T_PAGEFLT, > - error == EACCES ? SEGV_ACCERR : SEGV_MAPERR, sv); > } > + if (error == EACCES) > + sicode = SEGV_ACCERR; > + if (error == EIO) { > + signal = SIGBUS; > + sicode = BUS_OBJERR; > + } > + sv.sival_ptr = (void *)fa; > + trapsignal(p, signal, T_PAGEFLT, sicode, sv); > KERNEL_UNLOCK(); > break; > } > Index: sys/arch/i386/i386/trap.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/arch/i386/i386/trap.c,v > retrieving revision 1.131 > diff -u -p -r1.131 trap.c > --- sys/arch/i386/i386/trap.c 14 Jul 2017 12:20:32 -0000 1.131 > +++ sys/arch/i386/i386/trap.c 20 Jul 2017 16:00:16 -0000 > @@ -374,6 +374,7 @@ trap(struct trapframe *frame) > struct vmspace *vm; > struct vm_map *map; > int error; > + int signal, sicode; > > cr2 = rcr2(); > KERNEL_LOCK(); > @@ -431,9 +432,17 @@ trap(struct trapframe *frame) > map, va, ftype, error); > goto we_re_toast; > } > + > + signal = SIGSEGV; > + sicode = SEGV_MAPERR; > + if (error == EACCES) > + sicode = SEGV_ACCERR; > + if (error == EIO) { > + signal = SIGBUS; > + sicode = BUS_OBJERR; > + } > sv.sival_int = fa; > - trapsignal(p, SIGSEGV, vftype, > - error == EACCES ? SEGV_ACCERR : SEGV_MAPERR, sv); > + trapsignal(p, signal, vftype, sicode, sv); > KERNEL_UNLOCK(); > break; > } > Index: sys/uvm/uvm_fault.c > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/sys/uvm/uvm_fault.c,v > retrieving revision 1.91 > diff -u -p -r1.91 uvm_fault.c > --- sys/uvm/uvm_fault.c 16 Sep 2016 01:09:53 -0000 1.91 > +++ sys/uvm/uvm_fault.c 20 Jul 2017 15:56:46 -0000 > @@ -1032,7 +1032,7 @@ Case2: > } > > if (!UVM_ET_ISNOFAULT(ufi.entry)) > - return (EACCES); /* XXX i/o error */ > + return (EIO); > > uobjpage = PGO_DONTCARE; > promote = TRUE; > Index: regress/sys/kern/siginfo-fault/siginfo-fault.c > =================================================================== > RCS file: > /data/mirror/openbsd/cvs/src/regress/sys/kern/siginfo-fault/siginfo-fault.c,v > retrieving revision 1.4 > diff -u -p -r1.4 siginfo-fault.c > --- regress/sys/kern/siginfo-fault/siginfo-fault.c 13 Jul 2017 00:29:14 > -0000 1.4 > +++ regress/sys/kern/siginfo-fault/siginfo-fault.c 20 Jul 2017 16:02:42 > -0000 > @@ -156,7 +156,7 @@ main() > p[3] = 1; > FAIL(); > } > - fail += checksig("mmap file", SIGBUS, BUS_ADRERR, p + 3); > + fail += checksig("mmap file", SIGBUS, BUS_OBJERR, p + 3); > > return (fail); > } > Index: lib/libc/sys/mmap.2 > =================================================================== > RCS file: /data/mirror/openbsd/cvs/src/lib/libc/sys/mmap.2,v > retrieving revision 1.55 > diff -u -p -r1.55 mmap.2 > --- lib/libc/sys/mmap.2 5 Apr 2017 18:15:43 -0000 1.55 > +++ lib/libc/sys/mmap.2 20 Jul 2017 16:15:35 -0000 > @@ -313,7 +313,7 @@ system call first appeared in > specifies that references to pages beyond the end of a mapped object > shall generate a > .Dv SIGBUS > -signal; however, > +signal; however, on some architectures > .Ox > generates a > .Dv SIGSEGV > >