1*bb4ee6a4SAndroid Build Coastguard Worker# Architecture 2*bb4ee6a4SAndroid Build Coastguard Worker 3*bb4ee6a4SAndroid Build Coastguard WorkerThe principle characteristics of crosvm are: 4*bb4ee6a4SAndroid Build Coastguard Worker 5*bb4ee6a4SAndroid Build Coastguard Worker- A process per virtual device, made using fork on Linux 6*bb4ee6a4SAndroid Build Coastguard Worker- Each process is sandboxed using [minijail] 7*bb4ee6a4SAndroid Build Coastguard Worker- Support for several CPU architectures, operating systems, and [hypervisors] 8*bb4ee6a4SAndroid Build Coastguard Worker- Written in Rust for security and safety 9*bb4ee6a4SAndroid Build Coastguard Worker 10*bb4ee6a4SAndroid Build Coastguard WorkerA typical session of crosvm starts in `main.rs` where command line parsing is done to build up a 11*bb4ee6a4SAndroid Build Coastguard Worker`Config` structure. The `Config` is used by `run_config` in `src/crosvm/sys/unix.rs` to setup and 12*bb4ee6a4SAndroid Build Coastguard Workerexecute a VM. Broken down into rough steps: 13*bb4ee6a4SAndroid Build Coastguard Worker 14*bb4ee6a4SAndroid Build Coastguard Worker1. Load the Linux kernel from an ELF or bzImage file. 15*bb4ee6a4SAndroid Build Coastguard Worker1. Create a handful of control sockets used by the virtual devices. 16*bb4ee6a4SAndroid Build Coastguard Worker1. Invoke the architecture-specific VM builder `Arch::build_vm` (located in `x86_64/src/lib.rs`, 17*bb4ee6a4SAndroid Build Coastguard Worker `aarch64/src/lib.rs`, or `riscv64/src/lib.rs`). 18*bb4ee6a4SAndroid Build Coastguard Worker1. `Arch::build_vm` will create a `RunnableLinuxVm` to represent a virtual machine instance. 19*bb4ee6a4SAndroid Build Coastguard Worker1. `create_devices` creates every PCI device, including the virtio devices, that were configured in 20*bb4ee6a4SAndroid Build Coastguard Worker `Config`, along with matching [minijail] configs for each. 21*bb4ee6a4SAndroid Build Coastguard Worker1. `Arch::assign_pci_addresses` assigns an address to each PCI device, prioritizing devices that 22*bb4ee6a4SAndroid Build Coastguard Worker report a preferred slot by implementing the `PciDevice` trait's `preferred_address` function. 23*bb4ee6a4SAndroid Build Coastguard Worker1. `Arch::generate_pci_root`, using a list of every PCI device with optional `Minijail`, will 24*bb4ee6a4SAndroid Build Coastguard Worker finally jail the PCI devices and construct a `PciRoot` that communicates with them. 25*bb4ee6a4SAndroid Build Coastguard Worker1. Once the VM has been built, it's contained within a `RunnableLinuxVm` object that is used by the 26*bb4ee6a4SAndroid Build Coastguard Worker VCPUs and control loop to service requests until shutdown. 27*bb4ee6a4SAndroid Build Coastguard Worker 28*bb4ee6a4SAndroid Build Coastguard Worker## Forking 29*bb4ee6a4SAndroid Build Coastguard Worker 30*bb4ee6a4SAndroid Build Coastguard WorkerDuring the device creation routine, each device will be created and then wrapped in a `ProxyDevice` 31*bb4ee6a4SAndroid Build Coastguard Workerwhich will internally `fork` (but not `exec`) and [minijail] the device, while dropping it for the 32*bb4ee6a4SAndroid Build Coastguard Workermain process. The only interaction that the device is capable of having with the main process is via 33*bb4ee6a4SAndroid Build Coastguard Workerthe proxied trait methods of `BusDevice`, shared memory mappings such as the guest memory, and file 34*bb4ee6a4SAndroid Build Coastguard Workerdescriptors that were specifically allowed by that device's security policy. This can lead to some 35*bb4ee6a4SAndroid Build Coastguard Workersurprising behavior to be aware of such as why some file descriptors which were once valid are now 36*bb4ee6a4SAndroid Build Coastguard Workerinvalid. 37*bb4ee6a4SAndroid Build Coastguard Worker 38*bb4ee6a4SAndroid Build Coastguard Worker## Sandboxing Policy 39*bb4ee6a4SAndroid Build Coastguard Worker 40*bb4ee6a4SAndroid Build Coastguard WorkerEvery sandbox is made with [minijail] and starts with `create_sandbox_minijail` in `jail` crate 41*bb4ee6a4SAndroid Build Coastguard Workerwhich set some very restrictive settings. Linux namespaces and seccomp filters are used for 42*bb4ee6a4SAndroid Build Coastguard Workersandboxing. Each seccomp policy can be found under `jail/seccomp/{arch}/{device}.policy` and should 43*bb4ee6a4SAndroid Build Coastguard Workerstart by `@include`-ing the `common_device.policy`. With the exception of architecture specific 44*bb4ee6a4SAndroid Build Coastguard Workerdevices (such as `Pl030` on ARM or `I8042` on x86_64), every device will need a different policy for 45*bb4ee6a4SAndroid Build Coastguard Workereach supported architecture. 46*bb4ee6a4SAndroid Build Coastguard Worker 47*bb4ee6a4SAndroid Build Coastguard Worker## The VM Control Sockets 48*bb4ee6a4SAndroid Build Coastguard Worker 49*bb4ee6a4SAndroid Build Coastguard WorkerFor the operations that devices need to perform on the global VM state, such as mapping into guest 50*bb4ee6a4SAndroid Build Coastguard Workermemory address space, there are the VM control sockets. There are a few kinds, split by the type of 51*bb4ee6a4SAndroid Build Coastguard Workerrequest and response that the socket will process. This also proves basic security privilege 52*bb4ee6a4SAndroid Build Coastguard Workerseparation in case a device becomes compromised by a malicious guest. For example, a rogue device 53*bb4ee6a4SAndroid Build Coastguard Workerthat is able to allocate MSI routes would not be able to use the same socket to (de)register guest 54*bb4ee6a4SAndroid Build Coastguard Workermemory. During the device initialization stage, each device that requires some aspect of VM control 55*bb4ee6a4SAndroid Build Coastguard Workerwill have a constructor that requires the corresponding control socket. The control socket will get 56*bb4ee6a4SAndroid Build Coastguard Workerpreserved when the device is sandboxed and the other side of the socket will be waited on in the 57*bb4ee6a4SAndroid Build Coastguard Workermain process's control loop. 58*bb4ee6a4SAndroid Build Coastguard Worker 59*bb4ee6a4SAndroid Build Coastguard WorkerThe socket exposed by crosvm with the `--socket` command line argument is another form of the VM 60*bb4ee6a4SAndroid Build Coastguard Workercontrol socket. Because the protocol of the control socket is internal and unstable, the only 61*bb4ee6a4SAndroid Build Coastguard Workersupported way of using that resulting named unix domain socket is via crosvm command line 62*bb4ee6a4SAndroid Build Coastguard Workersubcommands such as `crosvm stop` or programmatically via the [`crosvm_control`] library. 63*bb4ee6a4SAndroid Build Coastguard Worker 64*bb4ee6a4SAndroid Build Coastguard Worker## GuestMemory 65*bb4ee6a4SAndroid Build Coastguard Worker 66*bb4ee6a4SAndroid Build Coastguard Worker`GuestMemory` and its friends `VolatileMemory`, `VolatileSlice`, `MemoryMapping`, and 67*bb4ee6a4SAndroid Build Coastguard Worker`SharedMemory`, are common types used throughout crosvm to interact with guest memory. Know which 68*bb4ee6a4SAndroid Build Coastguard Workerone to use in what place using some guidelines 69*bb4ee6a4SAndroid Build Coastguard Worker 70*bb4ee6a4SAndroid Build Coastguard Worker- `GuestMemory` is for sending around references to all of the guest memory. It can be cloned 71*bb4ee6a4SAndroid Build Coastguard Worker freely, but the underlying guest memory is always the same. Internally, it's implemented using 72*bb4ee6a4SAndroid Build Coastguard Worker `MemoryMapping` and `SharedMemory`. Note that `GuestMemory` is mapped into the host address space 73*bb4ee6a4SAndroid Build Coastguard Worker (for non-protected VMs), but it is non-contiguous. Device memory, such as mapped DMA-Bufs, are not 74*bb4ee6a4SAndroid Build Coastguard Worker present in `GuestMemory`. 75*bb4ee6a4SAndroid Build Coastguard Worker- `SharedMemory` wraps a `memfd` and can be mapped using `MemoryMapping` to access its data. 76*bb4ee6a4SAndroid Build Coastguard Worker `SharedMemory` can't be cloned. 77*bb4ee6a4SAndroid Build Coastguard Worker- `VolatileMemory` is a trait that exposes generic access to non-contiguous memory. `GuestMemory` 78*bb4ee6a4SAndroid Build Coastguard Worker implements this trait. Use this trait for functions that operate on a memory space but don't 79*bb4ee6a4SAndroid Build Coastguard Worker necessarily need it to be guest memory. 80*bb4ee6a4SAndroid Build Coastguard Worker- `VolatileSlice` is analogous to a Rust slice, but unlike those, a `VolatileSlice` has data that 81*bb4ee6a4SAndroid Build Coastguard Worker changes asynchronously by all those that reference it. Exclusive mutability and data 82*bb4ee6a4SAndroid Build Coastguard Worker synchronization are not available when it comes to a `VolatileSlice`. This type is useful for 83*bb4ee6a4SAndroid Build Coastguard Worker functions that operate on contiguous shared memory, such as a single entry from a scatter gather 84*bb4ee6a4SAndroid Build Coastguard Worker table, or for safe wrappers around functions which operate on pointers, such as a `read` or 85*bb4ee6a4SAndroid Build Coastguard Worker `write` syscall. 86*bb4ee6a4SAndroid Build Coastguard Worker- `MemoryMapping` is a safe wrapper around anonymous and file mappings. Provides RAII and does 87*bb4ee6a4SAndroid Build Coastguard Worker munmap after use. Access via Rust references is forbidden, but indirect reading and writing is 88*bb4ee6a4SAndroid Build Coastguard Worker available via `VolatileSlice` and several convenience functions. This type is most useful for 89*bb4ee6a4SAndroid Build Coastguard Worker mapping memory unrelated to `GuestMemory`. 90*bb4ee6a4SAndroid Build Coastguard Worker 91*bb4ee6a4SAndroid Build Coastguard WorkerSee [memory layout](https://crosvm.dev/book/appendix/memory_layout.html) for details how crosvm 92*bb4ee6a4SAndroid Build Coastguard Workerarranges the guest address space. 93*bb4ee6a4SAndroid Build Coastguard Worker 94*bb4ee6a4SAndroid Build Coastguard Worker### Device Model 95*bb4ee6a4SAndroid Build Coastguard Worker 96*bb4ee6a4SAndroid Build Coastguard Worker### `Bus`/`BusDevice` 97*bb4ee6a4SAndroid Build Coastguard Worker 98*bb4ee6a4SAndroid Build Coastguard WorkerThe root of the crosvm device model is the `Bus` structure and its friend the `BusDevice` trait. The 99*bb4ee6a4SAndroid Build Coastguard Worker`Bus` structure is a virtual computer bus used to emulate the memory-mapped I/O bus and also I/O 100*bb4ee6a4SAndroid Build Coastguard Workerports for x86 VMs. On a read or write to an address on a VM's bus, the corresponding `Bus` object is 101*bb4ee6a4SAndroid Build Coastguard Workerqueried for a `BusDevice` that occupies that address. `Bus` will then forward the read/write to the 102*bb4ee6a4SAndroid Build Coastguard Worker`BusDevice`. Because of this behavior, only one `BusDevice` may exist at any given address. However, 103*bb4ee6a4SAndroid Build Coastguard Workera `BusDevice` may be placed at more than one address range. Depending on how a `BusDevice` was 104*bb4ee6a4SAndroid Build Coastguard Workerinserted into the `Bus`, the forwarded read/write will be relative to 0 or to the start of the 105*bb4ee6a4SAndroid Build Coastguard Workeraddress range that the `BusDevice` occupies (which would be ambiguous if the `BusDevice` occupied 106*bb4ee6a4SAndroid Build Coastguard Workermore than one range). 107*bb4ee6a4SAndroid Build Coastguard Worker 108*bb4ee6a4SAndroid Build Coastguard WorkerOnly the base address of a multi-byte read/write is used to search for a device, so a device 109*bb4ee6a4SAndroid Build Coastguard Workerimplementation should be aware that the last address of a single read/write may be outside its 110*bb4ee6a4SAndroid Build Coastguard Workeraddress range. For example, if a `BusDevice` was inserted at base address 0x1000 with a length of 111*bb4ee6a4SAndroid Build Coastguard Worker0x40, a 4-byte read by a VCPU at 0x39 would be forwarded to that `BusDevice`. 112*bb4ee6a4SAndroid Build Coastguard Worker 113*bb4ee6a4SAndroid Build Coastguard WorkerEach `BusDevice` is reference counted and wrapped in a mutex, so implementations of `BusDevice` need 114*bb4ee6a4SAndroid Build Coastguard Workernot worry about synchronizing their access across multiple VCPUs and threads. Each VCPU will get a 115*bb4ee6a4SAndroid Build Coastguard Workercomplete copy of the `Bus`, so there is no contention for querying the `Bus` about an address. Once 116*bb4ee6a4SAndroid Build Coastguard Workerthe `BusDevice` is found, the `Bus` will acquire an exclusive lock to the device and forward the 117*bb4ee6a4SAndroid Build Coastguard WorkerVCPU's read/write. The implementation of the `BusDevice` will block execution of the VCPU that 118*bb4ee6a4SAndroid Build Coastguard Workerinvoked it, as well as any other VCPU attempting access, until it returns from its method. 119*bb4ee6a4SAndroid Build Coastguard Worker 120*bb4ee6a4SAndroid Build Coastguard WorkerMost devices in crosvm do not implement `BusDevice` directly, but some are examples are `i8042` and 121*bb4ee6a4SAndroid Build Coastguard Worker`Serial`. With the exception of PCI devices, all devices are inserted by architecture specific code 122*bb4ee6a4SAndroid Build Coastguard Worker(which may call into the architecture-neutral `arch` crate). A `BusDevice` can be proxied to a 123*bb4ee6a4SAndroid Build Coastguard Workersandboxed process using `ProxyDevice`, which will create the second process using a fork, with no 124*bb4ee6a4SAndroid Build Coastguard Workerexec. 125*bb4ee6a4SAndroid Build Coastguard Worker 126*bb4ee6a4SAndroid Build Coastguard Worker### `PciConfigIo`/`PciConfigMmio` 127*bb4ee6a4SAndroid Build Coastguard Worker 128*bb4ee6a4SAndroid Build Coastguard WorkerIn order to use the more complex PCI bus, there are a couple adapters that implement `BusDevice` and 129*bb4ee6a4SAndroid Build Coastguard Workercall into a `PciRoot` with higher level calls to `config_space_read`/`config_space_write`. The 130*bb4ee6a4SAndroid Build Coastguard Worker`PciConfigMmio` is a `BusDevice` for insertion into the MMIO `Bus` for ARM devices. For x86_64, 131*bb4ee6a4SAndroid Build Coastguard Worker`PciConfigIo` is inserted into the I/O port `Bus`. There is only one implementation of `PciRoot` 132*bb4ee6a4SAndroid Build Coastguard Workerthat is used by either of the `PciConfig*` structures. Because these devices are very simple, they 133*bb4ee6a4SAndroid Build Coastguard Workerhave very little code or state. They aren't sandboxed and are run as part of the main process. 134*bb4ee6a4SAndroid Build Coastguard Worker 135*bb4ee6a4SAndroid Build Coastguard Worker### `PciRoot`/`PciDevice`/`VirtioPciDevice` 136*bb4ee6a4SAndroid Build Coastguard Worker 137*bb4ee6a4SAndroid Build Coastguard WorkerThe `PciRoot`, analogous to `BusDevice` for `Bus`s, contains all the `PciDevice` trait objects. 138*bb4ee6a4SAndroid Build Coastguard WorkerBecause of a shortcut (or hack), the `ProxyDevice` only supports jailing `BusDevice` traits. 139*bb4ee6a4SAndroid Build Coastguard WorkerTherefore, `PciRoot` only contains `BusDevice`s, even though they also implement `PciDevice`. In 140*bb4ee6a4SAndroid Build Coastguard Workerfact, every `PciDevice` also implements `BusDevice` because of a blanket implementation 141*bb4ee6a4SAndroid Build Coastguard Worker(`impl<T: PciDevice> BusDevice for T { … }`). There are a few PCI related methods in `BusDevice` to 142*bb4ee6a4SAndroid Build Coastguard Workerallow the `PciRoot` to still communicate with the underlying `PciDevice` (yes, this abstraction is 143*bb4ee6a4SAndroid Build Coastguard Workervery leaky). Most devices will not implement `PciDevice` directly, instead using the 144*bb4ee6a4SAndroid Build Coastguard Worker`VirtioPciDevice` implementation for virtio devices, but the xHCI (USB) controller is an example 145*bb4ee6a4SAndroid Build Coastguard Workerthat implements `PciDevice` directly. The `VirtioPciDevice` is an implementation of `PciDevice` that 146*bb4ee6a4SAndroid Build Coastguard Workerwraps a `VirtioDevice`, which is how the virtio specified PCI transport is adapted to a transport 147*bb4ee6a4SAndroid Build Coastguard Workeragnostic `VirtioDevice` implementation. 148*bb4ee6a4SAndroid Build Coastguard Worker 149*bb4ee6a4SAndroid Build Coastguard Worker### `VirtioDevice` 150*bb4ee6a4SAndroid Build Coastguard Worker 151*bb4ee6a4SAndroid Build Coastguard WorkerThe `VirtioDevice` is the most widely implemented trait among the device traits. Each of the 152*bb4ee6a4SAndroid Build Coastguard Workerdifferent virtio devices (block, rng, net, etc.) implement this trait directly and they follow a 153*bb4ee6a4SAndroid Build Coastguard Workersimilar pattern. Most of the trait methods are easily filled in with basic information about the 154*bb4ee6a4SAndroid Build Coastguard Workerspecific device, but `activate` will be the heart of the implementation. It's called by the virtio 155*bb4ee6a4SAndroid Build Coastguard Workertransport after the guest's driver has indicated the device has been configured and is ready to run. 156*bb4ee6a4SAndroid Build Coastguard WorkerThe virtio device implementation will receive the run time related resources (`GuestMemory`, 157*bb4ee6a4SAndroid Build Coastguard Worker`Interrupt`, etc.) for processing virtio queues and associated interrupts via the arguments to 158*bb4ee6a4SAndroid Build Coastguard Worker`activate`, but `activate` can't spend its time actually processing the queues. A VCPU will be 159*bb4ee6a4SAndroid Build Coastguard Workerblocked as long as `activate` is running. Every device uses `activate` to launch a worker thread 160*bb4ee6a4SAndroid Build Coastguard Workerthat takes ownership of run time resources to do the actual processing. There is some subtlety in 161*bb4ee6a4SAndroid Build Coastguard Workerdealing with virtio queues, so the smart thing to do is copy a simpler device and adapt it, such as 162*bb4ee6a4SAndroid Build Coastguard Workerthe rng device (`rng.rs`). 163*bb4ee6a4SAndroid Build Coastguard Worker 164*bb4ee6a4SAndroid Build Coastguard Worker## Communication Framework 165*bb4ee6a4SAndroid Build Coastguard Worker 166*bb4ee6a4SAndroid Build Coastguard WorkerBecause of the multi-process nature of crosvm, communication is done over several IPC primitives. 167*bb4ee6a4SAndroid Build Coastguard WorkerThe common ones are shared memory pages, unix sockets, anonymous pipes, and various other file 168*bb4ee6a4SAndroid Build Coastguard Workerdescriptor variants (DMA-buf, eventfd, etc.). Standard methods (`read`/`write`) of using these 169*bb4ee6a4SAndroid Build Coastguard Workerprimitives may be used, but crosvm has developed some helpers which should be used where applicable. 170*bb4ee6a4SAndroid Build Coastguard Worker 171*bb4ee6a4SAndroid Build Coastguard Worker### `WaitContext` 172*bb4ee6a4SAndroid Build Coastguard Worker 173*bb4ee6a4SAndroid Build Coastguard WorkerMost threads in crosvm will have a wait loop using a [`WaitContext`], which is a wrapper around a 174*bb4ee6a4SAndroid Build Coastguard Worker`epoll` on Linux and `WaitForMultipleObjects` on Windows. In either case, waitable objects can be 175*bb4ee6a4SAndroid Build Coastguard Workeradded to the context along with an associated token, whose type is the type parameter of 176*bb4ee6a4SAndroid Build Coastguard Worker`WaitContext`. A call to the `wait` function will block until at least one of the waitable objects 177*bb4ee6a4SAndroid Build Coastguard Workerhas become signaled and will return a collection of the tokens associated with those objects. The 178*bb4ee6a4SAndroid Build Coastguard Workertokens used with `WaitContext` must be convertible to and from a `u64`. There is a custom derive 179*bb4ee6a4SAndroid Build Coastguard Worker`#[derive(EventToken)]` which can be applied to an `enum` declaration that makes it easy to use your 180*bb4ee6a4SAndroid Build Coastguard Workerown enum in a `WaitContext`. 181*bb4ee6a4SAndroid Build Coastguard Worker 182*bb4ee6a4SAndroid Build Coastguard Worker#### Linux Platform Limitations 183*bb4ee6a4SAndroid Build Coastguard Worker 184*bb4ee6a4SAndroid Build Coastguard WorkerThe limitations of `WaitContext` on Linux are the same as the limitations of `epoll`. The same FD 185*bb4ee6a4SAndroid Build Coastguard Workercan not be inserted more than once, and the FD will be automatically removed if the process runs out 186*bb4ee6a4SAndroid Build Coastguard Workerof references to that FD. A `dup`/`fork` call will increment that reference count, so closing the 187*bb4ee6a4SAndroid Build Coastguard Workeroriginal FD will not actually remove it from the `WaitContext`. It is possible to receive tokens 188*bb4ee6a4SAndroid Build Coastguard Workerfrom `WaitContext` for an FD that was closed because of a race condition in which an event was 189*bb4ee6a4SAndroid Build Coastguard Workerregistered in the background before the `close` happened. Best practice is to keep an FD open and 190*bb4ee6a4SAndroid Build Coastguard Workerremove it from the `WaitContext` before closing it so that events associated with it can be reliably 191*bb4ee6a4SAndroid Build Coastguard Workereliminated. 192*bb4ee6a4SAndroid Build Coastguard Worker 193*bb4ee6a4SAndroid Build Coastguard Worker### `serde` with Descriptors 194*bb4ee6a4SAndroid Build Coastguard Worker 195*bb4ee6a4SAndroid Build Coastguard WorkerUsing raw sockets and pipes to communicate is very inconvenient for rich data types. To help make 196*bb4ee6a4SAndroid Build Coastguard Workerthis easier and less error prone, crosvm uses the `serde` crate. To allow transmitting types with 197*bb4ee6a4SAndroid Build Coastguard Workerembedded descriptors (FDs on Linux or HANDLEs on Windows), a module is provided for sending and 198*bb4ee6a4SAndroid Build Coastguard Workerreceiving descriptors alongside the plain old bytes that serde consumes. 199*bb4ee6a4SAndroid Build Coastguard Worker 200*bb4ee6a4SAndroid Build Coastguard Worker## Code Map 201*bb4ee6a4SAndroid Build Coastguard Worker 202*bb4ee6a4SAndroid Build Coastguard WorkerSource code is organized into crates, each with their own unit tests. 203*bb4ee6a4SAndroid Build Coastguard Worker 204*bb4ee6a4SAndroid Build Coastguard Worker- `./src/` - The top-level binary front-end for using crosvm. 205*bb4ee6a4SAndroid Build Coastguard Worker- `aarch64` - Support code specific to 64-bit ARM architectures. 206*bb4ee6a4SAndroid Build Coastguard Worker- `base` - Safe wrappers for system facilities which provides cross-platform-compatible interfaces. 207*bb4ee6a4SAndroid Build Coastguard Worker- `cros_async` - Runtime for async/await programming. This crate provides a `Future` executor based 208*bb4ee6a4SAndroid Build Coastguard Worker on `io_uring` and one based on `epoll`. 209*bb4ee6a4SAndroid Build Coastguard Worker- `devices` - Virtual devices exposed to the guest OS. 210*bb4ee6a4SAndroid Build Coastguard Worker- `disk` - Library to create and manipulate several types of disks such as raw disk, [qcow], etc. 211*bb4ee6a4SAndroid Build Coastguard Worker- `hypervisor` - Abstract layer to interact with hypervisors. For Linux, this crate is a wrapper of 212*bb4ee6a4SAndroid Build Coastguard Worker `kvm`. 213*bb4ee6a4SAndroid Build Coastguard Worker- `e2e_tests` - End-to-end tests that run a crosvm VM. 214*bb4ee6a4SAndroid Build Coastguard Worker- `infra` - Infrastructure recipes for continuous integration testing. 215*bb4ee6a4SAndroid Build Coastguard Worker- `jail` - Sandboxing helper library for Linux. 216*bb4ee6a4SAndroid Build Coastguard Worker- `jail/seccomp` - Contains minijail seccomp policy files for each sandboxed device. Because some 217*bb4ee6a4SAndroid Build Coastguard Worker syscalls vary by architecture, the seccomp policies are split by architecture. 218*bb4ee6a4SAndroid Build Coastguard Worker- `kernel_loader` - Loads kernel images in various formats to a slice of memory. 219*bb4ee6a4SAndroid Build Coastguard Worker- `kvm_sys` - Low-level (mostly) auto-generated structures and constants for using KVM. 220*bb4ee6a4SAndroid Build Coastguard Worker- `kvm` - Unsafe, low-level wrapper code for using `kvm_sys`. 221*bb4ee6a4SAndroid Build Coastguard Worker- `media/libvda` - Safe wrapper of [libvda], a ChromeOS HW-accelerated video decoding/encoding 222*bb4ee6a4SAndroid Build Coastguard Worker library. 223*bb4ee6a4SAndroid Build Coastguard Worker- `net_sys` - Low-level (mostly) auto-generated structures and constants for creating TUN/TAP 224*bb4ee6a4SAndroid Build Coastguard Worker devices. 225*bb4ee6a4SAndroid Build Coastguard Worker- `net_util` - Wrapper for creating TUN/TAP devices. 226*bb4ee6a4SAndroid Build Coastguard Worker- `qcow_util` - A library and a binary to manipulate [qcow] disks. 227*bb4ee6a4SAndroid Build Coastguard Worker- `sync` - Our version of `std::sync::Mutex` and `std::sync::Condvar`. 228*bb4ee6a4SAndroid Build Coastguard Worker- `third_party` - Third-party libraries which we are maintaining on the ChromeOS tree or the AOSP 229*bb4ee6a4SAndroid Build Coastguard Worker tree. 230*bb4ee6a4SAndroid Build Coastguard Worker- `tools` - Scripts for code health such as wrappers of `rustfmt` and `clippy`. 231*bb4ee6a4SAndroid Build Coastguard Worker- `vfio_sys` - Low-level (mostly) auto-generated structures, constants and ioctls for [VFIO]. 232*bb4ee6a4SAndroid Build Coastguard Worker- `vhost` - Wrappers for creating vhost based devices. 233*bb4ee6a4SAndroid Build Coastguard Worker- `virtio_sys` - Low-level (mostly) auto-generated structures and constants for interfacing with 234*bb4ee6a4SAndroid Build Coastguard Worker kernel vhost support. 235*bb4ee6a4SAndroid Build Coastguard Worker- `vm_control` - IPC for the VM. 236*bb4ee6a4SAndroid Build Coastguard Worker- `vm_memory` - VM-specific memory objects. 237*bb4ee6a4SAndroid Build Coastguard Worker- `x86_64` - Support code specific to 64-bit x86 machines. 238*bb4ee6a4SAndroid Build Coastguard Worker 239*bb4ee6a4SAndroid Build Coastguard Worker[hypervisors]: https://crosvm.dev/book/hypervisors.html 240*bb4ee6a4SAndroid Build Coastguard Worker[libvda]: https://chromium.googlesource.com/chromiumos/platform2/+/refs/heads/main/arc/vm/libvda/ 241*bb4ee6a4SAndroid Build Coastguard Worker[minijail]: https://crosvm.dev/book/appendix/minijail.html 242*bb4ee6a4SAndroid Build Coastguard Worker[qcow]: https://en.wikipedia.org/wiki/Qcow 243*bb4ee6a4SAndroid Build Coastguard Worker[vfio]: https://www.kernel.org/doc/html/latest/driver-api/vfio.html 244*bb4ee6a4SAndroid Build Coastguard Worker[`crosvm_control`]: https://crosvm.dev/book/running_crosvm/programmatic_interaction.html 245*bb4ee6a4SAndroid Build Coastguard Worker[`waitcontext`]: https://crosvm.dev/doc/base/struct.WaitContext.html 246