Booting Haiku with Hardware Virtualization on ARM64 Apple Devices?

Hello, everyone. :slight_smile:

I always look forward to reading the Haiku Activity & Contract Report every month, and the September report caught my eye.

ARM, RISC-V, M68K
przemub fixed some ARM64 memory management instruction macros, and changed the ARM64 VMTranslationMap to make use of them instead of just inline assembly. He also wrote a GICv3 interrupt controller driver, making it possible to boot Haiku with hardware virtualization on ARM64 Apple devices, added some CPU identification logic for ARM64, and fixed or implemented a significant number of things in ARM64 port code.

(Emphasis added).

What does “boot Haiku with hardware virtualization” mean in this context? I’m assuming it includes enhancements/better performance for booting Haiku in, say, Parallels or similar software, but that’s just a guess.

I believe it will allow the arm64 build to run better under virtualization. I ran an earlier version of the arm build with qemu on my m1 MacBook and it ran well. Personally hoping that after the new year I can run it on m1 bare metal. I believe it still needs a few drivers.

But PROGRESS!!! Thanks for all the hard work.

2 Likes

Previously you could only run the ARM64 port under software emulation (so it wasn’t much faster on ARM systems than x86 ones). With this new driver, it can now boot in QEMU on Apple devices under hardware virtualization, meaning the ARM64 instructions are actually run by the host CPU inside a virtual machine context, and get the huge performance benefits of doing that.

8 Likes

That sounds awesome!

Is there a guide to trying it with UTM, the QEMU cli, or Parallels? I YOLO’d it with UTM, and actually got the boot splash, but it just sat there for a while and kernel panicked. When it dropped me into the debugger, the keyboard wouldn’t work.

I’m guessing I’ll have to do it from the command line so I can specify more options.

I dont think there is an official one?
I used a couple random good hits to help me previously.

https://sergio101.com/installing-haiku-os-on-a-macbook-pro/

https://codingitwrong.com/2023/08/05/installing-haiku-on-apple-silicon-using-utm.html

1 Like

Thanks!

Both of those links are for x86 versions of Haiku, which would be emulated under UTM.

The ARM64 version will be virtualized, but I think the setup path is a bit different.

I also found this, for CLI qemu use:

(The directions for bringing it up after you’ve compiled it seem to apply just as readily to the nightly ARM64 build, just from reading it. I haven’t tried it yet.)

If I can get it working with raw qemu, I should be able to figure out how to do that in UTM. (There’s a place in UTM to give qemu custom arguments.)

All available guides are here: Virtualizing Haiku | Haiku Project

They don’t specifically target arm64 however

Using the sample in the compiling guide, I got it to start via the qemu cli, using a script (ZSH in my case, but I don’t see why the shell would matter for executing a single command):

#!/bin/zsh

qemu-system-aarch64 -bios /opt/homebrew/share/qemu/edk2-aarch64-code.fd -M virt -cpu host -accel hvf -smp 4 -m 8192 \
	-drive file=/Applications/QEMU/Haiku/haiku-mmc.image,if=none,format=raw,id=x0 \
	-device virtio-blk-device,drive=x0 \
	-device virtio-keyboard-device \
	-device virtio-tablet-device \
	-device virtio-gpu-device \
	-device virtio-rng-device \
	-netdev user,id=net0 \
	-device virtio-net-device,netdev=net0 \
	-serial stdio

It started fine, and I had mouse control, but it’s unusable in that state as the default resolution (the size of the window) is too small to see the entire desktop. It was enough that I could see the menu pop up when I right-clicked the desktop, so I know it was working, but I couldn’t see enough to do much.

EDIT: Okay, that actually did work. And it was startlingly easy.

When you start it, it’s in 640x480, and not scaling correctly. The VM will have 3 displays (QEMU’s command line, a parallel (serial?) display, and the actual desktop GUI that it opens up by default.

Switch to either of the other two, and then back to the desktop GUI, and it’ll be scaled down to 640x480 so you can see the entire desktop. Then you can change the resolution as normal from inside Haiku, and it’ll remember what you did the next time it starts up.

EDIT 2: There’s also an option to install Haiku, which I haven’t tried yet, but I installing the full OS onto an actual virtual HDD seems to be the next step … as soon as I figure out how to add a virtual HDD :stuck_out_tongue: .

EDIT 3: Networking also worked out of the box.

3 Likes

Also got Haiku booted virtualized with this command.

image

1 Like