Subject: error codes in UVM/UBC
To: None <tech-kern@netbsd.org>
From: Chuck Silvers <chuq@chuq.com>
List: tech-kern
Date: 12/31/2000 16:05:42
hi folks,

currently UVM has two sets of error codes separate from the traditional
unix E* error codes, the KERN_* set and the VM_PAGER_* set.  this causes
some trouble with UBC since now the read() path will often look like

	...
	vn_read()
	VOP_READ()
	uiomove()
	copyout()
	...
	trap()
	uvm_fault()
	ubc_fault()
	VOP_GETPAGES()
	... buffer cache or device interfaces.

since we have to translate back and forth between the various sets of
error codes in this path, we can't return the error codes from the device
driver back to the application.  currently, any i/o error in read() or
write() will turn into EFAULT, which isn't what we want.

to fix this, I'd like to eliminate the KERN_* and VM_PAGER_* error codes
and use the E* error codes instead.  this will allow us to pass error codes
from the device driver all the way back up through UVM and the page-fault
handler so that uiomove() can return the original error value, and from there
it's clear sailing back out to the application.  in addition to replacing
all the uses of the old error codes, this will also require enhancing
the pcb_onfault code for each platform to store the return value from
uvm_fault() somewhere that the caller can get at it.  for platforms that
do the client side of pcb_onfault in assembly, this could be done by
putting it in a specific register that the fault-recovery path could
then return to the caller.  platforms that do pcb_onfault setup in C
(or do something other than pcb_onfault entirely) would have to do
something different, but it should be pretty easy to come up with
something that works.

if everyone is happy with this, I'll convert all the MI code and do
the MD part for a couple platforms, but I'll leave most of the
assembly code for people more familiar with those platforms.
unconverted platforms will continue to return EFAULT instead of
the real error values until they are fixed.

-Chuck