Commit graph

1423 commits

Author SHA1 Message Date
Dylan Reid
23a2b7b8a2 io_uring: add reading and writing iovecs
Let the user of the io_uring interface specify a slice of iovecs to read
from or write to when queueing an operation to the ring.

These ops can be used by block that has a Vec of iovecs from the
descriptor chain already.

Change-Id: Ia91e03e441cdae03e4fdba33bb601de006ef53ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2140914
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-04-10 00:13:08 +00:00
Dylan Reid
40d0e01de6 io_uring: operation results are unsigned
Switch from returning an i32 to a u32. This will make handling the
number easier for users, as they can assume it is >= 0.

Any value < 0 would not be returned as Ok(value) anyways as ret < 0 is
used for error conditions.

Change-Id: I609ce55d3c6be6e28f4d7aadf7148b2ac3b18878
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2140913
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-04-10 00:13:06 +00:00
Daniel Verkamp
e1980a9c36 devices: pmem: implement flush using msync()
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>
2020-04-08 06:09:25 +00:00
A. Cody Schuffelen
f3081b120e Fix performance problem on Android Sparse images
This was adding ~11 minutes to the boot time with sparse images.

BUG=b:151981838
TEST=launch cuttlefish with sparse images.

Change-Id: I707258566aee338f742a3a5fe94d0bad8302c447
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2111117
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
2020-04-07 23:03:40 +00:00
Charles William Dick
0bf8a5590f crosvm balance available memory
Poll available memory from the host and guest every second. Resize the
balloon so that available memory in the guest is the same as in the
host.

balancemem_timer adds a Token::BalanceMemory to poll_ctx every second
which creates a balloon stats request.
When the stats results come back from the guest, we compute how much the
balloon should change to balance available memory between the guest and
host. If this new balloon size is > 5% different than the current
balloon size, we make a BalloonControlCommand::Adjust to resize the
balloon.

BUG=b:147334004
TEST=tast run <DUT> arc.MemoryChomeOSPerf*, .vm shows memory use similar
to the base arc test. tast run <DUT> arc.MemoryShiftingPerf.vm, both
chromeos and android counters report high numbers. Switch
LOWMEM_AVAILABLE constant to non-existing file, check the ARCVM reports
not running in ChromeOS, but still boots.

Change-Id: I8a581f86bf4881541d2f5f26dc541b35b862d244
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2061518
Reviewed-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Charles Dueck <cwd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Charles Dueck <cwd@chromium.org>
2020-04-06 05:27:09 +00:00
Dylan Reid
a9a1d02277 Add io_uring interfaces
Provide a low-level interface to operating the new io_uring interface.

This is an unsafe interface with the basic operations of setting up the
ring, adding to it, removing from it, and polling it.

This will be followed by a safe interface layer on top of this code,
then by additions to the asynchronous executor that allow for
asynchronously doing multiple operations to files from one context.

Change-Id: I71f7ffb04ce8cb4da470deda9aee768ab95d3d98
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2124009
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-04-05 21:32:20 +00:00
Dylan Reid
252d5b3cf3 handle mmap of large offsets on 32 bit systems
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>
2020-04-05 21:32:17 +00:00
Zach Reizner
146450b456 msg_socket: support dynamically sized types
This change is a major shift in how the MsgOnSocket trait works to allow
`self` to be used to determine the result `msg_size()`. This is to
support data structures with `Vec` or other dynamically sized type.

TEST=./build_test
     cargo test -p msg_socket
     tast run <DUT> crostini.CopyPaste.*
BUG=None

Cq-Depend: chromium:2025907
Change-Id: Ibdb51b377b2a2a77892f6c75e1a9f30b2f8b0240
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2029930
Tested-by: Zach Reizner <zachr@chromium.org>
Auto-Submit: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
2020-04-05 15:10:47 +00:00
Xiong Zhang
773c70740e Virtio-net: Let queue-num could configurable
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>
2020-04-04 19:52:11 +00:00
Keiichi Watanabe
c56bc98966 docker: Add setup for libvda
Add the following setup for libvda, which will be used by video features
introduced by CL:1973973:

* Pull down platform2 as /platform2
* Create a dummpy libvda.pc file

Note that we don't build libvda.so.

