Skip to content

Instantly share code, notes, and snippets.

@niw

niw/README.ja.md

Last active Apr 21, 2021
Embed
What would you like to do?
How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac

ARM 版 Windows 10 や Ubuntu for ARM64 を Apple Silicon な Mac で動かす

ARM 版 Windows 10 や Ubuntu を Apple Silicon な Mac で動かす簡単な方法です。

メモ: 2021年2月8日現時点での方法で、今後まだ改善されていくと思います。

ARM 版 Windows 10 を動かす

  1. Xcode を App Store で、あるいは Command Line Tools を Apple Silicon な Mac にインストール

    xcode-select --install
    
  2. ARM64 対応の Homebrew で QEMU の依存ライブラリをインストール

    すでに x86_64 の Homebrew が /usr/local にインストールされている場合は削除するなどしてください。 x86_64 の Homebrew では QEMU がビルドできません

    https://brew.sh/

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    brew install ninja pkgconfig glib pixman
    
  3. QEMU のソースコードをとってくる

    git clone https://git.qemu.org/git/qemu.git
    
  4. ローカルブランチを作って、@_AlexGraf氏がつくった Hypervisor.framework のパッチをあてる

    cd qemu
    git checkout d0dddab40e -b wip/hvf
    curl 'https://patchwork.kernel.org/series/418581/mbox/'|git am --3way
    
  5. QEMU をビルドする

    mkdir build
    cd build
    ../configure --target-list=aarch64-softmmu --enable-cocoa
    make -j
    
  6. QEMU 用の EDK II OVMF EFI イメージをダウンロードする。

    このイメージは stable202011 タグに、QemuRamfb.c に追加の解像度を足したものです。

    https://gist.github.com/niw/4f1f9bb572f40d406866f23b3127919b/raw/f546faea68f4149c06cca88fa67ace07a3758268/QEMU_EFI-cb438b9-edk2-stable202011-with-extra-resolutions.tar.gz

    さらに解像度を追加するなど、ソースコードからビルドする場合は以下を参照のこと。

  7. pflash イメージを作って、画面サイズなどを設定する不揮発なストレージを準備する

    QEMU_EFI-....tar.gz をダウンロードしたディレクトリで以下を実行。

    cd ~/Downloads
    tar xzvf QEMU_EFI-*.tar.gz
    dd if=/dev/zero of=pflash0.img bs=1m count=64
    dd if=/dev/zero of=pflash1.img bs=1m count=64
    dd if=QEMU_EFI.fd of=pflash0.img conv=notrunc
    dd if=QEMU_VARS.fd of=pflash1.img conv=notrunc
    
    • このステップは省略可能。その場合は次のステップで -drive ...,if=pflash,... のかわりに -bios ~/Downloads/QEMU_EFI.fd を指定すること。ただし、EFI での変更が保存されなくなります。
  8. Windows 10 on ARM Insider Preview をダウンロードする

    https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewARM64

  9. VHDX から qcow2 に変換する

    VHDX のままだとかなりの頻度でイメージが壊れる印象があるので qcow2 に変換しておく。

    qemu-img convert -p -O qcow2 ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_21286.VHDX ~/Downloads/Windows10.qcow2
    
  10. Windows 10 を起動する

    ./qemu-system-aarch64 \
      -monitor stdio \
      -M virt,highmem=off \
      -accel hvf \
      -cpu cortex-a72 \
      -smp 4 \
      -m 4096 \
      -drive file=~/Downloads/pflash0.img,format=raw,if=pflash,readonly=on \
      -drive file=~/Downloads/pflash1.img,format=raw,if=pflash \
      -device ramfb \
      -device qemu-xhci \
      -device usb-kbd \
      -device usb-tablet \
      -device intel-hda \
      -device hda-duplex \
      -nic user,model=virtio \
      -drive file=~/Downloads/Windows10.qcow2,format=qcow2,if=none,id=boot,cache=writethrough \
      -device nvme,drive=boot,serial=boot
    
    • イメージへのパスなどは適宜修正してください。
    • TianoCore のロゴが出ている時に ESC を押して、Device ManagerOVMF Platform ConfigurationChange Preferred Resolution for Next Boot と進めて解像度を変更できます。
    • 解像度を追加するには、下記の「EDK II の OVMF EFI イメージをビルドする」に従って OvmfPkg/QemuRamfbDxe/QemuRamfb.c を変更し、新しい QEMU_EFI.fd を作ってください。
    • -device usb-mouse より -device usb-tablet を使うことでマウスカーソルがロックされなくなり使いやすくなります。
    • -device intel-hda -device hda-duplex でオーディオが使えるようになります。
    • -nic user,model=virtio がネットワークインターフェイスです。有効にするには以下を参照してください。

インターネットに接続する

VirtIO NIC は標準では有効にならないので、デバイスドライバを入れる必要がある。

  1. VirtIO デバイスドライバの ISO を Fedora Project からダウンロード。

    https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.190-1/virtio-win-0.1.190.iso

  2. デバイスドライバの ISO をマウント

    qemu-system-aarch64 のオプションに以下を追加する。

    -drive file=~/Downloads/virtio-win-0.1.190.iso,media=cdrom,if=none,id=drivers \
    -device usb-storage,drive=drivers
    

    イメージへのパスなどは適宜修正してください。

  3. デバイスドライバの署名検証を無効にする

    Windows を起動して Windows スタートボタン を右クリック、Command Prompt (Admin) を選択。

    bcdedit を使ってテスト署名されたデバイスドライバを有効にする。

    bcdedit.exe -set TESTSIGNING ON
    

    このあと Windows を再起動すること。

    詳細はこちらを参照のこと。

  4. デバイスドライバのインストール

    Windows が再度起動したら Windows スタートボタン を右クリック、Device Manager を選択。

    Device Manager のウィンドウで、View メニューの Devices by Connection を選択。

    デバイスのツリーから、ACPU ARM64-based PCMicrosoft ACPI-Compliant SystemPCI Express Root Complex と選択してその中にある Unknown device を探す。 (Unknown device はデバイスのツリーに沢山あるけれど、PCI Express Root Complexの下にあるのが、VirtIO NIC。)

    該当の Unknown device を右クリックして、Update Drivers を選択、Browse my computer for drivers を選んで、D:\NetKVM\w10\ARM64 を指定。

    Next をクリックして Red Hat VertIO Ethernet Adapter をインストール。

ディスクイメージをを縮小する

ディスクイメージである Windows10.qcow2 ファイルは Windows Update などをすると容量まで大きくなる可能性があり、たとえファイルを削除してもディスクイメージのサイズは減りません。

