GSoC Introduction: x86_64 port

Blog post by xyzzy on Sun, 2012-04-29 14:52

My name is Alex, I am a first year computer science student with a strong interest in operating systems and low-level software. My GSoC project this year is to begin a port of Haiku to the x86_64 architecture. Almost all modern x86 CPUs have 64-bit support, therefore a port of Haiku will allow it to take full advantage of these CPUs. The GSoC coding period is almost certainly too little time to finish a port of the whole OS, however my plan is to have ported at least the boot loader, kernel and some modules/drivers.

Universities in the UK finish later than most US universities, I do not finish my exams until a couple of weeks into the GSoC coding period. Therefore, there is a limited amount of work I will be able to do during the community bonding period. However, while researching my project proposal I’ve got myself familiar with the Haiku codebase and also submitted patches to fix the GCC4 x86_64 toolchain, which have been committed. I will use time that I do have to continue to familiarise myself with the Haiku code and start thinking about some of the implementation details of my project.

During the coding period, I will first work on the boot loader. I intend to modify the existing x86 boot loader so that it is capable of loading both a 32-bit Haiku kernel and a 64-bit one. Once this is done, I will work on implementing the x86_64 architecture functionality in the kernel. Finally, I will port modules and drivers to the 64-bit kernel.

Should I have time, I will also begin work on porting userland. As I said, there may not be enough time to get that far, but even if I don’t, there’s some future work for me to do after GSoC.


Re: GSoC Introduction: x86_64 port

Hey man, I wish you all the best for this — definitely a vital part in helping Haiku prepare for the future whilst progressing towards R1. Hope you nail it!

Re: GSoC Introduction: x86_64 port

Hey Alex, this sound great.

How do you plan to handle linking / loading binaries?

Haiku uses ELF binaries right? Do you plan to support fat binaries?

Perhaps you might consider first working on the loader / linker before the kernel, OSX supported 64 bit binaries long before the kernel went 64 bit, this approach from what I understand really eased the 32 / 64 bit transition.

Re: GSoC Introduction: x86_64 port

It's not my project and Alex surely will explain better how he plans to do things, but I don't really think fat binaries are necessary. They were used mainly by Apple when they where switching to a completely different instruction set (68k to PowerPC and later PowerPC to x86). x86_64 allows to execute 32 bit code and all what's needed is a translation layer of some sort between 32 bit programs and 64 bit kernel (just like WoW64).

It was possible to make OS X have 32 bit kernel and 64 bit apps, because their kernel is located in a separate address space and there is a context switch at each syscall (this rather unique design on x86 is apparently a legacy from PowerPC times). However, it still needed to be to some extent "64 bit aware" since userland code could pass 64 bit values to the kernel. Haiku uses standard (on x86) memory layout where each process address space is divided into user and kernel space, thus it may be a lot more complicated (probably even impossible) to make 32 bit kernel support 64 bit apps.

Re: GSoC Introduction: x86_64 port

I see no logical reason why anyone would want to run 64bit apps on a 32bit kernel. Theonly reason i can see is to support open-sourcedrivers that are not easily ported, as the hardware for closed-source legacy BeOS drivers wouldn't be able to run 64bit code anyway.

Re: GSoC Introduction: x86_64 port

For now I only intend on implementing support for running 64-bit code. 32-bit compatibility could be implemented in the f