Calls to the kvm crate have been replaced by calls to hypervisor and
devices::irqchip. Plugin is unchanged and still KVM-specific.
x86 creates and configures vcpus on the vcpu thread instead of the main
thread.
Code that still depends on kvm or kvm_sys:
- crosvm_plugin, plugin, and protos use kvm and kvm_sys if built with
the plugin feature
- devices::VfioGroup does a kvm_sys ioctl
- devices::irqchip and hypervisor use kvm_sys. hypervisor uses
kvm::Cap and kvm::CpuId internally for now.
BUG=chromium:1077058
TEST=runs es2gears_wayland on kukui
TEST=runs evince on amd64-generic with kernel and split irqchip
TEST=build_test excluding tpm2
TEST=cargo check --features plugin
Change-Id: I0068e34da6a5ff0079b1237be1958933bf12ffe4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2307711
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Steven Richman <srichman@google.com>
This CL takes the global map_request and uses it as an Arc<Mutex<>>
reference in virtio gpu, enabling virtio gpu backends to generate
external library mappings.
The workflow is demonstrated in the gfxstream backend:
1. Guest triggers vkMapMemory on host
2. Host generates a blob id, sends back to guest
3. Guest asks to RESOURCE_CREATE_BLOB with the blob id,
creating a resource id
4. Guest asks to RESOURCE_MAP_BLOB with the resulting resource id
5. Host gets hva, size from the backend using the resource id
6. Host maps hva, size via KVM to the guest pci offset via sending a
ExternalMapping over map_request
7. Guest maps that PCI offset, exposing memory to guest userspace
BUG=b/153580313
TEST=dEQP.vk.memory.*
Change-Id: I242beedab1dcaf9eb08d9797ed10dc993b58abde
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035595
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
The balloon policy is based on the guest and host available memory
statistics; add some logs to make it possible to see why the balloon is
being resized when debugging memory balance issues.
BUG=chromium:1097385
TEST=Run crosvm on hatch; verify balloon messages match `free` output
Change-Id: Ia664d1ece7a5e088253984c9179aa72d42f35ec5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2321331
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
For now, this crate simply re-exports all of sys_util, but it will
be updated to provide new interfaces when needed. This is the
first step to making crosvm not directly depend on sys_util, so
that we can make the interface changes we need without fear of
negatively affecting (i.e. completely breaking) other usages
within chromeos.
BUG=b:162363783
TEST=./build_test
Change-Id: I7d0aa3d8a1f66af1c7fee8fd649723ef17027150
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2325168
Tested-by: Michael Hoyle <mikehoyle@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Move GuestAddress and GuestMemory to a new crate for VM memory. This
will make separating sys_util and crosvm independent making it easier
to use sys_util functions outside of crosvm.
Change-Id: I12e14948ea85754dfa6267b3a3fb32b77ef6796e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2311251
Auto-Submit: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
This is good for enabling non-exportable Vulkan host coherent memory,
along with anything else where an exportable OS object isn't supported.
This CL introduces:
1. ExternalMapping, which wraps an external library mapping using
function callbacks, for purposes of sharing device memory to the guest
in the case where the device memory is not compatible with the mmap interface.
This is common in Vulkan when VkDeviceMemory is host visible but not
external, or external but based on an opaque fd.
The lifetime of the library mapping is tied to the lifetime of the
ExternalMapping.
2. Usually, we would send such memory requests over a socket to the main
thread. However, since these new objects require more metadata than
other requests that are sent over the wire (because there's information
about inheritance and refcounts), we also plumb the "map_request" field,
which wraps a single ExternalMapping.
Note that this ExternalMapping will not work in the sandbox case. In the
sandbox case, we will then have to figure out how to serialize/deserialize
ExternalMapping requests over a socket.
BUG=b/146066070, b/153580313
TEST=compile and test
Change-Id: I3b099b308aec45a313a8278ed6274f9dec66c30b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2034029
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
When using vulkan and syncfd in the gpu parameters with backend
other than gfxstream, crosvm should quit with error messages.
BUG=None
TEST=cargo test --features=gpu,gfxstream
Change-Id: I63c3634598297450ab31f1c1d50c24a0d143e80d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2295841
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
This change includes support for core scheduling in sys_util and the
usage of it within the vcpu threads.
Because the core scheduling prctl is not yet stabilized, this feature is
specific to Chrome OS for now. To indicate this, the new "chromeos"
feature has been added to the appropriate Cargo.toml files.
TEST=cargo build --features "chromeos plugin"
BUG=b:153989878
Change-Id: I8b6ce00b26c482739536b632f08e55264dc513a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2284184
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Auto-Submit: Zach Reizner <zachr@chromium.org>
This will allow it to be disabled for Protected KVM usecases on Android.
BUG=b:158290206
TEST=cargo test
Change-Id: Ibddd8a98c42bb0847aba804f5e33df29feedd783
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2292372
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
BUG=chromium:1053847
TEST=Listen to the socket from VmLogForwarder, observer messages
forwarded into separate output file.
Change-Id: Ia472e34b78db599e91f63e72a13bf8539d0d6312
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2287077
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Nicholas Verne <nverne@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Auto-Submit: Nicholas Verne <nverne@chromium.org>
rlim64_t is defined as u64 in the 'Linux' version of the libc crate for
all architectures, so this shouldn't change current behaviour.
BUG=b:158290206
TEST=cargo test
Change-Id: Ie04a212c0dadcfc3010f13a058064ff75c7835a5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2283335
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
Add a gpu argument to control whether vulkan support should be enabled
for gfxstream backend. Default to enabled.
BUG=None
TEST=launch_cvd
Change-Id: Icf9b24890f7c0da30f6c64326391037c6df1c853
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2286238
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
io_jail has been migrated to aosp/external/minijail/rust/minijail.
This removes the crosvm copy and updates the references to use the new
location.
BUG=chromium:1096175
TEST=cargo test
Cq-Depend: chromium:2254418
Change-Id: I29d5c6178b6faf5e52671cfbe6fc7e51f0d21dd2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2254298
Tested-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Allen Webb <allenwebb@google.com>
Writing xattrs in the security namespace requires CAP_SYS_ADMIN in the
namespace that mounted the file system. The fs device doesn't have this
capability when run in a sandbox (and in the case of the /home directory
on chrome os, will never be able to gain it).
We've been able to set selinux xattrs so far because the selinux module
relaxes the capability check in favor of an selinux-based MAC check.
However, android also wants to be able to set the "security.sehash"
xattr, which is described in the manpage as a "performance optimization"
when recursively relabeling files.
Unfortunately since the android team nacked the kernel patch[1] that
would have relaxed the requirements for just the "security.sehash"
xattr, the only option for us is to rewrite the xattr name and prefix it
with "user.virtiofs" so that it ends up in the "user." xattr namespace.
The server should always have permission to create xattrs there.
BUG=b:155443663
TEST=start a vm and successfully set the security.sehash xattr then
check on the host side that it is actually stored as
user.virtiofs.security.sehash
[1]: https://www.spinics.net/lists/selinux/msg32330.html
Change-Id: Icd17b76c946c92d92009f0cc2b8b50c92ac580c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2243111
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
- Reduces code duplication between MMIO and mmap arenas
- Makes adding future types easier
- Makes upcoming deprecation of kvm crate easier
- Use BTreeMap instead of HashMap since it's more efficient
BUG=chromium:924405
TEST=compile and test
Change-Id: I520abed0926489e64aac046e0dc0cfeb72fae7b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2216446
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Steven Richman <srichman@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Enable support for user provided ACPI tables with supplementary system
description. Argument --acpi-table shall point to exsting file or
pseudo-file with valid ACPI table content.
BUG=None
TEST=boot Linux kernel with generated SSDT tables.
Change-Id: I8eac21da070dcc325884ed888cc7bcb01bc086ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2212501
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Tomasz Jeznach <tjeznach@chromium.org>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
The original stated purpose of this trait was to reduce memory
allocations but having the `into_iovec` method return a Vec kind of
defeats that purpose.
Refactor the trait so that it can either convert a T into an iovec or
convert a &[T] into a &[iovec]. Implement the trait for VolatileSlice,
IoSlice, and IoSliceMut and update all the callers.
BUG=none
TEST=unit tests
Cq-Depend: chromium:2210272
Change-Id: I9d0d617a23030d241d50411f4a5a16e7cba4bcee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2208527
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: Chirantan Ekbote <chirantan@chromium.org>
This CL adds a fundamental part of the virtio video device, which will
be shared between the encoder and the decoder.
Both devices uses the virtio-video protocol proposed as RFC v3 [1,2].
The corresponding driver code is at CL:2060327 and its children CLs.
The actual decoding and encoding logic will be implemented in different
CLs.
[1]: mail: https://markmail.org/thread/wxdne5re7aaugbjg
[2]: PDF: https://drive.google.com/file/d/1jOsS2WdVhL4PpcWLO8Zukq5J0fXDiWn-/view
BUG=b:147465619, b:140082257
TEST=cargo check --features=video-decoder,video-encoder
TEST=ARCVM started with --video-decoder --video-encoder
Cq-Depend: chromium:2203997
Change-Id: I01999eea218ba0f3aaed1558ca2311a57d0c6819
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1973973
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
The trait IntoRawFd isn't marked unsafe, but its documentation says that
an impl must return a uniquely owned RawFd. Some code blocks depended on
that behavior to ensure safety with the unsafe File::from_raw_fd, but
this leads to a soundness hole where a nominally safe impl of IntoRawFd
can lead to unsafety in functions that had been left as safe.
This change sidesteps the issue by not using IntoRawFd, and using only
safe conversions instead.
BUG=None
TEST=cargo build --features='wl-dmabuf plugin'
Change-Id: I9b357e5592be21189fb96e343823dd63000aac30
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2185580
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Auto-Submit: Zach Reizner <zachr@chromium.org>
Allow mounts from the parent namespace to propagate into the virtio-fs
device's mount namespace.
BUG=b:123377807
TEST=vm.Fio.virtiofs_stress_rw and manual
Change-Id: I1b8f1b411bd72a8cf5d5b4b30fa5dad466f1e48f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2156327
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1979257
created a padding of read-only pages between the end of the pmem region
and padding up to the next multiple of 2MiB. However, on ARM systems,
kvm_arch_prepare_memory_region does not permit read-only pages on a
write-able memory region.
BUG=b:148706939
TEST=Tested on x86_64 and arm64 board with pmem image < 2MiB
Tested-by: Iliyan Malchev <malchev@google.com>
Change-Id: If06c2e0f74fdcd7db1b7d56e1a8d732d17f352bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2153103
Tested-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Because TimerFd is a wrapper around a 'File' that is never modified
there isn't a need for a mutable borrow. The kernel already handles the
interior mutability of the underlying file descriptor.
Change-Id: I7ae068cc54050b0021d00620b561335b2ae0ba16
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2161625
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
This allows the creation of virtio-console devices using the new
hardware=virtio-console parameter to the --serial option.
Also add support for the serial earlycon option, which allows using
virtio-console as the main console device with a traditional serial
device as the early console. This allows logging during early boot
before PCI device discovery (when virtio-console devices are set up).
BUG=chromium:1059924
TEST=crosvm run -r vm_rootfs.img \
--serial hardware=serial,type=stdout,console=false,earlycon=true \
--serial hardware=virtio-console,type=stdout,console=true,stdin=true \
vm_kernel
Change-Id: Iff48800272b154d49b1da00f3914799089268afe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127322
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Split the serial code into two parts:
- Configuration and setup: arch/src/serial.rs
- Serial device emulation: devices/src/serial.rs
No change in functionality - this is just preparation for generalizing
the command line parsing/setup code so that it can be used with virtio
console devices as well.
BUG=chromium:1059924
TEST=emerge-nami crosvm
TEST=emerge-kevin crosvm
Change-Id: I0aaf9dd6f8096eac4a17077ab5bf569f57d64ff5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127319
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Allowing the input to be specified for file-based serial ports allows
the user of pipes as input/output. That enables kgdb over serial.
TEST=
Build a kernel with support for gdb
```
make x86_64_defconfig
make kvmconfig
./scripts/config --enable GDB_SCRIPTS
./scripts/config --enable KGDB
./scripts/config --enable KGDB_SERIAL_CONSOLE
./scripts/config --enable KGDB_LOW_LEVEL_TRAP
./scripts/config --enable KGDB_KDB
./scripts/config --enable KDB_KEYBOARD
./scripts/config --enable GDB_SCRIPTS
./scripts/config --set-val KDB_CONTINUE_CATASTROPHIC 0
make -j33
```
Setup devices for PTYs
To make sure crosvm doesn't create an ordinary file if socat is started
after it, create these named pipes first:
```
mkfifo ~/console_{in,out} ~/kgdb_{in,out}
```
Set up two PTYs: ~/kgdb for the debugger, and ~/serial for the console.
PTY ~/kgdb connects to ~/kgdb{in,out}, and ~/serial connects to
~/console{in,out}
```
socat -d -d -d \
'PIPE:$HOME/console_out,rdonly=1,nonblock=1,ignoreeof=1!!PIPE:$HOME/console_in,wronly=1' \
PTY,link=$HOME/serial,ctty,raw,echo=0
socat -d -d -d \
'PIPE:$HOME/kgdb_out,rdonly=1,nonblock=1,ignoreeof=1!!PIPE:$HOME/kgdb_in,wronly=1' \
PTY,link=$HOME/kgdb,ctty,raw,echo=0
```
Start crosvm with serial ports pointed at ~/console{in,out} and ~/kgdb{in,out}.
```
cargo run run -p 'init=/bin/sh panic=0 kgdboc=ttyS1,115200 kgdbwait kgdbcon' \
--serial type=file,path=$HOME/console_out,num=1,console=true,stdin=false,input=$HOME/console_in \
--serial type=file,path=$HOME/kgdb_out,input=$HOME/kgdb_in,num=2,console=false,stdin=false \
-r ~/rootfs.img \
~/src/linux/arch/x86/boot/bzImage
```
Start GDB
```
gdb vmlinux -ex "target remote /home/dgreid/kgdb"
```
To break into gdb, open up the serial console, mount /proc and send a SysRq
```
minicom -D ~/serial
mount -t proc none /proc
echo g > /proc/sysrq-trigger
```
Change-Id: I18a9c1087d38301df49de08eeae2f8559b03463a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2151856
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Receiving no data can be considered a special case for MsgOnSocket. It
doesn't necessarily indicate EOF because usually messages are sent over
a datagram channel and some fixed sized messages are actually zero
sized. This change handles this by adding a specific result for
receiving no data when at least some was expected. This will also
simplify some error handling that had to unpack the `BadRecvSize`
variant.
TEST=cargo test -p msg_socket
BUG=None
Change-Id: I16feeabc1481de93a2b189989d095434b5b417b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2079178
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zach Reizner <zachr@chromium.org>
In preparation for moving balloon sizing logic from crosvm to concierge,
expose a balloon_stats command in crosvm. This will allow concierge to
query the actual balloon size and available memory of VMs.
BUG=b:153134684
TEST=(chroot)$ tast run <DUT> arc.Boot.vm; (vm)$ crosvm balloon_stats
<pipe>; See stats are reported.
Change-Id: I1f544526ee728a085d842035754a0c17cf41ed3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2141752
Tested-by: Charles Dueck <cwd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Charles Dueck <cwd@chromium.org>
Previously, writable pmem devices implemented the flush command using
fsync(); however, this does not guarantee synchronization of memory
mappings via mmap() to the file on disk. What we actually need is
msync() on the pmem file mapping, but we don't have access to that
mapping in the pmem child process, and it isn't trivial to pass it along
since it is owned by the Vm object once it has been added as a
mmap_arena.
In order to call msync() on the mapping, add a new VmControl socket so
that the pmem device can request that the main process issues an msync()
on the MemoryMappingArena identified by its slot number.
BUG=chromium:1007535
TEST=mount filesystem on /dev/pmem0 and sync; verify msync in strace
Change-Id: Id0484757c422cf81d454fd54012a12dbcc1baaf6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2044365
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Poll available memory from the host and guest every second. Resize the
balloon so that available memory in the guest is the same as in the
host.
balancemem_timer adds a Token::BalanceMemory to poll_ctx every second
which creates a balloon stats request.
When the stats results come back from the guest, we compute how much the
balloon should change to balance available memory between the guest and
host. If this new balloon size is > 5% different than the current
balloon size, we make a BalloonControlCommand::Adjust to resize the
balloon.
BUG=b:147334004
TEST=tast run <DUT> arc.MemoryChomeOSPerf*, .vm shows memory use similar
to the base arc test. tast run <DUT> arc.MemoryShiftingPerf.vm, both
chromeos and android counters report high numbers. Switch
LOWMEM_AVAILABLE constant to non-existing file, check the ARCVM reports
not running in ChromeOS, but still boots.
Change-Id: I8a581f86bf4881541d2f5f26dc541b35b862d244
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2061518
Reviewed-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Charles Dueck <cwd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Charles Dueck <cwd@chromium.org>
While only 32 bits of address can be mapped, that 32 bits can be offset
by further than 32 bits in to a large file. As chirantan points out, the
try_mmap call was already casting the usize to u64 on all architectures.
Convert the usize offset in mmap to u64 and address users of the API as
well.
Change-Id: I67aed928ea521049fb51eb7aa61ea4de8b4d096c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2124879
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Virtio-net multi queue feature need multi queue pairs, this patch change
queue-num configurable instead of static. --net-vq-pairs parameter could
config virtio net device virtual queue pairs.
BUG=chromium:1064482
TEST=Test virtio net function in guest with --net-vq-pairs=1 and
--net-vq-pairs=2
Change-Id: I75202c8ae52a83b8087b52149ec6d2138d8831cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2120312
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
In order to support 2 vq pairs for virtio-net, this patch create 2
sockets in one tap interface, 2 vq pairs(rx/tx) and 2 threads in
device model, So one vq pair has one thread and one socket in tap
corresponding.
On my SkyLake desktop with crosvm and ubuntu 18.04 guest:
If run one iperf server on host and one iperf client in guest, 2 vq
pairs has the same netwrok bandwidth as 1 vq pair, the bandwidth is
5.99Gbits/sec
If run two iperf server on host and two iperf client in guest,
In 1 vq pair mode, two iperf cliens bandwidth are 3.19Gbits/sec and
3.18Gbits/sec.
In 2 vq pairs mode, two iperf clients bandwidth are 4.87Gbits/sec and
4.86Gbits/sec.
So 2 vq pairs improve net bandwidth 52.7% compared with 1 vq pair in
this case.
BUG=chromium:1064482
TEST=Run iperf test in guest
Change-Id: I1fa14d7e24085552dc828a89a883d4a2ada34789
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2099754
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Introduces the ability to request BalloonStats from a
BalloonControlCommand.
BUG=b:147334004
TEST=tast run <DUT> arc.Boot.vm, and the balance available changes based
on this.
Change-Id: I808c4024f8c644c9cc4e30cc455ceda5f477bff3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2061517
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Charles Dueck <cwd@chromium.org>
1. Replace --cras-audio, --cras-capture, null-audio options by --ac97
option to create audio devices.
2. "--ac97 backend=BACKEND\
[capture=true,capture_effect=EFFECT]" is comma
separated key=value pairs for setting up Ac97 devices.
It can be given more than once to create multiple devices. Possible
key values are:
backend=(null, cras) - Where to route the audio device.
`null` for /dev/null, and cras for CRAS server.
capture=true - Enable audio capture.
capture_effects - | separated effects to be enabled
for recording. The only supported effect value now is EchoCancellation
or aec.
BUG=b:140866281
TEST=1.crosvm run -r ./vm_rootfs.img -c 4 -m 1024 -s /run --cid 5 --host_ip\
100.115.92.25 --netmask 255.255.255.252 --ac97\
backend=cras,capture=true,capture_effect=aec\
--mac d2:47:f7:c5:9e:53 ./vm_kernel
2. Record with the vm by:
arecord -D hw:0,0 -d5 -fS16_LE -c2 -r48000 /tmp/test.mp3
3. Verify that AEC is enabled within the recording stream by
cras_test_cleint.
Cq-Depend: chromium:2053654
Cq-Depend: chromium:2095644
Cq-Depend: chromium:2038221
Change-Id: Ia9e0e7cda1671a4842ec77a354efaa4a2dc745eb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2038413
Tested-by: Judy Hsiao <judyhsiao@chromium.org>
Commit-Queue: Judy Hsiao <judyhsiao@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Auto-Submit: Judy Hsiao <judyhsiao@chromium.org>
Change the type of argument::Error::InvalidValue::expected from "&'static str" to String.
It allows the lower level parse error object to handle the output of the expected value so that
the rule of parsing will not be duplicated.
For example, instead of:
```
v.parse::<Settings>()
.map_err(|e| argument::Error::InvalidValue {
value: v.to_string(),
expected: "The value of setting should null or cras",
})?;
```
we can have:
```
v.parse::<Settings>()
.map_err(|e| argument::Error::InvalidValue {
value: v.to_string(),
expected: e.to_string(),
})?;
```
and the expected value can be handled in the Display implementaion of
Settings::ParseError.
BUG=b:140866281
TEST=cargo build
Change-Id: Ieba12a21103945fe0e47c70a190a4e5d985af537
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2103605
Tested-by: Judy Hsiao <judyhsiao@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Auto-Submit: Judy Hsiao <judyhsiao@chromium.org>
Commit-Queue: Judy Hsiao <judyhsiao@chromium.org>
Fixes warnings of the form:
warning: this method call currently resolves to `<&[T; N] as
IntoIterator>::into_iter` (due to autoref coercions), but that might
change in the future when `IntoIterator` impls for arrays are added.
BUG=None
TEST=emerge-nami crosvm
Change-Id: I2b46b55f0e967d985d04678c240604b542e27e07
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2093287
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Current one vm could have one vfio device only, this patch let one vm
could have multi vfio devices by changing the vfio parameter into vec<>.
BUG=chromium:992270
TEST=passthrough two/three devices into guest, these devices are in the
same vfio group, then check these devices function in guest.
Change-Id: I366d24d750a199d7862fb907fa44f9be429c5944
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2080111
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
These have been marked as deprecated for several release; use --disk or
--rwdisk instead.
BUG=None
TEST=./build_test.py
Change-Id: I8a52c9abaf3f41e2dfc4189dd19c7d828802772e
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1906992
Reviewed-by: Zach Reizner <zachr@chromium.org>
current one container contains one group only, but one container could
contain multi groups actually. The main gap that current code to
support multi groups is that container will be initialized multi times
when multi groups exist, as each group will initialize container one time.
This patch extracts the code which should run one time only on a
container, so when the first group is added into container, this
container initialize code will run once. The container once initialize
code contains:
a. Set iommu driver type as VfioType1V2
b. Setup Iommu table on each guest memory region
c. create vfio_kvm device, so kernel kvm and vfio is associated.
BUG=chromium:992270
TEST=passthrough two/three vfio devices into guest, these devices belong
to different vfio groups, then check these devices function in guest.
Change-Id: I94c9c86f70f49957a5e5c1dfd2c7d823ad042320
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2078970
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Previously, all input events in CrosVM were required to be linux
input_events, which have a timestamp field that is actually unused by
when we send/receive from the guest which are of type
virtio_input_event. This CL allows CrosVM to understand both types of input
events in a first class manner. It is a follow up on
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1930405.
This CL also addresses some bugs with window driven input:
1. attach_event_device was being called before the surface was
created, so the devices were never attached.
2. The default touchpad size was not being set to the display window
size.
Additionally, it removes the unused event "filter" feature on event
sources.
Breaking change: from this point forward, CrosVM will treat input events sent
via a socket (e.g. SocketEventSource) to be virtio_input_events.
BUG=None
TEST=builds + manual
Change-Id: I7fec07c582e5a071a6f116975ba70d6e621bb483
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2034046
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
When features for Hyper-V are enabled there's a another type of exit
that can be triggered. This change attempts to add support for those
types of exits.
BUG=b:150151095
TEST=ran build_test
Change-Id: I3131a2c8d9c610576ac177dbfe82f78e8d5dbfb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2073254
Reviewed-by: Matt Delco <delco@chromium.org>
Tested-by: Matt Delco <delco@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Matt Delco <delco@chromium.org>
Auto-Submit: Matt Delco <delco@chromium.org>
Devices use irqfd to inject interrupts, we listen to them in the main
thread and activate userspace pic/ioapic accordingly.
BUG=chromium:908689
TEST=lanuch linux guest with `--split-irqchip` flag
Change-Id: If30d17ce7ec9e26dba782c89cc1b9b2ff897a70d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945798
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
TODO: Route irqfd to PIC, and use signal to kick vCPU thread when
interrupt is triggered.
BUG=chromium:908689
TEST=Unit tests in file.
Change-Id: I9a87502da57e725d3bb26d746a337d0ba44ef337
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945797
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
When the gpu feature is not enabled, the compiler warns about unused
imports of DEFAULT_TOUCH_DEVICE_HEIGHT and DEFAULT_TOUCH_DEVICE_WIDTH.
Put these imports behind a cfg check to silence the warning.
BUG=None
TEST=cargo build
TEST=emerge-nami crosvm # test with gpu feature enabled
Change-Id: Ib60072cc78a8ffd0ac39dcb4d3a60ba4c9d424b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2080645
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Convert playback and capture for the AC97 device to use the zero-copy
ShmStreamSource instead of the old StreamSource.
In the process, rework start_playback and start_capture unit tests so
they rely less on sleep statements.
BUG=chromium:968724
BUG=chromium:1006035
TEST="sox -n -r 48000 -b 16 output.raw synth 5 sine 330 &&
aplay -f dat output.raw" within a VM, check that sine wave is played
accurately.
Change-Id: Ie9cddbc5285a9505872c9951a8a1da01de70eb88
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1749950
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Fletcher Woodruff <fletcherw@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>