そのため、ディスクサイズが大きくなりすぎた場合などは使用していない領域を開放する必要があります。

  1. Windows 10に付属の Defragment and Optimize Drives で、C: ドライブを Optimize する。

  2. SDelete をダウンロードする。SDelete64a -z C: を Administrator Command Prompt で実行し、使用していない領域をゼロで埋める。 このコマンドの実行はしばらくかかります。この時、ディスクイメージがとても大きくなるので Mac の空き容量に注意。

  3. Windows を終了して、以下のコマンドを Mac で実行する。 このコマンドの実行はしばらくかかります。また縮小したディスクイメージは別に作られるので Mac の空き容量に注意。

    qemu-img convert -O qcow2 ~/Downloads/Windows10.qcow2 ~/Downloads/Windows10_compacted.qcow2
    
  4. Windows10.qcow2 を縮小した Windows10_compacted.qcow2 で置き換え。

Ubuntu Server for ARM64 を動かす

ARM 版 Windows 10 を動かす手順に従って QEMU を準備して、Ubuntu Server for ARM64 をダウンロードしてインストールします。

  1. 上記の手順 1 から 7 までに従って QEMU を準備する。

  2. 空のディスクイメージを作成する。

    ./qemu-img create -f qcow2 ~/Downloads/ubuntu.qcow2 40G 
    
  3. Ubuntu Server for ARM64 をダウンロードする。

    https://ubuntu.com/download/server/arm

  4. Ubuntu Server for ARM をインストールする。

    ./qemu-system-aarch64 \
      -monitor stdio \
      -M virt,highmem=off \
      -accel hvf \
      -cpu cortex-a72 \
      -smp 4 \
      -m 4096 \
      -drive file=~/Downloads/pflash0.img,format=raw,if=pflash,readonly=on \
      -drive file=~/Downloads/pflash1.img,format=raw,if=pflash \
      -device virtio-gpu-pci \
      -display default,show-cursor=on \
      -device qemu-xhci \
      -device usb-kbd \
      -device usb-tablet \
      -device intel-hda \
      -device hda-duplex \
      -drive file=~/Downloads/ubuntu.qcow2,if=virtio,cache=writethrough \
      -cdrom ~/Downloads/ubuntu-20.04.1-live-server-arm64.iso
    
    • 指示に従ってインストールしたあとは -cdrom は不要です。

EDK II の OVMF EFI イメージをビルドする

上記の手順に従って Ubuntu Server for ARM64 を動かします。

  1. EDK II のソースコードを取ってくる。

    git clone --depth 1 --branch edk2-stable202011 https://github.com/tianocore/edk2.git
    cd edk2
    git submodule update --init --recursive
    

    Hypervisor.framework パッチの制限で xHCI を無効にする必要があれば /ArmVirtPkg/ArmVirtQemu.dsc/ArmVirtPkg/ArmVirtQemuFvMain.fdf.inc にある MdeModulePkg/Bus/Pci/XhciDxe/XhciDxe.inf の行をコメントアウト。たぶん現状は問題ない。

  2. ビルドする

    sudo apt install iasl python3 python3-distutils uuid-dev make g++
    source edksetup.sh
    make -C BaseTools
    build -a AARCH64 -t GCC5 -p ArmVirtPkg/ArmVirtQemu.dsc
    

    Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/FVQEMU_EFI.fdQEMU_VARS.fd ができるはず。

    • これらのファイルを簡単に macOS ホストに取り出すには macOS でリモートアクセスを有効にして scp10.0.2.2 にコピー。

    • x86_64 の環境でビルドする場合は以下のツールチェーンでクロスコンパイル。

      sudo apt install gcc-aarch64-linux-gnu
      env GCC5_AARCH64_PREFIX=aarch64-linux-gnu- build -a AARCH64 -t GCC5 -p ArmVirtPkg/ArmVirtQemu.dsc
      

How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac

Here is easy steps to try Windows 10 on ARM or Ubuntu for ARM64 on your Apple Silicon Mac. Enjoy!

NOTE: that this is current, 2/8/2021 state. I think it will be improved in upcoming a few months.

Running Windows 10 on ARM

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

    xcode-select --install
    
  2. Install ARM64 Homebrew and QEMU dependencies.

    If you already installed x86_64 Homebrew in /usr/local, please uninstall it. It's not possible to build QEMU with x86_64 Homebrew

    https://brew.sh/

    /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
    brew install ninja pkgconfig glib pixman
    
  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 made.

    cd qemu
    git checkout d0dddab40e -b wip/hvf
    curl 'https://patchwork.kernel.org/series/418581/mbox/'|git am --3way
    
  5. Build QEMU

    mkdir build
    cd build
    ../configure --target-list=aarch64-softmmu --enable-cocoa
    make -j
    
  6. Download pre-build EDK II OVMF EFI image for QEMU.

    This EFI image is built from stable202011 tag with additional resolutions in QemuRamfb.c.

    https://gist.github.com/niw/4f1f9bb572f40d406866f23b3127919b/raw/f546faea68f4149c06cca88fa67ace07a3758268/QEMU_EFI-cb438b9-edk2-stable202011-with-extra-resolutions.tar.gz

    To build it from the source code for adding more resolutions, see the following section.

  7. Prepare pflash for non-volatile variable store, such as screen resolution.

    In the directory where you downloaded QEMU_EFI-....tar.gz, run following commands.

    cd ~/Downloads
    tar xzvf QEMU_EFI-*.tar.gz
    dd if=/dev/zero of=pflash0.img bs=1m count=64
    dd if=/dev/zero of=pflash1.img bs=1m count=64
    dd if=QEMU_EFI.fd of=pflash0.img conv=notrunc
    dd if=QEMU_VARS.fd of=pflash1.img conv=notrunc
    
    • This step is optional, you can use -bios ~/Downloads/QEMU_EFI.fd instead of -drive ...if=pflash lines in the next step, but in that case, any changes in EFI will not be persistent.
  8. Download Windows 10 on ARM Insider Preview

    https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewARM64

  9. Convert VHDX downloaded Windows image to qcow2 format

    It seems that VHDX often gets broken while it is being used, so probably it is better to convert it to qcow2 format before using it.

    qemu-img convert -p -O qcow2 ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_21286.VHDX ~/Downloads/Windows10.qcow2
    
  10. Run Windows 10

    ./qemu-system-aarch64 \
      -monitor stdio \
      -M virt,highmem=off \
      -accel hvf \
      -cpu cortex-a72 \
      -smp 4 \
      -m 4096 \
      -drive file=~/Downloads/pflash0.img,format=raw,if=pflash,readonly=on \
      -drive file=~/Downloads/pflash1.img,format=raw,if=pflash \
      -device ramfb \
      -device qemu-xhci \
      -device usb-kbd \
      -device usb-tablet \
      -device intel-hda \
      -device hda-duplex \
      -nic user,model=virtio \
      -drive file=~/Downloads/Windows10.qcow2,format=qcow2,if=none,id=boot,cache=writethrough \
      -device nvme,drive=boot,serial=boot
    
    • Please modify each path to the image depends on your environment.
    • Hit ESC while you see TianoCore, then Device Manager, OVMF Platform Configuration, Change Preferred Resolution for Next Boot to change screen resolution.
    • To add more resolutions, follow "Build EDK II OVMF EFI image from the source code" below and modify OvmfPkg/QemuRamfbDxe/QemuRamfb.c then build new QEMU_EFI.fd.
    • Use -device usb-tablet instead of -device usb-mouse allows transparently moving mouse cursor.
    • -device intel-hda -device hda-duplex to enable audio.
    • -nic user,model=virtio is the network interface. To enable it, see the following section.

