summary refs log tree commit diff
path: root/devices
Commit message (Collapse)AuthorAge
...
| * virtio-gpu: add support for exporting virtgpu resourcesDavid Stevens2020-04-04
| | | | | | | | | | | | | | | | | | | | | | | | | | BUG=b:136269340 TEST=boot ARCVM and launch play store Change-Id: I2d78ffb15dcf2dc0f245916485f5ebb636ef6e78 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2014680 Reviewed-by: David Stevens <stevensd@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: David Stevens <stevensd@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
| * Virtio-net: Add multi queues in multi threadsXiong Zhang2020-04-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In order to support 2 vq pairs for virtio-net, this patch create 2 sockets in one tap interface, 2 vq pairs(rx/tx) and 2 threads in device model, So one vq pair has one thread and one socket in tap corresponding. On my SkyLake desktop with crosvm and ubuntu 18.04 guest: If run one iperf server on host and one iperf client in guest, 2 vq pairs has the same netwrok bandwidth as 1 vq pair, the bandwidth is 5.99Gbits/sec If run two iperf server on host and two iperf client in guest, In 1 vq pair mode, two iperf cliens bandwidth are 3.19Gbits/sec and 3.18Gbits/sec. In 2 vq pairs mode, two iperf clients bandwidth are 4.87Gbits/sec and 4.86Gbits/sec. So 2 vq pairs improve net bandwidth 52.7% compared with 1 vq pair in this case. BUG=chromium:1064482 TEST=Run iperf test in guest Change-Id: I1fa14d7e24085552dc828a89a883d4a2ada34789 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2099754 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org>
| * crosvm virtio balloon statsCharles William Dick2020-03-31
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Introduces the ability to request BalloonStats from a BalloonControlCommand. BUG=b:147334004 TEST=tast run <DUT> arc.Boot.vm, and the balance available changes based on this. Change-Id: I808c4024f8c644c9cc4e30cc455ceda5f477bff3 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2061517 Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Charles Dueck <cwd@chromium.org>
| * devices: fs: Replace RwLock with MutexChirantan Ekbote2020-03-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The RwLock implementation on linux has a tendency to starve writers. Since the fs device workload has a roughly evenly distributed number of reads and writes, using a Mutex should give us better performance. BUG=b:150264042 TEST=vm.Blogbbench.virtiofs Change-Id: I85ec4053bf03d19bb21b420c0aa506720e666708 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2103604 Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Stephen Barber <smbarber@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
| * devices: fs: Use l{get,set,list,remove}xattrChirantan Ekbote2020-03-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using the `open_inode` method on an fd for a symlink results in the kernel returning -ELOOP. Since there are no `*at` methods for extended attributes, manually read the path for the file and then use the l{get,set,list,remove}xattr method on the returned path. BUG=b:136128512 TEST=boot arcvm with virtio-fs and selinux enabled Change-Id: I2fde57db8a075838a3a877309f6cf89059f19258 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2120763 Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Stephen Barber <smbarber@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
| * devices: fs: Add missing `&` in copy_file_rangeChirantan Ekbote2020-03-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | `offset_dst` is supposed to be a pointer. BUG=none TEST=none Change-Id: I033501ba5a57a130625e68be88457b15ad1484ef Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2120762 Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* | devices: remove unnecessary RefCell in VmRequesterAlyssa Ross2020-04-09
| | | | | | | | | | | | | | There's no need for vm_socket to be mutably borrowed. Neither send() nor recv() are mutating methods, we don't have to worry about multiple racing immutable borrows, because the type can only be used on one thread thanks to Rc.
* | Merge remote-tracking branch 'origin/master'Alyssa Ross2020-03-26
|\|
| * gfxstream: fix buildLingfeng Yang2020-03-26
| | | | | | | | | | | | | | | | | | | | | | | | | | | | API for export_resource changed Bug: b/146066070 Change-Id: I614880704658bbe7aae2f7ad8b10c76555d99c1f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2102760 Tested-by: Lingfeng Yang <lfy@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Lingfeng Yang <lfy@google.com> Reviewed-by: Jason Macnak <natsu@google.com> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
| * vhost-net: implement direct msix irq fdChuanxiao Dong2020-03-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current vhost-net msix irq injection flow is from vhost-kernel to crosvm vhost-net, then to the KVM for irq injection. It still need crosvm vhost-net to trigger irq, which is because the set_vring_call is not directly using the msix irq fd. To optimize this flow to be from vhost-kernel to KVM directly, need: 1. if the msix is enabled and unmasked, use the misx irq fd for the vring_call directly so that all the misx injection can directly to KVM from vhost-kernel. 2. if the msix is disabled or masked, use the indirect vhost_interrupt fd to let the crosvm to control the irq injection. BUG=None TEST=cargo test -p devices TEST=start crosvm with vhost-net, and run the iperf3 on the network without any issue Change-Id: Idb3427f69f23b728305ed63d88973156a03e7c6b Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2046452 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
| * vhost: pass response_socket to activate threadChuanxiao Dong2020-03-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Pass the Option of the response socket should be used by the activate thread, to communicate with its device model. BUG=None TEST=cargo test -p devices Change-Id: I929f4c901468e920116f2a744ec73571d91080e3 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2046451 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
| * vhost-net: add control socket basic supportChuanxiao Dong2020-03-25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a pair of control socket for vhost net. This pair can be used for the vhost-net device model to control and communicate with its activate thread. BUG=None TEST=cargo test -p devices Change-Id: I8bacdb9132787dc499ef00eea1df26ff3b35028d Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2046450 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
| * usb: avoid setting configuration when unnecessaryDaniel Verkamp2020-03-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | On devices with only one configuration, skip the code that attempts to change the device's active configuration, since it must always be the single available configuration. This works around an issue observed with some USB devices (e.g. Servo Micro) where the initial Get Configuration control request fails with -EPIPE. BUG=chromium:1061382 BUG=b:151408644 TEST=Attach servo micro, see /dev/ttyUSB[012], screen /dev/ttyUSB0 Change-Id: Ic3333e1d70a0c57b090de64e4d3b7932ce2cf81d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2108871 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: George Engelbrecht <engeg@google.com> Commit-Queue: George Engelbrecht <engeg@google.com>
| * devices: gpu: complete resource V2 rebaseGurchetan Singh2020-03-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Remove RESOURCE_V2_UNREF * Add RESOURCE_MAP/RESOURCE_UNMAP to enable resources without guest storage that don't need to be mapped directly either BUG=chromium:924405 TEST=compile and test Change-Id: I10d6cd120d86131fa7ed8917ddad25cdb99ae50c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2015587 Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
| * devices: gpu: modify resource v2Gurchetan Singh2020-03-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rebase of zero-copy virtio-gpu flow: * Removes guest_memory_type/guest_caching_type in favor of a bitmask * Removes ALLOCATION_METADATA, since ideally we'd just read from guest memory to get guest responses * Renames HOST_COHERENT to HOST_VISIBLE * Adds a few more feature flags BUG=chromium:924405 TEST=compile Change-Id: I0d5a84b66cfa6d09f7e2d07ed8e761e7ba850284 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2013767 Tested-by: Gurchetan Singh <gurchetansingh@chromium.org> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org> Reviewed-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
| * audio: Create AC97 device with --ac97 optionJudy Hsiao2020-03-20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 1. Replace --cras-audio, --cras-capture, null-audio options by --ac97 option to create audio devices. 2. "--ac97 backend=BACKEND\ [capture=true,capture_effect=EFFECT]" is comma separated key=value pairs for setting up Ac97 devices. It can be given more than once to create multiple devices. Possible key values are: backend=(null, cras) - Where to route the audio device. `null` for /dev/null, and cras for CRAS server. capture=true - Enable audio capture. capture_effects - | separated effects to be enabled for recording. The only supported effect value now is EchoCancellation or aec. BUG=b:140866281 TEST=1.crosvm run -r ./vm_rootfs.img -c 4 -m 1024 -s /run --cid 5 --host_ip\ 100.115.92.25 --netmask 255.255.255.252 --ac97\ backend=cras,capture=true,capture_effect=aec\ --mac d2:47:f7:c5:9e:53 ./vm_kernel 2. Record with the vm by: arecord -D hw:0,0 -d5 -fS16_LE -c2 -r48000 /tmp/test.mp3 3. Verify that AEC is enabled within the recording stream by cras_test_cleint. Cq-Depend: chromium:2053654 Cq-Depend: chromium:2095644 Cq-Depend: chromium:2038221 Change-Id: Ia9e0e7cda1671a4842ec77a354efaa4a2dc745eb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2038413 Tested-by: Judy Hsiao <judyhsiao@chromium.org> Commit-Queue: Judy Hsiao <judyhsiao@chromium.org> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org> Auto-Submit: Judy Hsiao <judyhsiao@chromium.org>
| * devices: virtio: add virtio-console deviceDaniel Verkamp2020-03-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a virtio device that provides a serial console. It has constructors matching the existing Serial device (new_in_out, new_out, and new_sink) that take generic io::Read and io::Write streams. This change just adds the device code; additional changes are required to add the console device to the command-line parsing and device setup code. BUG=chromium:1059924 TEST=boot linux with console=hvc0 Change-Id: I917157d5ecb5160c9b00b499eabe6fb08486776c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2095534 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * devices: fs: Bump fuse minor version to 31Chirantan Ekbote2020-03-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add new definitions and constants to support fuse minor version 31. These include the FUSE_SETUPMAPPING and FUSE_REMOVEMAPPING opcodes used by the virtio-fs driver for implementing DAX support. BUG=b:147341783 TEST=vm.Virtiofs Change-Id: Ie59ec1a44e555910f2ee2c5ba7afccb8bd435db9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2105823 Tested-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
| * devices: fs: Implement copy_file_rangeChirantan Ekbote2020-03-19
| | | | | | | | | | | | | | | | | | | | | | | | BUG=none TEST=vm.Virtiofs Change-Id: I2ed7137a901e6e506e6b1562b77fdb042bdc58ab Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2105822 Tested-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
| * devices: fs: Support FOPEN_CACHE_DIRChirantan Ekbote2020-03-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for FOPEN_CACHE_DIR so that the guest can cache directory entries for longer. BUG=b:150264964 TEST=vm.Virtiofs Change-Id: Iade67b54084ed72378afa70af9e9e0f7f0bc03e8 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2105821 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
| * devices: fs: Add support for fuse minor version 28Chirantan Ekbote2020-03-19
| | | | | | | | | | | | | | | | | | | | | | BUG=b:150264964 TEST=vm.Virtiofs Change-Id: I544329b63352956647d07aefdfce3118947d0821 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2105820 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
| * Fix warnings added in rust 1.42Dylan Reid2020-03-17
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | rustc now warns about return statements that have an extra set of parenthesis. Remove such instances so that the code is warning free. TEST=cargo build completes without warnings Change-Id: I55148f8aceca8ba90f6bead2b6929e2c843351aa Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2104767 Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
| * devices: Ignore O_DIRECT in 9p and fs devicesChirantan Ekbote2020-03-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Specifying O_DIRECT in the 9p device doesn't actually work correctly and leads to an error. O_DIRECT handling in the fs device works correctly but also makes it look much worse in disk I/O benchmarks because the block device gets the benefit of the host cache while the fs device depends on the performance of the actual storage device. BUG=none TEST=`tast run vm.Fio.*` Change-Id: I738e4032081e331ef956c9d4c33616607e403d86 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2093967 Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Tested-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
| * Allow all serial port types to read from stdinJorge E. Moreira2020-03-11
| | | | | | | | | | | | | | | | | | | | | | | | | | Bug=b/148677254 Change-Id: I1fa38bc95ca303c7a2c38dbe4b938a6042c910c6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2093800 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org> Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
| * descriptor_utils: Add `iter` methodChirantan Ekbote2020-03-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add an `iter` method to the `Reader` struct so that callers can iterate over the objects in place rather than having to store them in a separate collection. BUG=none TEST=unit tests Change-Id: I29671910a4244a8d7786ca2eb241416ae72b8c9f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2093966 Tested-by: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
* | devices: don't make virtio device Results pubAlyssa Ross2020-03-20
| | | | | | | | | | These would pollute the module, and would override std's Result in modules that imported super::* like virtio_device.
* | devices: add missing PCI derivesAlyssa Ross2020-03-17
|/ | | | | | A lot of the PCI types had some derives missing that it would be quite clearly beneficial to add, and I think it's better to add them all now than piecemeal as required.
* devices: virtio: resource_bridge: Transfer plane metadataKeiichi Watanabe2020-03-06
| | | | | | | | | | | | | | | | | Transfer plane offsets and strides for exported GPU resource over resource bridge as well as a resource itself. These metadata will be required by virtio-video decoder and encoder. BUG=b:120456557 TEST=Start ARCVM on atlas Change-Id: Iaf539857c0f8525bd5be294521e75ad32cae05e7 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1787032 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Reviewed-by: David Stevens <stevensd@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
* ac97: Mark pci::ac97_bus_master::test::start_playback ignoredMattias Nissler2020-03-06
| | | | | | | | | | | | | | | | The test is flaky and causes continuous build failures. BUG=chromium:1058881 TEST=Tests run, offending test is listed as ignored. Exempt-From-Owner-Approval: Sheriff action to silence flakes on builders Change-Id: I204e6ef548e6f203b0c15b0d01fde3b88660bd44 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2090414 Reviewed-by: Mattias Nissler <mnissler@chromium.org> Commit-Queue: Mattias Nissler <mnissler@chromium.org> Tested-by: Mattias Nissler <mnissler@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
* virtio: Add VIRTIO_RING_F_EVENT_IDX test caseXiong Zhang2020-03-06
| | | | | | | | | | | | | | VIRTIO_RING_F_EVENT_IDX use Wrapping(u16) for irq suppressing, this test case to avoid some corner case for Wrapping. BUG=None TEST=Run build_test.py Change-Id: I47d377056fefcc36739bb197e30319deafb0faf4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2073902 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
* Vfio: multi vfio group supportXiong Zhang2020-03-06
| | | | | | | | | | | | | | | | | | | | | | | | | current one container contains one group only, but one container could contain multi groups actually. The main gap that current code to support multi groups is that container will be initialized multi times when multi groups exist, as each group will initialize container one time. This patch extracts the code which should run one time only on a container, so when the first group is added into container, this container initialize code will run once. The container once initialize code contains: a. Set iommu driver type as VfioType1V2 b. Setup Iommu table on each guest memory region c. create vfio_kvm device, so kernel kvm and vfio is associated. BUG=chromium:992270 TEST=passthrough two/three vfio devices into guest, these devices belong to different vfio groups, then check these devices function in guest. Change-Id: I94c9c86f70f49957a5e5c1dfd2c7d823ad042320 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2078970 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
* Use simple virtio_input_events where possible.Noah Gold2020-03-06
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, all input events in CrosVM were required to be linux input_events, which have a timestamp field that is actually unused by when we send/receive from the guest which are of type virtio_input_event. This CL allows CrosVM to understand both types of input events in a first class manner. It is a follow up on https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1930405. This CL also addresses some bugs with window driven input: 1. attach_event_device was being called before the surface was created, so the devices were never attached. 2. The default touchpad size was not being set to the display window size. Additionally, it removes the unused event "filter" feature on event sources. Breaking change: from this point forward, CrosVM will treat input events sent via a socket (e.g. SocketEventSource) to be virtio_input_events. BUG=None TEST=builds + manual Change-Id: I7fec07c582e5a071a6f116975ba70d6e621bb483 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2034046 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Noah Gold <nkgold@google.com>
* crosvm: Add plumbing for split-irqchip interruptsZhuocheng Ding2020-03-05
| | | | | | | | | | | | | | | Devices use irqfd to inject interrupts, we listen to them in the main thread and activate userspace pic/ioapic accordingly. BUG=chromium:908689 TEST=lanuch linux guest with `--split-irqchip` flag Change-Id: If30d17ce7ec9e26dba782c89cc1b9b2ff897a70d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945798 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
* Virtio: Add blk VIRTIO_RING_F_EVENT_IDX featureXiong Zhang2020-03-05
| | | | | | | | | | | | | | | | | | | | | | Previous interrupt suppress patch only supply crude interrupt suppress, VIRTIO_RING_F_EVENT_IDX feature supply a more performant alternative: 1) where the driver specifies how far the device can progress before a notification is required 2) where the device specifies how far the driver can progress before a interrrupt is required. This patch add this feature into blk. For gpu and network, this could be added also, but gpu and network performance don't get better. BUG=None TEST=run benchmark for blk in guest Change-Id: I73fe3f8b72a9e88fd6073890bc6ab2bee891d51d Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2008341 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
* devices: PIC: implement interrupt injectionZhuocheng Ding2020-03-05
| | | | | | | | | | | | | | TODO: Route irqfd to PIC, and use signal to kick vCPU thread when interrupt is triggered. BUG=chromium:908689 TEST=Unit tests in file. Change-Id: I9a87502da57e725d3bb26d746a337d0ba44ef337 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945797 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
* Add logic to setup PIC/IOAPIC.Zhuocheng Ding2020-03-05
| | | | | | | | | | | | | TODO: Route irqfd to PIC/IOAPIC to make them fully work. BUG=chromium:908689 TEST=None Change-Id: I301287b1cf32cfccffce6c52ebbb5e123931178e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945796 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
* Virtio: Add queue ack_features() interfaceXiong Zhang2020-03-01
| | | | | | | | | | | | | | | | | Virtio spec define some features like VIRTIO_F_RING_INDIRECT_DESC, VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_RING_PACKED. If one feature is enabled in guest, device's queue will have corresponding behavior for this feature. Queue's ack_features() interface let queue know which features is enabled in guest. BUG=None TEST=build_test Change-Id: I865f93940a1f4db8ca6da8829136127353cc1c6f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2008340 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* ac97: switch to ShmStreamSourceFletcher Woodruff2020-02-28
| | | | | | | | | | | | | | | | | | | | | Convert playback and capture for the AC97 device to use the zero-copy ShmStreamSource instead of the old StreamSource. In the process, rework start_playback and start_capture unit tests so they rely less on sleep statements. BUG=chromium:968724 BUG=chromium:1006035 TEST="sox -n -r 48000 -b 16 output.raw synth 5 sine 330 && aplay -f dat output.raw" within a VM, check that sine wave is played accurately. Change-Id: Ie9cddbc5285a9505872c9951a8a1da01de70eb88 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1749950 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Fletcher Woodruff <fletcherw@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
* x86_64: generate ACPI tablesChuanxiao Dong2020-02-28
| | | | | | | | | | | | | | | | | | | | | | | | Add acpi_rsdp_addr in boot_params to allow crosvm to pass a physicall address of RSDP to the Linux guest kernel, so that the linux guest kernel can parse the constructed ACPI tables and enable the ACPI. Although there is ACPI tables but as we still have "acpi=off" in command line parameter, there is still no ACPI in guest kernel. The ACPI construction refers to the implementation of the Cloud-hypervisor commit: - arch: x86_64: Generate basic ACPI tables BUG=chromium:1018674 TEST=None Change-Id: Ibcb2ae98c43da8ef8c07a07eda9213f61570d14c Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035351 Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
* devices: block: let resize convert to non-sparseDaniel Verkamp2020-02-27
| | | | | | | | | | | | | | | | | | | | | Change the behavior of the resize operation on virtio-block devices so that it causes a disk to become fully allocated (non-sparse) even if it had previously been sparse. This means that we could have a disk that was previously sparse and is now non-sparse, so treat discard requests for sparse disks as a no-op instead of an error. This is acceptable since discard is a hint and doing nothing is a valid implementation. BUG=chromium:858815 TEST=`crosvm disk resize` a sparse disk Change-Id: I8b79e460e5432cc71bed98172527fe1cd2e726ed Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2070846 Reviewed-by: David Munro <davidmunro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* devices: pci: add error handling for msix_enableDaniel Verkamp2020-02-27
| | | | | | | | | | | | | | | | | | | | This more gracefully handles failure of msix_enable; in particular, if it fails, the self.enabled state is returned to false so that future device operations won't try to access uninitialized parts of self.irq_vec. In addition, the AddMsiRoute response is now checked (previously, it was just ignored), and errors are bubbled up via MsixError rather than just printing a message. BUG=chromium:1041351 TEST=Boot Crostini on nami Change-Id: I9999f149817bc9f49176487446b52e74fb8be9a9 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2067964 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
* Vfio: Disable msix bar's mmapXiong Zhang2020-02-21
| | | | | | | | | | | | | | | | | If vfio device's bar is mmappable, vcpu could access it directly through ept without trapping. But msix's table and pba exist on pci bar, they must be trapped and emulated by crosvm, so these bars mmappable must be disabled. BUG=chromium:992270 TEST=pass through a device with msix cap to guest, then test device function in guest. Change-Id: If7504a924902c940e00cc759c1ca64a116bbca17 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1987815 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* devices: IOAPIC: implement interrupt routingZhuocheng Ding2020-02-21
| | | | | | | | | | | | | | This change implements MSI routing and injection, so that service_irq can actually inject an interrupt into guest. BUG=chromium:908689 TEST=Unit tests in file. Change-Id: I2db4f00f569db56f5765c707faaa87c64fd3da9f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1945795 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zhuocheng Ding <zhuocheng.ding@intel.corp-partner.google.com>
* Vfio: Emulate MSI-xXiong Zhang2020-02-20
| | | | | | | | | | | | | | | | | When VFIO device have msix capability, vfio kernel doesn't emulate msix, so all the msix emulation are handled by crosvm. This include msix capability register read/write, msix table read/write, msix pba table read/write. BUG=chromium:992270 TEST=passthrough a device with msix capabilty to guest, and check device msix function in guest Change-Id: Ic39737662a5051ac6b9e29aad227d3d4946190a8 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1987814 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* Vfio: Enable multi vectors in irq_enable()Xiong Zhang2020-02-19
| | | | | | | | | | | | | | | When msix is enabled, msix will have multi vectors, this patch enable mutlti vectors in vfio_device.irq_enable() function. BUG=chromium:992270 TEST=passthrough a device with msix capability to guest, and check device msix function in guest Change-Id: I5f8265e7badec8551ff9a974462f08425ee93ab2 Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1987813 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* Virtio: Add virtio block irq suppressXiong Zhang2020-02-19
| | | | | | | | | | | | | | | The flag in avail descriptor supplies irq suppress, it could reduce irq injection from device, so many redundant interrupts could be removed from guest, then improve guest performance. BUG=None TEST=run fio read and fio write in guest Change-Id: I68789d8ca24d0e84d0b446db65057f4da2fac56f Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2008339 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* acpipm: implement suspend and resume mechanismChuanxiao Dong2020-02-19
| | | | | | | | | | | | | | | | | | | For suspend request from VM, will write suspend event and notify crosvm main process to pause VCPUs. For resume request, it is not from VM itself but by the resume command through crosvm socket. Resume request will notify the PM device to fill its wakeup registers with wakeup event so that when VCPUs start to run, VM can know there is wakeup from outside. BUG=chromium:1018674 TEST=cargo test -p devices Change-Id: I4724ffee10150065a62bf520076c16cbc70b7749 Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2035169 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
* devices: virtio: Implement Reader::collect() and Writer::consume()Charles William Dick2020-02-19
| | | | | | | | | | | | | | Adds a method Reader::collect() to read a collection of DataInit types, and a method Writer::consume() to write a collection of DataInit types. BUG=b:147334004 TEST=cargo test -p devices Change-Id: Ib5947d30b44b74dc6cf0474e5b87778aad6f08a0 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2061516 Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org> Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org> Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
* virtio-gpu: gfxstream backendLingfeng Yang2020-02-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Adds a new backend type, gfxstream, that calls out to a C library implementing the actual rendering. The purpose is to allow the Cuttlefish and Android Studio Emulator teams to use crosvm with the current API-forwarding style of rendering employed in the Android Studio Emulator. Also, introduces a new key to the --gpu command line interface, backend=, which selects from different backends. Note that the previous behavior is now deprecated and will be removed after some time (when all clients switch over to backend=). The gfxstream backend itself implements a subset of 3d-related resource and context creation/transfer/execbuffer commands. Their meaning is specific to the way in which they are interpreted in the backend library. To interface with display, gfx stream backend takes a callback that is run on guest vsync. The callback is responsible for repainting the display's contents. gfx stream provides a callback, get_pixels, that can be used asynchronously. The asyncness is not taken advantage of currently but will be useful for cases where the client attached to the VMM might want to update at a different rate than guest vsync. The guts of the stream backend library is currently defined here: https://android.googlesource.com/platform/external/qemu/+/refs/heads/emu-master-dev/android-qemu2-glue/emulation/virtio-goldfish-pipe.cpp The linking of the library is controlled via the feature "gfxstream". If the feature is turned off, we use a default do-nothing stub impl. Next steps: - integrate virtio-gpu-next so as to have host coherent memory for vulkan - Figure out low latency command submit/response with SUBMIT_CMD_3DV2 BUG=b:146066070 Change-Id: If647381c15e5459cec85e2325f97e2f0a963b083 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2033305 Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Lingfeng Yang <lfy@google.com> Reviewed-by: Jason Macnak <natsu@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Auto-Submit: Lingfeng Yang <lfy@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org>
* virtio: Inject virtio-blk interrupt quicklyXiong Zhang2020-02-19
| | | | | | | | | | | | | | | | | | | Current blk interrupt is injected into guest after device handle a batch of requests. While this patch injects interrupt at the end of each request. So guest block will get much more interrupts and could handle request more quickly. With this patch, the guest fio read test improves 13%, while fio write doesn't get better. BUG=none TEST=run fio_read and fio_write in guest Change-Id: Ib0bd23e624dfc5d940d6cc124468b898d8ba128e Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2008338 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>