# How to run Windows 10 on ARM in QEMU with Hypervisor.framework patches on Apple Silicon Mac Here is easy steps to try Windows 10 on ARM on your Apple Silicon Mac. Enjoy! > NOTE: that this is current, 11/30/2020 state. It will be improved a lot in upcoming a few months... (I hope.) ## Steps 1. Install Xcode from App Store or install Command Line Tools on your Mac running on Apple Silicon. ``` xcode-select --install ``` 2. Install MacPorts and QEMU dependencies. https://www.macports.org/install.php ``` sudo port install ninja pkgconfig texinfo libtool glib2 libpixman ``` Don’t want to use sudo with MacPorts? Create `/opt/local` as `$USER:staff` and install MacPorts from the source code. 3. Clone QEMU source code. ``` git clone https://git.qemu.org/git/qemu.git ``` 4. Create a local branch then apply Hypervisor.framework patches that @[_AlexGraf](https://twitter.com/_AlexGraf) made. ``` cd qemu git checkout 944fdc5 -b wip/hvf # This is current `origin/master` when this document is written. curl https://patchwork.kernel.org/series/392975/mbox/|git am ``` 5. Build QEMU ``` mkdir build cd build ../configure --target-list=aarch64-softmmu --enable-cocoa make -j ``` - Please disable any x86_64 tools such as the one installed by Homebrew, please rewrite `PATH` etc to disable them. - This is surprisingly fast on Apple Silicon Mac, compare to Intel Mac... 6. Download Windows 10 on ARM Insider Preview https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewARM64 7. Download prebild, xHCI disabled version of EDK II OVMF EFI image for QEMU. https://gist.github.com/niw/4f1f9bb572f40d406866f23b3127919b/raw/d3dc861d1c8578f996bbfcd0e014586a2eb52d8c/QEMU_EFI-8c552e8.tar.gz To build it from the source code, see the following section. 8. Run Windows 10 ``` ./qemu-system-aarch64 \ -monitor stdio \ -M virt,highmem=off \ -accel hvf \ -cpu cortex-a72 \ -smp 4 \ -m 4096 \ -bios ~/Downloads/QEMU_EFI.fd \ -device ramfb \ -device qemu-xhci \ -device usb-kbd \ -device usb-mouse \ -nic user,model=virtio \ -drive file=~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.VHDX,if=none,id=boot,cache=writethrough \ -device nvme,drive=boot,serial=boot ``` Please modify each path to the image depends on your environment. ## Enable the internet VirtIO NIC is not enabled by default. To make it works, you need to install device driver. 1. Download VirtIO device drivers ISO from [Fedora Project](https://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/index.html#virtio-win-direct-downloads). https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso 2. Mount device drivers ISO Add next options to `qemu-system-aarch64`. ``` -drive file=~/Downloads/virtio-win-0.1.190.iso,media=cdrom,if=none,id=drivers \ -device usb-storage,drive=drivers ``` Please modify each path to the image depends on your environment. 3. Disable device driver signature enforcement Boot Windows, then right click Windows Start button, then select Command Prompt (Admin). Use BCDEdit to enable test-signed device drivers. ``` Bcdedit.exe -set TESTSIGNING ON ``` Then reboot Windows. See [here](https://docs.microsoft.com/en-us/windows-hardware/drivers/install/the-testsigning-boot-configuration-option) for the details. 4. Install driver Once Windows booted again, then right click Windows Start button, then select Device Manager. In Device Manager, select View menu then Devices by Connection. Navigate in the device tree, select `ACPU ARM64-based PC`, `Microsoft ACPI-Compliant System`, `PCI Express Root Complex`, then you will see one `Unknown device` there. (There are many `Unknown device` in tree but the one under `PCI Express Root Complex` is the VirtIO NIC.) Right click `Unknown device` then select Update Drivers, then Browse my computer for drivers, then select `D:\NetKVM\w10\ARM64`. Click Next to install `Red Hat VertIO Ethernet Adapter`. ## Build EDK2 OVMF EFI Image from the source code To build this from the source code, you may need to setup Linux environment. Install VMWare Fusion or VirtualBox on your Intel Mac (Yes, Intel Mac.) and install Ubuntu. 1. Checkout EDK II source code. ``` git clone https://github.com/tianocore/edk2.git cd edk2 git checkout edk2-stable202008 # or any stable tagged commit git submodule update --init --recursive ``` 2. Then you need to disable xHCI due to current Hypervisor.framework patch limitation. Comment out `MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf` in `/ArmVirtPkg/ArmVirtQemu.dsc` and `/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc`. 3. Then, build it. ``` apt install install iasl python3 python3-distutils uuid-dev gcc-aarch64-linux-gnu source edksetup.sh make -C BaseTools env GCC5_AARCH64_PREFIX=aarch64-linux-gnu- build -a AARCH64 -t GCC5 -p ArmVirtPkg/ArmVirtQemu.dsc ``` Then, you will get `QEMU_EFI.fd` in `Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/FV`. ## Note - ~~It is Hypervisor.framework patch’s known issue that CPU usage keeps about number of cores x 100%.~~ It's fixed now. - You can run Ubuntu Server for ARM in same way, which is stabler than that. https://ubuntu.com/download/server/arm - You may need to reduce memory from 4096, if you’re using 8GB Apple Silicon Mac.