Enable the internet

VirtIO NIC is not enabled by default. To make it works, you need to

device driver.

  1. Download VirtIO device drivers ISO from Fedora Project.

    https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.190-1/virtio-win-0.1.190.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 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.

Compact disk image

The disk image, Windows10.qcow2, can be getting bigger as using Windows, especially after Windows Update, even if you delete files.

If the disk image is too big, you may want to compact it to release free space.

  1. Use Defragment and Optimize Drives coming with Windows 10 and optimize C: drive.

  2. Download SDelete. Run SDelete64a -z C: by using Administrator Command Prompt to zero-fill free space. This may take a while. While running this command, the disk image can be bigger, so be sure Mac have enough free space.

  3. Shutdown Windows, then run next command on Mac. This may take a while. Since this command creates compacted disk image, so be sure Mac has enough free space.

    qemu-img convert -O qcow2 ~/Downloads/Windows10.qcow2 ~/Downloads/Windows10_compacted.qcow2
    
  4. Replace Windows10.qcow2 by compacted Windows10_compacted.qcow2.

Running Ubuntu Server for ARM64

Follow the same steps for Windows 10 to prepare QEMU, then download Ubuntu Server for ARM64 and install it.

  1. Follow previous steps from 1. to 7. to prepare QEMU.

  2. Create an empty disk image.

    ./qemu-img create -f qcow2 ~/Downloads/ubuntu.qcow2 40G 
    
  3. Download Ubuntu Server for ARM64

    https://ubuntu.com/download/server/arm

  4. Install Ubuntu Server for ARM

    ./qemu-system-aarch64 \
      -monitor stdio \
      -M virt,highmem=off \
      -accel hvf \
      -cpu cortex-a72 \
      -smp 4 \
      -m 4096 \
      -drive file=~/Downloads/pflash0.img,format=raw,if=pflash,readonly=on \
      -drive file=~/Downloads/pflash1.img,format=raw,if=pflash \
      -device virtio-gpu-pci \
      -display default,show-cursor=on \
      -device qemu-xhci \
      -device usb-kbd \
      -device usb-tablet \
      -device intel-hda \
      -device hda-duplex \
      -drive file=~/Downloads/ubuntu.qcow2,if=virtio,cache=writethrough \
      -cdrom ~/Downloads/ubuntu-20.04.1-live-server-arm64.iso
    
    • Follow instruction to install Ubuntu Server. Once it's installed, -cdrom argument is not needed.

Build EDK II OVMF EFI image from the source code

Follow the previous instructions to run Ubuntu Server for ARM64.

  1. Checkout EDK II source code.

    git clone --depth 1 --branch edk2-stable202011 https://github.com/tianocore/edk2.git
    cd edk2
    git submodule update --init --recursive
    

    You may want 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. Probably this is no longer needed.

  2. Build it.

    sudo apt install iasl python3 python3-distutils uuid-dev make g++
    source edksetup.sh
    make -C BaseTools
    build -a AARCH64 -t GCC5 -p ArmVirtPkg/ArmVirtQemu.dsc
    

    Then, you will get QEMU_EFI.fd and QEMU_VARS.fd in Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/FV.

    • The easiest way to take these files to the host macOS, run Remote Login on macOS then scp these to 10.0.2.2.

    • To build these on x86_64 environment, use following toolchain to cross compile.

      sudo apt install gcc-aarch64-linux-gnu
      env GCC5_AARCH64_PREFIX=aarch64-linux-gnu- build -a AARCH64 -t GCC5 -p ArmVirtPkg/ArmVirtQemu.dsc
      
@fcicq

This comment has been minimized.

Copy link

@fcicq fcicq commented Nov 30, 2020

1 (OP already updated) patch v2 is released https://lists.gnu.org/archive/html/qemu-devel/2020-11/msg06886.html
2 testsigning is NOT required for virtio drivers for 19H2 or earlier windows. "-cpu max" might be better or maybe https://gist.github.com/KhaosT/ffc2d04f6137aa4ce4cc0897415f76e9.
3 imbushuo's patch for p-core binding imbushuo/qemu@70b95c7
4 you can find ESD images for windows 10 stable releases (search clientbusiness_vol_a64fre_en-us). but in order to test x64 emulation maybe next month, have to stay with vhdx.
5 for testsigning issue, lets blame MS or RedHat for https://docs.microsoft.com/en-us/windows-hardware/drivers/install/deprecation-of-software-publisher-certificates-and-commercial-release-certificates (more context: https://www.osr.com/blog/2020/10/15/microsoft-driver-updates-allowed-win7-win8/ )

@armandsarkani

This comment has been minimized.

Copy link

@armandsarkani armandsarkani commented Nov 30, 2020

I run into an error when trying to run make -j for QEMU (step 5). The build process fails at qemu-system-aarch64-unsigned with an ld: symbol(s) not found for architecture arm64. Anyone know how to fix this so I can build QEMU?

@kjwamlex

This comment has been minimized.

Copy link

@kjwamlex kjwamlex commented Nov 30, 2020

Hm, I'm getting:
qemu-system-aarch64:~/Downloads/Windows10.VHDX,if=none,id=boot: drive with bus=0, unit=0 (index=0) exists

Not sure what to do from here...

@armandsarkani

This comment has been minimized.

Copy link

@armandsarkani armandsarkani commented Nov 30, 2020

@kjwamlex were you able to successfully build QEMU? I'm stuck on this step

@AlickH

This comment has been minimized.

Copy link

@AlickH AlickH commented Nov 30, 2020

Finally end up with error message:

qemu-system-aarch64: -accel hvf: invalid accelerator hvf
@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Nov 30, 2020

@fcicq Thanks, I will follow up what you mentioned and update doc later, testsigning on was however needed to me or Windows prevents me to install vertio nic driver.

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Nov 30, 2020

@armandsarkani probably unrelated but I remember actually I had to chmod 755 scripts/entitlement.sh to make script works to sign and give entitlement for qemu-system-aarch64-unsigned.

@SIDmao probably you didn't apply Hypervisor.framework patch?

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Nov 30, 2020

@kjwamlex do you have any other -drive option that conflicts with it or probably wrong path to vhdx?

@kjwamlex

This comment has been minimized.

Copy link

@kjwamlex kjwamlex commented Nov 30, 2020

The path to vhdx is exactly the same as the one you've written above. I had to put a space between file= and the actual path to make it recognize it though. There weren't other -drive options I added.

@jonmasters

This comment has been minimized.

Copy link

@jonmasters jonmasters commented Nov 30, 2020

@armandsarkani you're building using the x86 toolchain, ports, or homebrew. You need to be using the arm64 version