BUG=b:147465619
TEST=build_crosvm.sh

Change-Id: I1f61df57244a13b7df1b7a373d955b6cfe91e188
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2133987
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2020-04-04 13:49:20 +00:00
Keiichi Watanabe
abf8dabae9 docker: Run cargo check with all features enabled
The current Dockerfile builds crosvm only with some selected features.
To cover all of crosvm code, this CL adds 'cargo check' command.

BUG=none
TEST=./build_crosvm_base.sh && ./build_crosvm.sh

Change-Id: I6e1efa8f68476912c9cec46188f096d430df663c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2134003
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2020-04-04 13:49:19 +00:00
David Stevens
11e71a1838 virtio-gpu: add support for exporting virtgpu resources
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>
2020-04-04 13:49:16 +00:00
Xiong Zhang
4cbcc26f5c Virtio-net: Add multi queues in multi threads
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>
2020-04-04 05:57:05 +00:00
Charles William Dick
664cc3ca49 crosvm virtio balloon stats
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>
2020-03-31 05:59:32 +00:00
Dylan Reid
31deb9fd45 sys_util: Allow pre-populating mmaps
io_uring would like to pre-fault the ring pages as they are likely to be
accessed regularly. Allow mmap users to specify the MAP_POPULATE flag
through a new API.

Change-Id: I5fefc13443280fe832c9601fe5a497b572127f0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2124008
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2020-03-29 08:58:42 +00:00
Dylan Reid
d32100205f syscall_defines: add new/updated syscalls
io_uring is needed so update the syscall defines to match 5.6-rc5.

There was a slight refactor in arm upstream which changed some syscall
names to better reflect their 32 vs 64 bit variants. See kernel commit:
00bf25d6: y2038: use time32 syscall names on 32-bit

TEST=samus,  kukui, and kevin64 build.

Change-Id: Idcceb4bba313a3f826556e90ffde94f166de0a05
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2124007
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
2020-03-28 21:09:03 +00:00
Chirantan Ekbote
c6f1380932 devices: fs: Replace RwLock with Mutex
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>
2020-03-27 20:07:34 +00:00
Daniel Verkamp
bbb82287c1 devices: usb: temporarily disable resets
This is a workaround for a bug encountered with newer Android phones -
when connected to the Linux VM, resetting the USB device via
USBDEVFS_RESET causes the device to disconnect from the host, preventing
its use in the VM.

This works around the issue by removing both paths that can cause a
USB device reset (initial reset at device insertion plus reset when
requested by the guest kernel).  Both of these must be removed to
restore functionality; if either is still in place, the failure is still
observed.

The workaround specifically exempts Edge TPU devices, which need a reset
for firmware update; these devices will still issue a reset on connect
and when requested by the guest.

BUG=chromium:1058059
TEST=Connect Pixel 3 to eve, adb logcat

