This document outlines the requirements and steps to integrate device assignment support for Android Virtualization Framework (AVF) using pKVM (Protected KVM). Device assignment allows a protected VM (pVM) to have direct, exclusive access to a hardware device.
In the pKVM model, the host kernel is untrusted by the guest pVM. Therefore, the hypervisor (EL2) must mediate device assignment to ensure:
These are some of the main prerequisites to be able to use device assignment.
arm64 only.To enable device assignment, changes are required across the stack: kernel, device tree, and userspace.
Unlike traditional virtualization, pKVM considers the host malicious. The host cannot be trusted to reset the device safely. Therefore, the hypervisor must be able to reset the device.
device_register_reset (internal pKVM API).Note: That is different from the kernel VFIO-platform reset, that is not required in the pKVM model and can be disabled with kernel command line vfio-platform.reset_required=0
The hypervisor needs to know which devices are “assignable” at boot time. This is defined in the host device tree.
Add a pkvm_assignable_devices node to your host device tree:
pkvm_assignable_devices { compatible = "pkvm,device-assignment"; // List of <phandle group_id> pairs devices = <&device_node_1 group_id_1>, ..., <&device_node_N group_id_N>; };
&device_node_X: The phandle to the platform device node in the DT.group_id: An integer identifier. Devices with the same group_id are considered a group (similar to IOMMU groups) and must be assigned together.Starting with kernel 6.12, GKI guests use the pkvm-pviommu driver.
The guest needs to know about the device it is receiving. This is handled via a Device Tree Overlay (DTBO).
crosvm uses this to generate the final guest DT, and pvmfw uses it to verify the configuration.The guest VM likely needs a specific driver to drive the hardware.
Android userspace needs to know which devices are available for assignment.
assignable_devices.xml configuration file.crosvm (the VMM) interacts with the host kernel's vfio-platform driver to bind the device.crosvm uses the KVM-VFIO device to request the hypervisor to assign the device to the VM context.pvmfw (Protected VM Firmware) validates the device assignment against the trusted VM DTBO.pvmfw uses hypercalls to query the hypervisor.