@kjwamlex

This comment has been minimized.

Copy link

@kjwamlex kjwamlex commented Nov 30, 2020

It seems like Hypervisor should be enabled... I think it's missing from your tutorial?

@armandsarkani

This comment has been minimized.

Copy link

@armandsarkani armandsarkani commented Nov 30, 2020

@armandsarkani probably unrelated but I remember actually I had to chmod 755 scripts/entitlement.sh to make script works to sign and give entitlement for qemu-system-aarch64-unsigned.

Thanks. I tried that and I got the same error.

@jonmasters I am building from source, exactly following the steps.

@imbushuo

This comment has been minimized.

Copy link

@imbushuo imbushuo commented Dec 1, 2020

The v2 patchset fixes WFI/WFE so CPU usage is much better:

image

Windows will mandate Microsoft signing for kernel drivers from 2021, therefore testsigning is required (the change is already present in recent Insider Preview versions.)

I would suggest using writethrough cache policy to avoid potential filesystem corruptions (I can reliably reproduce the issue, trying to understand what happened right now.) It has implication to the performance but maintains filesystem integrity at this moment:

-drive file=~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.VHDX,if=none,id=boot,cache=writethrough
@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Dec 1, 2020

@imbushuo amazing!!! appreciate your comments, I had filesystem corruptions a few times while I was testing as well, I will update instructions soon.

@jmcarbo

This comment has been minimized.

Copy link

@jmcarbo jmcarbo commented Dec 1, 2020

  • My problem is that ../configure keeps detecting host machine as x86_64 although uname -m states arm64. Need to debug why.

  • To apply patch v2

curl https://patchew.org/QEMU/20201130030723.78326-1-agraf@csgraf.de/mbox|git am
@imbushuo

This comment has been minimized.

Copy link

@imbushuo imbushuo commented Dec 1, 2020

My problem is that ../configure keeps detecting host machine as x86_64 although uname -m states arm64. Need to debug why.

@jmcarbo your system might have either ninja, meson or Python3 overridden by the x86_64 version.

@jmcarbo

This comment has been minimized.

Copy link

@jmcarbo jmcarbo commented Dec 1, 2020

@imbushuo thanks a lot for pointing out. It was python3 from homebrew x86_64 that caused the conflict.

@jmcarbo

This comment has been minimized.

Copy link

@jmcarbo jmcarbo commented Dec 1, 2020

@niw you have a typo in ~/Downlaods/QEMU_EFI.fd it's Downloads

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Dec 1, 2020

@jmcarbo Fixed 😅

@datavisoryuechen

This comment has been minimized.

Copy link

@datavisoryuechen datavisoryuechen commented Dec 1, 2020

@jmcarbo Have you finished all the steps and successfully run Windows?

@luisrh01

This comment has been minimized.

Copy link

@luisrh01 luisrh01 commented Dec 1, 2020

Windows working with version 2 patch, but cannot change resolution from 800x600, has anyone found a solution yet?

Also, I added -device usb-tablet \ to the configuration to allow for easier use in a working system (transparently move mouse to Windows 10)

Thanks for all your hard work!

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Dec 1, 2020

@luisrh01 It's possible to create -pflash instead of -bios and change resolution in EFI. I will update instruction to add these steps. Using usb-table is nice idea!

@luisrh01

This comment has been minimized.

Copy link

@luisrh01 luisrh01 commented Dec 1, 2020

@luisrh01 It's possible to create -pflash instead of -bios and change resolution in EFI. I will update instruction to add these steps. Using usb-table is nice idea!

Thanks! I would appreciate it!

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Dec 1, 2020

@luisrh01 Updated!

@luisrh01

This comment has been minimized.

Copy link

@luisrh01 luisrh01 commented Dec 2, 2020

You can add audio with:

-device intel-hda -device hda-duplex

@luisrh01

This comment has been minimized.

Copy link

@luisrh01 luisrh01 commented Dec 2, 2020

@luisrh01 Updated!

Awesome! I get 1024x768 now. Much appreciated!

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Dec 2, 2020

@luisrh01 Thanks, updated with audio!

@datavisoryuechen

This comment has been minimized.

Copy link

@datavisoryuechen datavisoryuechen commented Dec 2, 2020

@niw I have finished installing Windows on M1 macbook by your steps. But Windows disc size is small. Do you know how to enlarge the Windows disc size? Thanks

@jmcarbo

This comment has been minimized.

Copy link

@jmcarbo jmcarbo commented Dec 2, 2020

@jmcarbo Have you finished all the steps and successfully run Windows?

Yes indeed, working.

@datavisoryuechen

This comment has been minimized.

Copy link

@datavisoryuechen datavisoryuechen commented Dec 2, 2020

@niw @jmcarbo I have finished installing Windows on M1 macbook by your steps. But Windows disc size is small. Do you know how to enlarge the Windows disc size? Thanks

@jmcarbo

This comment has been minimized.

Copy link

@jmcarbo jmcarbo commented Dec 2, 2020

@niw @jmcarbo I have finished installing Windows on M1 macbook by your steps. But Windows disc size is small. Do you know how to enlarge the Windows disc size? Thanks

Try

qemu-img convert ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.VHDX -O qcow2 dest.qcow2
qemu-img resize -f qcow2 dest.qcow2 +100G
@datavisoryuechen

This comment has been minimized.

Copy link

@datavisoryuechen datavisoryuechen commented Dec 2, 2020

@jmcarbo Many Thanks

@ksjazmati

This comment has been minimized.

Copy link

@ksjazmati ksjazmati commented Dec 2, 2020

Currently stuck on no such file or directory: ./qemu-system-aarch64 when trying to run Windows. Anyone have any ideas?

@datavisoryuechen

This comment has been minimized.

Copy link

@datavisoryuechen datavisoryuechen commented Dec 2, 2020

@ksjazmati qemu-system-aarch64 is in the build folder after make -j

@datavisoryuechen

This comment has been minimized.

Copy link

@datavisoryuechen datavisoryuechen commented Dec 2, 2020

@jmcarbo @niw I tried to install some apps in Windows on M1 macbook but failed due to OpenGL 2.0 not supported and need to update graphics driver. Any ideas? Thanks

@woachk

This comment has been minimized.

Copy link

@woachk woachk commented Dec 2, 2020

@datavisoryuechen there's no graphics acceleration.

However to enable OpenGL with software rendering, you can download the appx of the OpenGL and OpenCL Compatibility Pack and install those through PowerShell.

@NattyNarwhal

This comment has been minimized.

Copy link

@NattyNarwhal NattyNarwhal commented Dec 3, 2020

I'm getting a BSoD installing the virtio network drivers, always KMODE_EXCEPTION_NOT_HANDLED. Tried four permutations of master/that specific commit in there with the v1/v2 version of the patchset.

@Aloereed

This comment has been minimized.

Copy link

@Aloereed Aloereed commented Dec 3, 2020

