VirtualBox amd64 build instructions revision [Work In Progress]

sossego

Retired from the forums
I'm reposting this seeing that I have successfully built a base.


Notes:

Virtualbox build:
1)libxml2 needed for virtual box build if using linux binary.
2)patch submitted by walt must be applied to dev86
3)bcc must be imported
4)dev86 separate from the above dev/bin86 must be imported
5)bcc must link with dev86 folder maybe even binutil
6) libpng needs to be installed.
7) compat6x needs to be installed.
a: Virtual box build from both sdk and linux source are being built.
b: On linux hosts, virtual box and kqemu conflict with each other. Also, multi-level virtualization cannot be done unless all levels are of the same vm type.
c: Virtual box is a loadable kernel module for linux, there isn't a "kldload vbox" or a "VBox_enable=YES" for FreeBSD.
d: Kqemu can work with Xen on the layer above. Virtual box may conflict. Anyone having any experience with this, let me know.
e: There is talk of porting KVM to FreeBSD.
f: Some people, such as myself, like to use multiple vm types. How can we use more than one VM when two are conflicting?

8) Java needs to be installed. I'm using the diablo environment.
9) Add these lines to the build. "source env.sh && kmk"
g: No one has yet made a comparison between the FreeBSD and Linux builds. This needs to be done.
10) Environment must be set to bash.

Mailing lists quotes:

"Looks like env.sh has a #!/bin/bash as it's first line - you'll need
to either change that to #!/usr/local/bin/bash or symlink
/usr/local/bin/bash->/bin/bash to have the script find the correct

[code/] #bash
(/path/to/vbox-release/folder)# ./configure --disable-xpcom --disable-pulse --disable-kmods --disable-hardening && source env.sh && kmk -k -s -t [/code]
shell. The bash port installs to /usr/local/bin/bash on FreeBSD (and
bash is not in the base system). I recommend the symlink approach -
I've had better luck with that.

" [This needs to be done along with changing to bash]

"
http://www.datahead.org/wiki/index.php/VirtualBox"
[This link needs to be re-activated.]

="I assume this is on freebsd host, because I also encountered it on FreeBSD
7.0.

In the "configure" script, I went and changed the following 2 variable:

From:

INCPNG=""
LIBPNG="-lpng"

To:

INCPNG="/usr/local/include"
LIBPNG="-L/usr/local/lib -lpng"=
[This needs to be added}

"http://www.bsdportal.ru/viewtopic.php?t=18808&sid=c0a8b366efa1d8496aa764be393bc53a"
[A good reference to helping the build.]


The patch- credit goes to walt:
--- ld/x86_aout.h.orig 2003-01-28 17:17:14.000000000 -0500
+++ ld/x86_aout.h 2005-05-07 22:40:05.000000000 -0400
@@ -13,7 +13,9 @@
typedef long Long;
#define __OUT_OK 1
#else
-typedef char Long[4];
+#define __OUT_OK 1
+#include <sys/types.h>
+typedef int32_t Long;
#endif


Howto patch- I'm going full force blind into developing, the patch is necessary:

#cd /tmp (see the mirror image process already?)
#tar -xvzf /path/to/bin86-0.16.17.tar.gz
#cd bin86-0.16.17
#patch -p0 < /path/to/mynewpatch (there's that -p flag at last!)

Edit configure so that TARGET_CPU="amd64" and TARGET_MACHINE="amd64".

Okay this all has to be done in bash. <-- just a reminder.
Su to root. You can use sudo but I don't like it too much.

Code:
#bash
path/to/vbox/folder# ./configure --disable-xpcom --disable-hardening --disable-pulse --disable-kmods && source env.sh && kmk -k -s -t

Create a vboxusers group with /usr/sbin/sysinstall. Don't add anyone to it. Just exit back to the vboxfolder.
Edit /etc/groups to include root and the initial user in the vboxusers group you just created.
I'll post the testcases later after I have ran all of them.

There are no amd64 flags listed for freebsd. Maybe they need to be ported from qemu?

This will get you started.

Edit: I've copied the cpu flags from -m32 for the vboxdrv and added -mtype=MyArchitectureType.

Chmod 0777 both the configure and Config.kmk file.
use kate or gedit or what-have-you to search Config.kmk for "port me to"
Copy the the cpu flags from -m32 and paste them to -m64.
Add your machine type with -mtype=your-cpu-type.
This will build a vboxdrv but how to install it, I don't know.
 
Seems that all of the testcases come up as permission denied.
I'm going to try the build with no flags and see if that makes a difference
 
Well , it still doesn't do shit for shit.
Anyone with any ideas is welcome.
 
It's a howto. I started working on this earlier when qemu was difficult. Since there seems to be no one else trying to port virtualbox to freebsd amd64, this is a general howto with updates.
If I can get the test cases to work, then the base will work. It's x86 only, so dev86 needed to be patched. Plenty of errors in building, so I've come up with the most optimum flags. Doesn't seem to be much information about long mode for virtualbox.
 
test results

Seems to be only one failure.

All other tests don't return anything or they are successful

