microsoft / microsoft/WSL

Start CPU at EL2 in ARM bootloader when nestedVirtualization=true

Open
#9,794 3 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

feature
Dominant language
C++
Stars
33.7k
Forks
1.8k
Avg merge
3d 17h
Merged PRs (30d)
116

Description

**Describe the solution you'd like**

The EFI bootloader on WSL on ARM starts the CPU at EL1.

`[ 0.255558] CPU: All CPU(s) started at EL1
`

This prevents the WSL kernel from enabling HYP mode:

```
[hayden@~]$ dmesg | grep -i kvm
[ 0.528909] kvm [1]: HYP mode not available
```

And this prevents utilizing KVM on WSL on ARM, with a custom kernel built [with KVM enabled](https://gist.github.com/sirredbeard/0865b5b9bd1635c297f5ee8002798734):

```
[hayden@~]$ qemu-system-aarch64 -machine virt -cdrom ubuntu-22.04.2-live-server-arm64.iso -net nic -net user -boot d -m 1024 -bios /usr/share/qemu/linuxboot_dma.bin -enable-kvm
Could not access KVM kernel module: No such file or directory
qemu-system-aarch64: failed to initialize kvm: No such file or directory
```

```
:~ # qemu-system-aarch64 -m 2048 -cpu cortex-a57 -smp 2 -M virt -bios /usr/share/qemu/qemu-uefi-aarch64.bin -drive if=none,file=openSUSE-Tumbleweed-ARM-JeOS-efi.aarch64.raw,id=hd0 -device virtio-blk-device,drive=hd0 -enable-kvm
Could not access KVM kernel module: No such file or directory
qemu-system-aarch64: failed to initialize kvm: No such file or directory
```

The nestedVirtualization setting in .wslconfig should boot the CPU as EL2 (or, optionally, enabling HYP mode), enabling KVM on WSL on ARM.

**Describe alternatives you've considered**

Without KVM, virtualization can still be achieved in usermode, but without KVM acceleration.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the ARM EFI bootloader behavior controlled by the nestedVirtualization setting in .wslconfig. Reproduce the current state with dmesg and the provided qemu-system-aarch64 commands; done means the CPU starts at EL2 and KVM is available on WSL on ARM.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, linux
Domain
operating-systems
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.