summary refs log tree commit diff
Commit message (Collapse)AuthorAge
* Fix into_iter() usage where iter() sufficesDaniel Verkamp2020-03-10
| | | | | | | | | | | | | | | | | 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>
* gpu_renderer: add virglrenderer logging callbackDavid Stevens2020-03-10
| | | | | | | | | | | BUG=None TEST=boot ARCVM Change-Id: Iea6c5ecc2475ec6f78df100b5df62622c41bd88a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2090956 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Commit-Queue: David Stevens <stevensd@chromium.org>
* descriptor_utils: Add `iter` methodChirantan Ekbote2020-03-10
| | | | | | | | | | | | | | | | Add an `iter` method to the `Reader` struct so that callers can iterate over the objects in place rather than having to store them in a separate collection. BUG=none TEST=unit tests Change-Id: I29671910a4244a8d7786ca2eb241416ae72b8c9f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2093966 Tested-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
* Vfio: Multi vfio device supportXiong Zhang2020-03-09
| | | | | | | | | | | | | | | 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>
* crosvm: remove deprecated --qcow and --rwqcow optionsDaniel Verkamp2020-03-09
| | | | | | | | | | | | | 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>
* devices: virtio: resource_bridge: Transfer plane metadataKeiichi Watanabe2020-03-06
| | | | | | | | | | | | | | | | | Transfer plane offsets and strides for exported GPU resource over resource bridge as well as a resource itself. These metadata will be required by virtio-video decoder and encoder. BUG=b:120456557 TEST=Start ARCVM on atlas Change-Id: Iaf539857c0f8525bd5be294521e75ad32cae05e7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1787032 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Reviewed-by: David Stevens <stevensd@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
* ac97: Mark pci::ac97_bus_master::test::start_playback ignoredMattias Nissler2020-03-06
| | | | | | | | | | | | | | | | The test is flaky and causes continuous build failures. BUG=chromium:1058881 TEST=Tests run, offending test is listed as ignored. Exempt-From-Owner-Approval: Sheriff action to silence flakes on builders Change-Id: I204e6ef548e6f203b0c15b0d01fde3b88660bd44 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2090414 Reviewed-by: Mattias Nissler <mnissler@chromium.org> Commit-Queue: Mattias Nissler <mnissler@chromium.org> Tested-by: Mattias Nissler <mnissler@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* virtio: Add VIRTIO_RING_F_EVENT_IDX test caseXiong Zhang2020-03-06
| | | | | | | | | | | | | | VIRTIO_RING_F_EVENT_IDX use Wrapping(u16) for irq suppressing, this test case to avoid some corner case for Wrapping. BUG=None TEST=Run build_test.py Change-Id: I47d377056fefcc36739bb197e30319deafb0faf4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2073902 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>
* fuzz: ensure sys_util path dependency is usedDaniel Verkamp2020-03-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | When compiling a new-enough crosvm for fuzzing (after https://crrev.com/c/1749950), the build would fail with an error about importing two different version of sys_util: expected struct `sys_util::shm::SharedMemory`, found a different struct `sys_util::shm::SharedMemory` expected reference `sys_util::shm::SharedMemory (struct `sys_util::shm::SharedMemory`) found reference sys_util::shm::SharedMemory (struct `sys_util::shm::SharedMemory`) perhaps two different versions of crate `sys_util` are being used? Fix this by patching the version of sys_util used by audio_streams so that it also uses the path dependency instead of the sys_util from the dev-rust/sys_util ebuild in the fuzz-specific Cargo.toml. BUG=chromium:1057532 TEST=`USE='asan fuzzer' emerge-nami crosvm` Change-Id: I38252465a1111a9a8f643a59e36733016c5db99d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2086401 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
* seccomp: Add missing syscalls to fs device policyChirantan Ekbote2020-03-06
| | | | | | | | | | | | | BUG=none TEST=`tast run <dut> vm.Fio.virtiofs` Change-Id: I937df0be738e0aa302a4ad3e87ed33ff97afb4fc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2089174 Tested-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
* Vfio: multi vfio group supportXiong Zhang2020-03-06
| | | | | | | | | | | | | | | | | | | | | | | | | 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>
* Use simple virtio_input_events where possible.Noah Gold2020-03-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* crosvm: add handling for hyperv exitsMatt Delco2020-03-05
| | | | | | | | | | | | | | | | | 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>
* crosvm: Add plumbing for split-irqchip interruptsZhuocheng Ding2020-03-05
| | | | | | | | | | | | | | | 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>
* Virtio: Add blk VIRTIO_RING_F_EVENT_IDX featureXiong Zhang2020-03-05
| | | | | | | | | | | | | | | | | | | | | | Previous interrupt suppress patch only supply crude interrupt suppress, VIRTIO_RING_F_EVENT_IDX feature supply a more performant alternative: 1) where the driver specifies how far the device can progress before a notification is required 2) where the device specifies how far the driver can progress before a interrrupt is required. This patch add this feature into blk. For gpu and network, this could be added also, but gpu and network performance don't get better. BUG=None TEST=run benchmark for blk in guest Change-Id: I73fe3f8b72a9e88fd6073890bc6ab2bee891d51d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2008341 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>
* devices: PIC: implement interrupt injectionZhuocheng Ding2020-03-05
| | | | | | | | | | | | | | 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>
* Add logic to setup PIC/IOAPIC.Zhuocheng Ding2020-03-05
| | | | | | | | | | | | | TODO: Route irqfd to PIC/IOAPIC to make them fully work. BUG=chromium:908689 TEST=None Change-Id: I301287b1cf32cfccffce6c52ebbb5e123931178e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945796 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>
* linux: fix unused code warning without gpu featureDaniel Verkamp2020-03-02
| | | | | | | | | | | | | | | | 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>
* Virtio: Add queue ack_features() interfaceXiong Zhang2020-03-01
| | | | | | | | | | | | | | | | | Virtio spec define some features like VIRTIO_F_RING_INDIRECT_DESC, VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_RING_PACKED. If one feature is enabled in guest, device's queue will have corresponding behavior for this feature. Queue's ack_features() interface let queue know which features is enabled in guest. BUG=None TEST=build_test Change-Id: I865f93940a1f4db8ca6da8829136127353cc1c6f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2008340 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* acpi: add S1 capability in DSDTChuanxiao Dong2020-02-28
| | | | | | | | | | | | | | | | | | | | S1 is a sleep state which is lighter than S3, but enough to put the devices into the suspended state. With this DSDT, the guest kernel is able to see the S1 capability and to put the VM into virtual S1. During the virtual S1, guest kernel will call each suspend callbacks of the devices driver to put the devices into the suspend state, including the pass through device. BUG=chromium:1018674 TEST=boot linux guest with ACPI enabled, and able to see "shallow" by "cat /sys/power/mem_sleep", which means the S1 Change-Id: I232609f6f2474895fd9ec4046d88236c413e51af Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035353 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
* acpi: allocate sci_irq instead of use fixed numberChuanxiao Dong2020-02-28
| | | | | | | | | | | | | | | | sci_irq can be allocated so not to use the fixed number 9. Actually this irq is not used for injecting any event but the Linux guest OS requires to see meaning value from the FADP table. So just fill it to satisfy. BUG=chromium:1018674 TEST=None Change-Id: If3ea3bb2844fc7fc1c24a577b7098d2a3e6f1c7f Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035352 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
* ac97: switch to ShmStreamSourceFletcher Woodruff2020-02-28
| | | | | | | | | | | | | | | | | | | | | 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>
* x86_64: generate ACPI tablesChuanxiao Dong2020-02-28
| | | | | | | | | | | | | | | | | | | | | | | | Add acpi_rsdp_addr in boot_params to allow crosvm to pass a physicall address of RSDP to the Linux guest kernel, so that the linux guest kernel can parse the constructed ACPI tables and enable the ACPI. Although there is ACPI tables but as we still have "acpi=off" in command line parameter, there is still no ACPI in guest kernel. The ACPI construction refers to the implementation of the Cloud-hypervisor commit: - arch: x86_64: Generate basic ACPI tables BUG=chromium:1018674 TEST=None Change-Id: Ibcb2ae98c43da8ef8c07a07eda9213f61570d14c Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035351 Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
* linux: add disk path to open error messageDaniel Verkamp2020-02-27
| | | | | | | | | | | | | | | | | | | Previously, if a disk could not be opened, the error message did not include the path of the disk, e.g.: The architecture failed to build the vm: error creating devices: failed to load disk image: Read-only file system (os error 30) To make debugging easier, add the path to Error::Disk. BUG=b:150181514 TEST=crosvm run --rwdisk ro.img vm_kernel Change-Id: I7b319c419b889334ecadbb0497dc4b3dc5115aa6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2070844 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* devices: block: let resize convert to non-sparseDaniel Verkamp2020-02-27
| | | | | | | | | | | | | | | | | | | | | Change the behavior of the resize operation on virtio-block devices so that it causes a disk to become fully allocated (non-sparse) even if it had previously been sparse. This means that we could have a disk that was previously sparse and is now non-sparse, so treat discard requests for sparse disks as a no-op instead of an error. This is acceptable since discard is a hint and doing nothing is a valid implementation. BUG=chromium:858815 TEST=`crosvm disk resize` a sparse disk Change-Id: I8b79e460e5432cc71bed98172527fe1cd2e726ed Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2070846 Reviewed-by: David Munro <davidmunro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* devices: pci: add error handling for msix_enableDaniel Verkamp2020-02-27
| | | | | | | | | | | | | | | | | | | | This more gracefully handles failure of msix_enable; in particular, if it fails, the self.enabled state is returned to false so that future device operations won't try to access uninitialized parts of self.irq_vec. In addition, the AddMsiRoute response is now checked (previously, it was just ignored), and errors are bubbled up via MsixError rather than just printing a message. BUG=chromium:1041351 TEST=Boot Crostini on nami Change-Id: I9999f149817bc9f49176487446b52e74fb8be9a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2067964 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* acpi_tables: Add initial ACPI tables supportChuanxiao Dong2020-02-27
| | | | | | | | | | | | | | | | | The basic ACPI table support for creating XSDT. It refers to the implementation of the Cloud-hypervisor's ACPI commit: - Cloud-hypervisor: acpi_tables: Add initial ACPI tables support BUG=chromium:1018674 TEST=cargo test -p acpi_tables Change-Id: Ia3b597936fef214fcb92fce28c91152dfa03bec9 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035350 Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* sys_util: cleanup shared mem file after testMatt Delco2020-02-26
| | | | | | | | | | | | | | | | | | Running "build_test" fails if it's been previously run using sudo. The failure is: thread 'main' panicked at 'error creating shared memory;' and errno is 17, so apparently the shared memory name is left behind. BUG=None TEST=Verified that "sudo build_teat" followed by "build_test" results in a failure, while with this change it reports success. Change-Id: I09748b9c0b89ac953e054de852277d819ad85287 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1876662 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Matt Delco <delco@chromium.org>
* msg_socket: Add async receiving of messagesDylan Reid2020-02-26
| | | | | | | | | | | | | | | | | Add a member to MsgSocket that effectively returns an async iterator over messages received on the socket. This is done by setting the socket as non-blocking and registering with the async infrastructure when the socket would block. This feature will be used by devices that wish to handle messages in an async fn context. Change-Id: I47c6e83922068820cd19ffd9ef604ed8a16b755e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1997243 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>
* Better errors on missing composite disk components.A. Cody Schuffelen2020-02-26
| | | | | | | | | | | | | | | | | When there is an error opening one of the composite disk components now, it gives the message `failed to open component file: "No such file or directory (os error 2)"` without specifying the file path it tried to use. Exposing the file path will make it faster to act on errors, rather than trying to examine the composite disk file for paths. TEST=n/a BUG=b:150150052 Change-Id: I9341b330e7e6dcd517d5bfb5262b1657a2da46fe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2072738 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Cody Schuffelen <schuffelen@google.com>
* Support the Android Sparse disk formatA. Cody Schuffelen2020-02-25
| | | | | | | | | | | | | | | | | | | | | Android defines its own "sparse disk" format, which its images are usually published in. Cuttlefish has special-cased this to build raw images in the android build system, but it still causes a performance hit when downloading and extracting the image zip files. Experimentally, running bsdtar on the zip file of raw images is about 50 seconds slower than bsdtar on the equivalent zip file of android sparse images. These disks can only be opened as read-only, as the Android Sparse format is designed around writing once then interpreting the contents while flashing a physical device through e.g. fastboot. TEST=Run with aosp/1184800 on cuttlefish, unit tests BUG=b:145841395 Change-Id: I13337b042e92841bd3cba88dc8b231fde88c091e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1956487 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Cody Schuffelen <schuffelen@google.com>
* Initialize qcow clusters off the backing file when presentA. Cody Schuffelen2020-02-25
| | | | | | | | | | | | | | | This preserves any data that the backing file had on a cluster when doing a write to a subset of that cluster. These writes cause a performance penalty on creating new clusters if a backing file is present. TEST=unit tests BUG=b:140069322 Change-Id: I724990225617c05e5f2dea39e39ce84c940328fc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1982832 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Cody Schuffelen <schuffelen@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* x86_64: use __cpuid intrinsicDaniel Verkamp2020-02-22
| | | | | | | | | | | | | | | | | | | | | | Use the Rust __cpuid and __cpuid_count intrinsics to replace the C implementation in host_cpuid.c. These are defined in core, but they are also re-exported in std, despite being undocumented there due to technical reasons: https://github.com/rust-lang/rust/pull/57808#issuecomment-457390549 Use the std version for consistency (we don't currently use anything from core anywhere else in crosvm). BUG=None TEST=cargo test -p x86_64 TEST=Boot crosvm on x86_64 Change-Id: Ic7a1094d1b804304a2944f8ee1fe55c5e2db23e9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2067159 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* linux.rs: Don't pivot_root when using host's root directoryChirantan Ekbote2020-02-22
| | | | | | | | | | | | | | | pivot_root(2) will fail with EBUSY if we try to pivot_root to "/". Check for this case and skip the pivot_root if necessary. BUG=b:147258662 TEST=`tast run <dut> vm.Virtiofs` Change-Id: I1d7645844e183222a561578677fc5f59c080d58c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2067823 Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
* Read from the backing file if present on read missA. Cody Schuffelen2020-02-21
| | | | | | | | | | | | | | Reads to qcow files with backing files will fall through to the backing file if there is no allocated cluster. As of this change, a write will still trash the cluster and hide any data already present. TEST=unit tests BUG=b:140069322 Change-Id: Iba353fa1e7c25bb6267eb96b30b8f5a6ac61d423 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1982831 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* Support generating and opening backing filesA. Cody Schuffelen2020-02-21
| | | | | | | | | | | | | | | | | | | | | | The new functionality can be invoked through "crosvm create_qcow2 --backing_file=backing new_file". The old behavior of creating a qcow image with a particular size is still available with its original syntax. This is relevant to implement as by default something like qemu-img will create a new image that assumes the backing file is raw or qcow, while crosvm can use its knowledge of other formats (such as composite disk, and later android sparse) to determine the true size of the backing file. TEST=unit tests BUG=b:140069322 Change-Id: I22de6a79c6d8566a9fcb0bc8124e2d74fea9ca55 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1982833 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* build_test.py: set env vars for cross compileMatt Delco2020-02-21
| | | | | | | | | | | | | | | | | | | | | | | Now that minijail-sys is added a simple run of ./build_test fails with messages like: error: failed to run custom build command for `minijail-sys v0.0.11 (/mnt/host/source/src/aosp/external/minijail)` thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: CrossCompilation', src/libcore/result.rs:1165:5 This change adds various environment variables to address the problem. BUG=None TEST=./build_test.py --arm-sysroot /build/cheza/ --aarch64-sysroot /build/kevin64/ Change-Id: Iba15ceafa35ba3ab2d08dc5827af3cb8ee07530c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2064821 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Matt Delco <delco@chromium.org>
* Vfio: Disable msix bar's mmapXiong Zhang2020-02-21
| | | | | | | | | | | | | | | | | If vfio device's bar is mmappable, vcpu could access it directly through ept without trapping. But msix's table and pba exist on pci bar, they must be trapped and emulated by crosvm, so these bars mmappable must be disabled. BUG=chromium:992270 TEST=pass through a device with msix cap to guest, then test device function in guest. Change-Id: If7504a924902c940e00cc759c1ca64a116bbca17 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1987815 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* devices: IOAPIC: implement interrupt routingZhuocheng Ding2020-02-21
| | | | | | | | | | | | | | This change implements MSI routing and injection, so that service_irq can actually inject an interrupt into guest. BUG=chromium:908689 TEST=Unit tests in file. Change-Id: I2db4f00f569db56f5765c707faaa87c64fd3da9f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945795 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
* linux.rs: Refactor 9p device jailChirantan Ekbote2020-02-21
| | | | | | | | | | | | | | | | | Give the 9p device the same jail as the fs device. In particular it needs a higher max open file limit and should map the current euid/egid in its user namespace rather than always using the crosvm user. BUG=b:147258662 TEST=`tast run <dut> vm.Blogbench.p9` Change-Id: I12e7ba7b651da4bae1435e0598b62fe2c35ff1bf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2065254 Tested-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
* Vfio: Emulate MSI-xXiong Zhang2020-02-20
| | | | | | | | | | | | | | | | | When VFIO device have msix capability, vfio kernel doesn't emulate msix, so all the msix emulation are handled by crosvm. This include msix capability register read/write, msix table read/write, msix pba table read/write. BUG=chromium:992270 TEST=passthrough a device with msix capabilty to guest, and check device msix function in guest Change-Id: Ic39737662a5051ac6b9e29aad227d3d4946190a8 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1987814 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* crosvm: add ability to enable caps on vcpuMatt Delco2020-02-20
| | | | | | | | | | | | | | | | | This change primarily adds functionality to allow kvm features to be enabled on a vcpu (most of the current infra only supporst the ioctl for the vm fd). BUG=b:144746965 TEST=ran 'build_test' and verified that the added tests passed. Change-Id: I30c00b6f462377c21d477602ceba5853df953b37 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2055883 Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Matt Delco <delco@chromium.org>
* crosvm: support kvm's hyper-v cpuid ioctlMatt Delco2020-02-20
| | | | | | | | | | | | | | | | | | | | | Kvm can emulate the hyper-v paravirt interface. Newer versions of kvm can advertise the features they support via an ioctl() that reports the cpuid leafs for this interface. This change adds some support for the ioctl() and plumbs it through the plugin interface so that plugins can determine the level of support available in kvm. BUG=b:144746965 TEST=Ran build_test on kernel that supports the ioctl. Added temporary code to print the cpuid leafs and verified that the output is as expected. Instrumented failure as expected from older kernels and verified that results still passed. Change-Id: I6cd7dade1793e4edb52b331d5b960685541f7ba3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2037919 Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Matt Delco <delco@chromium.org>
* tests: avoid internal error in pause testMatt Delco2020-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When running plugin tests it's not uncommon to see: vcpu 0 has internal error Though the tests don't actually fail on this problem. This seems to occur as a side effect of the plugin_vcpu_pause.c calling crosvm_destory_memory() before the test VM has actually finished running. The main thread will call read() on the 'kill' eventfd 5 times for: init, pause, unpause, unpause, kill The vcpu thread will call write() on the eventfd up to 8 times: init, pause #1, unpause #1, pause #2, unpause #2, pause #3, unpause #3, kill The main thread's third pause request might occur before the second pause request has been processed, in which case the vcpu thread will only be paused twice (thus there will only be 6 calls to write()). Given the unpredictable # of events I've opted to split the init/pause/unpause events to a separate eventfd and keep the 'kill' eventfd solely for its intended purpose. BUG=None TEST=ran ./build_test several times and observed no failures in the pause plugin test. Change-Id: Ie0817a4419ae6199fcc5c53496360b2bd81556e3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2012788 Reviewed-by: Matt Delco <delco@chromium.org> Commit-Queue: Matt Delco <delco@chromium.org> Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* linux.rs: unify jail creationMatt Delco2020-02-19
| | | | | | | | | | | | | | | | This change unifies two substantially similiar segments of code used to create a jail. BUG=none TEST=Ran 'build_test'. Local build, deployed to DUT, and verified that termina VM could still be used. Change-Id: Ib1f2f9bc5cfe1e6c9f3633af7e23f52e5eafe3c7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2057744 Tested-by: Matt Delco <delco@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Matt Delco <delco@chromium.org>
* Vfio: Enable multi vectors in irq_enable()Xiong Zhang2020-02-19
| | | | | | | | | | | | | | | When msix is enabled, msix will have multi vectors, this patch enable mutlti vectors in vfio_device.irq_enable() function. BUG=chromium:992270 TEST=passthrough a device with msix capability to guest, and check device msix function in guest Change-Id: I5f8265e7badec8551ff9a974462f08425ee93ab2 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1987813 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* Virtio: Add virtio block irq suppressXiong Zhang2020-02-19
| | | | | | | | | | | | | | | The flag in avail descriptor supplies irq suppress, it could reduce irq injection from device, so many redundant interrupts could be removed from guest, then improve guest performance. BUG=None TEST=run fio read and fio write in guest Change-Id: I68789d8ca24d0e84d0b446db65057f4da2fac56f Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2008339 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* acpipm: implement suspend and resume mechanismChuanxiao Dong2020-02-19
| | | | | | | | | | | | | | | | | | | For suspend request from VM, will write suspend event and notify crosvm main process to pause VCPUs. For resume request, it is not from VM itself but by the resume command through crosvm socket. Resume request will notify the PM device to fill its wakeup registers with wakeup event so that when VCPUs start to run, VM can know there is wakeup from outside. BUG=chromium:1018674 TEST=cargo test -p devices Change-Id: I4724ffee10150065a62bf520076c16cbc70b7749 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035169 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
* devices: virtio: Implement Reader::collect() and Writer::consume()Charles William Dick2020-02-19
| | | | | | | | | | | | | | Adds a method Reader::collect() to read a collection of DataInit types, and a method Writer::consume() to write a collection of DataInit types. BUG=b:147334004 TEST=cargo test -p devices Change-Id: Ib5947d30b44b74dc6cf0474e5b87778aad6f08a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2061516 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
* virtio-gpu: gfxstream backendLingfeng Yang2020-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds a new backend type, gfxstream, that calls out to a C library implementing the actual rendering. The purpose is to allow the Cuttlefish and Android Studio Emulator teams to use crosvm with the current API-forwarding style of rendering employed in the Android Studio Emulator. Also, introduces a new key to the --gpu command line interface, backend=, which selects from different backends. Note that the previous behavior is now deprecated and will be removed after some time (when all clients switch over to backend=). The gfxstream backend itself implements a subset of 3d-related resource and context creation/transfer/execbuffer commands. Their meaning is specific to the way in which they are interpreted in the backend library. To interface with display, gfx stream backend takes a callback that is run on guest vsync. The callback is responsible for repainting the display's contents. gfx stream provides a callback, get_pixels, that can be used asynchronously. The asyncness is not taken advantage of currently but will be useful for cases where the client attached to the VMM might want to update at a different rate than guest vsync. The guts of the stream backend library is currently defined here: https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/android-qemu2-glue/emulation/virtio-goldfish-pipe.cpp The linking of the library is controlled via the feature "gfxstream". If the feature is turned off, we use a default do-nothing stub impl. Next steps: - integrate virtio-gpu-next so as to have host coherent memory for vulkan - Figure out low latency command submit/response with SUBMIT_CMD_3DV2 BUG=b:146066070 Change-Id: If647381c15e5459cec85e2325f97e2f0a963b083 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2033305 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Jason Macnak <natsu@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Auto-Submit: Lingfeng Yang <lfy@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org>