I'm getting a BSoD installing the virtio network drivers, always KMODE_EXCEPTION_NOT_HANDLED. Tried four permutations of master/that specific commit in there with the v1/v2 version of the patchset.

the same situation happened here.

@Aloereed

This comment has been minimized.

Copy link

@Aloereed Aloereed commented Dec 3, 2020

I'm getting a BSoD installing the virtio network drivers, always KMODE_EXCEPTION_NOT_HANDLED. Tried four permutations of master/that specific commit in there with the v1/v2 version of the patchset.

I found that 0.1.190 ver will be fine. 0.1.185 is not okay.

@nonarkitten

This comment has been minimized.

Copy link

@nonarkitten nonarkitten commented Dec 3, 2020

I'm getting a BSoD installing the virtio network drivers, always KMODE_EXCEPTION_NOT_HANDLED. Tried four permutations of master/that specific commit in there with the v1/v2 version of the patchset.

the same situation happened here.

Grab this one instead: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/archive-virtio/virtio-win-0.1.190-1/virtio-win-0.1.190.iso

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Dec 3, 2020

Thanks, I updated the link.

@ReturnRei

This comment has been minimized.

Copy link

@ReturnRei ReturnRei commented Dec 4, 2020

@niw さん、問題:qemu-system-aarch64: -accel hvf: invalid accelerator hvf
I used ”curl https://patchwork.kernel.org/series/394901/mbox/\ | git apply -v” instead of "git am"

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Dec 4, 2020

@ReturnRei I think you installed x86_64 Homebrew? any such makes build confused so recommend to disable them. Also use git am or it may not able to change files’ permission correctly.

@ReturnRei

This comment has been minimized.

Copy link

@ReturnRei ReturnRei commented Dec 5, 2020

@niw It works now! Thanks
I had an error using git am, it worked for me using "git apply -v"
The problem was active x86 homebrew packages, for a next time do you know what's a clean way to temporarily disable brew packages?

@txlpaul

This comment has been minimized.

Copy link

@txlpaul txlpaul commented Dec 5, 2020

Windows on M1 runs great until I install Visual Studio 2019. I get "Preparing for Automatic Repair" on booting the VM after that which fails every time. Any idea?

@mrkspflr

This comment has been minimized.

Copy link

@mrkspflr mrkspflr commented Dec 5, 2020

hey there! awesome patchwork ;) .. I am able to start setup but run into a no-network-avlbl-so-reboot situation bc it seems that even though I mounted the virtio iso, from script and also from the qemu gui menu it's not accessible in the setup of the vm, basically no drive letter is assigned in win10/arm and the setup seemingly needs an internet connection to proceed otherwise it restarts and I get to same point over and over again. anyway: yeah it's snappy..

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Dec 6, 2020

@txlpaul Probably... VHDX gets broken, it may be better actually to convert it to qcow2 before using downloaded VHDX image.
I updated the instructions and adde that step.

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Dec 6, 2020

@mrkspflr So... you added new -drive ... line for the VirtIO drivers ISO image yet didn’t see D:\ drive?

@mrkspflr

This comment has been minimized.

Copy link

@mrkspflr mrkspflr commented Dec 6, 2020

@niw .. 1 starting qemu (or also w/ ACVM and also w/ UTM same situation)..start boot option progress bar (relatively long) .. 2 win10_arm starting .. marbleindicator.. 3 Hi there lets get a few basic things out of the way screen for setting the keyboardlayout etc .. click next .. "why did my pc restart? there's a problem that's keeping us from getting your pc ready to use but we think an update will help to get this working again. Here's how to get the update bla" basically instructions for network connectivity ... 4 click next . . "just a moment" reboots ... goto 3

maybe I'll try to convert to qcow2 - I downloaded the Win10/ARM Version from Microsoft Insider Program yd, if I open up cmd prompt > ver > it says Microsoft Windows Version 10.0.20231.1000

@NattyNarwhal

This comment has been minimized.

Copy link

@NattyNarwhal NattyNarwhal commented Dec 6, 2020

I just made a new qcow2 image that used the VHDX as a backing file.

@mrkspflr

This comment has been minimized.

Copy link

@mrkspflr mrkspflr commented Dec 6, 2020

@niw .. 1 starting qemu (or also w/ ACVM and also w/ UTM same situation)..start boot option progress bar (relatively long) .. 2 win10_arm starting .. marbleindicator.. 3 Hi there lets get a few basic things out of the way screen for setting the keyboardlayout etc .. click next .. "why did my pc restart? there's a problem that's keeping us from getting your pc ready to use but we think an update will help to get this working again. Here's how to get the update bla" basically instructions for network connectivity ... 4 click next . . "just a moment" reboots ... goto 3

maybe I'll try to convert to qcow2 - I downloaded the Win10/ARM Version from Microsoft Insider Program yd, if I open up cmd prompt > ver > it says Microsoft Windows Version 10.0.20231.1000


edit: @niw ok this is up and running. things I've changed:

  • redownloaded iso,
  • used ACVM instead of UTM
  • didn't change any regional settings (keyboard layout = US now)
@txlpaul

This comment has been minimized.

Copy link

@txlpaul txlpaul commented Dec 7, 2020

@txlpaul Probably... VHDX gets broken, it may be better actually to convert it to qcow2 before using downloaded VHDX image.
I updated the instructions and adde that step.

Thanks a lot - runs very reliable now. Compiles .NET builds a lot faster than VirtualBox Windows on Intel-Mac. Amazing.

@ShotSkydiver

This comment has been minimized.

Copy link

@ShotSkydiver ShotSkydiver commented Dec 8, 2020

anybody else having problems opening Microsoft Store? I've never been able to get it to launch, it just closes itself a few seconds after opening

@oscarbg

This comment has been minimized.

Copy link

@oscarbg oscarbg commented Dec 8, 2020

thanks for instructions..

@luisrh01

This comment has been minimized.

Copy link

@luisrh01 luisrh01 commented Dec 8, 2020

anybody else having problems opening Microsoft Store? I've never been able to get it to launch, it just closes itself a few seconds after opening

I have not been able to open it either... or mail in Windows 10 ARM

@ChasLui

This comment has been minimized.

Copy link

@ChasLui ChasLui commented Dec 8, 2020

qemu/include/crypto/tlscreds.h:28:10: fatal error: 'gnutls/gnutls.h' file not found
#include <gnutls/gnutls.h>
         ^~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
make: *** [run-ninja] Error 1

@RonerBent

This comment has been minimized.

Copy link

@RonerBent RonerBent commented Dec 11, 2020

anybody else having problems opening Microsoft Store? I've never been able to get it to launch, it just closes itself a few seconds after opening

I have not been able to open it either... or mail in Windows 10 ARM

It won't open at the moment, just sniffed the download app from. my windows client from the store, to download the apps, but it happens, that they have dependencies, that you don't get this easy ... like windows.ui.xaml.2... also trying to figuring out, how to get these, to get Azure VPN Client App working

@woachk

