Gabriel Somlo, a researcher at Carnegie Mellon, writes about running Mac OS X on KVM and building a free 64-bit RISC-V computer.
HN links his OSX-KVM work for running macOS on non-Apple hardware and his trustworthy RISC-V computer page, which commenters suggest to those worried about hardware backdoors.
Sosumi Snap uses Clover internally.
[1] showed how to boot macOS in KVM without the usual Clover / Opencore setup but is not maintained for newer versions anymore. [2] shows how to run current macOS versions without Clover or Opencore in VirtualBox by changing the VM's ACPI(?) entries and loading variables into the NVRAM. [3] uses KVM but also uses Opencore.
I tried to translate [2] to QEMU but was never successful.
Does anybody know some resources how to have a pure KVM macOS VM without any hackintoshing?
[1] https://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/
[2] https://github.com/myspaghetti/macos-virtualbox
[3] https://github.com/kholia/OSX-KVM
There's a good explanation here, including a tool to read the key from a running Mac: http://osxbook.com/book/bonus/chapter7/tpmdrmmyth/
Summary: important system binaries (such as Finder.app) are encrypted with a key held in the SMC. The OS transparently decrypts them, but needs access to that key to do so.
It is possible to convince QEMU to run OS X: http://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/ (though I've not tried this myself). They do require you to provide the relevant key yourself, I imagine for legal reasons.
This little line, copyrighted by Apple, is what I understand to be the legal protection they have against people running OS X on non-Apple hardware:
https://github.com/kholia/OSX-KVM/blob/476ae8b082088049f2f8c547518f35b1cf5d0647/macOS-libvirt.xml#L55
I would not be surprised if a DMCA takedown will be filed against this repository soon.
More information here: http://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/#sec_3_2_1
Off the top of my head: the VM executes either HLT or MWAIT, and those instructions are generally programmed to cause a VM exit, so the hypervisor can take action. The hypervisor will deschedule the VM and possibly go idle itself.
TBH, I have no idea how MONITOR works in a VM. It might be quite messy.
Edit: Here's a really nice explanation: http://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/mwait.html
..and only a single copy, it appears.
These links are fun:
https://github.com/kholia/OSX-KVM/blob/master/README.md
http://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/#sec_4
OSX can be ran in the KVM (Kernel Virtual Machine) so if you don't want to quit your side job over the switch :)
[1] http://www.contrib.andrew.cmu.edu/~somlo/OSXKVM/