Change-Id: I7a689da1120e1fb772d95e41a0d4debe64f7d6a4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2105814
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-03-27 03:58:37 +00:00
Chirantan Ekbote
d74bb77a3e devices: fs: Use l{get,set,list,remove}xattr
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>
2020-03-27 00:44:06 +00:00
Chirantan Ekbote
9e8aa131d3 devices: fs: Add missing & in copy_file_range
`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>
2020-03-26 17:32:29 +00:00
Lingfeng Yang
22964eab88 gfxstream: fix build
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>
2020-03-26 02:52:58 +00:00
Chuanxiao Dong
45a94bedae vhost-net: implement direct msix irq fd
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>
2020-03-25 17:41:42 +00:00
Chuanxiao Dong
57b8201eeb vhost: pass response_socket to activate thread
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>
2020-03-25 01:33:59 +00:00
Chuanxiao Dong
02f58e6d74 vhost-net: add control socket basic support
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>
2020-03-25 01:33:57 +00:00
Daniel Verkamp
928a8395e0 docker: update ADHD commit to fix kokoro build
Update the audio_streams dependency to fix a build failure introduced in
https://crrev.com/c/2038413.

BUG=None
TEST=docker/build_crosvm_base.sh && docker/wrapped_smoke_test.sh

Change-Id: I99b26c925a8bc5bb6f77575eb64c0972a5a5e0ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2116274
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: George Engelbrecht <engeg@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-03-24 20:59:23 +00:00
Daniel Verkamp
0dcbfa1176 usb: avoid setting configuration when unnecessary
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>
2020-03-24 11:29:57 +00:00
Gurchetan Singh
83fc5c49ba devices: gpu: complete resource V2 rebase
* 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>
2020-03-23 20:37:12 +00:00
Gurchetan Singh
151af70ac9 devices: gpu: modify resource v2
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>
2020-03-23 20:37:11 +00:00
David Stevens
911e21e392 gpu_renderer: disable debug callback on arm
The vararg bindings are different for different architectures. Limit
support to x86 and x86_64, since those are the bindings that are checked
in.

BUG=chromium:1063640
TEST=compiles

Change-Id: Ic69753959684f55855fd7a8577a422638cd05f8b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2114633
Reviewed-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Tested-by: David Stevens <stevensd@chromium.org>
2020-03-23 10:56:31 +00:00
Judy Hsiao
d5c1e968c9 audio: Create AC97 device with --ac97 option
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>
2020-03-20 15:26:02 +00:00
Daniel Verkamp
e5113047d5 devices: virtio: add virtio-console device
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>
2020-03-19 19:47:10 +00:00
Chuanxiao Dong
9486e57a09 ACPI: enable ACPI from command line
Previously the "acpi=off" in cmdline has disabled the ACPI for the
guest kernel. With removing the "acpi=off", the ACPI will be enabled
for the guest kernel by default. With acpi enabled, the SCI irq will
be needed by the ACPI core driver. Register the SCI irq in MP table
so that it can use IO-APIC routing.

The reason to have "pci=noacpi" is that, in the current DSDT there is
only suspend capability, so PCI scan still need to be done by the
traditional way.

BUG=chromium:1018674
TEST=Linux guest is able to boot up with the virtio devices functional.
Also able to see the S1 capability from kernel dmesg.

Change-Id: Id54e788f4aa4c944fac5e3fa1c92b76865dd5021
Signed-off-by: Chuanxiao Dong <chuanxiao.dong@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2078967
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2020-03-19 12:11:51 +00:00
Chirantan Ekbote
5b2447ceaf devices: fs: Bump fuse minor version to 31
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>
2020-03-19 08:13:32 +00:00
Chirantan Ekbote
6dfa1e4ce5 devices: fs: Implement copy_file_range
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>
2020-03-19 08:13:31 +00:00
Chirantan Ekbote
93a9877057 devices: fs: Support FOPEN_CACHE_DIR
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>
2020-03-19 08:13:30 +00:00
Chirantan Ekbote
a07d84ad68 devices: fs: Add support for fuse minor version 28
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>
2020-03-19 08:13:29 +00:00
Matt Delco
6d2a834827 seccomp: add frequency file to x86_64
Add a frequency file that teaches the seccomp compiler to weight the
comparison tree in favor of the most frequenctly called syscalls.

This frequency file was created by running strace against vm_conciege's
pid (e.g., "strace -p PID -ff -e raw=all -o /tmp/strace") when
performing a start and stop of a VM, deleting the trace files that
weren't for a crosvm process, passing the files to minijail's
tools/generate_seccomp_policy.py (using the -frequency option), and
combining the results of the frequency file.  I rounded the #s to the
nearest multiple of 5 and only retained the syscalls that had at least
10 calls.

BUG=None
TEST=Local build and deploy.  Verified that crostini VM still boots and
shuts down properly.  Used scmp_bpf_disasm to disassemble a few bpf
files before and after this change to confirm that with the frequency
file the first comparision is "jge 2" (to quickly whitelist syscalls
0 and 1 ['read' and 'write']) instead of a comparison around the middle
of the range of syscall numbers that are used.

Change-Id: Icace2b5cdbcae6e51cfd67a3034a1a17fdb6d59e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2005793
Commit-Queue: Matt Delco <delco@chromium.org>
Commit-Queue: Stephen Barber <smbarber@chromium.org>
Tested-by: Matt Delco <delco@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Matt Delco <delco@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2020-03-19 07:24:56 +00:00
Judy Hsiao
5934305f37 crosvm: Change expected field to String in InvalidValue
Change the type of argument::Error::InvalidValue::expected from "&'static str" to String.
It allows the lower level parse error object to handle the output of the expected value so that
the rule of parsing will not be duplicated.

For example, instead of:
```
v.parse::<Settings>()
  .map_err(|e| argument::Error::InvalidValue {
             value: v.to_string(),
	     expected: "The value of setting should null or cras",
  })?;

