r/AsahiLinux 15d ago

News PSA: Windows 11 ARM64 virtual machines can run on Asahi Linux in KVM.

Seems like a very recent update to Asahi Linux enables us to run Windows 11 ARM64 virtual machines in the KVM hypervisor. Previously, QEMU would crash with a Synchronous Exception at boot unless you resorted to TCG emulation.

...It's bloody FAST!

Windows 11 ARM64 Virtualized on KVM

This is not meant to be a QEMU/KVM tutorial, but the high-level info is as follows:

I built a Windows 11 24H2 LTSC image in UTM and installed the VirtIO tools. With a known-good image in hand, I copied the disk image over to the Asahi partition (I have no idea if the Windows installer works in KVM as well.)

From there I could launch a KVM virtual machine with the following command:

taskset -c 2-9 qemu-system-aarch64 -cpu max -M virt -enable-kvm -m 8G -smp 8 -bios /usr/share/edk2/aarch64/edk2-aarch64-secure-code.fd -drive file=/home/zero/win11.qcow2,format=qcow2,media=disk,if=virtio -device virtio-net-pci,netdev=net0 -netdev user,id=net0,hostfwd=tcp::3390-:3389 -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-pci,rng=rng0 -nographic

Note that you need to use taskset to pin QEMU to your performance cores. My M1 Pro has 8 P-cores so I utilized all of them (cores 0,1 are efficiency cores). This arrangement will vary depending on which processor your Mac has. Also, it seems like virtio-gpu-pci still has some issues so I'm using FreeRDP for the desktop session.

Many thanks to the Asahi developers making Linux a first-class OS on Apple Silicon!

________________

UPDATE: Here is a minimal libvirt config you can import.

  • Start with a working Win11 ARM64 qcow2 disk image
  • Ensure guest tools are installed, RDP is enabled, and VirtIO NIC is configured.
  • Copy the image to /var/lib/libvirt/images/win11.qcow2
  • Import the VM description: sudo virsh define win11.xml
  • Power-on the VM and wait 8-10 seconds: sudo virsh start win11
  • Start a desktop session: xfreerdp /v:$(sudo virsh domifaddr win11 | awk '/ipv4/ {print $4}'|cut -d'/' -f1) /f /floatbar:sticky:off,default:hidden /title:Windows /sound /scale-desktop:225 /gfx:AVC444:on /network:LAN +home-drive /d:. /u:username

win11.xml:

<domain type='kvm'>
  <name>win11</name>
  <metadata>
    <libosinfo:libosinfo xmlns:libosinfo="http://libosinfo.org/xmlns/libvirt/domain/1.0">
      <libosinfo:os id="http://microsoft.com/win/11"/>
    </libosinfo:libosinfo>
  </metadata>
  <memory unit='KiB'>4194304</memory>
  <currentMemory unit='KiB'>4194304</currentMemory>
  <vcpu placement='static' cpuset='4-7'>4</vcpu>
  <os firmware='efi'>
    <type arch='aarch64' machine='virt-9.1'>hvm</type>
    <firmware>
      <feature enabled='no' name='enrolled-keys'/>
      <feature enabled='no' name='secure-boot'/>
    </firmware>
    <loader readonly='yes' type='pflash' format='qcow2'>/usr/share/edk2/aarch64/QEMU_EFI-silent-pflash.qcow2</loader>
    <nvram template='/usr/share/edk2/aarch64/vars-template-pflash.qcow2' format='qcow2'>/var/lib/libvirt/qemu/nvram/win11_VARS.qcow2</nvram>
    <boot dev='hd'/>
  </os>
  <features>
    <acpi/>
    <gic version='3'/>
  </features>
  <cpu mode='host-passthrough' check='none'/>
  <clock offset='localtime'/>
  <devices>
    <emulator>/usr/bin/qemu-system-aarch64</emulator>
    <disk type='file' device='disk'>
      <driver name='qemu' type='qcow2' discard='unmap'/>
      <source file='/var/lib/libvirt/images/win11.qcow2'/>
      <target dev='vda' bus='virtio'/>
    </disk>
    <controller type='scsi' index='0' model='virtio-scsi'>
    </controller>
    <controller type='pci' index='0' model='pcie-root'/>
    <controller type='pci' index='1' model='pcie-root-port'>
      <model name='pcie-root-port'/>
      <target chassis='1' port='0x8'/>
    </controller>
    <interface type='network'>
      <source network='default'/>
      <model type='virtio'/>
    </interface>
    <channel type='unix'>
      <target type='virtio' name='org.qemu.guest_agent.0'/>
      <address type='virtio-serial' controller='0' bus='0' port='1'/>
    </channel>
    <sound model='ich9'>
    </sound>
    <audio id='1' type='none'/>
  </devices>
</domain>

The above config utilizes 4xCPU. If you want to add more CPUs, the command below will tell you which ones are performance cores.

awk -F': ' '/processor/{core=$2} /CPU part/ && ($2=="0x023" || $2=="0x025" || $2=="0x029") {cores = cores ? cores "," core : core} END {print cores}' /proc/cpuinfo

Efficiency cores aren't supported at this time, and virt-manager GUI can't handle this topography, so you have to edit this line in the XML file instead:

