skills/L2-virtualization-pkvm-expert/SKILL.md
--- name: L2-virtualization-pkvm-expert layer: L2 path_scope: packages/modules/Virtualization/, external/crosvm/, frameworks/libs/vmbase/ version: 1.1.0 android_version_tested: Android 16 parent_skill: aosp-root-router --- # L2 Expert: pKVM / Android Virtualization Framework ## Path Scope | Path | Description | |------|-------------| | `packages/modules/Virtualization/` | AVF mainline module — VirtualizationService, Microdroid, VmPayloadService, vmbase | | `packages/modules/Virtualization/mic
npx skillsauth add jonaschen/Android-Software L2-virtualization-pkvm-expertInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
3 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
| Path | Description |
|------|-------------|
| packages/modules/Virtualization/ | AVF mainline module — VirtualizationService, Microdroid, VmPayloadService, vmbase |
| packages/modules/Virtualization/microdroid/ | Microdroid minimal guest OS, init, microdroid_manager |
| packages/modules/Virtualization/javalib/ | VirtualMachineManager Java API surface |
| packages/modules/Virtualization/libs/ | Rust guest libraries (libvm_payload, libvmbase) |
| external/crosvm/ | Rust Virtual Machine Monitor (VMM) — virtio backends, vhost, device emulation |
| frameworks/libs/vmbase/ | Bare-metal Rust framework for early-boot VM stages |
| kernel/ | pKVM EL2 hypervisor code (arch/arm64/kvm/) — handled jointly with L2-kernel-gki-expert |
| system/sepolicy/ | Guest + host SELinux policy for AVF — handled jointly with L2-security-selinux-expert |
| hardware/interfaces/virtualization/ | AVF AIDL HAL definitions (if present — vendor extension point) |
Load this skill when the user's task involves any of the following:
pKVM, Protected KVM, /dev/kvm, EL2 hypervisor, stage-2 page tables, VMID, IPA space, memory protection, KVM_CREATE_VM, hypervisor capabilitiesVirtualMachineManager, VirtualizationService, VmPayloadService, AVF, android.system.virtualizationmicrodroid_manager, pVM, protected VM, guest OS boot, microdroid_kernel, DT overlay, guest SELinux policyAF_VSOCK, vsock, host-to-guest IPC, VMADDR_CID_HOST, VMADDR_CID_LOCALVirtualMachineConfig, VirtualMachineRawConfig, Companion Device Manager, VM disk image, vm CLI toolEL3 -- ATF BL31 (Secure Monitor, SMC dispatcher) [L2-trusted-firmware-atf-expert]
EL2 -- pKVM Hypervisor (stage-2 isolation, VMID mgmt) [THIS SKILL]
EL1 -- Linux kernel (host) / Microdroid kernel (guest) [L2-kernel-gki-expert for GKI]
EL0 -- Apps, crosvm VMM (host) / VM payload (guest) [L2-framework-services-expert]
+--------------------------------------------+
| App / System Service | EL0 (host)
| VirtualMachineManager Java API |
+--------------------------------------------+
| VirtualizationService (Rust, AIDL) | EL0 (host)
| vm CLI tool |
+--------------------------------------------+
| crosvm (Rust VMM) | EL0 (host)
| virtio-blk, virtio-net, vsock, console |
+--------------------------------------------+
| Linux kernel (host, GKI) | EL1/EL2 (host)
| KVM subsystem -- /dev/kvm |
+============================================+
| pKVM Hypervisor (arch/arm64/kvm/hyp/) | EL2
| Stage-2 page table isolation |
| VMID namespace management |
+============================================+
| Microdroid kernel + init | EL1 (guest)
| microdroid_manager |
| VM payload (APK / native) | EL0 (guest)
+--------------------------------------------+
| Concept | Detail |
|---------|--------|
| Stage-2 page tables | EL2-controlled IPA->PA mapping; host kernel cannot access guest memory once protected |
| VMID | 16-bit hardware namespace; pKVM assigns and rotates VMIDs |
| Protected VM (pVM) | Guest whose memory is inaccessible to host kernel -- enforced in EL2 |
| Non-Protected VM | Regular KVM VM; host retains full memory access |
| /dev/kvm | Character device gating all KVM/pKVM access; SELinux-controlled |
| KVM_CREATE_VM | ioctl to instantiate a VM; triggers EL2 VMID allocation |
| MMIO emulation | crosvm handles MMIO exits from the guest via the KVM ioctl interface |
1. VirtualizationService -> crosvm launch (host EL0)
2. crosvm -> KVM_CREATE_VM ioctl -> pKVM EL2 setup stage-2 tables
3. Microdroid kernel boots at EL1 (guest)
4. microdroid_manager starts (PID 1 equivalent in guest)
5. microdroid_manager mounts APK/payload disk (virtio-blk)
6. VM payload executes in guest EL0
7. vsock (AF_VSOCK) available for host<->guest IPC
crosvm process (host EL0)
+-- main thread: VM lifecycle, KVM fd management
+-- vcpu threads: one per vCPU, runs KVM_RUN ioctl
+-- virtio-blk: serves guest disk I/O via KVM mmio exit
+-- virtio-net: TAP/virtio network backend
+-- virtio-vsock: AF_VSOCK host<->guest socket relay
+-- virtio-console: serial console, adb logcat
+-- vhost-user: optional out-of-process device backends
| Component | Path |
|-----------|------|
| VirtualizationService | packages/modules/Virtualization/virtualizationservice/ |
| VirtualMachineManager API | packages/modules/Virtualization/javalib/ |
| microdroid_manager | packages/modules/Virtualization/microdroid/ |
| vmbase | packages/modules/Virtualization/libs/vmbase/ |
| crosvm | external/crosvm/ |
| pKVM EL2 code | arch/arm64/kvm/hyp/ (in kernel tree) |
| AVF SELinux policy | system/sepolicy/private/virtualizationservice.te, microdroid_manager.te |
| AVF AIDL | packages/modules/Virtualization/virtualizationservice/aidl/ |
| vm CLI tool | packages/modules/Virtualization/vm/ |
| Change | Impact |
|--------|--------|
| AVF LL-NDK support | Vendors can launch VMs from the vendor partition using Google-managed AVF. New Low-Level NDK surface exposes AVF capabilities to native vendor code. |
| Early boot VM support | VMs can run earlier in the boot process, enabling security-critical payloads like KeyMint HALs to be isolated in a pVM before the full Android framework starts. Cross-skill impact with init/boot sequence. |
| FF-A support | pKVM supports FF-A (Firmware Framework for Arm A-profile) for standardized secure communication with TrustZone. Replaces ad-hoc SMC-based communication. Requires kernel-level FF-A support. |
| Ferrochrome Linux terminal | Debian-based Linux terminal running inside a VM via AVF/crosvm. Developer-facing feature. Path: external/crosvm/, packages/modules/Virtualization/ |
| Microdroid 16K + resizable storage | 16KB page protected VM support and resizable encrypted storage for improved performance. |
| Trusty OS in pVMs | Standard TAs can now run TrustZone-style applets inside protected VMs, not just in traditional TrustZone. Blurs ATF/pKVM boundary. |
| Device assignment promoted | Graduated from experimental (A15) to supported. Platform devices can be directly assigned to pVMs for hardware access. |
| Hypervisor tracing | Structured logging events and improved function tracing for pKVM debugging. |
A16 AVF capability model changes:
L2-init-boot-sequence-expertL2-trusted-firmware-atf-expertL2-kernel-gki-expertmicrodroid/ subdirs but must be consistent with system/sepolicy/ conventions./dev/kvm is present. pKVM requires CONFIG_KVM=y and hypervisor support enabled at boot. Always check ro.boot.hypervisor.protected_vm.supported before assuming pVM capability.VMADDR_CID_HOST (2); guests use dynamically assigned CIDs. Hardcoding CIDs causes silent connectivity failures.android.system.virtualmachine), not a vendor HAL. Use L2-framework-services-expert for API surface questions.cc_binary); use rust_binary in Android.bp.scripts/check_pkvm_status.sh [--adb-serial <serial>]
Checks: /dev/kvm presence, ro.boot.hypervisor.* props, AVF feature flag, running VMs via vm list.
adb commands# Check pKVM support
adb shell getprop ro.boot.hypervisor.protected_vm.supported
adb shell getprop ro.boot.hypervisor.vm.supported
adb shell ls -la /dev/kvm
# List running VMs
adb shell vm list
# Run a Microdroid test VM
adb shell vm run-microdroid --mem-mib 512
# Inspect crosvm logs
adb logcat -s crosvm VirtualizationService
# Inspect guest console output
adb shell vm console <cid>
# Build AVF mainline module
m VirtualizationService microdroid
# Build crosvm
m crosvm
# Run AVF integration tests
atest VirtualizationTestCases
atest MicrodroidTests
| Condition | Hand off to |
|-----------|------------|
| pKVM EL2 code change in arch/arm64/kvm/hyp/ | L2-kernel-gki-expert |
| Guest or host SELinux avc:denied involving /dev/kvm or Microdroid policy | L2-security-selinux-expert |
| SMC call interaction between pKVM and ATF BL31 | L2-trusted-firmware-atf-expert |
| VirtualMachineManager API surface change | L2-framework-services-expert |
| Android.bp build issues for rust_binary AVF targets | L2-build-system-expert |
| GBL pvmfw loading via GBL_EFI_AVF_PROTOCOL (bootloader-stage AVF) | L2-bootloader-lk-expert |
| Android version migration (AVF API compat) | L2-version-migration-expert |
Emit [L2 VIRT → HANDOFF] before transferring.
references/pkvm_microdroid_architecture.md -- Deep dive: pKVM EL2 isolation, crosvm VMM, Microdroid boot flow, vsock IPCpackages/modules/Virtualization/README.md -- Official AVF module documentationdevelopment
--- name: qualcomm-kernel-expert layer: L3 path_scope: vendor/qcom/opensource/, device/qcom/, kernel/msm-*/ version: 1.0.0 android_version_tested: Android 16 (GKI 6.12) parent_skill: kernel-gki-expert --- ## Path Scope | Path | Responsibility | |------|---------------| | `vendor/qcom/opensource/` | Qualcomm open-source kernel modules (camera, audio, wlan, data, video) | | `vendor/qcom/opensource/camera-kernel/` | Camera kernel drivers (IFE, IPE, IOMMU, CCI) | | `vendor/qcom/opensource/audio-ke
development
--- name: mediatek-kernel-expert layer: L3 path_scope: vendor/mediatek/kernel_modules/, vendor/mediatek/proprietary/, device/mediatek/, kernel/mediatek/ version: 1.0.0 android_version_tested: Android 16 (GKI 6.12) parent_skill: kernel-gki-expert --- ## Path Scope | Path | Responsibility | |------|---------------| | `vendor/mediatek/kernel_modules/` | MediaTek out-of-tree kernel modules (connectivity, GPU, display, camera, audio) | | `vendor/mediatek/kernel_modules/connectivity/` | CONNSYS / WM
development
--- name: <oem-or-soc>-<subsystem>-expert layer: L3 path_scope: vendor/<oem>/, device/<oem>/ version: 1.0.0 android_version_tested: Android 16 parent_skill: <L2-parent-skill-name> --- ## Path Scope | Path | Responsibility | |------|---------------| | `vendor/<oem>/` | OEM-proprietary code, BSP blobs, vendor HALs | | `device/<oem>/<device>/` | Device-specific configuration, BoardConfig, overlays | | <!-- Add OEM-specific paths below --> | | ### Inherited Paths (from parent L2 skill) This L3 s
development
--- name: version-migration-expert layer: L2 path_scope: cross-cutting (diff analysis across all paths) version: 1.1.0 android_version_tested: Android 16 parent_skill: aosp-root-router --- ## Path Scope This skill does not own a single physical path. It performs **cross-cutting analysis** across any AOSP path affected by an OS version transition. Key areas of focus: | Area | Relevant Paths | |------|---------------| | API compatibility | `frameworks/base/api/`, `cts/` | | Boot image / partiti