summary refs log tree commit diff
Commit message (Collapse)AuthorAge
...
| * devices: usb: ignore busy flag in interrupterDaniel Verkamp2020-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This works around an issue where the xhci controller hangs from the guest's point of view, with the guest kernel eventually timing out and disabling the controller. The xHCI spec says that the EHB (Event Handler Busy) bit should be cleared before signalling another interrupt. This bit is set by the controller before triggering an interrupt, and it is meant to be cleared by the guest (via write-1-to-clear) when it is done handling the interrupt. However, it seems that there is a race going on between the clearing and setting of this bit. Removing the check seems to avoid the issue, since we never get into the state where we think EHB is set but the guest thinks it is clear (where no further interrupts would be triggered). This will potentially trigger more interrupts than strictly necessary, but the Linux kernel xhci driver handles interrupts with no events available gracefully. BUG=chromium:1082930 TEST=`while adb shell echo hi; do : ; done` for 8+ hours without hangs Change-Id: I3c08f0c5675be10d8e46f73714d684f7ba3a3903 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2202745 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * devices: usb: remove interrupter pending variableDaniel Verkamp2020-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The pending variable was just duplicating state that can easily be determined based on whether the ring is empty. Remove the variable and replace it with an equivalent check in interrupt_if_needed() to avoid the possibility of accidentally getting these out of sync. BUG=chromium:1082930 TEST=cargo test -p devices Change-Id: Icb90e3d09c43de244f5fecffb0e55d4635be6d2b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2202744 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * Implements the Hypervisor trait for Kvm.Udam Saini2020-05-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This adds the ability for getting both supported/emulated cpuids from the kvm hypervisor. In addition, checking the available capabilities for kvm is now implemented. BUG=chromium:1077058 TEST=Added unit tests for each implemented function. Change-Id: Ide4c2840b7bfa022deae835eb734ea97c1859169 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2177641 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Udam Saini <udam@google.com>
| * descriptor_utils: Remove need for temporary vectorsChirantan Ekbote2020-05-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor the DescriptorChainConsumer, Reader, and Writer structs so that we don't have to allocate a Vec on the heap every time we read or write from a DescriptorChain. This should hopefully give us some small performance improvements as well as simplify the code in some places. Also switch from VolatileSlices to iovecs so that it's easier to use these structs with io_uring. Otherwise we would end up allocating temporary vectors to convert from VolatlieSlice to iovec. BUG=none TEST=unit tests Change-Id: I1657bc76cfff084df825dbbdc8ff414740b71a8f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2190106 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org>
| * acpi: refactor the ACPI PM deviceChuanxiao Dong2020-05-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the AML support to generate the S1 table instead of hard coding. Also use the IO allocater to allocate the IO resouce for ACPI PM. BUG=None TEST=boot crosvm by command "crosvm run -s crosvm.sock -m 4096 --cpus 4 --rwdisk rootfs.img -p "root=/dev/vda rootfstype=ext4" vmlinux". Check the S1 capability by "#echo standby > /sys/power/state" from guest side. Linux guest is suspended. And resume linux guest by "#crosvm resume crosvm.sock" from host side. Change-Id: I75b484c44db05f98d49557ba694a1531b57871c1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2119571 Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
| * hypervisor: add Vm/Vcpu traits and Kvm implsSteven Richman2020-05-09
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add arch-agnostic traits Vm and Vcpu. Add arch-specific traits HypervisorXXX, VmXXX, VcpuXXX, with impls for KVM. BUG=chromium:1077058 TEST=added test for functions and structs interacting with the traits Change-Id: I809f42f32a558c7835831c90e24fca82ce7744ab Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2176562 Reviewed-by: Udam Saini <udam@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Steven Richman <srichman@google.com>
| * Extract the DisplayBackend build process into BackendKind build functionKaiyi Li2020-05-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All 3 different virtio gpu backends share the same process of creating the GpuDisplay instance, so move that process out of their separate build functions and put it in the shared BackendKind build function. BUG=None TEST=build_test Change-Id: Ie15bae48c8f1b75df49ba066a677020ec5dbf744 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2182041 Reviewed-by: Jason Macnak <natsu@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Kaiyi Li <kaiyili@google.com>
* | crosvm: fix file_to_i64 commentAlyssa Ross2020-05-22
| | | | | | | | This was missed in 0bf8a5590f3556d8ec05c182cb612f254fd416e5.
* | msg_socket: impl std::error::Error for MsgErrorAlyssa Ross2020-05-22
| |
* | devices: print unexpected wl command in hexAlyssa Ross2020-05-16
| | | | | | | | | | This makes it easier to compare with linux/virtio_wl.h, where the commands are all declared in hex.
* | msg_socket: fmtAlyssa Ross2020-05-10
| |
* | Merge remote-tracking branch 'origin/master'Alyssa Ross2020-05-10
|\|
| * docker: update PLATFORM2 commit to fix kokoro build with videoKeiichi Watanabe2020-05-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update to "arc: vm: libvda: Remove redundant single-component import". BUG=None TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh w/ CL:1973973 and CL:1991380. Change-Id: I696f0bfd8d6d83396e9662ec537147b7d0772f68 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2190102 Tested-by: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
| * aarch64: Enable PMU in the guest.Suleiman Souhlal2020-05-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows us to use perf/simpleperf in the guest. BUG=b:153708112 TEST=Use simpleperf in ARCVM guest on jacuzzi board. Change-Id: Ia3d7dc5bcd3ca033ddf05b5ee2593102c98e8b49 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2156592 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Suleiman Souhlal <suleiman@chromium.org> Reviewed-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Suleiman Souhlal <suleiman@chromium.org>
| * remove instantes of using IntoRawFd in unsafe blocksZach Reizner2020-05-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The trait IntoRawFd isn't marked unsafe, but its documentation says that an impl must return a uniquely owned RawFd. Some code blocks depended on that behavior to ensure safety with the unsafe File::from_raw_fd, but this leads to a soundness hole where a nominally safe impl of IntoRawFd can lead to unsafety in functions that had been left as safe. This change sidesteps the issue by not using IntoRawFd, and using only safe conversions instead. BUG=None TEST=cargo build --features='wl-dmabuf plugin' Change-Id: I9b357e5592be21189fb96e343823dd63000aac30 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2185580 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org> Auto-Submit: Zach Reizner <zachr@chromium.org>
| * msg_socket: AsyncReceiver doesn't need a mut refDylan Reid2020-05-07
| | | | | | | | | | | | | | | | | | | | | | | | The AsyncReceiver doesn't need to modify the message receiver so let it take a plain old borrow. Change-Id: I07e93d2ed12327dd893fec654d2bdd613a848fe6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2167694 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
| * async_core: Add async TimerFdDylan Reid2020-05-07
| | | | | | | | | | | | | | | | | | | | | | | | An async timer FD will allow block to keep the flush timer when it is converted to async. Change-Id: I25759be0f969d1962fd13f33709166527d8f117d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2168644 Tested-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
| * cros_async: Hide the details of fd_executorDylan Reid2020-05-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | The type of the executor leaked from the cros_async crate. That was fine until the desire to add a new executor arose. Hide the fd_executor so that a uring_executor can be substituted on newer kernels. Change-Id: I8dd309fd47e1b4a6e16da274abbb8431c80474af Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2182042 Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
| * msg_socket: impl skip helper attributeZach Reizner2020-05-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fields with a default value can be skipped using the `#[msg_on_socket(skip)]` attribute. TEST=cargo test -p msg_socket BUG=None Change-Id: I9fea33e641a7da62b7864ba1847e884b32502491 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2168587 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org>
| * msg_socket: impl for Arc and MutexZach Reizner2020-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These types are simple wrappers, and so this change just adds trivial passthroughs. For data sent over a socket, the data is not Arc-ed or Mutex-ed on the other end with the same ref count or lock. Sending over the data is more like a deep copy, rather than a simple ref count increase. TEST=cargo test -p msg_socket BUG=None Change-Id: I519096b0b3b6ab75e79c37addf0d60ce3da4a717 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2168586 Commit-Queue: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
| * async_core: eventfd: implement a future for the next valueDylan Reid2020-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It is useful to have the ability to get a future for only the next value. This is helpful when borrowing the EventFd for the duration of a loop is not feasible. It is also helpful for situations where the future might be dropped. Because dropping a polled eventfd future can leak an FD, and there is no way to implement a custom `Drop` for the future returned by stream, using the new `read_next` is the only way to ensure there aren't any FD leaks if the future might be dropped before completion. TEST=added a unit test that makes use of the new feature and mirrors the existing stream test. cargo test eventfd_write_read Change-Id: I9b20c89be561e4a1ca43f2befc66c16188a91d4b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2173973 Tested-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
| * cros_async: implement waker_wakeDylan Reid2020-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some futures-rs combinators call wake directly instead of using wake_by_ref. This was left out as on oversight because the initial executor code only used wake_by_ref. TEST=run tests with the combinators from futures-rs Change-Id: I8ac06dfd47d34eee493a5b1194d00ef9d7f6bc18 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2173972 Tested-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
| * cros_async: Don't wake wakers on removalDylan Reid2020-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | There is no need to repoll the waker after it is canceled. This was a copy paste error that was harmless until tested with futures-rs combinators that re-use wakers aggressively. Change-Id: Ie84778b96ff6aa2b58bfe61cd96a78786797ad78 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2173971 Tested-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
| * cros_async: Add a function to run one future to completionDylan Reid2020-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adding the ability to run one future to completion will allow for driving the top level future through the executer when only one future is needed. For example, if a future-rs combinator is used to collect several sub futures. TEST=update doc test cargo test Change-Id: Idd1121310a3043bb4110853e5e72eef3bd06950e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2173970 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>
| * pci: refactor FDT/MPTABLE creation to use PciAddress.Tomasz Jeznach2020-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Simple refactor of FDT and MPTables generation to use PCI device addressing and allow declatation of non-zero PCI bus ids for x86 architectures. It also allows non sequential IRQ allocation for PCI devices. BUG=None TEST=build_test & tast run crostini.Sanity Change-Id: I6cc31ce412199a732499b2d8d18d99f08d765690 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2175739 Tested-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
| * Adding hypervisor crate to abstract out Kvm implementationUdam Saini2020-05-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a separate hypervisor crate for interacting with Kvm in an abstract manner. The intention is to not leak the internals of kvm with its specific calls in various places in the codebase. Currently, this just creates an initial structure for adding various implementations over time. In addition, a SafeDescriptor class is added, that wraps a raw file descriptor safely, without needing to wrap it in the rust file class. The intention is to use this for non file raw descriptors. BUG=chromium:1077058 TEST=added a basic kvm test that creates a Kvm struct Change-Id: I4229203902e480b52435cde12bf0d25a322c71be Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2174756 Commit-Queue: Udam Saini <udam@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
| * cros_async: Add select6Dylan Reid2020-05-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Balloon needs six futures to be selected between, allow that with a new macro. TEST=added doc test Change-Id: I6c15ae5e2f6a8dcbbf0e0700e6b64fb5ca459f97 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2167693 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>
| * descriptor_utils: Add write_iter methodChirantan Ekbote2020-05-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a method to write a series of objects produced by an iterator. Unlike the current `consume` method, this doesn't require the caller to first store the objects in an intermediate collection. Also change `consume` to be implemented using `write_iter`. This is the Writer equivalent of the `iter` and `collect` methods of the Reader struct. BUG=none TEST=unit tests Change-Id: I36bf2fef4d40e13a4741fa55fc35dd556c13a53b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2172841 Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org> Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
| * devices: pci: refactor PCI devices to use PciAddress.Tomasz Jeznach2020-05-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Simple refactor of PCI device addressing to use PciAddress type providing bus:device.function number. BUG=None TEST=build_test & tast run crostini.Sanity Change-Id: I7755ad6b31aa8c882475cd8212630e1cc86ef49e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2172766 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
| * docker: update CRAS commit to fix kokoro buildDaniel Verkamp2020-04-30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Update to "libcras: Expose try_with_socket_type API". BUG=None TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh Change-Id: Id103b44f1c47b39f4701ff2446fd0f31842b2bcc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2172633 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * devices: pci: refactor device location address.Tomasz Jeznach2020-04-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Simple refactor of PCI device addressing to use bus:device:function notation, including change allowing sparse alloction of device addresses in PCI topology. BUG=None TEST=build_test && cargo test Change-Id: I9ff02dd6b67b6784eac8c3d348661789fca3f422 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2171037 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Tomasz Jeznach <tjeznach@chromium.org> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
| * Stop tracking sub-mappings in MemoryMappingArenaChirantan Ekbote2020-04-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The kernel already takes care of tracking all our memory mappings. Doing it again ourselves doesn't provide any benefit and also adds additional restrictions (like not being able to overlap with existing mappings or partially remove mappings). Additionally, the `MemoryMappingArena` will already unmap the entire memory mapped region so there is no need to individually unmap the sub-mappings. The kernel's mmap api doesn't have these restrictions and as far as I can tell there are no safety concerns with allowing this behavior so just stop tracking the sub-mappings. Safe use of MAP_FIXED only requires that the address is part of a previously mmaped region so allow any MemoryMapping to be converted into a MemoryMappedArena. BUG=b:147341783 TEST=unit tests Change-Id: Iaf944a971b8ba9333802aab73c1d184fe388af89 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2162542 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
| * cros_async: allow wakers to be canceledDylan Reid2020-04-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allowing for wakers to be canceled will allow futures that register wakers properly implement `Drop`. As it is, they won't ever fire but the saved FD will leak. TEST=added 'cancel' unit test to fd_executor: "cargo test cancel" from the cros_async directory. Change-Id: Iab5bea6aac0cc689392997745f5dcc8c285200d9 Change-Id: I1df1a04897e8d2c5e9c414d84998084607209fb9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2164074 Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org>
| * ac97: Create CrasClient with unified socketpaulhsia2020-04-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Termina and ARCVM need both playback and capture functionalities, we create CrasClient with CrasSocketType::Unified. BUG=b:155048379 TEST=Apply full patch set and test with VMs Cq-Depend: chromium:2165697 Cq-Depend: chromium:2167813 Change-Id: Id4fb12423eb05859528406ae7ed5e62b46909a56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2167312 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: Chih-Yang Hsia <paulhsia@chromium.org> Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
| * docker: update CRAS commit to fix clippy errorDaniel Verkamp2020-04-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Update to "libcras: fix warning with Rust 1.43". BUG=None TEST=bin/clippy TEST=docker/wrapped_smoke_test.sh Change-Id: I1efcc58a5b65483ee3f816df345da9fb62e59e41 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2168154 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * linux.rs: Set MS_SLAVE mount propagation for virtio-fsChirantan Ekbote2020-04-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow mounts from the parent namespace to propagate into the virtio-fs device's mount namespace. BUG=b:123377807 TEST=vm.Fio.virtiofs_stress_rw and manual Change-Id: I1b8f1b411bd72a8cf5d5b4b30fa5dad466f1e48f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2156327 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
| * cros_async: remove rustdoc inside macroDaniel Verkamp2020-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes clippy 1.43.0 "error: unused doc comment" ("rustdoc does not generate documentation for macros"). BUG=None TEST=bin/clippy Change-Id: If6b2d7bb3fb2752394faa7131fb306869aaa5a56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2163785 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * Remove unnecessary parentheses in constsDaniel Verkamp2020-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix clippy "error: unnecessary parentheses around assigned value." BUG=None TEST=bin/clippy Change-Id: I31e61c770c62d7ff2ca8525bf754bd615e24c349 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2163204 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * Remove redundant single-component importsDaniel Verkamp2020-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix clippy 1.43.0 clippy::single-component-path-imports warnings. BUG=None TEST=bin/clippy Change-Id: I3f4f54138bedce16dc1ca937bb8bc00a94594f69 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2163203 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * acpi: add AML supportChuanxiao Dong2020-04-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is backported from cloud hypervisor, which can be used to generate the AML from ASL which is more easily for people to understand what this AML is doing. BUG=None TEST=cargo test -p acpi_tables Change-Id: Ib7c60caca92fd6ca7ab6800ddf36b2135fbcfc88 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2119570 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
| * seccomp: gpu: allow sysinfoDavid Stevens2020-04-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The glibc qsort implementation sometimes requires querying the physical page size. BUG=b:154580659 TEST=run fullscreen 3dmark in ARCVM on kukui Change-Id: I364d77cf66353e558e798a07a247c55c3e365c32 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2156596 Tested-by: David Stevens <stevensd@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: David Stevens <stevensd@chromium.org> Reviewed-by: Lepton Wu <lepton@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
| * msg_socket: AsyncReceiver doesn't need a mut refDylan Reid2020-04-23
| | | | | | | | | | | | | | | | | | | | | | | | The mut reference isn't used, an immutable reference is sufficient. Switch to make borrowing the receiver easier for users. Change-Id: Ic8582deb68997de53e5a53730b3909a1c4dcf699 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2159936 Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
| * devices: usb: allow arbitrary control request sizeDaniel Verkamp2020-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the maximum control request length that could be passed through the USB host_backend layer was limited to 1024 bytes. To lift this limit, remove the fixed-length ControlTransferBuffer structure definition and replace it with manual buffer allocation. This mirrors the behavior of the later part of this function, which already indexes into the control_buffer to copy the data back from a device to host transfer. BUG=chromium:1073503 TEST=Verify adb logcat still works Change-Id: I7354f6fa237b4df6db7898f27be76ab10faed9f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2161440 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * Apply same permissions to pmem-region alignments.Iliyan Malchev2020-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1979257 created a padding of read-only pages between the end of the pmem region and padding up to the next multiple of 2MiB. However, on ARM systems, kvm_arch_prepare_memory_region does not permit read-only pages on a write-able memory region. BUG=b:148706939 TEST=Tested on x86_64 and arm64 board with pmem image < 2MiB Tested-by: Iliyan Malchev <malchev@google.com> Change-Id: If06c2e0f74fdcd7db1b7d56e1a8d732d17f352bf Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2153103 Tested-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
| * sys_util: timerfd: Methods don't need to me mutDylan Reid2020-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Because TimerFd is a wrapper around a 'File' that is never modified there isn't a need for a mutable borrow. The kernel already handles the interior mutability of the underlying file descriptor. Change-Id: I7ae068cc54050b0021d00620b561335b2ae0ba16 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2161625 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org>
| * arch, main: add virtio-console parsing and creationDaniel Verkamp2020-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows the creation of virtio-console devices using the new hardware=virtio-console parameter to the --serial option. Also add support for the serial earlycon option, which allows using virtio-console as the main console device with a traditional serial device as the early console. This allows logging during early boot before PCI device discovery (when virtio-console devices are set up). BUG=chromium:1059924 TEST=crosvm run -r vm_rootfs.img \ --serial hardware=serial,type=stdout,console=false,earlycon=true \ --serial hardware=virtio-console,type=stdout,console=true,stdin=true \ vm_kernel Change-Id: Iff48800272b154d49b1da00f3914799089268afe Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127322 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * devices: add SerialDevice traitDaniel Verkamp2020-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will be used to allow generic code to create serial devices as well as virtio-console devices. Also remove the new_in_out, new_out, and new_sink constructors for Serial and Console, since they are not used anywhere. BUG=chromium:1059924 TEST=cargo build Change-Id: I76da343e347aed36dabd3aa0541acf24c64fe122 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127321 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
| * arch: serial: simplify device creationDaniel Verkamp2020-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Factor out the call to Serial::new so it isn't repeated for each output type. BUG=chromium:1059924 TEST=cargo build Change-Id: Ie0ad65b4315173a3f2a7c2bf04f041ad3b2157f1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127320 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * arch, devices: move serial creation to archDaniel Verkamp2020-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Split the serial code into two parts: - Configuration and setup: arch/src/serial.rs - Serial device emulation: devices/src/serial.rs No change in functionality - this is just preparation for generalizing the command line parsing/setup code so that it can be used with virtio console devices as well. BUG=chromium:1059924 TEST=emerge-nami crosvm TEST=emerge-kevin crosvm Change-Id: I0aaf9dd6f8096eac4a17077ab5bf569f57d64ff5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127319 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * Serial: add input path overriding stdin for --serialIliyan Malchev2020-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allowing the input to be specified for file-based serial ports allows the user of pipes as input/output. That enables kgdb over serial. TEST= Build a kernel with support for gdb ``` make x86_64_defconfig make kvmconfig ./scripts/config --enable GDB_SCRIPTS ./scripts/config --enable KGDB ./scripts/config --enable KGDB_SERIAL_CONSOLE ./scripts/config --enable KGDB_LOW_LEVEL_TRAP ./scripts/config --enable KGDB_KDB ./scripts/config --enable KDB_KEYBOARD ./scripts/config --enable GDB_SCRIPTS ./scripts/config --set-val KDB_CONTINUE_CATASTROPHIC 0 make -j33 ``` Setup devices for PTYs To make sure crosvm doesn't create an ordinary file if socat is started after it, create these named pipes first: ``` mkfifo ~/console_{in,out} ~/kgdb_{in,out} ``` Set up two PTYs: ~/kgdb for the debugger, and ~/serial for the console. PTY ~/kgdb connects to ~/kgdb{in,out}, and ~/serial connects to ~/console{in,out} ``` socat -d -d -d \ 'PIPE:$HOME/console_out,rdonly=1,nonblock=1,ignoreeof=1!!PIPE:$HOME/console_in,wronly=1' \ PTY,link=$HOME/serial,ctty,raw,echo=0 socat -d -d -d \ 'PIPE:$HOME/kgdb_out,rdonly=1,nonblock=1,ignoreeof=1!!PIPE:$HOME/kgdb_in,wronly=1' \ PTY,link=$HOME/kgdb,ctty,raw,echo=0 ``` Start crosvm with serial ports pointed at ~/console{in,out} and ~/kgdb{in,out}. ``` cargo run run -p 'init=/bin/sh panic=0 kgdboc=ttyS1,115200 kgdbwait kgdbcon' \ --serial type=file,path=$HOME/console_out,num=1,console=true,stdin=false,input=$HOME/console_in \ --serial type=file,path=$HOME/kgdb_out,input=$HOME/kgdb_in,num=2,console=false,stdin=false \ -r ~/rootfs.img \ ~/src/linux/arch/x86/boot/bzImage ``` Start GDB ``` gdb vmlinux -ex "target remote /home/dgreid/kgdb" ``` To break into gdb, open up the serial console, mount /proc and send a SysRq ``` minicom -D ~/serial mount -t proc none /proc echo g > /proc/sysrq-trigger ``` Change-Id: I18a9c1087d38301df49de08eeae2f8559b03463a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2151856 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>