summary refs log tree commit diff
path: root/devices
Commit message (Collapse)AuthorAge
...
* | Merge remote-tracking branch 'origin/master'Alyssa Ross2020-05-10
|\|
| * remove instantes of using IntoRawFd in unsafe blocksZach Reizner2020-05-07
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The trait IntoRawFd isn't marked unsafe, but its documentation says that an impl must return a uniquely owned RawFd. Some code blocks depended on that behavior to ensure safety with the unsafe File::from_raw_fd, but this leads to a soundness hole where a nominally safe impl of IntoRawFd can lead to unsafety in functions that had been left as safe. This change sidesteps the issue by not using IntoRawFd, and using only safe conversions instead. BUG=None TEST=cargo build --features='wl-dmabuf plugin' Change-Id: I9b357e5592be21189fb96e343823dd63000aac30 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2185580 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Zach Reizner <zachr@chromium.org> Auto-Submit: Zach Reizner <zachr@chromium.org>
| * pci: refactor FDT/MPTABLE creation to use PciAddress.Tomasz Jeznach2020-05-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Simple refactor of FDT and MPTables generation to use PCI device addressing and allow declatation of non-zero PCI bus ids for x86 architectures. It also allows non sequential IRQ allocation for PCI devices. BUG=None TEST=build_test & tast run crostini.Sanity Change-Id: I6cc31ce412199a732499b2d8d18d99f08d765690 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2175739 Tested-by: Tomasz Jeznach <tjeznach@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
| * descriptor_utils: Add write_iter methodChirantan Ekbote2020-05-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a method to write a series of objects produced by an iterator. Unlike the current `consume` method, this doesn't require the caller to first store the objects in an intermediate collection. Also change `consume` to be implemented using `write_iter`. This is the Writer equivalent of the `iter` and `collect` methods of the Reader struct. BUG=none TEST=unit tests Change-Id: I36bf2fef4d40e13a4741fa55fc35dd556c13a53b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2172841 Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org> Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
| * devices: pci: refactor PCI devices to use PciAddress.Tomasz Jeznach2020-05-01
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Simple refactor of PCI device addressing to use PciAddress type providing bus:device.function number. BUG=None TEST=build_test & tast run crostini.Sanity Change-Id: I7755ad6b31aa8c882475cd8212630e1cc86ef49e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2172766 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
| * devices: pci: refactor device location address.Tomasz Jeznach2020-04-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Simple refactor of PCI device addressing to use bus:device:function notation, including change allowing sparse alloction of device addresses in PCI topology. BUG=None TEST=build_test && cargo test Change-Id: I9ff02dd6b67b6784eac8c3d348661789fca3f422 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2171037 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Tomasz Jeznach <tjeznach@chromium.org> Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
| * Stop tracking sub-mappings in MemoryMappingArenaChirantan Ekbote2020-04-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The kernel already takes care of tracking all our memory mappings. Doing it again ourselves doesn't provide any benefit and also adds additional restrictions (like not being able to overlap with existing mappings or partially remove mappings). Additionally, the `MemoryMappingArena` will already unmap the entire memory mapped region so there is no need to individually unmap the sub-mappings. The kernel's mmap api doesn't have these restrictions and as far as I can tell there are no safety concerns with allowing this behavior so just stop tracking the sub-mappings. Safe use of MAP_FIXED only requires that the address is part of a previously mmaped region so allow any MemoryMapping to be converted into a MemoryMappedArena. BUG=b:147341783 TEST=unit tests Change-Id: Iaf944a971b8ba9333802aab73c1d184fe388af89 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2162542 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
| * ac97: Create CrasClient with unified socketpaulhsia2020-04-29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since Termina and ARCVM need both playback and capture functionalities, we create CrasClient with CrasSocketType::Unified. BUG=b:155048379 TEST=Apply full patch set and test with VMs Cq-Depend: chromium:2165697 Cq-Depend: chromium:2167813 Change-Id: Id4fb12423eb05859528406ae7ed5e62b46909a56 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2167312 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: Chih-Yang Hsia <paulhsia@chromium.org> Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
| * Remove unnecessary parentheses in constsDaniel Verkamp2020-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix clippy "error: unnecessary parentheses around assigned value." BUG=None TEST=bin/clippy Change-Id: I31e61c770c62d7ff2ca8525bf754bd615e24c349 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2163204 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * Remove redundant single-component importsDaniel Verkamp2020-04-26
| | | | | | | | | | | | | | | | | | | | | | | | | | Fix clippy 1.43.0 clippy::single-component-path-imports warnings. BUG=None TEST=bin/clippy Change-Id: I3f4f54138bedce16dc1ca937bb8bc00a94594f69 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2163203 Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * devices: usb: allow arbitrary control request sizeDaniel Verkamp2020-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, the maximum control request length that could be passed through the USB host_backend layer was limited to 1024 bytes. To lift this limit, remove the fixed-length ControlTransferBuffer structure definition and replace it with manual buffer allocation. This mirrors the behavior of the later part of this function, which already indexes into the control_buffer to copy the data back from a device to host transfer. BUG=chromium:1073503 TEST=Verify adb logcat still works Change-Id: I7354f6fa237b4df6db7898f27be76ab10faed9f4 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2161440 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Daniel Verkamp <dverkamp@chromium.org> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * devices: add SerialDevice traitDaniel Verkamp2020-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This will be used to allow generic code to create serial devices as well as virtio-console devices. Also remove the new_in_out, new_out, and new_sink constructors for Serial and Console, since they are not used anywhere. BUG=chromium:1059924 TEST=cargo build Change-Id: I76da343e347aed36dabd3aa0541acf24c64fe122 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127321 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
| * arch, devices: move serial creation to archDaniel Verkamp2020-04-23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Split the serial code into two parts: - Configuration and setup: arch/src/serial.rs - Serial device emulation: devices/src/serial.rs No change in functionality - this is just preparation for generalizing the command line parsing/setup code so that it can be used with virtio console devices as well. BUG=chromium:1059924 TEST=emerge-nami crosvm TEST=emerge-kevin crosvm Change-Id: I0aaf9dd6f8096eac4a17077ab5bf569f57d64ff5 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2127319 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * Serial: add input path overriding stdin for --serialIliyan Malchev2020-04-19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allowing the input to be specified for file-based serial ports allows the user of pipes as input/output. That enables kgdb over serial. TEST= Build a kernel with support for gdb ``` make x86_64_defconfig make kvmconfig ./scripts/config --enable GDB_SCRIPTS ./scripts/config --enable KGDB ./scripts/config --enable KGDB_SERIAL_CONSOLE ./scripts/config --enable KGDB_LOW_LEVEL_TRAP ./scripts/config --enable KGDB_KDB ./scripts/config --enable KDB_KEYBOARD ./scripts/config --enable GDB_SCRIPTS ./scripts/config --set-val KDB_CONTINUE_CATASTROPHIC 0 make -j33 ``` Setup devices for PTYs To make sure crosvm doesn't create an ordinary file if socat is started after it, create these named pipes first: ``` mkfifo ~/console_{in,out} ~/kgdb_{in,out} ``` Set up two PTYs: ~/kgdb for the debugger, and ~/serial for the console. PTY ~/kgdb connects to ~/kgdb{in,out}, and ~/serial connects to ~/console{in,out} ``` socat -d -d -d \ 'PIPE:$HOME/console_out,rdonly=1,nonblock=1,ignoreeof=1!!PIPE:$HOME/console_in,wronly=1' \ PTY,link=$HOME/serial,ctty,raw,echo=0 socat -d -d -d \ 'PIPE:$HOME/kgdb_out,rdonly=1,nonblock=1,ignoreeof=1!!PIPE:$HOME/kgdb_in,wronly=1' \ PTY,link=$HOME/kgdb,ctty,raw,echo=0 ``` Start crosvm with serial ports pointed at ~/console{in,out} and ~/kgdb{in,out}. ``` cargo run run -p 'init=/bin/sh panic=0 kgdboc=ttyS1,115200 kgdbwait kgdbcon' \ --serial type=file,path=$HOME/console_out,num=1,console=true,stdin=false,input=$HOME/console_in \ --serial type=file,path=$HOME/kgdb_out,input=$HOME/kgdb_in,num=2,console=false,stdin=false \ -r ~/rootfs.img \ ~/src/linux/arch/x86/boot/bzImage ``` Start GDB ``` gdb vmlinux -ex "target remote /home/dgreid/kgdb" ``` To break into gdb, open up the serial console, mount /proc and send a SysRq ``` minicom -D ~/serial mount -t proc none /proc echo g > /proc/sysrq-trigger ``` Change-Id: I18a9c1087d38301df49de08eeae2f8559b03463a Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2151856 Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Dylan Reid <dgreid@chromium.org>
| * devices: fs: Fix potential resource leakChirantan Ekbote2020-04-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | During a readdirplus call if we fail to add an entry to the response buffer, which can happen if the buffer doesn't have enough space to hold the entry, then the lookup count for that entry on the server will not match the lookup count in the kernel driver. Fix this by calling `forget_one` on that entry when this case happens. BUG=none TEST=vm.Virtiofs Change-Id: I66205ba94b451a726ddcde2376d731251eb7545f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2145548 Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
| * devices: fs: Strip padding from directory entry namesChirantan Ekbote2020-04-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When calling `getdents64`, the kernel will add additional nul bytes to the name of the directory entry to make sure the whole thing is 8-byte aligned. Previously we would pass on this padded name to the kernel driver. However, this seems to prevent the driver from detecting the "." and ".." entries, leading to the driver printing warnings like VFS: Lookup of '.' in virtiofs virtiofs would have caused loop Strip out the padding so that the kernel detection of the "." and ".." entries can work properly. BUG=b:153677176 TEST=vm.Virtiofs and manually start a vm and check that the kernel doesn't print warnings about lookups causing loops Change-Id: Id015182186cc3cb076e27556a1ab0a2de710aa59 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2145547 Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com>
| * devices: virtio: wl: Stop using non-blocking socketsRyo Hashimoto2020-04-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Non-blocking sockets require proper EAGAIN handling in crosvm and the guest kernel. Without it, guest writing data faster than host reading results in the guest kernel returning ENODEV. Use blocking sockets to avoid this problem, and to be consistent with pipes which are blocking in wl.rs. BUG=b:153858766 TEST=Launch ARCVM Change-Id: If795ee0035dc057de0e155470e231d41f30d3a0e Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2148985 Tested-by: Ryo Hashimoto <hashimoto@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Commit-Queue: Ryo Hashimoto <hashimoto@chromium.org>
| * devices: fs: Report "." and ".." entriesChirantan Ekbote2020-04-14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | BUG=b:153677176 TEST=vm.Virtiofs and manually check that the "." and ".." entries appear in a VM when you run `ls -al` Change-Id: I75045fd5bced67ff13045088e6f198fa61cb2d4b Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2142847 Auto-Submit: Chirantan Ekbote <chirantan@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
* | crosvm: collapse simple boolean matchesAlyssa Ross2020-04-11
| | | | | | | | | | Rust 1.42 introduces matches!(), which can be used to collapse simple match statements like these.
* | Merge remote-tracking branch 'origin/master'Alyssa Ross2020-04-10
|\|
| * ac97: Set CRAS_CLIENT_TYPE_CROSVM for crosvmpaulhsia2020-04-10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Set client type for debug log and ucm. BUG=b:140401362 TEST=Build, deploy and run `aplay -f dat /dev/zeros` and check `cras_test_client --dump_a` results Change-Id: I2b040ddaaafe0b7d6e7c3a6f3973598d0a79ff82 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2142836 Reviewed-by: Dylan Reid <dgreid@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Chih-Yang Hsia <paulhsia@chromium.org> Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
| * devices: pmem: implement flush using msync()Daniel Verkamp2020-04-08
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, writable pmem devices implemented the flush command using fsync(); however, this does not guarantee synchronization of memory mappings via mmap() to the file on disk. What we actually need is msync() on the pmem file mapping, but we don't have access to that mapping in the pmem child process, and it isn't trivial to pass it along since it is owned by the Vm object once it has been added as a mmap_arena. In order to call msync() on the mapping, add a new VmControl socket so that the pmem device can request that the main process issues an msync() on the MemoryMappingArena identified by its slot number. BUG=chromium:1007535 TEST=mount filesystem on /dev/pmem0 and sync; verify msync in strace Change-Id: Id0484757c422cf81d454fd54012a12dbcc1baaf6 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2044365 Reviewed-by: Stephen Barber <smbarber@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
| * handle mmap of large offsets on 32 bit systemsDylan Reid2020-04-05
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | While only 32 bits of address can be mapped, that 32 bits can be offset by further than 32 bits in to a large file. As chirantan points out, the try_mmap call was already casting the usize to u64 on all architectures. Convert the usize offset in mmap to u64 and address users of the API as well. Change-Id: I67aed928ea521049fb51eb7aa61ea4de8b4d096c Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2124879 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>
| * Virtio-net: Let queue-num could configurableXiong Zhang2020-04-04
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Virtio-net multi queue feature need multi queue pairs, this patch change queue-num configurable instead of static. --net-vq-pairs parameter could config virtio net device virtual queue pairs. BUG=chromium:1064482 TEST=Test virtio net function in guest with --net-vq-pairs=1 and --net-vq-pairs=2 Change-Id: I75202c8ae52a83b8087b52149ec6d2138d8831cb Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2120312 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>
| * 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.