Subject: Re: Loading DSP code from an LKM
To: B. James Phillippe <bryanxms@ecst.csuchico.edu>
From: gabriel rosenkoetter <gr@eclipsed.net>
List: tech-kern
Date: 09/28/2001 03:37:42
--19HmC3QOnaNVzKTI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Fri, Sep 28, 2001 at 12:18:12AM -0700, B. James Phillippe wrote:
> Hmm.  I guess I still don't get it, probably because I haven't read the
> NetBSD kernel yet.  In a nutshell, how are NetBSD LKM's different from
> Linux kernel modules in this respect?  I have done a fair bit of module
> development in that environment and never encountered a problem like this.
>=20
> Thanks for being patient. :-)

Well, for starters, this isn't a problem in the IA32 instruction
set, so that's probably why you haven't seen it on Linux. (To the
best of my knowledge, none of the PPC ports of Linux have functional
LKMs either.)

The issue is that, on PowerPC, you can't make a call outside of a
certain address range in the short (and efficient; it's a single
RISC instruction) way because of a limitation on the address space.
Rather, you have to set some registers in order to jump back between
the kernel and wherever your code is loaded (this takes three or
four instructions depending on who's talking... I don't speak
PowerPC assembly particularly well). gcc, in its present state,
doesn't know how to build code to do this on PowerPC. (Well... it
*sort of* can, but I was unable to produce a useable LKM, and I
spent a good couple days just trying to get it to hello world.)

LKMs, loaded significantly later than the kernel, are at a wildly
different address space, orders of magnitude beyond the range of a
short jump.

I'll point out again that this isn't inherently a problem with
NetBSD's LKM infrastructure, but rather with how gcc compiles LKM
code. (Which, really, is precisely how it was asked to do so... it's
just that it doesn't let us ask it to do what we really need it to
do.)

--=20
       ~ g r @ eclipsed.net

--19HmC3QOnaNVzKTI
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (NetBSD)
Comment: For info see http://www.gnupg.org

iD8DBQE7tCjG9ehacAz5CRoRAtnmAJ9gFVA5oSSLXxbgo/S8NjSANwDYPACgjwiT
O9kfet2s3tyGvSAFhIS9stA=
=fWpN
-----END PGP SIGNATURE-----

--19HmC3QOnaNVzKTI--