Code:
./tstVMStructSize
tstVMStructSize: TESTING
struct VM: 129472 bytes
sizeof(uint128_t): 0x10 (16)
sizeof(int128_t): 0x10 (16)
sizeof(uint64_t): 0x8 (8)
sizeof(int64_t): 0x8 (8)
sizeof(uint32_t): 0x4 (4)
sizeof(int32_t): 0x4 (4)
sizeof(uint16_t): 0x2 (2)
sizeof(int16_t): 0x2 (2)
sizeof(uint8_t): 0x1 (1)
sizeof(int8_t): 0x1 (1)
sizeof(X86DESC): 0x8 (8)
sizeof(X86DESC64): 0x10 (16)
sizeof(VBOXIDTE): 0x8 (8)
sizeof(VBOXIDTR): 0xa (10)
sizeof(VBOXGDTR): 0xa (10)
sizeof(VBOXTSS): 0x88 (136)
sizeof(X86FXSTATE): 0x200 (512)
sizeof(RTUUID): 0x10 (16)
sizeof(X86PTE): 0x4 (4)
sizeof(X86PD): 0x1000 (4096)
sizeof(X86PDE): 0x4 (4)
sizeof(X86PT): 0x1000 (4096)
sizeof(X86PTEPAE): 0x8 (8)
sizeof(X86PTPAE): 0x1000 (4096)
sizeof(X86PDEPAE): 0x8 (8)
sizeof(X86PDPAE): 0x1000 (4096)
sizeof(X86PDPE): 0x8 (8)
sizeof(X86PDPT): 0x1000 (4096)
sizeof(X86PML4E): 0x8 (8)
sizeof(X86PML4): 0x1000 (4096)
VM::selm.s.Tss offset=0xfb88 expected alignment 10, meaning 0x8 off
VM::selm.s.Tss offset 0xfb88 (64392) sizeof 136
VM::selm.s.TssTrap08 offset 0xfc10 (64528) sizeof 136
sizeof(PGMPAGE): 0x10 (16)
tstVMStructSize: Comparing HC and GC...
tstVMStructSize: FAILURE - 1 errors


Update: You may want to use no flags or just the mtune one. I'm not sure what it is looking for. Supposedly, the build works somewhat on x86.
 
In /path/to/vbox/src/VBox/VMM/SELMInternal.h
You can increase the padding value here but it returns the same error.

In Config.kmk look for "port me to freebsd amd64" and copy the values over if you forgot. Add -O2 to the build line. Using -march= or -mtype= should work.

I think it is the trap value and that increasing it from 8 to 10 will work but I am not sure.

Oh, yeah, sorry, cats,let's make this easier.

Code:
 #!/bin/sh /usr/bin/cd /path/to/vbox/folder/ && /bin/bash
Saving this as vb-test.sh should make the build easier, and you can also use this as the start environment when you need or want to work on virtualbox.
 
Hi,
do you use SVN trunk or a specific snapshot ?
because some progress has been reported by vbox developers recently
regarding vbox on FreeBSD host...they haven't mention the platform though (i386 or amd64)...
I've tried to compile the latest code from trunk on 7-STABLE amd64 but I got into many problems ... one of those I couldn't deal with was SDL...however I was just trying to see how far could it go without any modifications in the build scripts...so not too far :)
 
I started this project because of difficulties with building qemu and kqemu together.

I ended up with kBuild as a port then let it go.
Things happen.
My monitor blew. I had to use a smaller monitor.
I started with the amd64 build and stayed with it.
For some time.

Now..
I am the only one working.
I support two people off of less than $900 USD per month.

I don't have time.
This is an escape.
I am poor.
Whoever you are, don't say shit.
I've been poor to the point of having to steal food and to the point of digging out of trashcans.

Whoever you are, don't give me any *beep**beep**beep**beep*ing sarcastic replies.
I went years without medicine for asthma.
I coughed up blood because I couldn't afford treatment.


Whoever you are, keep your goddamn self righteousness to yourself.

I'm mixed.
Do you know what it feels like to not be white enough for your family but to be too white in the eyes of other Hispanics?


Whoever you are, just leave me the *beep**beep**beep**beep* alone.


I can still feel myself being beat with industrial strength hoses, with broomsticks.
I can still feel him shoving a gun down my throat.
I can still feel myself being jerked in the air and beat all over my body.

Whoever you are, go the *beep**beep**beep**beep* and and piss off.


I've been homeless, on the ground and sick.

I still managed to actually do things for other people. Positive things.


I've been poisoned, shot at, molested, beat, threatened, blackmailed, chased.

Do what you want.

Whoever you are, don't judge me unless you have gone through the exact same things.
 
Dude, I'm not judging you or anything, I just wanted to share my experience with vbox (and possibly help if I could) that's all.
 
Sossego, is that a (rightly unpublished) Bob Dylan protest lyric, or have you gone completely off the cliff? Anyway: your response is totally nonsensical in the context of what mgp wrote (which was not a criticism, nor selfrighteous in any way), so I suggest you calm down a little (like: all the way down).
 
I have seen that nox and others have managed to patch virtualbox to make it run.


The moderators may now close this post or do with it whatever they will seeing that all of this here is merely a reflection of failure
and incompetency.
 
Back
Top