找回密码
 加入会员

通过 Qemu 在 ARM Mac 上运行Windows 方法

71179 Wally 2020-11-30 15:33|显示全部楼层
Firefox 43.0 Win 7
原文来自
https://gist.github.com/niw/e4313b9c14e968764a52375da41b4278

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/29/2020 state. It will be improved a lot in upcoming a few months... (I hope.)

Steps
  • Install Xcode from App Store or install Command Line Tools on your Mac running on Apple Silicon.

    xcode-select --install
  • Install MacPorts and Qemu dependencies.

    [color=var(--color-text-link)]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.

  • Clone Qemu source code.

    git clone --depth 1 https://git.qemu.org/git/qemu.git
  • Create a local branch then apply Hypervisor.framework patches that @[color=var(--color-text-link)]_AlexGraf made.

    cd qemugit checkout 944fdc5 -b wip/hvf # This is current `origin/master` when this document is written.curl https://patchwork.kernel.org/series/391797/mbox/|git am
  • Build Qemu

    mkdir buildcd build../configure --target-list=aarch64-softmmu --enable-cocoamake -j

    This is surprisingly fast on Apple Silicon Mac, compare to Intel Mac...

  • Download Windows 10 on ARM Insider Preview

    [color=var(--color-text-link)]https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewARM64

  • Download prebild, xHCI disabled version of EDK II OVMF EFI image for Qemu.

    [color=var(--color-text-link)]https://gist.github.com/niw/4f1f9bb572f40d406866f23b3127919b/raw/d3dc861d1c8578f996bbfcd0e014586a2eb52d8c/QEMU_EFI-8c552e8.tar.gz

    To build it from the source code, see the following section.

  • Run Windows 10

    ./qemu-system-aarch64 \  -monitor stdio \  -M virt \  -accel hvf \  -cpu cortex-a72 \  -smp 4 \  -m 4096 \  -bios ~/Downlaods/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 \  -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.

  • Download VirtIO device drivers ISO from [color=var(--color-text-link)]Fedora Project.

    [color=var(--color-text-link)]https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso

  • 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.

  • 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 [color=var(--color-text-link)]here for the details.

  • 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.

  • Checkout EDK II source code.

    git clone https://github.com/tianocore/edk2.gitcd edk2git checkout edk2-stable202008 # or any stable tagged commitgit submodule update --init --recursive
  • 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.

  • Then, build it.

    apt install install iasl python3 python3-distutils uuid-dev gcc-aarch64-linux-gnusource edksetup.shmake -C BaseToolsenv 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%.
  • You can run Ubuntu Server for ARM in same way, which is stabler than that. [color=var(--color-text-link)]https://ubuntu.com/download/server/arm
  • You may need to reduce memory from 4096, if you’re using 8GB Apple Silicon Mac.

20-11-30 16:58:59

Chrome 86.0.4240.198 Win 7
按道理在ARM架构下模拟X86架构,那是要损失性能的,除非苹果的M1系列性能确实非常强。但是,两个硬件架构存在根本性的区别。所以,想完美运行Windows 10是是很困难的。
20-11-30 17:54:22
yzszx ( ☆☆☆ ) ( 赞 16 )

Safari 14.0.1 macOS 10.15.6
361181853 发表于 20-11-30 16:58按道理在ARM架构下模拟X86架构,那是要损失性能的,除非苹果的M1系列性能确实非常强。但是,两个硬件架构存在根本性的区别。所以,想完美运行Windows 10是是很困 ...

引用原文中的第 6 点已说明了:windowsinsiderpreviewARM64

所以,x86 的模拟目前基本不现实
20-11-30 21:29:15

Chrome 86.0.4240.198 Win 7
yzszx 发表于 20-11-30 17:54引用原文中的第 6 点已说明了:windowsinsiderpreviewARM64,,所以,x86 的模拟目前基本不现实

所以,现在就要看微软有没有决心对ARM市场进行深度发展。
20-11-30 21:52:34 发自iPhone客户端
yzszx ( ☆☆☆ ) ( 赞 16 )

? iPhone 12 mini
361181853 发表于 20-11-30 21:29所以,现在就要看微软有没有决心对ARM市场进行深度发展。

微软是有决心的,否则怎么会有 Surface?现在看开发者对的态度
20-11-30 22:20:10
Gavin-Wang ( ☆☆☆☆ ) ( 赞 13 )

Safari 11.1.2 macOS 10.11.6
据说 docker 也没法用
20-11-30 22:44:53
dym666 ( ☆☆☆ ) ( 赞 2 )

Safari 14.0.1 macOS 10.15.6
真是要了命了了,这几天的新闻都是关于M1安装windows的,都买了mac了,就不能不要这么折腾了吗?就不能安心的用mac吗?真想装windows,去买个外星人啊,,
PS:只是吐槽一下,没有任何恶意
20-12-1 09:02:59
linxyz ( ☆☆☆☆ ) ( 赞 3 )

Safari 14.0.1 macOS 10.15.6
Gavin-Wang 发表于 20-11-30 22:20据说 docker 也没法用

目前docker确实没办法用
docker是golang开发的,golang还不完全支持M1的arm64架构

 

您需要登录后才可以回帖 登录 | 加入会员

联系我们|急聘英才|移动版|站点地图|iPhone 客户端|保修查询|排行榜|Mac软件宝箱|麦克叉 ( 京ICP证110625号,京ICP备18054784号-1,公安部备案 11010802033015 )

Since Feb-16-2005

回顶部