[haiku-development] Re: Implement 32 bit userland support for 64 bit Haiku

  • From: Dario Casalinuovo <b.vitruvio@xxxxxxxxx>
  • To: haiku-development@xxxxxxxxxxxxx
  • Date: Wed, 2 May 2018 10:14:21 +0200

Hi, nice to see the irc discussion with Adrien had some further response.

On Tue, May 1, 2018 at 5:46 PM, Jérôme Duval <jerome.duval@xxxxxxxxx> wrote:

Hi,

I've started to push some patches to help to implement the support of
a 32 bit userland for 64 bit Haiku.

https://review.haiku-os.org/#/c/130/
https://review.haiku-os.org/#/c/133/



Adrien asked for a few details on how this would go. Here they are:
* support for gcc5 x86 binaries is the goal I expect to achieve: for
example run the x86 java binaries.


So are you working on this?

I may be interested to help a bit.


* a x86 runtime_loader is needed because runtime_loader runs in the
target process mode.
* the kernel needs to be able to identify an elf32 binary, and choose
the respective runtime_loader: this would be probably hardcoded.


Doesn't seem hard, the binary already tells the architecture.

So basically the 32 bit runtime_loader is the perfect test app itself to be
run in compat mode?


* x86 userland needs its own commpage: the commpage indexes are arch
specific. the plan is to add a "compat" commpage, used by the 32-bit
support code in the kernel.
* the kernel builds copies of userland code, which be copied in the
commpage, memcpy, syscall trampoline, signal exec. This is especially
difficult to support because the linker doesn't seem to like combining
32-bit code in a 64-bit binary. The idea here is simply producing
precompiled data and linking it in the kernel, not beautiful right.
x86 libroot can be made to not use the commpage, using a userland
memcpy.


One question is if there will be issues with 32 bit pointers. Long mode
seems to support PAE, so Adrien suggested this isn't a problem?


* handling 32-bit syscalls: in each syscall, we check whether the
thread runs in compatibility mode, then create the 64-bit structures
from the 32-bit ones.


Doesn't we need also to wrap fork() and similar functions? It seems under
linux they do it, while I didn't investigate why.

-- 
Saluti,
Dario

Other related posts: