summary refs log tree commit diff
Commit message (Collapse)AuthorAge
...
* virtio-gpu: Allocate buffers with shared bind flag using gbm.David Riley2019-07-03
| | | | | | | | | | | BUG=chromium:972237 TEST=eglgears_wayland Change-Id: If5a09c1ad95dfdbd47e7810c466c127c53413f21 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1657291 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: David Riley <davidriley@chromium.org> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
* gpu_renderer: update virglrenderer bindingsDavid Riley2019-07-03
| | | | | | | | | | | | | | | Results of: gpu_renderer/src/generated/generate --sysroot /build/$BOARD bin/fmt BUG=chromium:972237 TEST=builds Change-Id: I75063345a6cc77b54f51cfdaf244e5f73dffefcb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1657290 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: David Riley <davidriley@chromium.org> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
* devices: virtio: add bindings to a new capsetGurchetan Singh2019-07-03
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* gpu_buffer: add ability to get backend nameGurchetan Singh2019-07-03
| | | | | | | | | | | | | | | This is useful for letting the guest know about host-specific features. BUG=chromium:924405 TEST=compile Change-Id: I0edc4280eec7235644c9ad8561dbe063276bb3bd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1650288 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>
* main: add seccomp-log-failures flag to command lineZach Reizner2019-06-27
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* usb: switch to new libusb_wrap_sys_device APIDaniel Verkamp2019-06-27
| | | | | | | | | | | | | | | | | | | | 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>
* main: add --rwroot option to runDaniel Verkamp2019-06-27
| | | | | | | | | | | | | | | 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>
* usb: Arm seccomp policy needs _llseek, not lseekDaniel Verkamp2019-06-27
| | | | | | | | | | | | | | | | | 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>
* kernel_loader: check phdr memory size additionDaniel Verkamp2019-06-25
| | | | | | | | | | | | | | | 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>
* fuzz: zimage: use a fixed guest memory sizeDaniel Verkamp2019-06-25
| | | | | | | | | | | | | | | | | 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>
* devices: pci: preserve read-only bits in write_regDaniel Verkamp2019-06-25
| | | | | | | | | | | | | | | | | | 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>
* devices: pci: check BAR address alignmentDaniel Verkamp2019-06-25
| | | | | | | | | | | | | | | 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>
* devices: pci: allocate BARs with correct alignmentDaniel Verkamp2019-06-25
| | | | | | | | | | | | | | | | | | 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>
* devices: pci: Change host brige into IntelXiong Zhang2019-06-25
| | | | | | | | | | | | | | | | 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>
* devices: pci: use header type 0 for host bridgeDaniel Verkamp2019-06-25
| | | | | | | | | | | | | | | | | | | 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>
* gpu_renderer: make Box3 less error prone with constructorZach Reizner2019-06-24
| | | | | | | | | | | | | | | | | | | 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>
* data_model: add sub_slice method to VolatileSliceZach Reizner2019-06-24
| | | | | | | | | | | | | | | | | 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>
* gpu_display: fix dangling NULL pointer in dwl_context_setupZach Reizner2019-06-24
| | | | | | | | | | | | | | | | | | | | 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>
* devices: Use Reader/Writer interfaces in virtio-net.Jakub Staron2019-06-24
| | | | | | | | | | | | | BUG=chromium:966258 TEST=tast run ${IP} vm.CrostiniStartEverything TEST=tast run ${IP} vm.CrostiniNetworkPerf Change-Id: I99c5b9e564c219b76593d729fb934722fc8a3431 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1658980 Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Stephen Barber <smbarber@chromium.org>
* gpu: Allow more than one resource bridge socketChirantan Ekbote2019-06-24
| | | | | | | | | | | | | | | | | | | | | | | | 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>
* devices: Add separate seccomp policy for pmem deviceJakub Staron2019-06-21
| | | | | | | | | | | | | | | 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>
* fuzz: Comply with new guest memory requirement for page alignmentDylan Reid2019-06-21
| | | | | | | | | | | | | | | 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>
* crosvm: Implement Reader/Writer interface over DescriptorChain.Jakub Staron2019-06-21
| | | | | | | | | | | | | | | | | | | 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>
* qcow: disallow crazy l1 table sizesDylan Reid2019-06-21
| | | | | | | | | | | | | | | 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>
* qcow: Fix invalid_cluster_bits testDylan Reid2019-06-21
| | | | | | | | | | | | | | | | 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>
* crosvm: Ensure slices are the same size when copying.Jorge E. Moreira2019-06-21
| | | | | | | | | | | | | Bug=b/135190799 TEST=run cuttlefish in debian host Change-Id: I7f9343dd202da2a163b3e8aeb8fbde5eb4cfb1d3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1659144 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Cody Schuffelen <schuffelen@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Auto-Submit: Jorge Moreira Broche <jemoreira@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org>
* usb: update USBDEVFS_CONNINFO_EX value to new sizeDaniel Verkamp2019-06-21
| | | | | | | | | | | | | | | | | | | | 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>
* crosvm: default serial parameter `num` field to 1 if not providedTrent Begin2019-06-20
| | | | | | | | | | | | | | | | | 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>
* usb: update xhci policies to allow newer libusbDmitry Torokhov2019-06-13
| | | | | | | | | | | | | | | 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: Limit file setups that consume excessive RAMDylan Reid2019-06-12
| | | | | | | | | | | | | | | | | | | | | 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>
* qcow: Calculate the max refcounts as a u64Dylan Reid2019-06-12
| | | | | | | | | | | | 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>
* qcow: better limits on cluster sizeDylan Reid2019-06-12
| | | | | | | | | | | | | | | 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>
* src/linux.rs: Modify socket instead of add socket when remove other socketsXiong Zhang2019-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* crosvm: fix clippy warningsJakub Staron2019-06-08
| | | | | | | | | | | | | | | | | | | 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>
* serial: fix clippy warningsJakub Staron2019-06-08
| | | | | | | | | | | | | | | | 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>
* crosvm: add license blurb to bin/clippy and bin/fmt filesJakub Staron2019-06-08
| | | | | | | | | | | | | | bin/clippy and bin/fmt were missing license blurbs at the top, so update them to include the license blurbs. BUG=None TEST=None Change-Id: Ic6bb5af3885d3735dcad42614aff7ac3dd33d638 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1646736 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Jakub Staroń <jstaron@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* fuzz: adapt zimage fuzzer to new kernel loader APIDaniel Verkamp2019-06-06
| | | | | | | | | | | | | | | | | | After CL:1636685, the kernel_loader API is different - we need to pass a File instead of just a slice to load_kernel(). Borrow and adapt the make_elf_bin() function from the kernel_loader tests to create a shared memory file from a slice of bytes to fix the fuzzer. BUG=chromium:970981 TEST=USE='asan fuzzer' emerge-nami crosvm Change-Id: Ic17f6479fb355d45063ce6292552cb1e5664831a Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1645039 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* usb: reset backend device on port resetDaniel Verkamp2019-06-05
| | | | | | | | | | | | | | | | | | | | | | | | This enables the full firmware update/reset/use device in application mode sequence for Edge TPU USB Accelerator. There is a bit of a UI hiccup: once the firmware update and reset is complete, the device re-enumerates with a different VID/PID, and the "Connect to Linux" prompt shows up again. The user must re-affirm that the device should be connected to Linux to proceed with using the Edge TPU. This may be unavoidable - I'm not sure if we can tell the difference between a newly-inserted device and a reset one. Allowing USBDEVFS_DISCONNECT_CLAIM should be safe, since it can only operate on file descriptors passed into the xhci device jail. BUG=chromium:831850 TEST=Run Edge TPU Accelerator demo and verify that it can update FW Change-Id: I3d61c7bd914830ce25448b1ae4d60e1c16f10aed Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1599881 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* crosvm: virtio-pmem deviceJakub Staron2019-06-05
| | | | | | | | | | | | | | | | | | | | Adds support for virtio-pmem device as an alternative for virtio-blk. Exposing disk image to guest as virtio-blk device results in both guest and host independently caching the disk I/O. Using virtio-pmem device allows to mount disk image as direct access (DAX) in the guest and thus bypass the guest cache. This will reduce memory foodprint of the VMs. BUG=None TEST=cargo test TEST=Boot patched termina kernel in crosvm; mount virtio-pmem device as DAX and run xfstests. Change-Id: I935fc8fc7527f79e5169f07ec7927e4ea4fa6027 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1605517 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Jakub Staroń <jstaron@google.com>
* eliminate mut from non-mut referencesZach Reizner2019-06-04
| | | | | | | | | | | | | | | | | | | | | | | This manifested itself in a couple places that were turning shared memory buffers into slices for the purposes of passing these slices to `Read` and `Write` trait methods. However, this required the removal of the methods that took `Read` and `Write` instances. This was a convenient interface but impossible to implement safely because making slices from raw pointers without enforcing safety guarantees causes undefined behaviour in Rust. It turns out lots of code in crosvm was using these interfaces indirectly, which explains why this CL touches so much. TEST=crosvm run BUG=chromium:938767 Change-Id: I4ff40c98da6ed08a4a42f4c31f0717f81b1c5863 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1636685 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>
* docker: add adhd to checkout_commits.env and update all commitsZach Reizner2019-06-04
| | | | | | | | | | | | | | | | | | This change also includes some code that was missing from upgrade_checkout_commits.sh that actually generated the new checkout_commits.env. BUG=None TEST=kokoro/kokoro_simulator.sh docker/build_crosvm_base.sh docker/build_crosvm.sh Change-Id: If2505dd9af060d15c36eaf54741d4ae371f6a3c7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1641585 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org>
* Initial BIOS support.Cody Schuffelen2019-05-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The --bios argument is added as an alternative to the kernel positional argument. The BIOS runs in unreal mode (16-bit cs selector set to the end of 32-bit address space), which matches the default state KVM puts the segment and data registers into. Example usage: Build u-boot with "make qemu-x86_defconfig && make" Run crosvm with "crosvm_wrapper.sh run --bios=u-boot.rom" This produces the following message: """ U-Boot 2019.01-00017-gdc76aabe6a-dirty (May 21 2019 - 12:17:02 -0700) CPU: DRAM: 16 MiB unable to get online cpu number: -19 Warning: MP init failure Model: QEMU x86 (I440FX) Net: No ethernet found. error: can't find etc/table-loader Hit any key to stop autoboot: 0 => """ At this point the u-boot shell works with stdin/stdout, but virtual disks passed with --rwdisk weren't immediately visible from running "virtio scan" and "virtio info". This change puts the bios loading together with the linux kernel loading code since there is a lot of overlap in functionality. Bug: b/133358982 Test: ./crosvm_wrapper.sh run --mem=4097 --bios=u-boot.rom Change-Id: I65b0e1044233af662a642c592d35b106217f3c13 Reviewed-on: https://chromium-review.googlesource.com/1622648 Commit-Ready: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* linux: Add cras-capture option for cras-audio devicepaulhsia2019-05-31
| | | | | | | | | | | | | | | | | | | | The flag can enable capturing audio from CRAS server to the cras-audio device. We'll re-enable capture function on Crostini after finishing capture permission works. BUG=chromium:932268 TEST=Boot vm with crosvm --cras-audio --cras-capture to check recording functionality. Cq-Depend: chromium:1628633 Change-Id: I7502cbd668cbc722224164d9f69e50a16b0ab86b Reviewed-on: https://chromium-review.googlesource.com/1628687 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Chih-Yang Hsia <paulhsia@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
* enumn: fix duplicate fn in doc testsDaniel Verkamp2019-05-30
| | | | | | | | | | | | | | | Two parts of the documentation mention the generated `fn n`, which (as of Rust 1.35) causes a doc test failure. Change these code blocks to be ignored instead of executed to avoid the problem. BUG=None TEST=cargo test --doc -p enumn Change-Id: I9d08d2a35d65930bd2fa899256c00e1da643ba4f Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1632035 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* rust-toolchain: upgrade to Rust 1.35.0Daniel Verkamp2019-05-30
| | | | | | | | | | | BUG=None TEST=docker/wrapped_smoke_test.sh Change-Id: I0a159d9b54d97098d633ce80b92eeb48eb5c4b55 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1632036 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* crosvm: fix unused variable warning in create_virtio_devicesDmitry Torokhov2019-05-29
| | | | | | | | | | | | | | | The gpu_device_socket is not used when GPU support is disabled. BUG=chromium:967436 TEST=cargo build --no-default-features Change-Id: I5c0ef0ecf27349bcfbc19474879a282c9f6fb8ef Reviewed-on: https://chromium-review.googlesource.com/1631292 Commit-Ready: Dmitry Torokhov <dtor@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dmitry Torokhov <dtor@chromium.org> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
* devices: block: issue fsync when FlushTimer expiresDaniel Verkamp2019-05-29
| | | | | | | | | | | | | | | | | | The RequestType::Flush handler correctly uses fsync(), which issues an fsync to the underlying disk image file. However, the flush timer (started on write and cancelled if a flush request is executed) was only calling flush(), which is insufficient when the disk image is a raw file - it just flushes in-memory buffers and does not issue an fsync. BUG=None TEST=Issue writes in crosvm; verify fsync in strace output Change-Id: I1de8a35615031b5fdf5599dd6b49015d0b245c31 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1632876 Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* virtio-gpu: add gpu control socketGurchetan Singh2019-05-28
| | | | | | | | | | | | | | | The GPU process will need access to KVM. BUG=chromium:924405 TEST=compile Change-Id: I9e454d79a36a40a20c6c4b3a62ea367f339e526b Reviewed-on: https://chromium-review.googlesource.com/1626793 Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: David Riley <davidriley@chromium.org>
* crosvm: update xhci abi to use new bit_field featuresJingkui Wang2019-05-25
| | | | | | | | | | | | | | We don't need schema anymore. Will use bool and custom enums. BUG=None TEST=local build and run crosvm Change-Id: I1396916878f2903b17a75f375aee4eec1ced0583 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1564780 Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Add an OWNERS fileDylan Reid2019-05-25
| | | | | | | | | | | | | | Per new cros policy. Signed-off-by: Dylan Reid <dgreid@chromium.org> Change-Id: I57c6b4bb5465c5fcdd9477c23547a835c0cfaf33 Reviewed-on: https://chromium-review.googlesource.com/1627218 Commit-Ready: Chris McDonald <cjmcdonald@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>