This comment has been minimized.

Copy link

@woachk woachk commented Dec 11, 2020

Microsoft Store and other 32-bit Arm apps will not run, because Apple M1 doesn't support them in hardware.

You'll have to force the x86_32 or x86_64 versions to get installed.

@luisrh01

This comment has been minimized.

Copy link

@luisrh01 luisrh01 commented Dec 12, 2020

Microsoft Store and other 32-bit Arm apps will not run, because Apple M1 doesn't support them in hardware.

You'll have to force the x86_32 or x86_64 versions to get installed.

thanks for the explanation.

@immortalCO

This comment has been minimized.

Copy link

@immortalCO immortalCO commented Dec 13, 2020

How to support higher resolutions like 1920x1080? Does compiling QXL drivers like https://github.com/vrozenfe/qxl-dod in the installed ARM windows work?

@hjmr

This comment has been minimized.

Copy link

@hjmr hjmr commented Dec 19, 2020

You can modify QemuRamfb.c in EDK II and get EFI images with higher resolution. I have tried 1440x900 and 1680x1050 working great.

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Dec 20, 2020

@hjmr Yeah, that works! I updated the instructions and added how to runs Ubuntu for ARM64, so now building EDK can be done on QEMU on M1 Mac itself, then it’s not difficult to change them in ramfb. Also added a few resolutions to prebuild EFI image and updated the link to it.

@ivo-roilev

This comment has been minimized.

Copy link

@ivo-roilev ivo-roilev commented Dec 20, 2020

qemu/include/crypto/tlscreds.h:28:10: fatal error: 'gnutls/gnutls.h' file not found
#include <gnutls/gnutls.h>
         ^~~~~~~~~~~~~~~~~
1 error generated.
ninja: build stopped: subcommand failed.
make: *** [run-ninja] Error 1

../configure --extra-cflags=-I/opt/homebrew/opt/gnutls/include --extra-ldflags=-L/opt/homebrew/opt/gnutls/lib

@leocodeninja

This comment has been minimized.

Copy link

@leocodeninja leocodeninja commented Dec 22, 2020

You can modify QemuRamfb.c in EDK II and get EFI images with higher resolution. I have tried 1440x900 and 1680x1050 working great.

How do you do that?

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Dec 22, 2020

@leocodeninja the one linked from current document is already have these extra resolution. You can also follow the instructions on this page about EDK II to patch and build own version.

@leocodeninja

This comment has been minimized.

Copy link

@leocodeninja leocodeninja commented Dec 22, 2020

@leocodeninja the one linked from current document is already have these extra resolution. You can also follow the instructions on this page about EDK II to patch and build own version.

Works great now! Do you know how I could get the sound working in Windows?

@leocodeninja

This comment has been minimized.

Copy link

@leocodeninja leocodeninja commented Dec 22, 2020

When I try and build the new qemu source with the patch I get:

Applying: hvf: Add hypervisor entitlement to output binaries
Applying: hvf: x86: Remove unused definitions
Applying: hvf: Move common code out
error: patch failed: MAINTAINERS:444
error: MAINTAINERS: patch does not apply
Patch failed at 0003 hvf: Move common code out
hint: Use 'git am --show-current-patch' to see the failed patch
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
@leocodeninja

This comment has been minimized.

Copy link

@leocodeninja leocodeninja commented Dec 22, 2020

I fixed it and got it to build by using this updated patch: https://patchwork.kernel.org/series/400619/mbox/

I had to use
git apply --reject ~/Downloads/hvf-Implement-Apple-Silicon-Support.patch
To get the patch applied

@ovidiy1

This comment has been minimized.

Copy link

@ovidiy1 ovidiy1 commented Dec 24, 2020

I applied the patch, but still cannot compile QEMU, getting this:
[1194/2413] Linking target qemu-io
FAILED: qemu-io
cc -o qemu-io qemu-io.p/qemu-io.c.o -Wl,-dead_strip_dylibs -Wl,-headerpad_max_install_names -Wl,-undefined,error -Wl,-force_load libblock.fa -Wl,-force_load libcrypto.fa -Wl,-force_load libauthz.fa -Wl,-force_load libqom.fa -Wl,-force_load libio.fa -framework CoreFoundation -framework IOKit -fstack-protector-strong libqemuutil.a libblock.fa libcrypto.fa libauthz.fa libqom.fa libio.fa @block.syms -Wl,-framework -Wl,CoreFoundation -Wl,-framework -Wl,CoreFoundation -L/opt/local/lib -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -L/opt/local/lib -lgio-2.0 -lgobject-2.0 -lglib-2.0 -lintl -lutil -L/usr/local/opt/libgcrypt/lib -lgcrypt -L/usr/local/opt/libgpg-error/lib -lgpg-error -lm -Wl,-framework -Wl,CoreFoundation -L/opt/local/lib -lgthread-2.0 -lglib-2.0 -lintl -L/opt/local/lib -lz -framework IOKit -Wl,-framework -Wl,CoreFoundation -L/opt/local/lib -lgthread-2.0 -lglib-2.0 -lintl -framework CoreFoundation -lcurl -lbz2 -L/usr/local/opt/libgcrypt/lib -lgcrypt -L/usr/local/opt/libgpg-error/lib -lgpg-error -lpam
ld: warning: ignoring file /usr/local/opt/libgcrypt/lib/libgcrypt.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
ld: warning: ignoring file /usr/local/opt/libgpg-error/lib/libgpg-error.dylib, building for macOS-arm64 but attempting to link with file built for macOS-x86_64
Undefined symbols for architecture arm64:
"_gcry_check_version", referenced from:
_qcrypto_init in libqemuutil.a(crypto_init.c.o)
"_gcry_cipher_close", referenced from:
_qcrypto_cipher_new in libcrypto.fa(crypto_cipher.c.o)
_qcrypto_gcrypt_ctx_free in libcrypto.fa(crypto_cipher.c.o)
_qcrypto_gcrypt_xts_ctx_free in libcrypto.fa(crypto_cipher.c.o)
"_gcry_cipher_ctl", referenced from:
_qcrypto_gcrypt_setiv in libcrypto.fa(crypto_cipher.c.o)
"_gcry_cipher_decrypt", referenced from:
_qcrypto_gcrypt_decrypt in libcrypto.fa(crypto_cipher.c.o)
_qcrypto_gcrypt_xts_wrapd in libcrypto.fa(crypto_cipher.c.o)
"_gcry_cipher_encrypt", referenced from:
_qcrypto_gcrypt_encrypt in libcrypto.fa(crypto_cipher.c.o)
_qcrypto_gcrypt_xts_wrape in libcrypto.fa(crypto_cipher.c.o)
"_gcry_cipher_get_algo_blklen", referenced from:
_qcrypto_cipher_new in libcrypto.fa(crypto_cipher.c.o)
"_gcry_cipher_open", referenced from:
_qcrypto_cipher_new in libcrypto.fa(crypto_cipher.c.o)
"_gcry_cipher_setctr", referenced from:
_qcrypto_gcrypt_ctr_setiv in libcrypto.fa(crypto_cipher.c.o)
"_gcry_cipher_setiv", referenced from:
_qcrypto_gcrypt_setiv in libcrypto.fa(crypto_cipher.c.o)
"_gcry_cipher_setkey", referenced from:
_qcrypto_cipher_new in libcrypto.fa(crypto_cipher.c.o)
"_gcry_control", referenced from:
_qcrypto_init in libqemuutil.a(crypto_init.c.o)
"_gcry_kdf_derive", referenced from:
_qcrypto_pbkdf2 in libcrypto.fa(crypto_pbkdf-gcrypt.c.o)
"_gcry_md_close", referenced from:
_qcrypto_gcrypt_hash_bytesv in libcrypto.fa(crypto_hash-gcrypt.c.o)
"_gcry_md_get_algo_dlen", referenced from:
_qcrypto_gcrypt_hash_bytesv in libcrypto.fa(crypto_hash-gcrypt.c.o)
"_gcry_md_open", referenced from:
_qcrypto_gcrypt_hash_bytesv in libcrypto.fa(crypto_hash-gcrypt.c.o)
"_gcry_md_read", referenced from:
_qcrypto_gcrypt_hash_bytesv in libcrypto.fa(crypto_hash-gcrypt.c.o)
"_gcry_md_write", referenced from:
_qcrypto_gcrypt_hash_bytesv in libcrypto.fa(crypto_hash-gcrypt.c.o)
"_gcry_randomize", referenced from:
_qcrypto_random_bytes in libqemuutil.a(crypto_random-gcrypt.c.o)
"_gcry_strerror", referenced from:
_qcrypto_pbkdf2 in libcrypto.fa(crypto_pbkdf-gcrypt.c.o)
_qcrypto_cipher_new in libcrypto.fa(crypto_cipher.c.o)
_qcrypto_gcrypt_encrypt in libcrypto.fa(crypto_cipher.c.o)
_qcrypto_gcrypt_decrypt in libcrypto.fa(crypto_cipher.c.o)
_qcrypto_gcrypt_setiv in libcrypto.fa(crypto_cipher.c.o)
_qcrypto_gcrypt_ctr_setiv in libcrypto.fa(crypto_cipher.c.o)
_qcrypto_gcrypt_hash_bytesv in libcrypto.fa(crypto_hash-gcrypt.c.o)
...
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
make[1]: *** [run-ninja] Error 1
make: *** [all] Error 2

