Subject: Re: emulation-specific page fault handling
To: Jaromir Dolecek <>
From: Emmanuel Dreyfus <>
List: tech-kern
Date: 09/07/2002 22:58:15
> > In sys/arch/mips/mips/trap.c, we would replace occurences of uvm_fault
> > by (*p->p_emul->e_fault). 
> It might be better to use something along:
>       if (__predict_false(p->p_emul->e_fault != NULL))
>               (*p->p_emul->e_fault)(...)
>       else
>               uvm_fault(...)
> Primarily so that it wouldn't be necessary to set emul struct to anything
> unless you want to use it, i.e. that it wouldn't be necessary to change
> any sys/compat/ code besides compat/irix.

My plan was to set e_fault for all struct emul, but only use it where it
is needed: in sys/arch/mips/mips/trap.c

No code change for non mips ports, but the field would be there just in
case another emulation needs it some day.

> Since it only appears on two places in mips/trap.c, this should
> be feasible.

Only one: the second occurence uses kernel_map.

> I'd probably mark e_fault as either #ifdef __mips__  or with comment saying
> where exactly it is currently used and for what purpose. Basically just
> to avoid any confusion on whether it is or isn't needed for other compat code.

Why introducing MD conditionals in MI code? The current practice is not
crippling struct emul with ifdefs: e_sysctl or e_nosys are defined for
all archs, even if only arch supporting COMPAT_LINUX use it. 

The e_fault field just add 4 bytes to struct emul, that makes your
kernel 80 bytes bigger and it introduce no performance loss. It's not
exactly what I'd call an expensive change. IMHO it's not worth an ifdef.

> Doesn't seem to cause any warning from compiler (not in a tiny
> program I tested this with).

The goal of declaring the prototype for e_fault is to avoid referencing
a wrong function. The check is a bit useless if you start cheating :o)

Emmanuel Dreyfus.  
JavaScript est encapsule dans HTML, qui encapsulait
deja pas mal d'autres conneries comme ca.