[Haifux] Injecting a 32-bit module into a 64-bit kernel?!
Shachar Shemesh
shachar at shemesh.biz
Sun Feb 14 16:59:32 MSK 2010
Eli Billauer wrote:
>
> So I wondered if I could compile it all as 32 bit, and then somehow get
> the 64-bit kernel to accept this alien module?
>
>
Gut feeling - no, you can't. Not with unreasonable effort, which is
about tantamount to running 32 and 64 bit kernels simultaneously.
Instead of thinking of the linker as the problem, why not look at the
desired end result. Even if we, somehow, get the module to load, what
will it have? The kernel is running in virtual addresses that are
located at the very end of the virtual address space. I'm not sure
whether this means 42, 48 or 64 bits, but is definitely more than than
where a 32 bit kernel would be located. This also means that the 32 bit
module has no means of even containing the pointers to the functions it
needs inside its registers/GOT.
In order to solve this, you would need to map some parts of the kernel
to its usual address (0xc0000000). Since the kernel's address space is
mapped across all user space contexts, this would punch a hole in the
middle of the address space for all 64 bit applications, as well as
restore the wasted 1GB virtual area that running on 64bit kernel saves
you when running 32bit user space.
Even if you, somehow, manage to solve this problem, you are very far
from being able to actually run the module. The X86 architecture assigns
32/64 bit meaning to specific segments. In other words, the SEGMENT
REGISTER of a 32bit module needs to be different than a 64bit module.
This implies a type of context switching between the main kernel and the
32bit module which I'm not sure whether the kernel is built to perform.
In conclusion - if you want to go that route, you are far better off
implementing the kernel interfaces in user space, and running the 32bit
module there.
Shachar
--
Shachar Shemesh
Lingnu Open Source Consulting Ltd.
http://www.lingnu.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://haifux.org/pipermail/haifux/attachments/20100214/4a6fad34/attachment.html
More information about the Haifux
mailing list