@hjmr

This comment has been minimized.

Copy link

@hjmr hjmr commented Dec 25, 2020

Seems like you are trying to link libraries (openssl?) for x86_64. You need arm64 libraries to get arm64 executables.

@ovidiy1

This comment has been minimized.

Copy link

@ovidiy1 ovidiy1 commented Dec 25, 2020

thanks, but... how?

@hjmr

This comment has been minimized.

Copy link

@hjmr hjmr commented Dec 25, 2020

Please specify libraries, not in "/usr/local", but in "/opt/homebrew" if you are using Homebrew. In the case of MacPorts, I'm sorry that I don't know much about it. According to documents on the MacPorts' site, you seem to need uninstalling and re-installing causal libraries. Then, MacPorts will install the arm64 library if available. Hope this works well.

@sudhakar-muthumani

This comment has been minimized.

Copy link

@sudhakar-muthumani sudhakar-muthumani commented Dec 25, 2020

qemu-system-aarch64: -accel hvf: invalid accelerator hvf

patch error: curl: (23) Failed writing body (0 != 16384)

@IamVigneshC

This comment has been minimized.

Copy link

@IamVigneshC IamVigneshC commented Dec 25, 2020

I am getting error
iamvignesh@Vigneshs-MacBook-Pro Downloads % qemu-img convert -p -O qcow2 ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.VHDX ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.qcow2
zsh: command not found: qemu-img

though found this directory qemu/build/ -> qemu-img

@hjmr

This comment has been minimized.

Copy link

@hjmr hjmr commented Dec 26, 2020

@sudhakar-muthumani You can get a list of supported accelerators by "qemu-system-aarch64 -accel help". Please make sure if "hvf" is in the list.

@hjmr

This comment has been minimized.

Copy link

@hjmr hjmr commented Dec 26, 2020

@IamVigneshC Please make sure the environment variable PATH includes the location of "qemu-img", or you can specify the location of "qemu-img" like "./qemu/build/qemu-img".

@sudhakar-muthumani

This comment has been minimized.

Copy link

@sudhakar-muthumani sudhakar-muthumani commented Dec 26, 2020

@sudhakar-muthumani You can get a list of supported accelerators by "qemu-system-aarch64 -accel help". Please make sure if "hvf" is in the list.

hvf is not in the list it seems how to get that. Any ideas of doing it? Thanks in advance

@wrobelda

This comment has been minimized.

Copy link

@wrobelda wrobelda commented Dec 28, 2020

Making the git-am use 3-way mode of patching will fix the MAINTAINERS file rejects:

curl 'https://patchwork.kernel.org/series/400619/mbox/' |git am -3

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Dec 28, 2020

@wrobelda Ah, nice, master seems advanced and patch conflicts now probably. Let me update it.

@sudhakar-muthumani

This comment has been minimized.

Copy link

@sudhakar-muthumani sudhakar-muthumani commented Dec 29, 2020

curl: (23) Failed writing body (0 != 16384)
when applying patch. any ways to solve it?

@hjmr

This comment has been minimized.

Copy link

@hjmr hjmr commented Dec 30, 2020

@sudhakar-muthumani Please try to use UTM.app. It's much more easy to use.

@noenthu

This comment has been minimized.

Copy link

@noenthu noenthu commented Jan 1, 2021

@niw Thanks for putting this together. Any idea what it would take to get a raspbian-jessie 32bit image running on the m1 mac using QEMU?

@NattyNarwhal

This comment has been minimized.

Copy link

@NattyNarwhal NattyNarwhal commented Jan 1, 2021

M1 doesn't support aarch32 at all, it'll have to be using emulation instead of virtualization.

@noenthu

This comment has been minimized.

Copy link

@noenthu noenthu commented Jan 3, 2021

@NattyNarwhal, Using the aarch64 ubuntu server with QEMU on M1, I am then able to run the raspbian os on the ubuntu server following steps at https://azeria-labs.com/emulate-raspberry-pi-with-qemu/

However, not directly on the M1 with QEMU.

@evennotodd

This comment has been minimized.

Copy link

@evennotodd evennotodd commented Jan 3, 2021

How would I apply this patch to a QEMU install?

@hjmr

This comment has been minimized.

Copy link

@hjmr hjmr commented Jan 5, 2021

  1. Clone QEMU source code.
git clone https://git.qemu.org/git/qemu.git
  1. Apply patches.
