base: Add more safety nets for checking cpu online status
To see if a cpu is online, in descending order:
1. Parse `/sys/devices/system/cpu/online`
- This is usually globally readable
- Might only exist on Linux Kernel 2.6.20 (~2007) or later
2. Check `/sys/devices/system/cpu/cpuX/online`
- Usually more restricted and some users can't read this file
- x86 and ARM might not have one for CPU 0 since it's special and
can't be offlined
- Might not exist if CONFIG_HOTPLUG_CPU isn't enabled
3. Assume CPU online
- Logs a warning and just guess. This could cause issues later down
the road if we try to probe other sys props of an offline CPU
(b/478085580), so it could just be delaying the crash. Or we could
get lucky and it's actually online.
Cache the cpu online info once at startup so we don't read the files
each time. crosvm currently doesn't handle hotplugged CPUs at runtime
anyways since much of our internal state is only initialized once.
BUG=498448415, 502869543
TEST=./tools/dev_container ./tools/presubmit
Change-Id: Ie28cbbf6290b757e09601c5b33a995d134093237
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/7768126
Commit-Queue: Cassie Wang <cassiewang@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
The ChromeOS Virtual Machine Monitor
crosvm is a secure, lightweight, and performant Virtual Machine Monitor (VMM) written in Rust. Originally developed for ChromeOS to run Linux (Crostini) and Android guests (ARCVM). It is now used across multiple products and platforms such as TerminalApp on Android, Cuttlefish and Windows.
crosvm focuses on security through strong isolation and a modern, memory-safe implementation. It leverages hardware-assisted virtualization to provide a robust execution environment for untrusted code.
io_uring, vhost, and an internal async runtime (cros_async).crosvm implements a wide range of paravirtualized devices via the virtio standard:
virtio-net with optional vhost and slirp backends.virtio-block supporting raw, qcow2, zstd, and Android sparse formats.virtio-gpu with 2D and 3D acceleration (via virglrenderer, gfxstream, or vulkano).virtio-snd with backends for CRAS (ChromeOS), AAudio (Android), and more.virtio-fs and virtio-9p.crosvm is designed with a “process-per-device” model:
forked into its own process.The recommended way to build and develop crosvm is using the provided development container.
Use the dev container to build a release version of crosvm:
./tools/dev_container ./tools/build_release
Follow this example usage to run a simple Linux guest.
#crosvm channel on Matrix.crosvm is an open-source project licensed under the BSD-3-Clause License.