Jump to content

I would like to virtualize macos on freebsd with bhyve.


5 posts in this topic

Recommended Posts

Hello to everyone.

 

I'm trying to understand if I can virtualize macosx with bhyve on freebsd. I'm collaborating with some qemu + kvm and bhyve developers to be able to accomplish this task. Can u give some suggestions to understand what to do to fix the error that I'm getting,please. According with this page :

 

https://github.com/kholia/OSX-KVM/tree/master/OpenCore

 

On Linux I did :

 

sudo ./opencore-image-ng.sh --cfg config.plist --img OpenCore.qcow2

 

In config.plist I have enabled ONLY  the VirtualSMC kext because it was currently disabled, since I don't have an emulated isa-applesmc device attached to the VM :

 

 

<dict>
			<key>Arch</key>
			<string>Any</string>
			<key>BundlePath</key>
			<string>VirtualSMC.kext</string>
			<key>Enabled</key>
			<string>SMC emulator</string>
			<key>Enabled</key>
			<true/>
			<key>ExecutablePath</key>
			<string>Contents/MacOS/VirtualSMC</string>
			<key>MaxKernel</key>
			<string></string>
			<key>MinKernel</key>
			<string>8.0.0</string>
			<key>PlistPath</key>
			<string>Contents/Info.plist</string>
		</dict>

 

and then,since bhyve does not support the qcow2 format,I have converted the OpenCore image from qcow2 to raw with :

 

dmg2img -i Catalina-BaseSystem.dmg Catalina-BaseSystem.img

 

And finally in FreeBSD,I ran bhyve with these parameters :

 

bhyve -S -c 2 -m 4G -w -H \
-s 0,hostbridge \
-s 1,ahci-hd,/usr/home/marietto/bhyve/OpenCore.img \
-s 2,ahci-hd,/mnt/$vmdisk1'p2'/bhyve/img/Mac/OSX-KVM/Catalina-BaseSystem.img \
-s 8:,virtio-net,tap19 \
-s 29,fbuf,tcp=0.0.0.0:5919,w=1440,h=900 \
-s 30,xhci,tablet \
-s 31,lpc
-l bootrom,/usr/local/share/uefi-firmware/BHYVE_UEFI.fd
vm19 < /dev/null & sleep 2 && vncviewer 0:19

 

OpenCore worked and I've seen the MacOS BaseSystem Catalina entry on the boot list. I also tried it with Monterey. They were able to boot, but they stopped early showing some errors on the screen.

 

As you can see : https://ibb.co/album/Ng7Yt9

 

Can you give a look at the recorded video stored on my google drive ? you will see what happens when I try to boot MacOS with bhyve :

 

https://drive.google.com/file/d/1bDuKB3jQCVQvf88KVprjvjL08nDjK-iv/view?usp=sharing

 

Now,I've moved to Linux and I've started mac os x virtualizing it with qemu and kvm and I used the following parameters :

 

https://paste.ubuntu.com/p/jjrr2PfRfM/

 

When I booted mac os x like that I've got the same error that I've got when I have virtualized mac os on bhyve. So,it means that on bhyve it does not boot because the following parameters are missing :

 

https://pastebin.ubuntu.com/p/KsVPVx7bhj/

 

I suppose that the MacOS needs to read the missing parameters to boot properly. So we need to find a way to pass them through to mac os x adding them to bhyve in some way. Or maybe,if I can omit the offending parameters. I'm reading that the kholia macOsx needs the -cpu penryn parameter to work. But it's also true that the newest versions of macosx supports the coffee lake cpus and I have one of them. (I have the I9-9900K with the Z390 gigabyte aorus pro mobo). So do you know another port of MacOS that supports the coffee lake cpus ?

 
On 2018 Intel has released 8th Gen, Coffee Lake CPU. The CPU uses LGA 1151 socket. The Coffee Lake CPUs paired with 300 series Motherboard are natively recognized by macOS High Sierra without any need of using a Fake CPU ID. The new 300 series Motherboards are compatible with the Coffee Lake CPUs. The Coffee Lake CPUs uses LGA 1151 socket. Please note that the 100/200 series Motherboards are incompatible with the new Coffee Lake CPUs.
 
So,do I need to emulate the Penryn cpu and all the MSRs in bhyve or the error that I get is caused by some wrong kext or driver ? thanks.
 
Edited by marietto2008
  • Thanks 1
Link to comment
Share on other sites

Ah, finally an interesting thread. I've personally been watching the development of bhyve for quite a while and it's exploring new features like this that really peak my curiosity.

 

I'm wondering if it's an issue with your OpenCore config - from what I recall OpenCore needs very specific configuration for each of its hardware devices, including the CPU. You might need to configure OpenCore as if you were going to install macOS on your system bare metal, at least on the CPU side.

 

Without any configuration, Clover seems to work better out of the box in my experience, and does ACPI patching and such automatically so perhaps in this case you should try that as the bootloader given there are lots of unknowns with this setup.

 

You may have to create a custom image yourself rather than using the KVM image for Linux from github, seeing as KVM and Bhyve from what I can tell are quite different it might be best to start with a vanilla macOS image and load your custom kexts and configs on top of that.

 

 

Link to comment
Share on other sites

One developer who is colalborating with me says :

 

Nothing new. The plan should be:

 

1) Add SET_CPUID ioctl to bhyve and code that sends this ioctl to qemu according to '-cpu' option.
2) Add IA32_FSB_FREQ, IA32_CORE_THREAD_COUNT, IA32_PLATFORM_INFO, IA32_PERF_STATUS and IA32_PERF_CTL MSR support to bhyve. The returned values can be hardcoded in bhyve.
3) If that will not help, add debug prints after vm-exits in bhyve and analyze last exits before the error.

 

>So,according with these considerations,I think that maybe I could try to install macos physically on one of my ssd disk and then I could try to boot it in bhyve adding the parameters below :
>-s 1,ahci-hd,/usr/home/marietto/bhyve/Clover.img \-s 2,ahci-hd,/dev/ada2 \


This will not help. UEFI and Clover images are still virtual, they require Penryn.

 

These assumptions seem to be different from what it seems to me that you are telling to me. So,please join us.

Link to comment
Share on other sites

55 minutes ago, marietto2008 said:

I would like to add you to our developers group. Your help can be precious. Drop me an email here if you want : marietto2008@gmail.com

I'd be happy to join, will shoot you an email.

I've actually been out of the Hackintosh scene for quite a while now, kinda lost interest in it a little but I will help where I can - I think considering my interest in FreeBSD and Bhyve is a little niche and hard to find on this forum I'll try and jump back in to the hackintosh side of things to help you out :)

Might actually give setting up a macOS VM a go on my own when I have the time, pretty busy this week so I might have to look at it on the weekend.

Edited by 0000-1248
Link to comment
Share on other sites

 Share

×
×
  • Create New...