cd qemu
git checkout master -b wip/hvf
# Hypervisor.framework patch
curl 'https://patchew.org/QEMU/20201211151300.85322-1-agraf@csgraf.de/mbox' | git am -3
# TCG patch for Apple Silicon host
curl 'https://patchew.org/QEMU/20210105022055.12113-1-j@getutm.app/mbox' | git am -3
# Mirror map JIT memory for TCG
curl 'https://patchew.org/QEMU/20210105171950.415486-1-richard.henderson@linaro.org/mbox' | git am -3
# fix openFile: deprecation on Big Sur
curl 'https://patchew.org/QEMU/20210102150718.47618-1-r.bolshakov@yadro.com/mbox' | git am -3
# some config fixes for macOS
curl 'https://patchew.org/QEMU/20210102125017.41032-1-r.bolshakov@yadro.com/mbox' | git am -3
curl 'https://patchew.org/QEMU/20201230221623.60423-1-chris@hofstaedtler.name/mbox' | git am -3
  1. Build QEMU.
mkdir build
cd build
../configure --target-list=aarch64-softmmu,arm-softmmu,x86_64-softmmu --enable-cocoa
make -j

I have tested Raspberry Pi3 (in 64bit) with the following script:

qemu-system-aarch64 \
  -monitor stdio \
  -M raspi3 \
  -accel tcg,split-wx,tb-size=65536 \
  -display default,show-cursor=on \
  -m 1G \
  -smp 4 \
  -dtb ./RasPi3B/bcm2710-rpi-3-b.dtb \
  -kernel ./RasPi3B/kernel8.img \
  -no-reboot \
  -device usb-kbd \
  -device usb-tablet \
  -device usb-net,netdev=net0 \
  -netdev user,id=net0 \
  -drive file=./RasPi3B/RasPi3B.qcow2,format=qcow2,if=sd \
  -append "console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait"

Hopefully, 32bit emulation will work with qemu-system-arm.

@evennotodd

This comment has been minimized.

Copy link

@evennotodd evennotodd commented Jan 6, 2021

  1. Clone QEMU source code.
git clone https://git.qemu.org/git/qemu.git
  1. Apply patches.
cd qemu
git checkout master -b wip/hvf
# Hypervisor.framework patch
curl 'https://patchew.org/QEMU/20201211151300.85322-1-agraf@csgraf.de/mbox' | git am -3
# TCG patch for Apple Silicon host
curl 'https://patchew.org/QEMU/20210105022055.12113-1-j@getutm.app/mbox' | git am -3
# Mirror map JIT memory for TCG
curl 'https://patchew.org/QEMU/20210105171950.415486-1-richard.henderson@linaro.org/mbox' | git am -3
# fix openFile: deprecation on Big Sur
curl 'https://patchew.org/QEMU/20210102150718.47618-1-r.bolshakov@yadro.com/mbox' | git am -3
# some config fixes for macOS
curl 'https://patchew.org/QEMU/20210102125017.41032-1-r.bolshakov@yadro.com/mbox' | git am -3
curl 'https://patchew.org/QEMU/20201230221623.60423-1-chris@hofstaedtler.name/mbox' | git am -3
  1. Build QEMU.
mkdir build
cd build
../configure --target-list=aarch64-softmmu,arm-softmmu,x86_64-softmmu --enable-cocoa
make -j

I have tested Raspberry Pi3 (in 64bit) with the following script:

qemu-system-aarch64 \
  -monitor stdio \
  -M raspi3 \
  -accel tcg,split-wx,tb-size=65536 \
  -display default,show-cursor=on \
  -m 1G \
  -smp 4 \
  -dtb ./RasPi3B/bcm2710-rpi-3-b.dtb \
  -kernel ./RasPi3B/kernel8.img \
  -no-reboot \
  -device usb-kbd \
  -device usb-tablet \
  -device usb-net,netdev=net0 \
  -netdev user,id=net0 \
  -drive file=./RasPi3B/RasPi3B.qcow2,format=qcow2,if=sd \
  -append "console=ttyAMA0,115200 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait"

Hopefully, 32bit emulation will work with qemu-system-arm.

Do steps 6 and 7 in the guide to run Windows 10 on ARM matter here?

@hjmr

This comment has been minimized.

Copy link

@hjmr hjmr commented Jan 6, 2021

Do steps 6 and 7 in the guide to run Windows 10 on ARM matter here?

Yes. You still need to follow the instructions after steps 6.

@mattfack

This comment has been minimized.

Copy link

@mattfack mattfack commented Jan 16, 2021

I tried to make it work also with focal-desktop-arm64.

I had to use absolute paths for the install/launch of the vm and the vm does not start properly. Guess we have to wait to be able to use a desktop version of Linux.

Great patch though

@hjmr

This comment has been minimized.

Copy link

@hjmr hjmr commented Jan 17, 2021

@mattfack I've tried one from Ubuntu 20.04.01 LTS Daily Build. Not every but some could be installed.

@lingxd

This comment has been minimized.

Copy link

@lingxd lingxd commented Jan 20, 2021

这个方法可以安装ubuntu18.04呢?

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Jan 20, 2021

@lingxd Yeah, logically it should work, try aarch64 iso image, but I didn’t try.

@viniciusartur

This comment has been minimized.

Copy link

@viniciusartur viniciusartur commented Jan 22, 2021

I could test successfully with Ubuntu ARM. Do you think it's possible to run Big Sur having Big Sur ARM as host?

@hjmr

This comment has been minimized.

Copy link

@hjmr hjmr commented Jan 25, 2021

@viniciusartur According to the following article, Apple has radically changed the boot sequence on M1 Macs. Seems it doesn't use EFI. I think it's difficult to boot Big Sur ARM on QEMU for now.
https://eclecticlight.co/2021/01/14/m1-macs-radically-change-boot-and-recovery/

@ramanic

This comment has been minimized.

Copy link

@ramanic ramanic commented Feb 8, 2021

How can I convert network to NAT ? I want the default gateway of windows to be same as my host. Is there anything that I can do with NAT options ?

@niw

This comment has been minimized.

Copy link
Owner Author

@niw niw commented Feb 10, 2021

@ramanic I think you do NOT want to use NAT in that case (join guest in your local network directly, right?) cause it’s NAT-ed by default (user networking.) See https://wiki.qemu.org/Documentation/Networking and other documentations about QEMU networking.

@SebDanielsson

This comment has been minimized.

Copy link

@SebDanielsson SebDanielsson commented Feb 14, 2021

Does anyone have a good tutorial to enable spice/qxl video driver for this? Read somewhere that it enables you to run in retina resolutions.

@conath

This comment has been minimized.

Copy link

@conath conath commented Feb 27, 2021

Thanks, the build instructions for the Tianocore EFI were especially helpful.

@sh4d0wph03n1x

This comment has been minimized.

Copy link

@sh4d0wph03n1x sh4d0wph03n1x commented Mar 8, 2021

@niw Thanks for this!

@fcicq

This comment has been minimized.

Copy link

@fcicq fcicq commented Apr 21, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment