3 ms·
Well, first off, Apple isn't virtualizing Intel, they're emulating it. "Virtualization" implies that your CPU has special hardware support for running a kernel
by kmeisthax 5y ago
Well, first off, Apple isn't virtualizing Intel, they're emulating it. "Virtualization" implies that your CPU has special hardware support for running a kernel as if it were a regular OS process; which almost never crosses architecture boundaries. Apple does have special support in M1 for certain x86 features like total store order, but most of the work is done in software to translate binaries to ARM64 before they are executed. They just omitted emulating anything beyond Intel macOS user-mode, because that's relatively easy and lightweight[0].
Intel doesn't virtualize Apple hardware because it doesn't make business sense and is questionably legal (see also: Corellium). Apple silicon is just-different-enough from a regular ARM64 design that anything that can actually boot macOS almost certainly exists purely to break the macOS license agreement.
[0] Specifically, having all your code neatly packaged into executables and libraries means that you can AOT-compile nearly everything and not have to actually interpret or JIT x86 code. There's also no need to emulate, say, x86 context switches or page table walking; you just stop emulation, run the syscall on the ARM side, and then restart the emulation once that's done.
Of course, they still have a JIT, just in case you decide to run a binary that also contains a JIT.
- marcan_42 5y ago> anything that can actually boot macOS almost certainly exists purely to break the macOS license agreement. Apple provides a hypervisor framework that emulates a standard ARM64 system and macOS ARM64 kernels that run on it. This is how macOS on Apple Silicon virtualization works. It's not really Apple Silicon, it's boring standard ARM on Apple Silicon. Soon after Apple started shipping these kernels, before it was even announced, someone tried it on QEMU on another platform and found it worked just fine in single user mode. The only catch is the macOS UI requires Metal, and paravirtualized graphics are implemented using serialized Metal passthrough. In other words, if you want to boot ARM64 macOS to a desktop, you have to implement Metal in your VM host.
- kmeisthax 5y agoAah, TIL. Do we have paravirtualized Metal support in Linux guests yet? That would probably neatly brush away any legal claims against third-party hosts for implementing it on non-Apple hardware.
- jsjohnst 5y ago> They just omitted emulating anything beyond Intel macOS user-mode, because that's relatively easy and lightweight Is it that? I would’ve assumed it’s because the patents hadn’t expired yet.
- kmeisthax 5y agoI'm pretty sure some of the AVX and SSE instructions are patented still, and those are accessible in user-mode and supported by Rosetta 2. Apple almost certainly was able to either brow-beat Intel into a license, or design around the claims of said patents[0]. FWIW Apple has UI strings for when Rosetta 2 is disabled, so they might have had to consider cases where their license expires or something. [0] Notably I have no idea if patent claims on a hardware instruction & it's associated implementation would automatically prohibit emulation of that instruction, or if emulation would be a separate patentable.
- jsjohnst 5y ago> Rosetta translates all x86_64 instructions, but it doesn’t support the execution of some newer instruction sets and processor features, such as AVX, AVX2, and AVX512 vector instructions. https://developer.apple.com/documentation/apple-silicon/about-the-rosetta-translation-environment https://developer.apple.com/documentation/apple-silicon/abou...