1.38 nightly started warning about using `...` vs `..=`, update to avoid
the warning.
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: Ibc3d24c5410b6eed9a1207db21e529ec6a763376
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1715575
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Zeroing a cluster will be done from more than one place in qcow.rs soon,
add a helper to reduce duplication.
Change-Id: Idb40539f8e4ed2338fc84c0d53b37c913f2d90fe
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1697122
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Input devices were using GuestMemory's read_to_memory and
write_from_memory under the (incorrect) assumption that these function
used the io::Read and io::Write traits, when they in fact use AsRawFd.
BUG=b/137138116
TEST=ran cuttlefish in workstation
Change-Id: I7ab1e2d0ab685dd25dcc91e794766c2f210665f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1700418
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Looks like we ended up with two totally different tempdir
implementations: one from CL:520706 and the other from CL:1409705.
This CL consolidates them into one implementation.
BUG=chromium:974059
TEST=tempfile: cargo test
TEST=crosvm: cargo check --all-features
TEST=devices: cargo check --tests
TEST=sys_util: cargo check --tests
TEST=local kokoro
TEST=./build_test
Cq-Depend: chromium:1574668
Change-Id: Id70e963c9986ed2fc5f160819c4a7f9f16092b3b
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1573227
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Now that nothing uses the PCI-to-PCI bridge device type, the compiler
warns that it is never constructed. Mark the PciHeaderType enum to
allow this, since the enum is public and could be constructed outside
this file.
BUG=None
TEST=./build_test
Change-Id: I6832996c4e00a33cc1ba88d97fede65b226cbfc5
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1691239
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
The crosvm TPM process calls ssleay_rand_bytes(), which in some cases
attempts to acquire entropy through an EGD ("entropy gathering daemon")
- see OpenSSL's RAND_query_egd_bytes(). Attempting to communicate with
this daemon by creating a socket would cause the process to exit
currently because the syscall whitelist did not allow socket() or
connect().
Since we don't have an EGD and don't want to expose it to the sandboxed
TPM process anyway, modify the TPM seccomp policy to cause socket() to
return an error rather than aborting.
BUG=None
TEST=`vmc start --software-tpm termina`
Change-Id: Ib7c6bceced0f6cbe7199614ece8446aa300cec1e
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1684411
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
There are many corner cases when handling sizes that approach u64::max.
Limit the files to 16TB.
BUG=979458
TEST=Added unittest to check large disks fail
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: I93a87c17267ae69102f8d46ced9dbea8c686d093
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1679892
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
The extra % operation will be slower, but none of these divisions are in
hot paths. They are only used during setup. Many of these operations
take untrusted input from the disk file, so need to be hardened.
BUG=979458
TEST=unit tests still pass
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: I0e93c73b345faf643da53ea41bde3349d756bdc7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1679891
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
mem::uninitialized is unsafe, and we already replaced most instances of
it with alternate implementations; however, another one slipped in since
then. Replace it with Default::default() as a safe alterantive.
BUG=None
TEST=./build_test
Change-Id: Idacdcb0ebe197cc93fba4b15c3dda774bb56e73e
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1691233
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
POSIX provides a standard mkdtemp() function to securely create a
temporary directory; use it rather than reinventing the wheel.
This also drops the dependency of tempfile on rand_ish, which will allow
easier use of the tempfile implementation outside of crosvm.
BUG=chromium:974059
TEST=cargo test -p tempfile
Change-Id: I34a226b046dc6f272106988a78d121a24a377f44
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1659971
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Add a number of packages to the build_test.py list so that they are
built and tested during local development. build_test.py doesn't run in
any automated tests currently, but it's still useful for checking
whether everything still builds for multiple architectures without the
overhead of a full portage build.
BUG=None
TEST=./build_test.py
Change-Id: I6d3300ae3189311fb6faffaf10c254636adba7c1
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1682925
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Currently device impliments PciDevice trait, it will return config
register to bus trait at pci cfg r/w, then BusDevice trait on behave
of device to do actual pci config r/w.
But vfio device need to handle the pci config r/w by itself, as
vfio device need to transfer this request to kernel.
For pci config read, this patch delete PciDevice->config_registers(),
and add PciDevice->read_config_register(), then BusDevice->
config_register_read() call PciDevice->read_config_register(), finally
Device could trap the PciConfig Read.
For pci config write, it is similiar with pci config read. But the
common code is moved into PciConfiguration.
BUG=none
TEST=none
Change-Id: Ie6bd3a8c94f523d6fb1ef3d1e97d087bb0407d9f
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1580457
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
This is useful for prototyping new virtgpu features (zero copy, YUV, Vulkan)
without stepping on virglrenderer's capsets.
Initially, the plan is just to transparently support zero-copy in ARCVM.
The bindings were generated from the following header:
https://gitlab.freedesktop.org/gurchetansingh/virtio-gpu-test/blob/master/virtgpu_hw.h
Generated via:
bindgen --with-derive-default virtgpu_hw.h -o virtgpu_hw.rs --no-doc-comments --no-layout-tests \
--whitelist-type=virtgpu_.+ --whitelist-var VIRTGPU_.+ --no-prepend-enum-name
BUG=chromium:924405
TEST=compile
Change-Id: I6000244faa0d619c3ac74105713e63a52d0d9cb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1650289
Reviewed-by: David Riley <davidriley@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
All cros-debug versions of crosvm enabled seccomp logging, which is now
broken on kernels <4.4 thanks to new minijail changes as explained in
the referenced BUG. This seems to be intended by the minijail folks as
the aim to improve the seccomp logging in part by changing its semantics
to logging failures without killing the violating process. In such a
world, crosvm should not as a compile time choice, enable logging, which
would amount to disabling some of the security. This change adds a
command line flag to emulate the old behavior for the purposes of
developer debugging, as long as that developer is running on a kernel
that supports the new minijail seccomp filter failure logging.
BUG=chromium:978998
TEST=USE=cros-debug emerge-eve crosvm && cros deploy eve crosvm
then start crostini in UI
Change-Id: I98190a068a919929e466fe22d6d630b90a758336
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1679380
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@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>
Replace use of our custom, patched libusb APIs with the new
libusb_wrap_sys_device() function, which has been submitted to libusb
upstream. This allows us to drop the bindings for the custom APIs (and
will also allow us to drop the libusb patch that introduces them).
For now, keep this path behind the sandboxed-libusb feature to allow
crosvm to build against older libusb versions that do not have the new
API. This should be cleaned up eventually once we are comfortable with
raising the minimum libusb version required.
BUG=b:133773289
TEST=Attach Android device to Linux VM; deploy app via adb
Change-Id: Ie249c6f3f3b4c63210dd163ca7ad03e2de8a8872
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1676601
Tested-by: kokoro <noreply+kokoro@google.com>
This allows specifying a read-write rootfs (rather than read-only as
with --root), including the automatic kernel command line additions
normally added by --root.
BUG=None
TEST=Boot crosvm with --rwroot and write to root filesystem
Change-Id: I6a3dc9176bffdefe664139cb33bf3e65a751dbf2
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1679531
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Since our Arm version is a 32-bit process, it uses the _llseek syscall
rather than lseek for 64-bit file offset support. Fix the seccomp
filter to match.
Fixes a SIGSYS when attaching a USB device to Linux VM on Arm.
BUG=None
TEST=Attach USB device to kevin; verify device in `adb devices`
Change-Id: Ia46e60df17950bfbe967c4730c62ddb26fb6faa7
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1677318
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
The mem_offset + phdr.memsz addition is using untrusted input
(phdr.memsz) and can overflow; add an explicit check to avoid panics on
invalid values.
BUG=None
TEST=/usr/libexec/fuzzers/crosvm_zimage_fuzzer in cros_fuzz shell
Change-Id: Ie6f7f27bd00958ff85201cecaa75ce2b19779b8b
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1674664
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
GuestMemory::new returns an error if the requested size is not divisible
by the page size. The zimage fuzzer was using a GuestMemory size based
on the size of the fuzzer input; however, it doesn't necessarily make
sense to limit the guest memory to the size of the input. Pick an
arbitrary 256 MB (matching the block fuzzer), which is also a page size
multiple to resolve the original issue.
BUG=chromium:977883
TEST=/usr/libexec/fuzzers/crosvm_zimage_fuzzer in cros_fuzz shell
Change-Id: I08c6be9d920bede18d67f8a1c5c39b9d37fb839c
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1645040
Tested-by: kokoro <noreply+kokoro@google.com>
The 32-bit write_reg() function for PCI configuration space masked off
non-writable (read-only) bits from the incoming value, but it did not
preserve the original bits from the register; this results in writes to
read-only registers to clear all read-only bits to 0 instead. Preserve
the original value of the read-only bits and add a test to verify that
this works.
BUG=None
TEST=./build_test
Change-Id: Icc67b429f17d519ec4e9090f8e0ce48aaff76491
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1660204
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Each PCI BAR address must be aligned to at least its own size to allow
the BAR sizing mechanism to work properly. Add a check in add_pci_bar()
to enforce this.
BUG=None
TEST=Boot vm_kernel in crosvm
Change-Id: Iee9d866c4982bd79935337682bd50b9205b95024
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1660203
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Each PCI BAR must be aligned to at least its own size to allow the BAR
sizing mechanism to work. Change all BAR allocations to use
allocate_with_align(), specifying the size as the alignment.
In particular, this fixes the alignment of the XHCI BAR, whose size is
larger than a page (the default MMIO allocator alignment).
BUG=None
TEST=Boot vm_kernel in crosvm
Change-Id: Icba03771a896b9b4feae608efdb7685fe24f8b98
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1660202
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
For kvmgt linux guest, intel graphic driver i915 need intel host bridge
located at 0000:00.0, so this patch change the vendor id of 0000:00.0 device
to intel.
BUG=none
TEST=none
Change-Id: I52f2341d25859f2b7d4a3837f4f0c8a4b2443525
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581139
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Previously, we were using header type 1 (which is meant to be used only
for PCI-to-PCI bridges), which upsets the Linux PCI probing code:
pci 0000:00:00.0: ignoring class 0x060000 (doesn't match header type 01)
Switch to the standard type 0 header instead, which makes the kernel
happy and matches what real hardware uses.
BUG=None
TEST=Boot vm_kernel (Linux 4.19) in crosvm
Change-Id: I33d10bda39edf6d949827963cebbfe66c9147ea2
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1660892
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
The argument order of the new_2d constructor was very odd. That has been
changed to the ordinary x,y,w,h order. Also, each Box3 is checked by
is_empty() before being used, which prevents some degenerate operations
on zero area boxes.
TEST=cargo run -- run --gpu
BUG=None
Change-Id: I6954fa4846f20353517fe81028058b639752d8ea
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1670549
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
The new method is a copy of the get_slice trait method without the
restriction that the returned VolatileSlice has a lifetime limited to the
VolatileSlice, rather the VolatileSlice's lifetime parameter, which is
longer.
TEST=None
BUG=None
Change-Id: I1578981fcd046ce2d6232b28746c08d912c51b4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1670548
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
If the dwl_context_setup routine fails after creating a wayland
connection succesfully (e.g. if an extension is missing), the fail label
is jumped to in order to disconnect the wayland connection and
deallocate the wl_display structure. That label did not set
self->display to NULL after calling wl_display_disconnect, which would
cause the dwl_context_destroy routine to call wl_display_disconnect again,
which is a double free. This CL fixes that ommission.
TEST=None
BUG=None
Change-Id: I5b6c2d6fadda82dff4130bd4abb0e7764c15e004
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1668528
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Currently the wayland device accesses buffers allocated by the gpu
device via a dedicated socket connection. Upcoming virtual devices like
vdec and camera will also need access to these buffers. Modify the gpu
device so that it can process requests on multiple resource_bridge
sockets.
Each future device that needs access to gpu device buffers should create
a new resource bridge socket pair and add it to the list of sockets that
the gpu device monitors.
The actual interface between the devices is unchanged.
BUG=b:133381367
TEST=run glxgears in a crostini container with and without gpu enabled
Change-Id: I58693881945965071a53653bf4f86681725267d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1652876
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
This change adds separate seccomp policy for pmem device. Previously,
pmem device was using block device seccomp policy.
BUG=None
TEST=Boot VM and run xfstests on pmem device
Change-Id: I3f25d64d4da6ad8f0ff22b285e1a7e958f545c55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1652441
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jakub Staroń <jstaron@google.com>
When the input's length is not page aligned, round it up. This allows
the fuzzer to provide more random inputs without causing the `unwrap`
call to trigger false positives when creating guest memory.
BUG=chromium:972172
TEST=run fuzz case from the bug
Change-Id: Iaf8f2ba943f38b90e168301dbb8c15dee5ee45c8
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1659626
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
This change adds a convinient interface over DescriptorChain. It hides
the complexity of DescriptorChain and allows to treat it as a pair
of read-only and write-only buffers. In the future, it will also allow
to easily support indirect descriptors.
BUG=chromium:966258
TEST=cargo test --package devices descriptor_utils
TEST=run crosvm without sandbox, share a directory, compare
checksum of shared file between host and guest
Change-Id: I9fb722ee2024c8d7d40f560571ec7d7c454bfc2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1647370
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jakub Staroń <jstaron@google.com>
Before this change, a corrupt or malicious qcow file could cause crosvm
to allocate absurd amounts of memory. The fuzzer found this case,
limit the L1 table size so it can't cause issues.
BUG=chromium:974123
TEST=run fuzzer locally, add unit test
Change-Id: Ieb6db6c87f71df726b3cc9a98404581fe32fb1ce
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1660890
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Start with a valid header so the invalid cluster bits field is tested in
isolation. Before this change the test would pass even if the cluster
bits check was removed from the code because the header was invalid for
other reasons.
BUG=none
TEST=this is a test
Change-Id: I5c09417ae3f974522652a50cb0fdc5dc0e10dd44
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1660889
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
The layout of struct usbfs_conninfo_ex was changed in the final revision
of the patch, so the corresponding ioctl number needs to change to
match, since the parameter size is encoded in the ioctl.
The new size is 0x18 or 24, which matches the struct usbfs_conninfo_ex
layout with 7 ports.
BUG=chromium:977020
TEST=Attach Android device to Linux VM on nami
Change-Id: Iec60b4c04880d7d2c71fdea49cfdf7fb5a75f5c6
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1669530
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
If multiple serial parameters do not have `num` fields, or a different
parameter has already defined serial num 1, then crosvm will show an
error.
BUG=chromium:974885
TEST=cargo test; emerge-sarien crosvm && cros deploy dut crosvm;
Manual testing with and without num field in --serial parameter
Change-Id: Ia80247e8d055179adfd9e7471a98e8a2923cf1f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1662773
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Trent Begin <tbegin@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Trent Begin <tbegin@chromium.org>
The updated version of libusb uses USBFS_CONNECTINFO and
USBFS_CONNINFO_EX ioctls, as well as readlink and lseek syscalls,
so let's enable them.
BUG=b:133773289
TEST=Try attaching a USB device to Crostini VM.
Change-Id: Ibdcab2da9abe1c0bb35c989d9d62b44ce403e268
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1650534
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dmitry Torokhov <dtor@chromium.org>
qcow currently makes assumptions about being able to fit the L1 and
refcount tables in memory. This isn't necessarily true for very large
files. The new limits to the size of in-memory buffers still allow 1TB
files with default cluster sizes. Because there aren't any 1 TB
chromebooks available yet, limit disks to that size.
This works around issues found by clusterfuzz related to large files
built with small clusters.
BUG=972165,972175,972160,972172
TEST=fuzzer locally + new unit tests
Change-Id: I15d5d8e3e61213780ff6aea5759b155c63d49ea3
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1651460
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
u32's get multiplied together and can overflow. A usize was being
returned, make everything a u64 to make sure it fits.
Change-Id: I87071d294f4e62247c9ae72244db059a7b528b62
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1651459
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Add a lower limit because cases such as eight byte clusters aren't
practical and aren't worth handling, tracking a cluster costs 16 bytes.
Also put an upper limit on the cluster size, choose 21 bits to match
qemu.
Change-Id: Ifcab081d0e630b5d26b0eafa552bd7c695821686
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1651458
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
When an ill socket is detected, it will be removed from poll_context and
control_sockets, then the remaining good sockets should change their indices,
So modify should be used instead of add, as all of them have been added
into poll_context already, the add will return an error.
This change is merge of another change at
I977be57ea0898cc8226505f7d3da103a46ea626c that was identical to this one
except it contained the following similar commit message:
linux: when renumbering control sockets, use modify instead of add
In some circumstances, a VM control socket will get removed from the
list of control sockets in the run_control loop. Usually, the last
control socket in the list gets removed, but if that is not the case,
the control sockets will get reordered to fill in the gap in the list.
The `add` method of `PollContext` was used to change the token used for
a given control socket, when `modify` should have been used instead.
The problem with using `add` when a control socket is already part of a
`PollContext` is that it will return an error and terminate crosvm. This
CL fixes that issue.
BUG=none
TEST="crosvm run --vfio=$GVT_UUID", then run many gpu workloads in guest
TEST=crosvm run --gpu
Change-Id: Ic00a781d8839e652e2a8fd54ccd8e55849fa20bb
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Signed-off-by: Zach Reizner <zachr@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581151
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Resolve a couple of minor clippy warnings:
- unneeded return statement
- use `if let` instead of `match` for single pattern destruction
- use `values()` function to iterate over map values
- supress warning about `ptr::null()` as expressed by the comment
BUG=None
TEST=./bin/clippy
TEST=cargo build
Change-Id: Ic4cea94cd3a25a9edf6ef38119de8c46dcfec563
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1646739
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Jakub Staroń <jstaron@google.com>
Resolve couple of minor clippy warnings:
- unneeded return statement in last expression of the function
- redundant closure
BUG=None
TEST=./bin/clippy
TEST=cargo build
Change-Id: I602e56289315cb88779c0029d400b24a8180b899
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1646738
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jakub Staroń <jstaron@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>