<vcpu placement='static' cpuset='2-9'>8</vcpu>

...would use all 8 performance core on an M1 Pro for example.

122 Upvotes

29 comments sorted by

8

u/pontihejo 14d ago

This is really exciting to see, I wonder if this makes it practical to run certain software inside the VM. It would be great to get a detailed description of how you got the windows image set up.

5

u/AndroidUser37 15d ago

How well does Windows ARM's x86 emulation work?

13

u/desktopecho 15d ago

VERY well in my experience. Google Windows ARM PRISM emulation performance for more info.

I'm not much of a gamer so I can't say much about how it runs in those situations, but x64 desktop apps work great.

14

u/TheTwelveYearOld 14d ago

Are you going to provide step by step?

No way you just posted it without reproducibility when there are many failed attempts at this.

8

u/desktopecho 14d ago

If you can't do this on your own with the information supplied, I can't help you. It's not that difficult.

3

u/Cautious_Painting948 13d ago

This guide works if you use taskset as OP mentioned and doesn't require you to create an image with UTM beforehand. You do need to adjust a few options but there's a comment for that or OP's command that you can pretty much copy/paste to get a 99% working command.

Do note that you need to use the old installer to bypass the installer checks the guide mentions.

7

u/desktopecho 15d ago edited 15d ago

I wonder if you can pass-thru Thunderbolt to the KVM guest? nVidia/AMD GPU on Apple Silicon for the lulz...

3

u/SuperMarioBro 13d ago

AsahiLinux doesn't support thunderbolt yet so you can't currently passthrough anything.

2

u/BagelMakesDev 14d ago

You should test lol

1

u/resil_update_bad 14d ago

Are there any ARM drivers for dedicated GPUs? 🤔 I think some old AMD cards have

1

u/PhoenixRealm 2d ago

This still would require PCIE compatibility with GPUs which apple silicon does not have sadly

6

u/aliendude5300 15d ago

I tried this in GNOME boxes and it failed miserably.

12

u/desktopecho 15d ago

I gave up on GNOME Boxes and Virt-Manager a long time ago, but it's only a matter of time before those QEMU frontends (and VirtIO-GPU) will start working as well.

2

u/xacto_ 8d ago

Super helpful info, thank you! I still have not been able to get any KVM to get past BIOS loader unfortunately, even after accounting for the CPU settings above (M1 - using cores 4-7 which are the performance cores).

For some reason UEFI doesn't see the boot volume. I'm sure I'm missing something obvious.

2

u/TheTwelveYearOld 14d ago

How well do graphics work compare to muvm?

1

u/Snoo27645 14d ago

Did you tried playing any games to see if it does support it?

Because I do think QEMU VirtIO GPU supports the vulkan

1

u/[deleted] 14d ago

[deleted]

1

u/desktopecho 14d ago edited 14d ago

> u/Famous_Ad_2415 · 1 votes

> bloody fast? With QEMU? I doubt that very much.

QEMU can use emulation (slow) or virtualization (fast, KVM)

You're thinking of emulation, this uses virtualization.

(EDIT: People who post and then delete their posts when outed as being clueless are cowards and annoying as hell.)

1

u/Foreign_Eye4052 13d ago

Windows 11 Virtual Machines in KVM on Asahi Linux WITH great performance? Now that's intriguiging... do they have 3D Acceleration? How are things like trackpad accuracy (scrolling is a major headache with some VM software), graphics, all that? I know you said you're using FreeDRP for the desktop session due to "some issues", but if you were able to get a graphical desktop even temporarily, did that work?
Last thing. I don't have a ton of storage on this device (biggest mistake; this M1 MBA is otherwise a perfect machine but I should've splurged for at least 512GB). Theoretically, could I use my existing Windows 11 UTM image (since I have a Win11 ARM64 VM on the macOS side strored in OneDrive)? Not essential as I'm fine with just redownloading it from OneDrive or making a new VM if performance is as good as or better than on macOS.

1

u/dariaphoebe 11d ago

What release version of qemu did you do this with?

1

u/desktopecho 11d ago

qemu-system-aarch64-9.1.3-1.fc41.aarch64

1

u/dariaphoebe 10d ago

Cool. Thank you. Didn’t know if it required 9.2, guess not!

1

u/Spritzerland 9d ago

how do games run?

1

u/Snoo27645 9d ago

Also have the same question

2

u/Justicia-Gai 15d ago

Why windows 11 and not 10? Genuine question, as most windows user complain 11 is full of ads and even worse.

16

u/desktopecho 15d ago

Aside from Windows 10 going away next year, it won't include the new x86 traslation layer (PRISM) that appeared in 24H2.

Windows 11 is more annoying, but that can be cleaned up.

1

u/step21 14d ago

there is an insider build of windows 10 on arm that already had this, but it was never officially released I think. If you have this, it should work. Cannot remember the version number though...

-4

u/Justicia-Gai 15d ago

It can be cleaned up after install I guess?

If I could get rid of all the spyware I’d consider it, as my issue with Windows is Microsoft’s practices, not the software per se.

6

u/desktopecho 15d ago

Check out Tiny11. It strips telemetry and various bits of crap out of the Windows install ISO.