summary refs log tree commit diff
Commit message (Collapse)AuthorAge
* crosvm: fix balloon and USB sockets HEAD masterAlyssa Ross2020-06-15
| | | | | | | | | | | | | | | | | | | | 5bd2e7f606b726b598fdc26fe26a9b4029fab6d3 introduced queued_device_reqs to accomodate devices that are not ready to receive messages until they are activated in response to an event. But, devices that are ready immediately were not added to the map. When an event came in to one of these sockets (balloon and USB), the socket file descriptor would be looked up in queued_device_reqs, and crosvm would then crash because it wouldn't be found. The correct behaviour, which this patch implements, is to treat a missing entry the same as a Ready entry. An alternative would have been to add all other sockets to queued_device_reqs, and set them to Ready up front, but that would be more difficult to keep up to date than having a default. This way, only devices that need queueing need to be added to queued_device_reqs. Fixes: 5bd2e7f606b726b598fdc26fe26a9b4029fab6d3
* crosvm: fix deadlock on early VmRequestAlyssa Ross2020-06-15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If a DiskCommand was received on the crosvm socket before the virtio-block device was activated, the Token::VmRequest case in the main event loop would forward the request to the block device socket, and then wait syncronously for a response. That response would never come because the device hadn't been activated, and it would never be activated because the event loop would never continue, and therefore never be able to respond to the event that causes the device to be activated. crosvm would therefore just hang forever, waiting for a response that would never come. This patch fixes this deadlock by keeping track of whether devices that send a response in this way have been activated yet. If they have already been activated, messages are sent and responses are received as normal. If they have not been activated, messages are instead put into a per-device queue. Once the device is activated, queued messages are processed all at once, and then the device is marked as ready, and the queue is dropped. Future messages are processed immediately as they come in, with no further queueing. A device indicates that it is ready by sending a message on its socket. The main crosvm event loop can then poll the socket, to be notified when the device is ready. This poll event will only trigger once -- once it has been received, it is removed from the poll context. Currently, the only device type that responds to external control messages AND needs to be activated by an event is the block device. The balloon device does not respond to messages, and the xhci controller device is activated up front. The code is nevertheless structured so that it should be very easy to drop another kind of device in to the queuing system, should that be required. Message-Id: <20200614114344.22642-3-hi@alyssa.is> Notes: Reviewed-by: Cole Helbling <cole.e.helbling@outlook.com>
* msg_socket: introduce UnixSeqpacketExtAlyssa Ross2020-06-15
| | | | | | | | | | | | | | | | | | | | | | Occasionally, it is useful to be able to use UnixSeqpacket as a type that can represent any kind of MsgSocket. For example, to keep some MsgSockets of different types in a Vec. In this case, it may be known what type of messages should be sent over a socket, even though that may not be represantable in the type system. To accomodate this situation, this patch introduces send_msg_on_socket and recv_msg_on_socket methods on UnixSeqpacket, that can be used to send or receive any kind of MsgOnSocket. The caller is obviously responsible for ensuring that the messages being sent are of the type expected by the socket. This lack of type safety for message types is not ideal, and so MsgSender and MsgReceiver should still be preferred wherever possible. Message-Id: <20200614114344.22642-2-hi@alyssa.is> Notes: Reviewed-by: Cole Helbling <cole.e.helbling@outlook.com>
* crosvm: fmtAlyssa Ross2020-06-14
| | | | | I should have run this before committing 28d9682698d287d14cbe67a0ed7acc1427add320, but I did not.
* msg_socket: fix broken testsAlyssa Ross2020-06-14
| | | | I must have forgotten to test these after merging with upstream.
* Merge remote-tracking branch 'origin/master'Alyssa Ross2020-06-14
|\
| * io_uring: update for mmap api changeDylan Reid2020-06-12
| | | | | | | | | | | | | | | | | | | | | | | | | | A recent change to sys_util moved the definition of 'as_ptr' for an mmap to a new trait, include that trait here. Change-Id: Ib48113738fdace50e2dc7f72a5107dd95db867f9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2241590 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Dylan Reid <dgreid@chromium.org>
| * resources: add address_from_pci_offset functionGurchetan Singh2020-06-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Refactor current code and add tests. BUG=chromium:924405 TEST=compile and test Change-Id: I9476f3a4ffd8ae85fc95d6889ada6b056613bbfa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2216447 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
| * kvm: use MappedRegion traitGurchetan Singh2020-06-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Reduces code duplication between MMIO and mmap arenas - Makes adding future types easier - Makes upcoming deprecation of kvm crate easier - Use BTreeMap instead of HashMap since it's more efficient BUG=chromium:924405 TEST=compile and test Change-Id: I520abed0926489e64aac046e0dc0cfeb72fae7b2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2216446 Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org> Reviewed-by: Steven Richman <srichman@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
| * devices: video: dec: Support arbitrary buffers to be mapped as resourcesKeiichi Watanabe2020-06-12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support a case where a guest client who may use arbitrary numbers of buffers. (e.g. C2V4L2Component with default pool in ARCVM) Such a client is valid as long as it uses at most 32 buffers at the same time. More specifically, this CL allows the guest to call ResourceCreate for an output resource_id which was already processed by the host. Such ResourceCreate calls will be handled as reassignment of DMAbuf to a FrameBufferId. BUG=b:157702336 TEST=Play a YouTube video on ARCVM w/ C2V4L2Component using default pool Change-Id: Ie9c457867abd91b6b7a17a5bca4a1a1e9f53c1ae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2198327 Reviewed-by: Alexandre Courbot <acourbot@chromium.org> Tested-by: Keiichi Watanabe <keiichiw@chromium.org> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
| * seccomp: add policy file video_device on ARM.Alexandre Courbot2020-06-11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | BUG=b:151399776 BUG=b:151394062 TEST=Video device is properly probed with policy enabled on a guest kernel with VIRTIO_VIDEO enabled. Change-Id: Ia29afa0ab3eb969291c046d8657cd28e88d54b96 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2230418 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: Alexandre Courbot <acourbot@chromium.org> Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
| * hypervisor: add Vm user memory region functionsSteven Richman2020-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The separate Vm functions for MemoryMappings and MemoryMappingArenas have been combined and now use a MappedRegion trait that the mappings implement. msync_memory_region replaces the get_mmap_arena function, which is used by VmMsyncRequest. Since Vm uses mutexes for cloning, it can't return mem region references. BUG=chromium:1077058 TEST=cargo test, cargo test -p sys_util, cargo test -p hypervisor Change-Id: If257b16ee34d07820ae7ebdb9a3a598a41df013c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2202845 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
| * devices: irqchip: KvmKernelIrqchip x86_64 implColin Downs-Razouk2020-06-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implemented get/set_pic/ioapic/pit functions for the KvmKernelIrqchip. Added respective functions on KvmVm for interacting with the underlying KVM API. Added associated tests for get/set functions. BUG=chromium:1077058 TEST=ran devices tests and added get/set function tests Change-Id: I66a29828fe2f1fbdf54d7325656a003ac09e36d0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2219422 Reviewed-by: Udam Saini <udam@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Colin Downs-Razouk <colindr@google.com>
| * README: Document permissions needed for running.Andrew Walbran2020-06-05
| | | | | | | | | | | | | | | | | | Change-Id: Ia86cb49ffc89ad66fe67698e05968e6d6f19f743 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2231364 Auto-Submit: Andrew Walbran <qwandor@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Commit-Queue: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org>
| * io_uring: Take Vecs or iterators of iovecsDylan Reid2020-06-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The pointer passed to the kernel for the iovecs must remain valid until the operation completes. This is true even if the kernel copies the sqe containing the pointer, that isn't a deep copy. If the iovecs are freed before the kernel actually processes the op, it will fail with a bad address error. Move the responsibility for maintaining the list in memory from the caller to io_uring itself. This mean io_uring must allocate. Taking iterators for IoSlice/IoSliceMut, means that the caller doesn't need to allocate as well if there isn't a Vec already allocated. Change-Id: I63a009d8ab543c8bac4132809fb851536d4ad82c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2227082 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>
| * devices: irqchip: IrqChipX86_64 traitColin Downs-Razouk2020-06-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This trait handles the x86-specific features of an irqchip, including getting and setting the state of the pic, ioapic, lapics, and pit. Also includes an empty implementation of this trait for the KvmKernelIrqChip. BUG=chromium:1077058 TEST=cargo test -p devices Change-Id: I36034661f4a2baedc7ac2b8f311cab6327afefba Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197717 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Colin Downs-Razouk <colindr@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
| * devices: fs: Use 2 stage create and mkdirChirantan Ekbote2020-06-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When creating a file or directory the virtio-fs server changes its effective uid and gid to the uid and gid of the process that made the call. This ensures that the file or directory has the correct owner and group when it is created and also serves as an access check to ensure that the process that made the call has permission to modify the parent directory. However, this causes an EACCES error when the following conditions are met: * The parent directory has g+rw permissions with gid A * The process has gid B but has A in its list of supplementary groups In this case the fuse context only contains gid B, which doesn't have permission to modify the parent directory. Unfortunately there's no way for us to detect this on the server side so instead we just have to rely on the permission checks carried out by the kernel driver. If the server receives a create call, then assume that the kernel has verified that the process is allowed to create that file/directory and just create it without changing the server thread's uid and gid. Additionally, in order to ensure that a newly created file appears atomically in the parent directory with the proper owner and group, change the create implementation to use `O_TMPFILE` and `linkat` as described in the open(2) manpage. There is no `O_TMPFILE` equivalent for directories so create a "hidden" directory with a randomly generated name, modify the uid/gid and mode, and then rename it into place. BUG=b:156696212 TEST=tast run $DUT vm.Virtiofs TEST=Create a test directory with group wayland and permissions g+rw. Then run `su -s /bin/bash -c 'touch ${dir}/foo' - crosvm` and `su -s /bin/bash -c 'mkdir ${dir}/bar' - crosvm`. Change-Id: If5fbcb1b011664c7c1ac29542a2f90d129c34962 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2217534 Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Tested-by: Chirantan Ekbote <chirantan@chromium.org>
| * devices: fs: Refactor ioctl handling codeChirantan Ekbote2020-06-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now that the ioctl number method is const we can use a match statement rather than a series of if-else expressions. BUG=b:157189438 TEST=unit tests Change-Id: I9839f2de842ec512811101c07445ca5f99f3fe2f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2214963 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
| * sys_util: Make ioctl number method a const fnChirantan Ekbote2020-06-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This allows us to define const variables that are the return value of the method, which we can then use in match statements. BUG=b:157189438 TEST=unit tests Change-Id: I2475c59bfd43ec9ec149a6b688bf680fa2361a0b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2214962 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
| * msg_socket: implement MsgOnSocket for Vec and tuplesZach Reizner2020-06-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | These container types are similar to arrays except tuples have heterogeneous data types and Vec has a dynamic number of elements. BUG=None TEST=cargo test -p msg_socket Change-Id: I2cbbaeb7f13b7700294ac50751530510098ba16d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2168588 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> 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>
| * hypervisor: add get/set_pvclockSteven Richman2020-06-03
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The clock functions on the Vm trait are for any arch, to support hypervisors that might have ARM pv clocks. The KVM implementation (x86 only) is mostly the same as before, but uses a hypervisor-agnostic ClockState struct instead of the KVM struct. BUG=chromium:1077058 TEST=cargo test -p hypervisor Change-Id: I0e77ae997d6a30851d28aeb5f73c9ef8ebc464a1 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2202742 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Steven Richman <srichman@google.com>
| * docker: update ADHD checkout for BoxErrorDaniel Verkamp2020-06-03
| | | | | | | | | | | | | | | | | | | | | | | | | | Fixes missing BoxError references and clippy errors. BUG=None TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh Change-Id: Icba02a1e1284cce6b40555fad86aecaf7956aa30 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2224775 Tested-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* | seccomp: allow getdents64 if getdents is allowedAlyssa Ross2020-06-14
| | | | | | | | | | | | | | | | | | | | This fixes a crash where crosvm would crash if run on x86_64 with --shared-dir when running ls in the shared directory. I suspect whether getdents or getdents64 is used depends on the host libc, so allow both of them. I suspect upstream's libc uses getdents, and that's why they haven't fixed the problem. Message-Id: <20200605234757.28848-1-hi@alyssa.is>
* | Merge remote-tracking branch 'origin/master'Alyssa Ross2020-06-14
|\|
| * acpi: support user provided ACPI SDTs.Tomasz Jeznach2020-06-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Enable support for user provided ACPI tables with supplementary system description. Argument --acpi-table shall point to exsting file or pseudo-file with valid ACPI table content. BUG=None TEST=boot Linux kernel with generated SSDT tables. Change-Id: I8eac21da070dcc325884ed888cc7bcb01bc086ce Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2212501 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Tomasz Jeznach <tjeznach@chromium.org> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
| * pci: ac97: Fix unused import warningDylan Reid2020-06-01
| | | | | | | | | | | | | | | | | | | | The Error type is not used, remove it. Change-Id: Ibcc1328b62635dd62a666412eb0f56a8c2f4fc93 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2224013 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org>
| * ac97: Uses audio_streams::BoxErrorJudy Hsiao2020-06-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | audio_streams export BoxError which can be passed between threads. Adopts the API change accordingly. BUG=b:149437381 TEST=emerge-{BOARD} crosvm Cq-Depend: chromium:2215772 Change-Id: I524e9d7ab3c16b7b6d3714187f166dce72d243cb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2214971 Tested-by: Judy Hsiao <judyhsiao@chromium.org> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Judy Hsiao <judyhsiao@chromium.org>
| * resources: release support for address_allocatorTomasz Jeznach2020-05-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support for address_allocator by-alloc release. Address regions coalescing is performed at the release time. BUG=None TEST=cargo test -p resources && tast test vm.* Change-Id: Ibd39dac923d1b2f8b6a711d2a9fcbb662fc95bdc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2209171 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
| * arch: serial: open file outputs for appendDaniel Verkamp2020-05-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When opening the same output file for two serial devices (earlycon and console), the output would be overwritten by the later device. Change the file creation to use append mode so that the output file contains all of the logs from both devices instead of overwriting it. Tested with: crosvm run \ --serial hardware=serial,type=file,console=false,earlycon=true,path=test.log \ --serial hardware=virtio-console,type=file,console=true,stdin=true,path=test.log \ vm_kernel BUG=None TEST=see above - verify log contains earlycon and console output Change-Id: I14dab9eaf56dbb0ae410215324b20b34fea723ae Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2208712 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * fuzz: update virtqueue fuzzer for new VolatileSlice APIDaniel Verkamp2020-05-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | BUG=chromium:1087578 TEST=emerge-amd64-generic crosvm Change-Id: Ia206abf03f95ca92f5944fb8efc23d3f8355e292 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2220731 Tested-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Auto-Submit: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Manoj Gupta <manojgupta@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
| * docker: update adhd commit for IntoIovec changeDaniel Verkamp2020-05-29
| | | | | | | | | | | | | | | | | | | | | | BUG=None TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh Change-Id: Idf81ad58954995bcfb8b222d1613f76f72a2c730 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2220154 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
| * hypervisor: x86 irqchip structsColin Downs-Razouk2020-05-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Hypervisor-agnostic structures for the pic, ioapic, lapic, and pit. These are derived from existing structures in the pic, ioapic, and pit implementations, as well as from the kvm_sys bindings. Includes From implementations converting these structures to their associated KVM structures. Also includes tests for these conversion implementations. BUG=chromium:1077058 TEST=added tests to convert kvm structures to hypervisor-agnostic structures Change-Id: Ie2f254bf2dba3aed755008296c00cb6a49f845fd Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197716 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Colin Downs-Razouk <colindr@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
| * sys_util: Refactor IntoIovecChirantan Ekbote2020-05-28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The original stated purpose of this trait was to reduce memory allocations but having the `into_iovec` method return a Vec kind of defeats that purpose. Refactor the trait so that it can either convert a T into an iovec or convert a &[T] into a &[iovec]. Implement the trait for VolatileSlice, IoSlice, and IoSliceMut and update all the callers. BUG=none TEST=unit tests Cq-Depend: chromium:2210272 Change-Id: I9d0d617a23030d241d50411f4a5a16e7cba4bcee Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2208527 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Tested-by: Chirantan Ekbote <chirantan@chromium.org>
| * devices: usb: add unit test for ring buffer cycleDaniel Verkamp2020-05-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Validate that the toggle_cycle code works as expected. I initially misunderstood the behavior of toggle_cycle in the Link TRB, but it appears to work correctly as written after writing a unit test to verify my understanding. Add the unit test anyway to be sure the behavior doesn't regress in the future. BUG=None TEST=cargo test -p devices Change-Id: I9dbc34b26225945fa6d31c34261f53d5b64ba259 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2199956 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * arch: check property_string result in create_android_fdtDaniel Verkamp2020-05-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add the missing '?' to check the result of the newly-added property_string call to match the rest in this function. Fixes clippy warning about an unused result. BUG=None TEST=docker/wrapped_smoke_test.sh Change-Id: I428b377e1a4f15e0ee96c8e96540f2fc8edce560 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2216400 Tested-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Auto-Submit: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * Fix VolatileSlice calls in all modulesDaniel Verkamp2020-05-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The VolatileSlice API changed, but some callers were not updated to match. Fix them up so that builds with additional features enabled (e.g. kokoro) pass again. BUG=None TEST=cargo test -p disk --features=composite-disk TEST=docker/wrapped_smoke_test.sh Change-Id: I97b3cd04549af30b7dc1515245f025d9439669bc Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2216399 Tested-by: Daniel Verkamp <dverkamp@chromium.org> Auto-Submit: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * docker: update ADHD commit for VolatileSlice changesDaniel Verkamp2020-05-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update to include commit 172fe3dee939f4bdc622088699fce8c0653b5389 ("libcras: Update VolatileSlice call"). BUG=None TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh Change-Id: Ib4cf4128204c42abfb8a04c823db2c4faedccbc9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2216398 Tested-by: Daniel Verkamp <dverkamp@chromium.org> Auto-Submit: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * Cargo.lock: add sync dependency to hypervisorDaniel Verkamp2020-05-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update Cargo.lock via `cargo build` after commit 0aacc50fd25d61ae1274d6054550f45acaa50897. BUG=None TEST=`cargo build` does not modify Cargo.lock TEST=kokoro Change-Id: Ib8942b38f881322f3e74726fdabe4fc68a2f3b6d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2212948 Tested-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * resources: allocate_at support for address_allocatorTomasz Jeznach2020-05-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Support for address range allocation at specific location and size. Allocation is successful only if requested range is available and free. Change to address_allocator allocation algorithm from contiguous memory allocation to first-fit like implementation to allow memory release/reuse in future. BUG=None TEST=cargo test -p resources && tast test vm.* Change-Id: I58218f5a2c6a215152904cc1cf0748e842fa7374 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2203297 Tested-by: Tomasz Jeznach <tjeznach@chromium.org> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
| * Make VolatileSlice ABI-compatible with iovecChirantan Ekbote2020-05-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change VolatileSlice so that it is ABI-compatible with iovec. This allows us to directly pass in a VolatileSlice for a C function that expects an iovec without having to create temporaries that convert from one to the other. Also change all the parameters from u64 to usize. It's not possible to address more memory than fits into a usize so having u64 here didn't really provide much benefit and led to a lot of tedious casting back and forth all over the place. BUG=none TEST=unit tests Cq-Depend: chromium:2206621 Change-Id: I258f9123c603d9a4c6c5e2d4d10eb4aedf74466d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2203998 Tested-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
| * devices: virtio: video: Implement video decoder deviceKeiichi Watanabe2020-05-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement virtio-video decoder which supports hardware-accelerated video decoding backed by libvda. Note that this implementation assumes that a guest client uses a fixed-size set of output buffers. We support a case where arbitrary numbers of buffers are used by a client like C2V4L2Component in the next CL. BUG=b:147465619 TEST=Run v4l2-decoder-sample on ARCVM R TEST=Play YouTube videos on ARCVM R with C2VDAComponent Change-Id: I3a19381f923ba9c9c0d587dc4ff2c2ee3b31269d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1991380 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
| * devices: virtio: Initial implementation of virtio-video deviceKeiichi Watanabe2020-05-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds a fundamental part of the virtio video device, which will be shared between the encoder and the decoder. Both devices uses the virtio-video protocol proposed as RFC v3 [1,2]. The corresponding driver code is at CL:2060327 and its children CLs. The actual decoding and encoding logic will be implemented in different CLs. [1]: mail: https://markmail.org/thread/wxdne5re7aaugbjg [2]: PDF: https://drive.google.com/file/d/1jOsS2WdVhL4PpcWLO8Zukq5J0fXDiWn-/view BUG=b:147465619, b:140082257 TEST=cargo check --features=video-decoder,video-encoder TEST=ARCVM started with --video-decoder --video-encoder Cq-Depend: chromium:2203997 Change-Id: I01999eea218ba0f3aaed1558ca2311a57d0c6819 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1973973 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
| * devices: gpu: random cleanupGurchetan Singh2020-05-22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | - Remove unused phantom data - scannout --> scanout BUG=none TEST=compile Change-Id: I5054833025eef5be766b547fa3e61d2ca46e226f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2211154 Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org> Reviewed-by: David Riley <davidriley@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
* | Merge remote-tracking branch 'origin/master'Alyssa Ross2020-05-22
|\|
| * Cargo.lock: add kvm to hypervisor dependenciesDaniel Verkamp2020-05-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Update Cargo.lock to match the latest commit. (Updated automatically via `cargo build`.) BUG=None TEST=`cargo build` does not modify Cargo.lock any further TEST=kokoro passes Change-Id: I1c022c6111b063eb0d31dda59ed3125c91b49d19 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2209351 Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * hypervisor: add KvmVm new and try_cloneSteven Richman2020-05-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Vms and Vcpus will be try_cloneable and Send, so we can configure on vcpu threads and so IrqChips can reference all Vcpus. To support cloning, collection fields in Vm have been moved into arc mutexes, and Vm and Vcpu are now Sized. Because this breaks object safety, all usage of the traits will be via static binding. Add impl AsRawFd for SafeDescriptor, to get the sys_util ioctl functions working with SafeDescriptor; eventually the functions will change to take SafeDescriptors. Copy set_user_memory_region helper from kvm crate. BUG=chromium:1077058 TEST=cargo test -p hypervisor Change-Id: I23de47c4472a77632006d0d45de9754394b400c2 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197337 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>
| * Put files in device tree for AndroidLepton Wu2020-05-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With this, Android can access files from host in early stage so it can import properties from host. To avoid introduce more command line flags, just reuse the fstab file: any entries begin with #dt-vendor means a host side file need to be put in device tree. BUG=b:155128030 TEST=manual - Run ARCVM and check there is file under sysfs Change-Id: I6b209e05faabd3a82fe0194cf462ee450918ae5c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2203298 Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: Lepton Wu <lepton@chromium.org> Auto-Submit: Lepton Wu <lepton@chromium.org>
| * devices: irqchip: new irqchip moduleColin Downs-Razouk2020-05-18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This new module contains the irqchip trait and it's implementations. The irqchips will work with the new hypervisor crate to abstract the interaction between crosvm and kvm. This just defines the irqchip trait and an empty implementation of the KvmKernelIrqChip. BUG=chromium:1077058 TEST=added test for creating a KvmKernelIrqChip and adding a Vcpu to it Change-Id: Ic1609c965e0a057f5a9d4d74f1cae46edb46dcb4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197398 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Commit-Queue: Colin Downs-Razouk <colindr@google.com>
| * msg_socket: remove MsgOnSocket impl for RawFd, an alias for i32Zach Reizner2020-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This implementation makes it impossible to use i32 as ordinary data in a MsgOnSocket implementation. It is also error prone because i32 is the default type for integer literals in Rust, and #[derive(MsgOnSocket)] on structs with an i32 would suddenly be transmitting a RawFd. This change also replaces the uses of RawFd's MsgOnSocket impl for one based on File. TEST=cargo build BUG=None Change-Id: I9da392e34e62fe61f773f24d656dbcbf4716f1a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197777 Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
| * msg_socket: fix MsgOnSocket::msg_size for Option<T>Zach Reizner2020-05-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This caused None values to be transmitted as zero-bytes, which usually caused not enough buffer space to be allocated for sending. BUG=None TEST=cargo test -p msg_socket Change-Id: If12d2df56689a84054405f2ba15d1c268afad15e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2197776 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Zach Reizner <zachr@chromium.org>