Subject: Re: kernfs
To: None <port-macppc@netbsd.org>
From: der Mouse <mouse@Rodents.Montreal.QC.CA>
List: port-macppc
Date: 12/25/2001 01:40:11
> Speaking of modules, if they don't work on macppc, how far off are
> they?  Really broken ... or just a little broken?

Here's what I recall from the last serious discussion I saw on the
subject.  (I've been sort of waiting for someone who knows better to
speak up, but nobody has, yet.)

The problem is that LKMs get loaded in kernel dynamic virtual space,
which is mapped with segment register e and hence is in virtual
addresses 0xe0000000-0xefffffff.  However, the statically linked kernel
lives in low virtual space (from 0 upwards).  "Normal" routine calls
use an instruction sequence that cannot span the distance between those
two; I forget the limit, but it's way less than needed to call between
low VM and SR e space.  Thus, you could do an LKM, but it wouldn't be
able to do normal calls into routines in the statically linked kernel.

It is possible to do what we might term a long call, but it uses (IIRC)
three instructions instead of one and one register instead of none; it
amounts to constructing a pointer and then calling through the pointer.
It would _work_ to compile the LKM using long calls everywhere, but
intra-LKM calls would then be unnecessarily expensive.  (I also have a
fuzzy memory that says the compiler doesn't know how to do this at
all.)  What I think would be ideal would be a linker switch that causes
it to notice when a call is out of range and create a small stub to
which the short call is redirected, the stub doing a long jump.  This
was mentioned on-list at the time - but AFIAK nobody has implemented
it, and I don't know whether it's because it's infeasible for some
reason or it just hasn't been done.

/~\ The ASCII				der Mouse
\ / Ribbon Campaign
 X  Against HTML	       mouse@rodents.montreal.qc.ca
/ \ Email!	     7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B