summary refs log tree commit diff
path: root/vm_control
Commit message (Collapse)AuthorAge
* usb: replace libusb with Rust usb_util libraryDaniel Verkamp2019-10-17
| | | | | | | | | | | | | | | | | | | | | Drop the dependency on libusb and reimplement the host USB backend using usb_sys to wrap the Linux usbdevfs ioctls. This allows sandboxing to work without any dependency on libusb patches, and it gives us the flexibility to modify and update the USB backend without depending on an external third-party library. BUG=chromium:987833 TEST=`adb logcat` on nami with Nexus 5 attached TEST=deploy app to phone with Android Studio TEST=Run EdgeTPU USB accelerator demo (including DFU mode transition) Cq-Depend: chromium:1773695 Change-Id: I4321c2b6142caac15f48f197795a37d59d268831 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1783601 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* vm_control: Add VmIrqRequest SocketXiong Zhang2019-10-15
| | | | | | | | | | | | | | | | | | | | | | | | | When vfio device's msi/msi-x or virtio device's msi-x is enabled, its irq routing info should be notified to kvm. But this is a runtime vm service call, so vm_control is used to call vm service. VmIrqRequest->AllocateOneMsi() is used to allocate one gsi for a msi and a msi-x vector, and link gsi with irqfd through vm->register_irqfd. The orignal interrupt_evt and interrupt_resample_interrupt is used for INTX only. VmIrqRequest->AddMsiRoute is used to add msi routing info into kvm route table. BUG=chromium:992270 TEST=none Change-Id: I4f1beeb791943e09d957573dd2a58d55bf895d16 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1846603 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
* vm_control: support registering memory at a specific addressGurchetan Singh2019-10-01
| | | | | | | | | | | | | | | | | | The guest kernel will allocate from PCI range of the virtgpu device, and send physical addresses via a hypercall. Right now, only support buffers that can be mmap'ed. We could add optimizations for GBM buffers later if needed. BUG=chromium:924405 TEST=compile Change-Id: I094de96a2c35bcd2e18c8a6a2d8cdc39bb392e36 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1626794 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Remove remaining byteorder crate referencesDaniel Verkamp2019-08-26
| | | | | | | | | | | | | | Remove the last (unused) reference to byteorder in vm_control/Cargo.toml and remove it from the list of external crates in README.md. BUG=None TEST=./build_test Change-Id: Ie70c0bc2f96c19b34ef1596885245eca7bc202f4 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1761156 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: {WlDriverRequest, WlDriverResponse} --> {VmMemoryRequest, ↵Gurchetan Singh2019-05-24
| | | | | | | | | | | | | | | | | VmMemoryResponse} These type of requests are not necessarily specific to the virtio-wl, and other devices (virtio-gpu) may want to use them. BUG=chromium:924405 TEST=compile Change-Id: Iad0889da8ab3d23bb2378448fc05e3c840a93d93 Reviewed-on: https://chromium-review.googlesource.com/1626791 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: kokoro <noreply+kokoro@google.com> Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* usb: support for listing attached usb devicesZach Reizner2019-04-27
| | | | | | | | | | | | | | | | | | Originally, crosvm would list details about an attached usb device for a given port. This change allows getting details about multiple ports at once. This is intended to simplify command line usage and downstream consumers like concierge. TEST=various vmc commands Chrome UI for handling USB devices BUG=chromium:831850 Change-Id: I55681a7fea7425c897a22a579dcc15567683ef54 Reviewed-on: https://chromium-review.googlesource.com/1529765 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: Extracts Wayland commands from from VmRequest.Jakub Staron2019-04-27
| | | | | | | | | | | | | | | BUG=None TEST=cargo test TEST=cargo test --package msg_socket TEST=cargo test --package devices TEST=cargo test --package vm_control TEST=tast -verbose run ${IP} vm.CrostiniStartEverything Change-Id: I07f034b1cc41e30b9deae68ea9c510b0923e17a8 Reviewed-on: https://chromium-review.googlesource.com/1565299 Commit-Ready: Jakub Staroń <jstaron@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Extracts BalloonAdjust from VmRequest.Jakub Staron2019-04-25
| | | | | | | | | | | | | | | | | Extracts BalloonAdjust from VmRequest into BalloonControlCommand. BUG=None TEST=cargo test TEST=cargo test --package msg_socket TEST=cargo test --package devices TEST=cargo test --package vm_control TEST=tast -verbose run ${IP} vm.CrostiniStartEverything Change-Id: Ia9f5778c37c8fd4fa560df413134d1b441142f64 Reviewed-on: https://chromium-review.googlesource.com/1565298 Commit-Ready: Jakub Staroń <jstaron@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* resources+pci: allocator rework (allocation tags)Daniel Prilik2019-04-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | AddressAllocator now maintains a HashMap<Alloc, (u64, u64, u64)>, which uniquely maps a Allocation enum (e.g: PciBar(bus, dev, bar), GpuRenderNode, etc...) to it's address, size, and human-readable tag / description. The interface has also been modified to use Error instead of Option. Aside from improving debugging, tracking allocations will have numerous uses in the future. For example, when allocating guest memory over VmControl sockets, it will be possible to restrict allocations to pre-allocated slices of memory owned by the requesting device. To plumb through PCI information to PCI devices, this CL necessitated the addition of a PciDevice method called `assign_bus_dev`, which notifies PCI devices of their uniquely assigned Bus and Device numbers. BUG=chromium:936567 TEST=cargo test -p resources && cargo build --features="gpu gpu-forward" Change-Id: I8b4b0e32c6f3168138739249ede53d03143ee5c3 Reviewed-on: https://chromium-review.googlesource.com/1536207 Commit-Ready: Daniel Prilik <prilik@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Extracts DiskResize from VmRequest to a new type.Jakub Staron2019-04-19
| | | | | | | | | | | | | | | BUG=None TEST=cargo test TEST=cargo test --package msg_socket TEST=cargo test --package devices TEST=cargo test --package vm_control TEST=tast -verbose run ${IP} vm.CrostiniStartEverything Change-Id: Icf26f53d3fd813ab43b8f14079f90628d245eed7 Reviewed-on: https://chromium-review.googlesource.com/1565297 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* Removes RegisterIoevent and RegisterIrqfd.Jakub Staron2019-04-17
| | | | | | | | | | | | | | | | Removes unused RegisterIoevent and RegisterIrqfd variants from VmRequest. BUG=None TEST=cargo check TEST=cargo test TEST=tast -verbose run ${IP} vm.CrostiniStartEverything Change-Id: I3b4ced415b0f4a8e7969ddc149f82082593a8e8c Reviewed-on: https://chromium-review.googlesource.com/1565296 Commit-Ready: Jakub Staroń <jstaron@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* clippy: Resolve unneeded_field_patternDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: Ia0e0163441fafd4ce44fef7ebaa18d1cc947e20e Reviewed-on: https://chromium-review.googlesource.com/1566891 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* clippy: Resolve needless_returnDavid Tolnay2019-04-17
| | | | | | | | | | | TEST=bin/clippy Change-Id: I62eb3f86b01a6000107c54a967689d4e430adf50 Reviewed-on: https://chromium-review.googlesource.com/1566743 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* edition: Remove extern crate linesDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In Rust 2018 edition, `extern crate` is no longer required for importing from other crates. Instead of writing: extern crate dep; use dep::Thing; we write: use dep::Thing; In this approach, macros are imported individually from the declaring crate rather than through #[macro_use]. Before: #[macro_use] extern crate sys_util; After: use sys_util::{debug, error}; The only place that `extern crate` continues to be required is in importing the compiler's proc_macro API into a procedural macro crate. This will hopefully be fixed in a future Rust release. extern crate proc_macro; TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu TEST=local kokoro Change-Id: I0b43768c0d81f2a250b1959fb97ba35cbac56293 Reviewed-on: https://chromium-review.googlesource.com/1565302 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* edition: Fill in macro importsDavid Tolnay2019-04-15
| | | | | | | | | | | | | | | | | | | | Macros were previously imported through `#[macro_use] extern crate`, which is basically a glob import of all macros from the crate. As of 2018 edition of Rust, `extern crate` is no longer required and macros are imported individually like any other item from a dependency. This CL fills in all the appropriate macro imports that will allow us to remove our use of `extern crate` in a subsequent CL. TEST=cargo check --all-features --tests TEST=kokoro Change-Id: If2ec08b06b743abf5f62677c6a9927c3d5d90a54 Reviewed-on: https://chromium-review.googlesource.com/1565546 Commit-Ready: David Tolnay <dtolnay@chromium.org> Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* Wrap the UnixSeqpacket with a more descriptive type.Jakub Staron2019-04-10
| | | | | | | | | | | | | | | | Host/device sockets are now created as a pairs of MsgSockets instead of UnixSeqpacket sockets. BUG=chromium:950663 TEST=cargo check TEST=cargo test Change-Id: I8f61a711fe3c2547bf5d18fcfa23bfd0dc0ef5fd Reviewed-on: https://chromium-review.googlesource.com/1559041 Commit-Ready: Jakub Staroń <jstaron@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Jakub Staroń <jstaron@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* cargo: Sort all dependency lists in Cargo.tomlDavid Tolnay2019-04-09
| | | | | | | | | | | | | | | This may help reduce cases of conflicts between independent CLs each appending a dependency at the bottom of the list, of which I hit two today rebasing some of my open CLs. TEST=cargo check --all-features Change-Id: Ief10bb004cc7b44b107dc3841ce36c6b23632aed Reviewed-on: https://chromium-review.googlesource.com/1557172 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* edition: Use dyn syntax for trait objectsDavid Tolnay2019-04-08
| | | | | | | | | | | | | | | | | | | | | Found by running: `cargo rustc -- -D bare_trait_objects` Bare trait objects like `&Trait` and `Box<Trait>` are soft-deprecated in 2018 edition and will start warning at some point. As part of this, I replaced `Box<Trait + 'static>` with `Box<dyn Trait>` because the 'static bound is implied for boxed trait objects. TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu TEST=local kokoro Change-Id: I41c4f13530bece8a34a8ed1c1afd7035b8f86f19 Reviewed-on: https://chromium-review.googlesource.com/1513059 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* edition: Update vm_control to 2018 editionDavid Tolnay2019-04-08
| | | | | | | | | | | | | | | | | | Separated out of CL:1513058 to make it possible to land parts individually while the affected crate has no other significant CLs pending. This avoids repeatedly introducing non-textual conflicts with new code that adds `use` statements. TEST=cargo check TEST=cargo check --all-features TEST=cargo check --target aarch64-unknown-linux-gnu Change-Id: Iedc030e90e4c4e11cf69dde711df24caafc0ea4c Reviewed-on: https://chromium-review.googlesource.com/1520074 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Tolnay <dtolnay@chromium.org>
* implement xhci and add it to pci busJingkui Wang2019-03-17
| | | | | | | | | | | | | | Implement xhci controller, setup seccomp filters and add xhci to pci bus. CQ-DEPEND=CL:1512761 BUG=chromium:831850 TEST=local build Change-Id: I5c05452ece66e99d3a670e259e095fca616e835d Reviewed-on: https://chromium-review.googlesource.com/1512762 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Jingkui Wang <jkwang@google.com>
* usb: add host backendJingkui Wang2019-03-16
| | | | | | | | | | | | | | | | | | Host backend implement backend device. It will attach a read device to xhci controller. Also squashed from ce6b35, author: zachr@. CQ-DEPEND=CL:1510820 BUG=chromium:831850 TEST=local build Change-Id: Idcf2d7d6aca92de9859b7c38d1bf1d98032eae91 Reviewed-on: https://chromium-review.googlesource.com/1512761 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* main: log responses to command line vm control requestsZach Reizner2019-02-28
| | | | | | | | | | | | | | | | Now that the connection oriented seqpacket sockets are used for vm control messages, a response can be received by the requested. This change prints out that response. TEST=crosvm suspend|resume|balloon|stop <socket> BUG=chromium:848187 Change-Id: I18ac23c26127332e2be498113cc0c3310fd09a7d Reviewed-on: https://chromium-review.googlesource.com/1482370 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* crosvm: use seqpacket rather than datagram socketsZach Reizner2019-02-28
| | | | | | | | | | | | | | | | | | | | The advantage of seqpacket is that they are connection oriented. A listener can be created that accepts new connections, useful for the path based VM control sockets. Previously, the only bidirectional sockets in crosvm were either stream based or made using socketpair. This change also whitelists sendmsg and recvmsg for the common device policy. TEST=cargo test BUG=chromium:848187 Change-Id: I83fd46f54bce105a7730632cd013b5e7047db22b Reviewed-on: https://chromium-review.googlesource.com/1470917 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* error: Print errors using Display implDavid Tolnay2019-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | I have been running into Debug-printed error messages too often and needing to look up in the source code each level of nested errors to find out from the comment on the error variant what the short name of the variant means in human terms. Worse, many errors (like the one shown below) already had error strings written but were being printed from the calling code in the less helpful Debug representation anyway. Before: [ERROR:src/main.rs:705] The architecture failed to build the vm: NoVarEmpty After: [ERROR:src/main.rs:705] The architecture failed to build the vm: /var/empty doesn't exist, can't jail devices. TEST=cargo check --all-features TEST=FEATURES=test emerge-amd64-generic crosvm Change-Id: I77122c7d6861b2d610de2fff718896918ab21e10 Reviewed-on: https://chromium-review.googlesource.com/1469225 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* crosvm: add suspend/resume commandsZach Reizner2019-01-23
| | | | | | | | | | | | | | | | | | | | | This change adds the suspend and resume commands to crosvm, as well as corresponding VmRequest variants and VCPU loop support. When a request triggers a VmRunMode change, the Mutex guarded shared VmRunMode variable is mutated and the associated Condvar is notified. Each VCPU thread is interrupted to kick it out of the KVM_RUN call and checks the VmRunMode, If the VCPU was already suspended by waiting for the Condvar, the notify_all call will wake up the thread, upon which the VCPU thread can respond to the new mode. TEST=crosvm suspend/crosvm resume BUG=chromium:920875 Change-Id: Ibbeb748ab0d64402c7196890815e8e1cb4dfca38 Reviewed-on: https://chromium-review.googlesource.com/1416317 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: block: add resize VmControl requestDaniel Verkamp2019-01-16
| | | | | | | | | | | | | | | | | | | | | | | | | This allows manual resizing of block devices at runtime via the command line ('crosvm disk resize <index> <size>'). The virtio config interrupt is asserted when the disk size changes so that the guest driver can update the block device to the updated size. Currently, there is no automatic policy for resizing disks - that will be implemented in another change. Additionally, this resize operation just changes the size of the block device; the filesystem will need to be resized by the guest (e.g. via the 'btrfs filesystem resize' command) as a separate step either before (shrinking) or after (expanding) the disk resize operation. BUG=chromium:858815 TEST=Start crosvm with a control socket (-s) and resize the disk with 'crosvm disk resize' from another shell. Change-Id: I01633a7af04bfbaffbd27b9227274406d2a2b9cb Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1394152 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: balloon: fix the 'crosvm balloon' commandDaniel Verkamp2019-01-05
| | | | | | | | | | | | | | | | | | The balloon socket interface was changed to take an absolute number of pages in a u64 in commit 448516e3f9 ("balloon: Implement device policy"), but the 'crosvm balloon' command wasn't updated to match. Fix the crosvm front-end to send a u64 as expected by the command socket reader instead of the i32 it was sending previously, and change the parameter to bytes instead of pages to match the receiving end as well. BUG=None TEST=crosvm balloon a running VM to various sizes Change-Id: I265bee55c06809de7559a79a5eb6d0d094533993 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1394157 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
* lint: Resolve the easier clippy lintsDavid Tolnay2018-12-03
| | | | | | | | | | | | | | | | | | | | Hopefully the changes are self-explanatory and uncontroversial. This eliminates much of the noise from `cargo clippy` and, for my purposes, gives me a reasonable way to use it as a tool when writing and reviewing code. Here is the Clippy invocation I was using: cargo +nightly clippy -- -W clippy::correctness -A renamed_and_removed_lints -Aclippy::{blacklisted_name,borrowed_box,cast_lossless,cast_ptr_alignment,enum_variant_names,identity_op,if_same_then_else,mut_from_ref,needless_pass_by_value,new_without_default,new_without_default_derive,or_fun_call,ptr_arg,should_implement_trait,single_match,too_many_arguments,trivially_copy_pass_by_ref,unreadable_literal,unsafe_vector_initialization,useless_transmute} TEST=cargo check --features wl-dmabuf,gpu,usb-emulation TEST=boot linux Change-Id: I55eb1b4a72beb2f762480e3333a921909314a0a2 Reviewed-on: https://chromium-review.googlesource.com/1356911 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: use msg_socket in vm_controlJingkui Wang2018-11-19
| | | | | | | | | | | | | Refactor existing code to use msg_socket. BUG=None TEST=local build and run Change-Id: Iee72326b330e035303f679e1aedd6e5d18ad4f8a Reviewed-on: https://chromium-review.googlesource.com/1260260 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: refactor ioeventfd datamatch interfaceDaniel Verkamp2018-10-11
| | | | | | | | | | | | | | | This allows the caller to specify the full range of datamatch options defined in the KVM ioeventfd API, including matching accesses of a particular size with or without matching a specific data value. BUG=None TEST=cargo test -p kvm Change-Id: I28b543f7c0b35eb2a6d47a14a33145ea00d09d1d Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1271836 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* cargo fmt all source codeZach Reizner2018-10-09
| | | | | | | | | | | | | | Now that cargo fmt has landed, run it over everything at once to bring rust source to the standard formatting. TEST=cargo test BUG=None Change-Id: Ic95a48725e5a40dcbd33ba6d5aef2bd01e91865b Reviewed-on: https://chromium-review.googlesource.com/1259287 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* sys_util: remove Scm struct and sock_ctrl_msg C libraryZach Reizner2018-09-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The Scm object was made to reduce the number of heap allocations in the hot paths of poll loops, at the cost of some code complexity. As it turns out, the number of file descriptors being sent or received is usually just one or limited to a fixed amount that can easily be covered with a fixed size stack allocated buffer. This change implements that solution, with heap allocation as a backup in the rare case that many file descriptors must be sent or received. This change also moves the msg and cmsg manipulation code out of C and into pure Rust. The move was necessary to allocate the correct amount of buffer space at compile time. It also improves safety by reducing the scope of unsafe code. Deleting the code for building the C library is also a nice bonus. Finally, the removal of the commonly used Scm struct required transitioning existing usage to the ScmSocket trait based methods. This includes all those changes. TEST=cargo test BUG=None Change-Id: If27ba297f5416dd9b8bc686ce740866912fa0aa0 Reviewed-on: https://chromium-review.googlesource.com/1186146 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Move gpu allocator to resourcesDylan Reid2018-07-09
| | | | | | | | | | Combine GPU buffer allocation with the system resource allocator making life easier as only one allocator needs to get passed to the execute function. Change-Id: I199eb0fd6b99b629aaec1ae3295e8a1942da5309 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1099856
* Remove the device manager and use the new resource allocatorDylan Reid2018-06-29
| | | | | | | | | | | | | | | | | Allow IRQs to be assigned before creating device manager. For PCI, we need to add devices with interrupts before MMIO setup. Add the ability to tell the architecture device manager about IRQs that we have stolen. There was only one function in device_manager and all of its state is now delegated to the resource allocator, remove it. Change-Id: I9afa0e3081a20cb024551ef18ae34fe76a1ef39d Reviewed-on: https://chromium-review.googlesource.com/1089720 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
* virtwl: better multi-plane DMABuf supportDavid Reveman2018-05-26
| | | | | | | | | | | | | | | | | | | Multi-plane DMABufs are useful for efficient video playback. The guest can already use this but has to guess the stride and offsets for the second and third plane as they are not passed by virtwl to the guest kernel. This extracts the correct strides and offsets for each buffer and passes them back to the guest in the allocation response message. BUG=chromium:837209 TEST=sommelier can use nv12 buffers without guessing stride/offset Change-Id: I36ae2fad6605293c907802121676296cbc607a57 Reviewed-on: https://chromium-review.googlesource.com/1070799 Commit-Ready: David Reveman <reveman@chromium.org> Tested-by: David Reveman <reveman@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* virtwl: Add DMABuf allocation support.David Reveman2018-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This implements DMABuf allocation type in the virtio wayland device. We attempt to locate a supported DRM device prior to engaging the device jail. If found, the DRM device is passed to the wayland device code and used to serve DMABuf allocations. DMABuf support can be disabled by not providing crosvm with access to any DRM device nodes. The guest is expected to handle the case when DMABuf allocation fails and fall-back to standard shared memory. This initial change uses DRM directly but is structured in a way that would allow the allocator to be replaced by minigbm with minimal effort. BUG=chromium:837209 TEST=crosvm finds drm device and returns valid dmabufs to guest Change-Id: Ic1fd776dfdfefae2d7b321d449273ef269e9cc62 Reviewed-on: https://chromium-review.googlesource.com/1034088 Commit-Ready: David Reveman <reveman@chromium.org> Tested-by: David Reveman <reveman@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* vm_control: more error signedness fixesDmitry Torokhov2018-03-01
| | | | | | | | | | | | Fix a couple more spaces where we used negative errno values. TEST=cargo test -p vm_control BUG=None Change-Id: Id622192d025d0ac733419411492ca53a50f957f3 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/942087 Reviewed-by: Zach Reizner <zachr@chromium.org>
* vm_control: do not use negative error coded for errno-based errorsDmitry Torokhov2018-02-27
| | | | | | | | | | | | | | | Errors derived from sysem errors delivered via -1 return code/errno should use positive error codes, not negative, in order for them to be recognized by other components. I.e. we should use errno::Error::new(EINVAL) and not -EINVAL. TEST=cargo test --features plugin; cargo test -p kvm BUG=None Change-Id: I10d5992cb1e1750aa9b8a7269c4f574d7c753683 Signed-off-by: Dmitry Torokhov <dtor@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/939866 Reviewed-by: Zach Reizner <zachr@chromium.org>
* kvm: support adding read only memory to VMsZach Reizner2018-02-06
| | | | | | | | | | | | | | | | | Read only memory is useful for triggering VM exits when the VM writes to memory while allowing reads transparently and quickly. For example, a virtual device implementation might not care if the VM reads a memory mapped device register, but a exit would be required if the VM wrote to the same register. TEST=cargo test -p kvm; ./build_test BUG=chromium:800626 Change-Id: Ic605b2cfc2a1e44941d91945f9390b9abb820040 Reviewed-on: https://chromium-review.googlesource.com/903075 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: change GuestAddress to always be a u64Sonny Rao2018-02-01
| | | | | | | | | | | | | | | We want to be able to run 64-bit ARM kernels using a 32-bit version of crosvm, to make it more consistent use a u64 to represent GuestAddress. BUG=chromium:797868 TEST=./build_test passes on all architectures TEST=crosvm runs on caroline Change-Id: I43bf993592caf46891e3e5e05258ab70b6bf3045 Signed-off-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/896398 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* kvm: add dirty log supportZach Reizner2018-01-03
| | | | | | | | | | | | | This add safe support for KVM's KVM_GET_DIRTY_LOG ioctl. TEST=./build_test BUG=None Change-Id: I3d0f996927844a33addd072f2bfc62361f8b7fe0 Reviewed-on: https://chromium-review.googlesource.com/848019 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* main: Add inflate/deflate interface for balloonDylan Reid2018-01-02
| | | | | | | | Change-Id: I0fc63abbed8db303c7d283ce392fd47777b60d19 Reviewed-on: https://chromium-review.googlesource.com/818207 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* sys_util/vm_control: Don't test shm if memfd_create doesn't existDylan Reid2017-11-16
| | | | | | | | | | On older kernels, the memfd_create syscall isn't available. Skip shm tests if that is the case. Change-Id: I39c1f1779f1f02e90df727c6ca18b5bdae52e855 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/768102 Reviewed-by: Stephen Barber <smbarber@chromium.org>
* Move vm_control to a top-level crateDylan Reid2017-10-09
Break out vm_control to a crate that will be able to used by more modules. Having vm_control usable from outside crosvm makes it possible to move the devices out of crosvm in a later commit. Change-Id: I1f060700ed49b5d77519d55efa2430490d521256 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/706558 Reviewed-by: Zach Reizner <zachr@chromium.org>