Port-powerpc archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Someone needs to fix pagefault handling



Hi folks,

Christos recently fixed a standards compliance issue, pagefault() can now
return EINVAL which means we should send SIGBUS to userland.

There is a test case for this that can be run like:

  cd /usr/tests/lib/libc/sys
  atf-run t_mmap | atf-report

This will (on ppc) show one failed test due to the test being killed with
SIGSEGV instead of SIGBUS.

The fix is trivial, you just need to replace the ksi setup code before
delivering the signal to userland with a switch like this:

		switch (rv) {
		case ENOMEM:
			printf("UVM: pid %d (%s), uid %d killed: out of swap\n",
			       p->p_pid, p->p_comm,
			       l->l_cred ?
			       kauth_cred_geteuid(l->l_cred) : -1);
			ksi.ksi_signo = SIGKILL;
			break;
		case EINVAL:
			ksi.ksi_signo = SIGBUS;
			ksi.ksi_code = BUS_ADRERR;
			break;
		case EACCES:
			ksi.ksi_signo = SIGSEGV;
			ksi.ksi_code = SEGV_ACCERR;
			break;
		default:
			ksi.ksi_signo = SIGSEGV;
			ksi.ksi_code = SEGV_MAPERR;
			break;
		}


and that's it. This all goes into the following files:

src/sys/arch/powerpc/booke/trap.c
src/sys/arch/powerpc/ibm4xx/trap.c
src/sys/arch/powerpc/powerpc/trap.c

Unfortunately the ppc code is arranged slightly different than other
architectures, and additionally I don't know which exception/machine check
this case affects, I need a volunteer to try, fix, and commit this.

Thanks,

Martin


Home | Main Index | Thread Index | Old Index