```
we can have:
```
v.parse::<Settings>()
  .map_err(|e| argument::Error::InvalidValue {
	   value: v.to_string(),
           expected: e.to_string(),
	   })?;
```
and the expected value can be handled in the Display implementaion of
Settings::ParseError.

BUG=b:140866281
TEST=cargo build

Change-Id: Ieba12a21103945fe0e47c70a190a4e5d985af537
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2103605
Tested-by: Judy Hsiao <judyhsiao@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Auto-Submit: Judy Hsiao <judyhsiao@chromium.org>
Commit-Queue: Judy Hsiao <judyhsiao@chromium.org>
2020-03-17 03:02:42 +00:00
Dylan Reid
8476d79a3c Fix warnings added in rust 1.42
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>
2020-03-17 00:05:44 +00:00
Chirantan Ekbote
752f9c2870 devices: Ignore O_DIRECT in 9p and fs devices
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>
2020-03-16 15:12:52 +00:00
Jorge E. Moreira
cba39f2fef Allow all serial port types to read from stdin
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>
2020-03-11 20:52:10 +00:00
Stephen Barber
d9082cff49 README: add instructions for building on Linux + CrOS
We have instructions for building with Docker, but it's now possible to build
for normal Linux distros too. Also add a pointer to the main CrOS developer
guide.

BUG=none
TEST=follow the instructions

Change-Id: Ic7ce498268f8057fbe90a88166017f54108d0e16
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2057747
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Stephen Barber <smbarber@chromium.org>
2020-03-11 01:09:04 +00:00
Daniel Verkamp
63c239496d Fix into_iter() usage where iter() suffices
Fixes warnings of the form:

warning: this method call currently resolves to `<&[T; N] as
IntoIterator>::into_iter` (due to autoref coercions), but that might
change in the future when `IntoIterator` impls for arrays are added.

BUG=None
TEST=emerge-nami crosvm

Change-Id: I2b46b55f0e967d985d04678c240604b542e27e07
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2093287
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2020-03-10 17:30:25 +00:00
David Stevens
a0fea29e0b gpu_renderer: add virglrenderer logging callback
BUG=None
TEST=boot ARCVM

Change-Id: Iea6c5ecc2475ec6f78df100b5df62622c41bd88a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2090956
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2020-03-10 07:28:03 +00:00
Chirantan Ekbote
265967bcda descriptor_utils: Add iter method
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>
2020-03-10 03:35:05 +00:00
Xiong Zhang
8bb4faa662 Vfio: Multi vfio device support
Current one vm could have one vfio device only, this patch let one vm
could have multi vfio devices by changing the vfio parameter into vec<>.

BUG=chromium:992270
TEST=passthrough two/three devices into guest, these devices are in the
same vfio group, then check these devices function in guest.

Change-Id: I366d24d750a199d7862fb907fa44f9be429c5944
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2080111
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
2020-03-09 21:48:54 +00:00
Daniel Verkamp
4b62cd9498 crosvm: remove deprecated --qcow and --rwqcow options
These have been marked as deprecated for several release; use --disk or
--rwdisk instead.

BUG=None
TEST=./build_test.py

Change-Id: I8a52c9abaf3f41e2dfc4189dd19c7d828802772e
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1906992
Reviewed-by: Zach Reizner <zachr@chromium.org>
2020-03-09 17:58:33 +00:00
Keiichi Watanabe
9515b05c08 devices: virtio: resource_bridge: Transfer plane metadata
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>
2020-03-06 13:27:50 +00:00
Mattias Nissler
3f3c0a3f6a ac97: Mark pci::ac97_bus_master::test::start_playback ignored
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>
2020-03-06 10:58:08 +00:00
Xiong Zhang
aee33b5862 virtio: Add VIRTIO_RING_F_EVENT_IDX test case
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>
2020-03-06 07:28:23 +00:00