Skip to content

Instantly share code, notes, and snippets.

@ctsrc
Forked from niw/README.en.md
Last active October 9, 2025 20:37
Show Gist options
  • Save ctsrc/a1f57933a2cde9abc0f07be12889f97f to your computer and use it in GitHub Desktop.
Save ctsrc/a1f57933a2cde9abc0f07be12889f97f to your computer and use it in GitHub Desktop.

Revisions

  1. ctsrc revised this gist Aug 3, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -79,7 +79,7 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    qemu-img resize -f raw FreeBSD-13.1-RELEASE-arm64-aarch64.raw +30G
    ```
    By performing this resize *before* you boot the VM for the first time, FreeBSD will automatically adjust the partition size.
    By performing this resize *before* you boot the VM for the first time, FreeBSD will automatically adjust the partition size during first boot.
    8. Run your FreeBSD 13.1-RELEASE for ARM64 VM
  2. ctsrc revised this gist Aug 3, 2022. 1 changed file with 12 additions and 2 deletions.
    14 changes: 12 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -71,10 +71,20 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    unxz -k FreeBSD-13.1-RELEASE-arm64-aarch64.raw.xz
    ```
    7. Run your FreeBSD 13.1-RELEASE for ARM64 VM
    7. Grow the disk image
    After you've decompressed the disk image, it'll be about 5 GiB in size. Depending on what you plan to do the amount of available space may be a bit on the low side. Let's grow the disk image by another 30 GiB.
    ```
    qemu-img resize -f raw FreeBSD-13.1-RELEASE-arm64-aarch64.raw +30G
    ```
    By performing this resize *before* you boot the VM for the first time, FreeBSD will automatically adjust the partition size.
    8. Run your FreeBSD 13.1-RELEASE for ARM64 VM
    ```
    ~/src/qemu/build/qemu-system-aarch64 \
    qemu-system-aarch64 \
    -M virt \
    -accel hvf \
    -cpu host \
  3. ctsrc revised this gist Aug 3, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # Guide: Run FreeBSD 13.1-RELEASE for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)
    # Guide: Run FreeBSD 13.1-RELEASE for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc) with HVF acceleration (Hypervisor.framework)

    ![FreeBSD 13.1-RELEASE for ARM64 boot in QEMU on Apple Silicon Mac screenshot](https://raw.githubusercontent.com/ctsrc/ctsrc/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/ef3d7019735ad9cb8d3af35aa91dfdec7674aa4b.png)

  4. ctsrc revised this gist Aug 3, 2022. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    # How to run FreeBSD 13.1-RELEASE for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)
    # Guide: Run FreeBSD 13.1-RELEASE for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)

    ![FreeBSD 13.1-RELEASE for ARM64 boot in QEMU on Apple Silicon Mac screenshot](https://raw.githubusercontent.com/ctsrc/ctsrc/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/ef3d7019735ad9cb8d3af35aa91dfdec7674aa4b.png)

  5. ctsrc revised this gist Aug 3, 2022. 1 changed file with 14 additions and 1 deletion.
    15 changes: 14 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -16,9 +16,22 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    https://brew.sh/
    ```
    ```zsh
    brew install qemu
    ```
    ```zsh
    rehash
    ```
    ```zsh
    qemu-system-aarch64 --version
    ```
    ```text
    QEMU emulator version 7.0.0
    Copyright (c) 2003-2022 Fabrice Bellard and the QEMU Project developers
    ```
    3. Download pre-build EDK II OVMF EFI image for QEMU.
  6. ctsrc revised this gist Aug 3, 2022. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -90,7 +90,7 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    (Installed via Homebrew.)
    **Events per second: 25445903.16**
    **Events per second: 25,445,903.16** or ~25.4 Mio events/sec
    ```zsh
    sysbench cpu --threads=2 run
    @@ -133,7 +133,7 @@ Threads fairness:

    (Installed via FreeBSD ports.)

    **Events per second: 15467914.47** or ~15.4 Mio events/sec
    **Events per second: 15,467,914.47** or ~15.5 Mio events/sec

    ```csh
    sysbench cpu --threads=2 run
  7. ctsrc revised this gist Aug 3, 2022. 1 changed file with 88 additions and 0 deletions.
    88 changes: 88 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -83,3 +83,91 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    ![A screenshot of FreeBSD 13.1-RELEASE for ARM64 console in QEMU on Apple Silicon Mac, showing the output of uname -a](https://raw.githubusercontent.com/ctsrc/ctsrc/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/467816f73fc23f12b9fd3bb5edeaa34dbd11e70b.png)
    ![Another screenshot of FreeBSD 13.1-RELEASE for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](https://raw.githubusercontent.com/ctsrc/ctsrc/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/c1c5d3bc3202d816215ee0612ef0b24fa3ca745e.png)
    ## `sysbench` CPU benchmark comparison
    ### Running natively in macOS Monterey Version 12.5 (21G72) on MacBook Pro (13-inch, M1, 2020)
    (Installed via Homebrew.)
    **Events per second: 25445903.16**
    ```zsh
    sysbench cpu --threads=2 run
    ```

    ```text
    sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
    Running the test with following options:
    Number of threads: 2
    Initializing random number generator from current time
    Prime numbers limit: 10000
    Initializing worker threads...
    Threads started!
    CPU speed:
    events per second: 25445903.16
    General statistics:
    total time: 10.0000s
    total number of events: 254468472
    Latency (ms):
    min: 0.00
    avg: 0.00
    max: 0.12
    95th percentile: 0.00
    sum: 8916.15
    Threads fairness:
    events (avg/stddev): 127234236.0000/15768.00
    execution time (avg/stddev): 4.4581/0.00
    ```

    ### Running in FreeBSD 13.1-RELEASE for ARM64 in QEMU on MacBook Pro (13-inch, M1, 2020)

    (Installed via FreeBSD ports.)

    **Events per second: 15467914.47** or ~15.4 Mio events/sec

    ```csh
    sysbench cpu --threads=2 run
    ```

    ```text
    sysbench 1.0.20 (using system LuaJIT 2.1.0-beta3)
    Running the test with following options:
    Number of threads: 2
    Initializing random number generator from current time
    Prime numbers limit: 10000
    Initializing worker threads...
    Threads started!
    CPU speed:
    events per second: 15467914.47
    General statistics:
    total time: 10.0003s
    total number of events: 154689213
    Latency (ms):
    min: 0.00
    avg: 0.00
    max: 0.21
    95th percentile: 0.00
    sum: 5684.03
    Threads fairness:
    events (avg/stddev): 77344606.5000/169564.50
    execution time (avg/stddev): 2.8420/0.00
    ```
  8. ctsrc revised this gist Aug 3, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # How to run FreeBSD 13.1-RELEASE for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)

    ![FreeBSD 13.1-RELEASE for ARM64 boot in QEMU on Apple Silicon Mac screenshot](https://github.com/ctsrc/ctsrc/blob/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/ef3d7019735ad9cb8d3af35aa91dfdec7674aa4b.png?raw=true)
    ![FreeBSD 13.1-RELEASE for ARM64 boot in QEMU on Apple Silicon Mac screenshot](https://raw.githubusercontent.com/ctsrc/ctsrc/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/ef3d7019735ad9cb8d3af35aa91dfdec7674aa4b.png)

    This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375da41b4278#running-ubuntu-server-for-arm64

    @@ -81,5 +81,5 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    -serial mon:stdio
    ```
    ![A screenshot of FreeBSD 13.1-RELEASE for ARM64 console in QEMU on Apple Silicon Mac, showing the output of uname -a](https://github.com/ctsrc/ctsrc/blob/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/467816f73fc23f12b9fd3bb5edeaa34dbd11e70b.png?raw=true)
    ![Another screenshot of FreeBSD 13.1-RELEASE for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](https://github.com/ctsrc/ctsrc/blob/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/c1c5d3bc3202d816215ee0612ef0b24fa3ca745e.png?raw=true)
    ![A screenshot of FreeBSD 13.1-RELEASE for ARM64 console in QEMU on Apple Silicon Mac, showing the output of uname -a](https://raw.githubusercontent.com/ctsrc/ctsrc/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/467816f73fc23f12b9fd3bb5edeaa34dbd11e70b.png)
    ![Another screenshot of FreeBSD 13.1-RELEASE for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](https://raw.githubusercontent.com/ctsrc/ctsrc/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/c1c5d3bc3202d816215ee0612ef0b24fa3ca745e.png)
  9. ctsrc revised this gist Aug 3, 2022. No changes.
  10. ctsrc revised this gist Aug 3, 2022. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # How to run FreeBSD 13.1-RELEASE for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)

    ![FreeBSD 13.0-RELEASE for ARM64 boot in QEMU on Apple Silicon Mac screenshot](https://user-images.githubusercontent.com/36199671/133963003-fc033083-c001-45fa-a98a-6cea3e28ec5d.png)
    ![FreeBSD 13.1-RELEASE for ARM64 boot in QEMU on Apple Silicon Mac screenshot](https://github.com/ctsrc/ctsrc/blob/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/ef3d7019735ad9cb8d3af35aa91dfdec7674aa4b.png?raw=true)

    This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375da41b4278#running-ubuntu-server-for-arm64

    @@ -81,5 +81,5 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    -serial mon:stdio
    ```
    ![A screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, showing the output of uname -a](https://user-images.githubusercontent.com/36199671/133963016-bf8559c9-74c3-422c-ada7-0df5bfb89e8c.png)
    ![Another screenshot of FreeBSD 13.0-RELEASE for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](https://user-images.githubusercontent.com/36199671/133963025-ec796870-332a-4ea8-b33c-541282143fc7.png)
    ![A screenshot of FreeBSD 13.1-RELEASE for ARM64 console in QEMU on Apple Silicon Mac, showing the output of uname -a](https://github.com/ctsrc/ctsrc/blob/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/467816f73fc23f12b9fd3bb5edeaa34dbd11e70b.png?raw=true)
    ![Another screenshot of FreeBSD 13.1-RELEASE for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](https://github.com/ctsrc/ctsrc/blob/01b8bc95d6b0a4a432712a471eb3ab208efd2ace/c1c5d3bc3202d816215ee0612ef0b24fa3ca745e.png?raw=true)
  11. ctsrc revised this gist Aug 3, 2022. 1 changed file with 17 additions and 43 deletions.
    60 changes: 17 additions & 43 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,60 +1,34 @@
    # How to run FreeBSD 13.0-RELEASE for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)
    # How to run FreeBSD 13.1-RELEASE for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)

    ![FreeBSD 13.0-RELEASE for ARM64 boot in QEMU on Apple Silicon Mac screenshot](https://user-images.githubusercontent.com/36199671/133963003-fc033083-c001-45fa-a98a-6cea3e28ec5d.png)

    This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375da41b4278#running-ubuntu-server-for-arm64

    ## Running FreeBSD 13.0-RELEASE for ARM64
    ## Running FreeBSD 13.1-RELEASE for ARM64

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

    ```
    xcode-select --install
    ```
    2. Install Homebrew and QEMU dependencies.
    2. Install Homebrew and QEMU.
    https://brew.sh/
    ```
    brew install ninja pkgconfig glib pixman libusb libssh zstd usbredir
    brew install qemu
    ```
    3. Clone QEMU source code with patches applied by patchew.
    ```
    mkdir -p ~/src/
    cd ~/src/
    git clone https://github.com/patchew-project/qemu.git
    ```
    4. Checkout tag that has Hypervisor.framework patches
    ```
    cd qemu
    git checkout patchew/[email protected]
    ```
    See https://patchew.org/QEMU/[email protected]/ for details.
    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.
    3. 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.
    4. Prepare pflash for non-volatile variable store, such as screen resolution.
    ```
    mkdir ~/qemu-vm/
    @@ -69,26 +43,26 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    - This step is optional, you can use `-bios 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 FreeBSD 13.0-RELEASE for ARM64 raw VM image xz-compressed file
    5. Download FreeBSD 13.1-RELEASE for ARM64 raw VM image xz-compressed file
    http://ftp4.se.freebsd.org/pub/FreeBSD/releases/VM-IMAGES/13.0-RELEASE/aarch64/Latest/FreeBSD-13.0-RELEASE-arm64-aarch64.raw.xz
    (See https://docs.freebsd.org/en/books/handbook/mirrors/ for a list of mirrors to choose from.)
    https://ftp2.uk.freebsd.org/pub/FreeBSD/releases/VM-IMAGES/13.1-RELEASE/aarch64/Latest/FreeBSD-13.1-RELEASE-arm64-aarch64.raw.xz
    9. Decompress xz-compressed file, keeping a copy of the original compressed file
    (See https://docs.freebsd.org/en/books/handbook/mirrors/ for a list of mirrors to choose from.)
    6. Decompress xz-compressed file, keeping a copy of the original compressed file
    Keeping a copy of the original file is convenient because then you can use it if you want to create additional VMs later. Just be careful not to overwrite the image of your first VM when you want to make a second VM though :P
    ```
    mv ~/Downloads/FreeBSD-13.0-RELEASE-arm64-aarch64.raw.xz .
    unxz -k FreeBSD-13.0-RELEASE-arm64-aarch64.raw.xz
    mv ~/Downloads/FreeBSD-13.1-RELEASE-arm64-aarch64.raw.xz .
    unxz -k FreeBSD-13.1-RELEASE-arm64-aarch64.raw.xz
    ```
    10. Run your FreeBSD 13.0-RELEASE for ARM64 VM
    7. Run your FreeBSD 13.1-RELEASE for ARM64 VM
    ```
    ~/src/qemu/build/qemu-system-aarch64 \
    -M virt,highmem=off \
    -M virt \
    -accel hvf \
    -cpu host \
    -smp 4 \
    @@ -102,10 +76,10 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    -device usb-tablet \
    -device intel-hda \
    -device hda-duplex \
    -drive file=FreeBSD-13.0-RELEASE-arm64-aarch64.raw,if=virtio,cache=writethrough \
    -drive file=FreeBSD-13.1-RELEASE-arm64-aarch64.raw,format=raw,if=virtio,cache=writethrough \
    -nographic \
    -serial mon:stdio
    ```
    ![A screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, showing the output of uname -a](https://user-images.githubusercontent.com/36199671/133963016-bf8559c9-74c3-422c-ada7-0df5bfb89e8c.png)
    ![Another screenshot of FreeBSD 13.0-RELEASE for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](https://user-images.githubusercontent.com/36199671/133963025-ec796870-332a-4ea8-b33c-541282143fc7.png)
    ![Another screenshot of FreeBSD 13.0-RELEASE for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](https://user-images.githubusercontent.com/36199671/133963025-ec796870-332a-4ea8-b33c-541282143fc7.png)
  12. ctsrc revised this gist Sep 20, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # How to run FreeBSD 13.0-RELEASE for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)

    ![FreeBSD 13.0-BETA1 for ARM64 boot in QEMU on Apple Silicon Mac screenshot](https://gist.githubusercontent.com/ctsrc/a1f57933a2cde9abc0f07be12889f97f/raw/53846253296984e890a7ea7d2956d9b4ff2dac76/screenshot-1.png)
    ![FreeBSD 13.0-RELEASE for ARM64 boot in QEMU on Apple Silicon Mac screenshot](https://user-images.githubusercontent.com/36199671/133963003-fc033083-c001-45fa-a98a-6cea3e28ec5d.png)

    This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375da41b4278#running-ubuntu-server-for-arm64

    @@ -107,5 +107,5 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    -serial mon:stdio
    ```
    ![A screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, showing the tail end of the boot output along with the login prompt and the output of uname -a](https://gist.githubusercontent.com/ctsrc/a1f57933a2cde9abc0f07be12889f97f/raw/53846253296984e890a7ea7d2956d9b4ff2dac76/screenshot-2.png)
    ![Another screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](https://gist.githubusercontent.com/ctsrc/a1f57933a2cde9abc0f07be12889f97f/raw/53846253296984e890a7ea7d2956d9b4ff2dac76/screenshot-3.png)
    ![A screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, showing the output of uname -a](https://user-images.githubusercontent.com/36199671/133963016-bf8559c9-74c3-422c-ada7-0df5bfb89e8c.png)
    ![Another screenshot of FreeBSD 13.0-RELEASE for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](https://user-images.githubusercontent.com/36199671/133963025-ec796870-332a-4ea8-b33c-541282143fc7.png)
  13. ctsrc revised this gist Sep 20, 2021. 1 changed file with 13 additions and 11 deletions.
    24 changes: 13 additions & 11 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    # How to run FreeBSD 13.0-BETA1 for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)
    # How to run FreeBSD 13.0-RELEASE for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)

    ![FreeBSD 13.0-BETA1 for ARM64 boot in QEMU on Apple Silicon Mac screenshot](https://gist.github.com/ctsrc/a1f57933a2cde9abc0f07be12889f97f/raw/53846253296984e890a7ea7d2956d9b4ff2dac76/screenshot-1.png)

    This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375da41b4278#running-ubuntu-server-for-arm64

    ## Running FreeBSD 13.0-BETA1 for ARM64
    ## Running FreeBSD 13.0-RELEASE for ARM64

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

    @@ -32,10 +32,10 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    ```
    cd qemu
    git checkout patchew/20210120224444.71840[email protected]
    git checkout patchew/20210916155404.86958[email protected]
    ```
    See https://patchew.org/QEMU/20210120224444.71840[email protected]/ for details.
    See https://patchew.org/QEMU/20210916155404.86958[email protected]/ for details.
    5. Build QEMU
    @@ -69,26 +69,28 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    - This step is optional, you can use `-bios 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 FreeBSD 13.0-BETA1 for ARM64 raw VM image xz-compressed file
    8. Download FreeBSD 13.0-RELEASE for ARM64 raw VM image xz-compressed file
    https://download.freebsd.org/ftp/releases/VM-IMAGES/13.0-BETA1/aarch64/Latest/FreeBSD-13.0-BETA1-arm64-aarch64.raw.xz
    http://ftp4.se.freebsd.org/pub/FreeBSD/releases/VM-IMAGES/13.0-RELEASE/aarch64/Latest/FreeBSD-13.0-RELEASE-arm64-aarch64.raw.xz
    (See https://docs.freebsd.org/en/books/handbook/mirrors/ for a list of mirrors to choose from.)
    9. Decompress xz-compressed file, keeping a copy of the original compressed file
    Keeping a copy of the original file is convenient because then you can use it if you want to create additional VMs later. Just be careful not to overwrite the image of your first VM when you want to make a second VM though :P
    ```
    mv ~/Downloads/FreeBSD-13.0-BETA1-arm64-aarch64.raw.xz .
    unxz -k ~/Downloads/FreeBSD-13.0-BETA1-arm64-aarch64.raw.xz
    mv ~/Downloads/FreeBSD-13.0-RELEASE-arm64-aarch64.raw.xz .
    unxz -k FreeBSD-13.0-RELEASE-arm64-aarch64.raw.xz
    ```
    10. Run your FreeBSD 13.0-BETA1 for ARM64 VM
    10. Run your FreeBSD 13.0-RELEASE for ARM64 VM
    ```
    ~/src/qemu/build/qemu-system-aarch64 \
    -M virt,highmem=off \
    -accel hvf \
    -cpu cortex-a72 \
    -cpu host \
    -smp 4 \
    -m 4096 \
    -drive file=pflash0.img,format=raw,if=pflash,readonly=on \
    @@ -100,7 +102,7 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    -device usb-tablet \
    -device intel-hda \
    -device hda-duplex \
    -drive file=FreeBSD-13.0-BETA1-arm64-aarch64.raw,if=virtio,cache=writethrough \
    -drive file=FreeBSD-13.0-RELEASE-arm64-aarch64.raw,if=virtio,cache=writethrough \
    -nographic \
    -serial mon:stdio
    ```
  14. ctsrc revised this gist Feb 7, 2021. 3 changed files with 0 additions and 0 deletions.
    Binary file removed screenshot-1.png
    Binary file not shown.
    Empty file removed screenshot-2.png
    Empty file.
    Empty file removed screenshot-3.png
    Empty file.
  15. ctsrc revised this gist Feb 7, 2021. 3 changed files with 0 additions and 0 deletions.
    Binary file modified screenshot-1.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
    Binary file modified screenshot-2.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
    Binary file modified screenshot-3.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  16. ctsrc revised this gist Feb 7, 2021. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -106,5 +106,4 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    ```
    ![A screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, showing the tail end of the boot output along with the login prompt and the output of uname -a](https://gist.github.com/ctsrc/a1f57933a2cde9abc0f07be12889f97f/raw/53846253296984e890a7ea7d2956d9b4ff2dac76/screenshot-2.png)
    ![Another screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](https://gist.github.com/ctsrc/a1f57933a2cde9abc0f07be12889f97f/raw/53846253296984e890a7ea7d2956d9b4ff2dac76/screenshot-3.png)
  17. ctsrc revised this gist Feb 7, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # How to run FreeBSD 13.0-BETA1 for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)

    ![FreeBSD 13.0-BETA1 for ARM64 boot in QEMU on Apple Silicon Mac screenshot](screenshot-1.png)
    ![FreeBSD 13.0-BETA1 for ARM64 boot in QEMU on Apple Silicon Mac screenshot](https://gist.github.com/ctsrc/a1f57933a2cde9abc0f07be12889f97f/raw/53846253296984e890a7ea7d2956d9b4ff2dac76/screenshot-1.png)

    This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375da41b4278#running-ubuntu-server-for-arm64

    @@ -105,6 +105,6 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    -serial mon:stdio
    ```
    ![A screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, showing the tail end of the boot output along with the login prompt and the output of uname -a](screenshot-2.png)
    ![A screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, showing the tail end of the boot output along with the login prompt and the output of uname -a](https://gist.github.com/ctsrc/a1f57933a2cde9abc0f07be12889f97f/raw/53846253296984e890a7ea7d2956d9b4ff2dac76/screenshot-2.png)
    ![Another screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](screenshot-2.png)
    ![Another screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](https://gist.github.com/ctsrc/a1f57933a2cde9abc0f07be12889f97f/raw/53846253296984e890a7ea7d2956d9b4ff2dac76/screenshot-3.png)
  18. ctsrc revised this gist Feb 7, 2021. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,7 @@
    # How to run FreeBSD 13.0-BETA1 for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)

    ![FreeBSD 13.0-BETA1 for ARM64 boot in QEMU on Apple Silicon Mac screenshot](screenshot-1.png)

    This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375da41b4278#running-ubuntu-server-for-arm64

    ## Running FreeBSD 13.0-BETA1 for ARM64
    @@ -102,3 +104,7 @@ This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375d
    -nographic \
    -serial mon:stdio
    ```
    ![A screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, showing the tail end of the boot output along with the login prompt and the output of uname -a](screenshot-2.png)
    ![Another screenshot of FreeBSD 13.0-BETA1 for ARM64 console in QEMU on Apple Silicon Mac, this time showing that networking is working and is able to connect over HTTP to the website www.example.com](screenshot-2.png)
  19. ctsrc revised this gist Feb 7, 2021. 5 changed files with 33 additions and 394 deletions.
    230 changes: 0 additions & 230 deletions README.ja.md
    Original file line number Diff line number Diff line change
    @@ -1,230 +0,0 @@
    # ARM 版 Windows 10 や Ubuntu for ARM64 を Apple Silicon な Mac で動かす

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

    > メモ: 2020年12月19日現時点での方法で、今後おおきく改善されていくと思います(だといいな。)
    ## ARM 版 Windows 10 を動かす

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

    ```
    xcode-select --install
    ```
    2. MacPorts で QEMU の依存ライブラリをインストール
    https://www.macports.org/install.php
    ```
    sudo port install ninja pkgconfig glib2 libpixman
    ```
    3. QEMU のソースコードをとってくる
    ```
    git clone https://git.qemu.org/git/qemu.git
    ```
    4. ローカルブランチを作って、@[_AlexGraf](https://twitter.com/_AlexGraf)氏がつくった Hypervisor.framework のパッチをあてる
    ```
    cd qemu
    git checkout master -b wip/hvf
    curl 'https://patchwork.kernel.org/series/400619/mbox/'|git am --3way
    ```
    5. QEMU をビルドする
    必ず `PATH` や `PKG_CONFIG_PATH` を書き換えるなどして、Homebrew などの **x86_64 のツールがインストールされていないか、有効になっていないことを確認してください**。
    ```
    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_InsiderPreview_Client_ARM64_en-us_21286.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_InsiderPreview_Client_ARM64_en-us_21286.qcow2,format=qcow2,if=none,id=boot,cache=writethrough \
    -device nvme,drive=boot,serial=boot
    ```
    - イメージへのパスなどは適宜修正してください。
    - TianoCore のロゴが出ている時に `ESC` を押して、`Device Manager`、`OVMF Platform Configuration`、`Change 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://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/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 を再起動すること。
    詳細は[こちら](https://docs.microsoft.com/en-us/windows-hardware/drivers/install/the-testsigning-boot-configuration-option)を参照のこと。
    4. デバイスドライバのインストール
    Windows が再度起動したら Windows スタートボタン を右クリック、Device Manager を選択。
    Device Manager のウィンドウで、View メニューの Devices by Connection を選択。
    デバイスのツリーから、`ACPU ARM64-based PC`、`Microsoft ACPI-Compliant System`、`PCI 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` をインストール。
    ## 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/FV` に `QEMU_EFI.fd` と `QEMU_VARS.fd` ができるはず。
    - これらのファイルを簡単に macOS ホストに取り出すには macOS でリモートアクセスを有効にして `scp` で `10.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
    ```
    197 changes: 33 additions & 164 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,47 +1,45 @@
    # How to run Windows 10 on ARM or Ubuntu for ARM64 in QEMU on Apple Silicon Mac
    # How to run FreeBSD 13.0-BETA1 for ARM64 in QEMU on Apple Silicon Mac (MacBook Pro M1, etc)

    Here is easy steps to try Windows 10 on ARM or Ubuntu for ARM64 on your Apple Silicon Mac.
    Enjoy!
    This guide was adapted from https://gist.github.com/niw/e4313b9c14e968764a52375da41b4278#running-ubuntu-server-for-arm64

    > NOTE: that this is current, 12/19/2020 state. It will be improved a lot in upcoming a few months... (I hope.)
    ## Running Windows 10 on ARM
    ## Running FreeBSD 13.0-BETA1 for ARM64

    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.
    2. Install Homebrew and QEMU dependencies.
    https://www.macports.org/install.php
    https://brew.sh/
    ```
    sudo port install ninja pkgconfig glib2 libpixman
    brew install ninja pkgconfig glib pixman libusb libssh zstd usbredir
    ```
    3. Clone QEMU source code.
    3. Clone QEMU source code with patches applied by patchew.
    ```
    git clone https://git.qemu.org/git/qemu.git
    mkdir -p ~/src/
    cd ~/src/
    git clone https://github.com/patchew-project/qemu.git
    ```
    4. Create a local branch then apply Hypervisor.framework patches that @[_AlexGraf](https://twitter.com/_AlexGraf) made.
    4. Checkout tag that has Hypervisor.framework patches
    ```
    cd qemu
    git checkout master -b wip/hvf
    curl 'https://patchwork.kernel.org/series/400619/mbox/'|git am --3way
    git checkout patchew/[email protected]
    ```
    5. Build QEMU
    See https://patchew.org/QEMU/[email protected]/ for details.
    Before building, **please ensure there are no x86_64 tools enabled**, such the one installed by Homebrew, by rewriting `PATH` or `PKG_CONFIG_PATH`.
    5. Build QEMU
    ```
    mkdir build
    cd build
    mkdir build/
    cd build/
    ../configure --target-list=aarch64-softmmu --enable-cocoa
    make -j
    ```
    @@ -56,180 +54,51 @@ Enjoy!
    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
    mkdir ~/qemu-vm/
    cd ~/qemu-vm/
    tar xvf ~/Downloads/QEMU_EFI-cb438b9-edk2-stable202011-with-extra-resolutions.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,
    - This step is optional, you can use `-bios 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_InsiderPreview_Client_ARM64_en-us_21286.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 \
    -drive file=~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_21286.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://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/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](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`.
    ## Running Ubuntu Server for ARM64
    8. Download FreeBSD 13.0-BETA1 for ARM64 raw VM image xz-compressed file
    Follow the same steps for Windows 10 to prepare QEMU, then download Ubuntu Server for ARM64 and install it.
    https://download.freebsd.org/ftp/releases/VM-IMAGES/13.0-BETA1/aarch64/Latest/FreeBSD-13.0-BETA1-arm64-aarch64.raw.xz
    1. Follow previous steps from 1. to 7. to prepare QEMU.
    9. Decompress xz-compressed file, keeping a copy of the original compressed file
    2. Create an empty disk image.
    Keeping a copy of the original file is convenient because then you can use it if you want to create additional VMs later. Just be careful not to overwrite the image of your first VM when you want to make a second VM though :P
    ```
    ./qemu-img create -f qcow2 ~/Downloads/ubuntu.qcow2 40G
    mv ~/Downloads/FreeBSD-13.0-BETA1-arm64-aarch64.raw.xz .
    unxz -k ~/Downloads/FreeBSD-13.0-BETA1-arm64-aarch64.raw.xz
    ```
    3. Download Ubuntu Server for ARM64
    https://ubuntu.com/download/server/arm
    4. Install Ubuntu Server for ARM
    10. Run your FreeBSD 13.0-BETA1 for ARM64 VM
    ```
    ./qemu-system-aarch64 \
    -monitor stdio \
    ~/src/qemu/build/qemu-system-aarch64 \
    -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 \
    -drive file=pflash0.img,format=raw,if=pflash,readonly=on \
    -drive file=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
    -drive file=FreeBSD-13.0-BETA1-arm64-aarch64.raw,if=virtio,cache=writethrough \
    -nographic \
    -serial mon:stdio
    ```
    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 Remove 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
    ```
    Binary file added screenshot-1.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
    Binary file added screenshot-2.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
    Binary file added screenshot-3.png
    Loading
    Sorry, something went wrong. Reload?
    Sorry, we cannot display this file.
    Sorry, this file is invalid so it cannot be displayed.
  20. @niw niw revised this gist Jan 17, 2021. 2 changed files with 4 additions and 4 deletions.
    4 changes: 2 additions & 2 deletions README.ja.md
    Original file line number Diff line number Diff line change
    @@ -76,7 +76,7 @@ ARM 版 Windows 10 や Ubuntu を Apple Silicon な Mac で動かす簡単な方
    VHDX のままだとかなりの頻度でイメージが壊れる印象があるので qcow2 に変換しておく。
    ```
    qemu-img convert -p -O qcow2 ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_21286.VHDX ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.qcow2
    qemu-img convert -p -O qcow2 ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_21286.VHDX ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_21286.qcow2
    ```
    10. Windows 10 を起動する
    @@ -98,7 +98,7 @@ ARM 版 Windows 10 や Ubuntu を Apple Silicon な Mac で動かす簡単な方
    -device intel-hda \
    -device hda-duplex \
    -nic user,model=virtio \
    -drive file=~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.qcow2,format=qcow2,if=none,id=boot,cache=writethrough \
    -drive file=~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_21286.qcow2,format=qcow2,if=none,id=boot,cache=writethrough \
    -device nvme,drive=boot,serial=boot
    ```
    4 changes: 2 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -79,7 +79,7 @@ Enjoy!
    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_InsiderPreview_Client_ARM64_en-us_20231.qcow2
    qemu-img convert -p -O qcow2 ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_21286.VHDX ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_21286.qcow2
    ```
    10. Run Windows 10
    @@ -100,7 +100,7 @@ Enjoy!
    -device usb-tablet \
    -device intel-hda \
    -device hda-duplex \
    -drive file=~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.qcow2,format=qcow2,if=none,id=boot,cache=writethrough \
    -drive file=~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_21286.qcow2,format=qcow2,if=none,id=boot,cache=writethrough \
    -device nvme,drive=boot,serial=boot
    ```
  21. @niw niw revised this gist Jan 17, 2021. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion README.ja.md
    Original file line number Diff line number Diff line change
    @@ -76,7 +76,7 @@ ARM 版 Windows 10 や Ubuntu を Apple Silicon な Mac で動かす簡単な方
    VHDX のままだとかなりの頻度でイメージが壊れる印象があるので qcow2 に変換しておく。
    ```
    qemu-img convert -p -O qcow2 ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.VHDX ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.qcow2
    qemu-img convert -p -O qcow2 ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_21286.VHDX ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.qcow2
    ```
    10. Windows 10 を起動する
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -79,7 +79,7 @@ Enjoy!
    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_20231.VHDX ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.qcow2
    qemu-img convert -p -O qcow2 ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_21286.VHDX ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.qcow2
    ```
    10. Run Windows 10
  22. @niw niw revised this gist Dec 28, 2020. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion README.ja.md
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@ ARM 版 Windows 10 や Ubuntu を Apple Silicon な Mac で動かす簡単な方
    ```
    cd qemu
    git checkout master -b wip/hvf
    curl 'https://patchwork.kernel.org/series/400619/mbox/'|git am
    curl 'https://patchwork.kernel.org/series/400619/mbox/'|git am --3way
    ```
    5. QEMU をビルドする
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -32,7 +32,7 @@ Enjoy!
    ```
    cd qemu
    git checkout master -b wip/hvf
    curl 'https://patchwork.kernel.org/series/400619/mbox/'|git am
    curl 'https://patchwork.kernel.org/series/400619/mbox/'|git am --3way
    ```
    5. Build QEMU
  23. @niw niw revised this gist Dec 20, 2020. 2 changed files with 10 additions and 4 deletions.
    7 changes: 5 additions & 2 deletions README.ja.md
    Original file line number Diff line number Diff line change
    @@ -46,9 +46,11 @@ ARM 版 Windows 10 や Ubuntu を Apple Silicon な Mac で動かす簡単な方
    6. QEMU 用の EDK II OVMF EFI イメージをダウンロードする。
    https://gist.github.com/niw/4f1f9bb572f40d406866f23b3127919b/raw/f4dab9b407a2ea94ceceb7905eb918e1317bc251/QEMU_EFI-a096471-edk2-stable202011.tar.gz
    このイメージは `stable202011` タグに、`QemuRamfb.c` に追加の解像度を足したものです。
    ソースコードからビルドする場合は以下を参照のこと。
    https://gist.github.com/niw/4f1f9bb572f40d406866f23b3127919b/raw/f546faea68f4149c06cca88fa67ace07a3758268/QEMU_EFI-cb438b9-edk2-stable202011-with-extra-resolutions.tar.gz
    さらに解像度を追加するなど、ソースコードからビルドする場合は以下を参照のこと。
    7. pflash イメージを作って、画面サイズなどを設定する不揮発なストレージを準備する
    @@ -102,6 +104,7 @@ ARM 版 Windows 10 や Ubuntu を Apple Silicon な Mac で動かす簡単な方
    - イメージへのパスなどは適宜修正してください。
    - TianoCore のロゴが出ている時に `ESC` を押して、`Device Manager`、`OVMF Platform Configuration`、`Change 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` がネットワークインターフェイスです。有効にするには以下を参照してください。
    7 changes: 5 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -48,9 +48,11 @@ Enjoy!
    6. Download pre-build EDK II OVMF EFI image for QEMU.
    https://gist.github.com/niw/4f1f9bb572f40d406866f23b3127919b/raw/f4dab9b407a2ea94ceceb7905eb918e1317bc251/QEMU_EFI-a096471-edk2-stable202011.tar.gz
    This EFI image is built from `stable202011` tag with additional resolutions in `QemuRamfb.c`.
    To build it from the source code, see the following section.
    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.
    @@ -104,6 +106,7 @@ Enjoy!
    - 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.
  24. @niw niw revised this gist Dec 20, 2020. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion README.ja.md
    Original file line number Diff line number Diff line change
    @@ -188,7 +188,7 @@ ARM 版 Windows 10 を動かす手順に従って QEMU を準備して、Ubuntu
    -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 ~/Downloads/ubuntu-20.04.1-live-server-arm64.iso
    ```
    - 指示に従ってインストールしたあとは `-cdrom` は不要です。
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -192,7 +192,7 @@ Follow the same steps for Windows 10 to prepare QEMU, then download Ubuntu Serve
    -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 ~/Downloads/ubuntu-20.04.1-live-server-arm64.iso
    ```
    - Follow instruction to install Ubuntu Server. Once it's installed, `-cdrom` argument is not needed.
  25. @niw niw revised this gist Dec 20, 2020. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion README.ja.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # ARM 版 Windows 10 や Ubuntu for ARM64 を Apple Silicon な Mac で動かす

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

    > メモ: 2020年12月19日現時点での方法で、今後おおきく改善されていくと思います(だといいな。)
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # 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 on your 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, 12/19/2020 state. It will be improved a lot in upcoming a few months... (I hope.)
  26. @niw niw revised this gist Dec 20, 2020. No changes.
  27. @niw niw revised this gist Dec 20, 2020. 2 changed files with 142 additions and 46 deletions.
    94 changes: 71 additions & 23 deletions README.ja.md
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,10 @@
    # ARM 版 Windows 10 を Hypervisor.framework のパッチをあてた QEMU を使って Apple Silicon な Mac で動かす
    # ARM 版 Windows 10 や Ubuntu for ARM64 を Apple Silicon な Mac で動かす

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

    > メモ: 2020年12月12日現時点での方法で、今後おおきく改善されていくと思います(だといいな。)
    > メモ: 2020年12月19日現時点での方法で、今後おおきく改善されていくと思います(だといいな。)
    ## 手順
    ## ARM 版 Windows 10 を動かす

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

    @@ -44,25 +44,13 @@ ARM 版 Windows 10 を Apple Silicon な Mac で動かす簡単な方法です
    make -j
    ```
    6. Windows 10 on ARM Insider Preview をダウンロードする
    https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewARM64
    7. VHDX から qcow2 に変換する
    VHDX のままだとかなりの頻度でイメージが壊れる印象があるので qcow2 に変換しておく。
    ```
    qemu-img convert -p -O qcow2 ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.VHDX ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.qcow2
    ```
    8. QEMU 用の EDK II OVMF EFI イメージをダウンロードする。
    6. QEMU 用の EDK II OVMF EFI イメージをダウンロードする。
    https://gist.github.com/niw/4f1f9bb572f40d406866f23b3127919b/raw/f4dab9b407a2ea94ceceb7905eb918e1317bc251/QEMU_EFI-a096471-edk2-stable202011.tar.gz
    ソースコードからビルドする場合は以下を参照のこと。
    9. pflash イメージを作って、画面サイズなどを設定する不揮発なストレージを準備する
    7. pflash イメージを作って、画面サイズなどを設定する不揮発なストレージを準備する
    `QEMU_EFI-....tar.gz` をダウンロードしたディレクトリで以下を実行。
    @@ -77,6 +65,18 @@ ARM 版 Windows 10 を Apple Silicon な Mac で動かす簡単な方法です
    - このステップは省略可能。その場合は次のステップで `-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_20231.VHDX ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.qcow2
    ```
    10. Windows 10 を起動する
    ```
    @@ -152,16 +152,56 @@ VirtIO NIC は標準では有効にならないので、デバイスドライバ
    Next をクリックして `Red Hat VertIO Ethernet Adapter` をインストール。
    ## 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 イメージをビルドする
    OVMF EFI イメージをソースコードから作る場合、とりあえず簡単にビルドするには、まず VMWare Fusion とか、VirtualBox とかを Intel Mac (そう、Intel Mac が必要)にインストールして、Ubuntu などの Linux が必要になります
    上記の手順に従って Ubuntu Server for ARM64 を動かします
    1. EDK II のソースコードを取ってくる。
    ```
    git clone https://github.com/tianocore/edk2.git
    git clone --depth 1 --branch edk2-stable202011 https://github.com/tianocore/edk2.git
    cd edk2
    git checkout edk2-stable202011 # stable ってタグされてるやつがいい
    git submodule update --init --recursive
    ```
    @@ -170,10 +210,18 @@ OVMF EFI イメージをソースコードから作る場合、とりあえず
    2. ビルドする
    ```
    sudo apt install iasl python3 python3-distutils uuid-dev gcc-aarch64-linux-gnu
    sudo apt install iasl python3 python3-distutils uuid-dev make g++
    source edksetup.sh
    make -C BaseTools
    env GCC5_AARCH64_PREFIX=aarch64-linux-gnu- build -a AARCH64 -t GCC5 -p ArmVirtPkg/ArmVirtQemu.dsc
    build -a AARCH64 -t GCC5 -p ArmVirtPkg/ArmVirtQemu.dsc
    ```
    `Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/FV` に `QEMU_EFI.fd` とかができるはず。
    `Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/FV` に `QEMU_EFI.fd` と `QEMU_VARS.fd` ができるはず。
    - これらのファイルを簡単に macOS ホストに取り出すには macOS でリモートアクセスを有効にして `scp` で `10.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
    ```
    94 changes: 71 additions & 23 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,11 @@
    # How to run Windows 10 on ARM in QEMU with Hypervisor.framework patches on Apple Silicon Mac
    # 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 on your Apple Silicon Mac.
    Enjoy!

    > NOTE: that this is current, 12/12/2020 state. It will be improved a lot in upcoming a few months... (I hope.)
    > NOTE: that this is current, 12/19/2020 state. It will be improved a lot in upcoming a few months... (I hope.)
    ## Steps
    ## Running Windows 10 on ARM

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

    @@ -46,25 +46,13 @@ Enjoy!
    make -j
    ```
    6. Download Windows 10 on ARM Insider Preview
    https://www.microsoft.com/en-us/software-download/windowsinsiderpreviewARM64
    7. 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_20231.VHDX ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.qcow2
    ```
    8. Download pre-build EDK II OVMF EFI image for QEMU.
    6. Download pre-build EDK II OVMF EFI image for QEMU.
    https://gist.github.com/niw/4f1f9bb572f40d406866f23b3127919b/raw/f4dab9b407a2ea94ceceb7905eb918e1317bc251/QEMU_EFI-a096471-edk2-stable202011.tar.gz
    To build it from the source code, see the following section.
    9. Prepare pflash for non-volatile variable store, such as screen resolution.
    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.
    @@ -80,6 +68,18 @@ Enjoy!
    - 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_20231.VHDX ~/Downloads/Windows10_InsiderPreview_Client_ARM64_en-us_20231.qcow2
    ```
    10. Run Windows 10
    ```
    @@ -156,16 +156,56 @@ device driver.
    Click Next to install `Red Hat VertIO Ethernet Adapter`.
    ## 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
    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.
    Follow the previous instructions to run Ubuntu Server for ARM64.
    1. Checkout EDK II source code.
    ```
    git clone https://github.com/tianocore/edk2.git
    git clone --depth 1 --branch edk2-stable202011 https://github.com/tianocore/edk2.git
    cd edk2
    git checkout edk2-stable202011 # or any stable tagged commit
    git submodule update --init --recursive
    ```
    @@ -175,10 +215,18 @@ To build this from the source code, you may need to setup Linux environment. Ins
    2. Build it.
    ```
    sudo apt install iasl python3 python3-distutils uuid-dev gcc-aarch64-linux-gnu
    sudo apt install iasl python3 python3-distutils uuid-dev make g++
    source edksetup.sh
    make -C BaseTools
    env GCC5_AARCH64_PREFIX=aarch64-linux-gnu- build -a AARCH64 -t GCC5 -p ArmVirtPkg/ArmVirtQemu.dsc
    build -a AARCH64 -t GCC5 -p ArmVirtPkg/ArmVirtQemu.dsc
    ```
    Then, you will get `QEMU_EFI.fd` in `Build/ArmVirtQemu-AARCH64/DEBUG_GCC5/FV`.
    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 Remove 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
    ```
  28. @niw niw revised this gist Dec 19, 2020. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion README.ja.md
    Original file line number Diff line number Diff line change
    @@ -170,7 +170,7 @@ OVMF EFI イメージをソースコードから作る場合、とりあえず
    2. ビルドする
    ```
    apt install iasl python3 python3-distutils uuid-dev gcc-aarch64-linux-gnu
    sudo apt 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
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -175,7 +175,7 @@ To build this from the source code, you may need to setup Linux environment. Ins
    2. Build it.
    ```
    apt install iasl python3 python3-distutils uuid-dev gcc-aarch64-linux-gnu
    sudo apt 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
  29. @niw niw revised this gist Dec 19, 2020. 2 changed files with 5 additions and 3 deletions.
    2 changes: 1 addition & 1 deletion README.ja.md
    Original file line number Diff line number Diff line change
    @@ -170,7 +170,7 @@ OVMF EFI イメージをソースコードから作る場合、とりあえず
    2. ビルドする
    ```
    apt install install iasl python3 python3-distutils uuid-dev gcc-aarch64-linux-gnu
    apt 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
    6 changes: 4 additions & 2 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -110,7 +110,9 @@ Enjoy!
    ## Enable the internet
    VirtIO NIC is not enabled by default. To make it works, you need to install device driver.
    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://docs.fedoraproject.org/en-US/quick-docs/creating-windows-virtual-machines-using-virtio-drivers/index.html#virtio-win-direct-downloads).
    @@ -173,7 +175,7 @@ To build this from the source code, you may need to setup Linux environment. Ins
    2. Build it.
    ```
    apt install install iasl python3 python3-distutils uuid-dev gcc-aarch64-linux-gnu
    apt 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
  30. @niw niw revised this gist Dec 12, 2020. 2 changed files with 6 additions and 6 deletions.
    6 changes: 3 additions & 3 deletions README.ja.md
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@

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

    > メモ: 2020年12月5日現時点での方法で、今後おおきく改善されていくと思います(だといいな。)
    > メモ: 2020年12月12日現時点での方法で、今後おおきく改善されていくと思います(だといいな。)
    ## 手順

    @@ -29,8 +29,8 @@ ARM 版 Windows 10 を Apple Silicon な Mac で動かす簡単な方法です
    ```
    cd qemu
    git checkout v5.2.0 -b wip/hvf
    curl https://patchwork.kernel.org/series/395899/mbox/|git am
    git checkout master -b wip/hvf
    curl 'https://patchwork.kernel.org/series/400619/mbox/'|git am
    ```
    5. QEMU をビルドする
    6 changes: 3 additions & 3 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -3,7 +3,7 @@
    Here is easy steps to try Windows 10 on ARM on your Apple Silicon Mac.
    Enjoy!

    > NOTE: that this is current, 12/5/2020 state. It will be improved a lot in upcoming a few months... (I hope.)
    > NOTE: that this is current, 12/12/2020 state. It will be improved a lot in upcoming a few months... (I hope.)
    ## Steps

    @@ -31,8 +31,8 @@ Enjoy!
    ```
    cd qemu
    git checkout v5.2.0 -b wip/hvf
    curl https://patchwork.kernel.org/series/395899/mbox/|git am
    git checkout master -b wip/hvf
    curl 'https://patchwork.kernel.org/series/400619/mbox/'|git am
    ```
    5. Build QEMU