Commit graph

1068 commits

Author SHA1 Message Date
Jianxun Zhang
a462f74b26 docker: fix a failure when building crosvm
What fixed by this change failed crosvm build with docker on
non-Nvidia platforms.

BUG=None
TEST=./build_crosvm_base.sh
./build_crosvm.sh
./wrapped_smoke_test.sh

Change-Id: Ib2cc70d5bd98bcad25410ba54c0492491a3ea799
Signed-off-by: Jianxun Zhang <jianxun.zhang@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1842519
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2019-10-10 18:33:47 +00:00
Jianxun Zhang
34533fe3ee docker: fix minigbm failure when building base image
Running ./build_crosvm_base.sh failed with the below error:

...
/scratch/minigbm/helpers.c: In function 'layout_from_format':
/scratch/minigbm/helpers.c:156:7: error: \
'DRM_FORMAT_ABGR16161616F' undeclared (first use in this function)
  case DRM_FORMAT_ABGR16161616F:
...

The header file in the libdrm-dev package from debian distro hasn't
included the missed macro. This change builds libdrm from the
upstream source to fix the issue.

BUG=None
TEST=./build_crosvm_base.sh
echo $?

Change-Id: Ifaae4313781ea02ebac9658ab8be9d990a3d5d25
Signed-off-by: Jianxun Zhang <jianxun.zhang@intel.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1841890
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2019-10-10 18:33:45 +00:00
Zach Reizner
a8adff0ff1 devices: jail serial device
This change plumbs the jail throughout the arch specific device creation
process. It also adds a custom callback support for the ProxyDevice so
that the main process can interrupt the child serial process when it has
incoming bytes.

TEST=crosvm run
BUG=None

Change-Id: I6af7d2cb0acbba9bf42eaeeb294cee2bce4a1f36
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1752589
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
2019-10-10 02:09:13 +00:00
paulhsia
0b6f02fea7 device: ac97: Cleanup interrupt logic
- Send only one event while re-sampling.
- Don't sent event if the new sr is identical to the old one

This can reduce the rate to trigger the issue.

BUG=chromium:937977
TEST=Build and run lots of aplay and arecord in guest vm

Change-Id: Ibd21f363076c977ae256079e2615094b7ed2408b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1840752
Tested-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2019-10-08 11:53:24 +00:00
Stephen Barber
7595d80248 devices: virtio_net: handle errors in tapfd poll adding/removal
Add error handling for adding/removing the tapfd to epoll.

We only remove the tap fd from the poll context if the tap is
readable, i.e. it would busy loop, so don't assume it's removed
from the poll context when there's a deferred rx frame.

BUG=chromium:1010742
TEST=arcvm network works

Change-Id: I84aab2dbe7ea31d724f04d3b3fb0a6916f232300
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1842399
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Stephen Barber <smbarber@chromium.org>
2019-10-08 08:55:59 +00:00
Daniel Verkamp
04e9c03f03 devices: ac97: fix interrupt triggering logic
Do not write to the irq_evt eventfd when interrupt_high is false; the
value written to the eventfd is ignored, so despite the '0' in the call,
this would re-trigger the interrupt even when it should not have been
asserted.  Since ac97 is a PCI device, its interrupt is level triggered,
and re-asserting it on EOI is handled by the irq_resample_thread code.

BUG=None
TEST=`aplay /dev/urandom` from Crostini on nami

Change-Id: I6ad8e40b818e0495ad58b6902d88dd61103aed9d
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1838762
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-10-08 01:57:20 +00:00
Chirantan Ekbote
bf67203f97 sys_util: Add ReadWriteAtVolatile trait and *vectored functions
Add the FileReadWriteAtVolatile trait, which is basically the same as
the FileReadWriteVolatile trait but additionally takes an offest.  This
is only useful for types that are seekable and can allow concurrent
operations on the same underlying type.

Also add `*_vectored` versions of all the functions.  These match the
`*_vectored` functions in the standard library and can reduce the number
of system calls needed to read or write a whole buffer.

Implement both traits for `&mut T` if `T` implements them.

Change the trait implementation for `File` to a macro so that we can
also implement it for `GuestMemory`.

BUG=b:136128319
TEST=unit tests

Change-Id: I3d8eb7bba17fe3247e18649b1b04e21a91a841e2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1724229
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>
2019-10-07 19:00:34 +00:00
Chirantan Ekbote
41e61d1fc3 virtio: queue: Enforce DescriptorChain ordering
The virtio spec requires that all read-only descriptors appear in the
chain before any write-only descriptors.  Enforce this in the
`checked_new` function by adding a new `required_flags` parameter.  The
`next_descriptor` function will set this to `VIRTQ_DESC_F_WRITE` if the
current descriptor is write-only.  This ensures that once we see a
write-only descriptor, all following descriptors must be write-only.

BUG=b:136127316
TEST=none

Change-Id: Id8f942a4236a20f62f35439f3648dbec17e14c00
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1757239
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2019-10-06 05:35:47 +00:00
Stephen Barber
28a9d2b70d devices: virtio_net: avoid busylooping when no rx buffers available
If the guest is unable to return rx queue buffers to the device, we should
temporarily stop polling for reads on the tap fd. Otherwise, we'll spin and
burn CPU needlessly.

BUG=chromium:1010742
TEST=repro from b/141940546

Change-Id: Iac004e870779a8dd39004f44b44e17a2b45bcfa1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1836914
Tested-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Stephen Barber <smbarber@chromium.org>
2019-10-03 19:44:37 +00:00
Fletcher Woodruff
82ff397489 sys_util: allow adding handlers for all signals
Currently, sys_util's register_signal_handler only permits handlers for
real-time signals. Rename that function to register_rt_signal_handler
and add a new register_signal_handler that supports all signals, then
update references to the old name.

BUG=chromium:1008990
TEST=builds

Change-Id: I455e14c562cd1f2ca4b308b4e38c503845321926
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1836185
Tested-by: Fletcher Woodruff <fletcherw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Fletcher Woodruff <fletcherw@chromium.org>
2019-10-03 06:57:34 +00:00
Cody Schuffelen
f9b035d50c Support composite disks.
This adds a new disk file type next to raw files and qcow images that
represent an indirection to further raw disk files. The disk file
itself is a proto file with references to file paths for other disks to
open and their virtual offsets and lengths.

The intention is to make it easy to assemble a single virtual hard disk
out of several distinct partition files. In the particular case of
Cuttlefish running Android in a VM, this is relevant as the Android
build system distributes partitions as separate raw files. While the
simple solution is to pass each partition as a separate raw disk, some
functionality (like the bootloader) assumes there is a partition table
with multiple distinct partitions on a single disk.

Implementing composite disk support in the VMM bridges this gap through
supporting the general-purpose case of a disk built out of multiple
component files.

If desired, this can be extended to support qcow files to support
unusual configurations like a mixed qcow/raw disk.

Enabled with the "composite-disk" feature.

Bug: b/133432409
Change-Id: I2b0c47d92fab13b5dc0ca5a960c7cfd2b7145b87
Signed-off-by: Cody Schuffelen <schuffelen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1667767
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-10-03 00:59:14 +00:00
Daniel Verkamp
b5237bbcf0 devices: virtio: pmem: use descriptor reader/writer
Convert the virtio pmem device to use the descriptor_utils Reader/Writer
helpers to simplify the code and allow support of arbitrary descriptor
layouts.

BUG=chromium:966258
TEST=./build_test.py

Change-Id: I9ccbdf2833980e4c44e19975f9091f9aea56c94b
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1811713
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-10-01 22:48:41 +00:00
Daniel Verkamp
42cd8b1472 devices: virtio: input: use descriptor reader/writer
Convert the virtio input device to use the descriptor_utils
Reader/Writer helpers to simplify the code and allow support of
arbitrary descriptor layouts.

BUG=chromium:966258
TEST=./build_test.py

Change-Id: Ia9272496dc59b29ea9cde9f6454099c881242d4c
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1811712
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-10-01 22:48:40 +00:00
Jakub Staron
d9c4398a31 crosvm: Use Reader/Writer interfaces in various virtio devices.
Switching the devices to the new interface reduces code duplication and
will ease fuzzing the devices as they now have a common input and output
interface for descriptors.

BUG=chromium:966258
TEST=vm.CrostiniStartEverything

Change-Id: I823c04dfc24e017433f8e8ab167bbd5dfafd338b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1647371
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2019-10-01 22:48:38 +00:00
Gurchetan Singh
719f2831ed virtio-gpu: handle VIRTIO_GPU_CMD_RESOURCE_CREATE_V2
BUG=chromium:924405
TEST=compile

Change-Id: I57379452f6805aaf429c268b95ddd3aecd07e90e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1591463
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2019-10-01 07:53:34 +00:00
Gurchetan Singh
5b636babc1 virtio-gpu: handle VIRTIO_GPU_CMD_ALLOCATION_METADATA
Designed to return metadata to the guest.

BUG=chromium:924405
TEST=compile

Change-Id: Ic04a0bbb6b0a5bb6d08314371181f256eb7230df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1591464
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2019-10-01 07:53:33 +00:00
Gurchetan Singh
144c279d28 crosvm: add 'virtio-gpu-next' feature flag
With this, crosvm builds that don't have the CrOS version of
virglrenderer can build against master without adjustments.

BUG=chromium:924405
TEST=compile

Change-Id: Iee27c003bee1eb8947cb048dc16e2da6c68af11e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1797067
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-10-01 07:53:33 +00:00
Gurchetan Singh
7ca5e3dba3 vm_control: support registering memory at a specific address
The guest kernel will allocate from PCI range of the virtgpu
device, and send physical addresses via a hypercall.

Right now, only support buffers that can be mmap'ed.  We could
add optimizations for GBM buffers later if needed.

BUG=chromium:924405
TEST=compile

Change-Id: I094de96a2c35bcd2e18c8a6a2d8cdc39bb392e36
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1626794
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-10-01 07:53:32 +00:00
Gurchetan Singh
f585543065 gpu_renderer: update bindings
Use virglrenderer to get the metadata associated with a buffer.
We must do this before we allocate the guest kernel pages, so
they agree with host requirements. This implements the rough API
outlined here:

https://gitlab.freedesktop.org/virgl/virglrenderer/issues/119

Probably we want this in virv-renderer eventually, but that may take
some time, so for prototyping just use non-upstreamed virglrenderer
functions.

BUG=chromium:924405
TEST=compile

Change-Id: If78f274c813c2131b297144172019848806e3a0e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1790831
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2019-10-01 07:53:30 +00:00
Xiong Zhang
c554fff206 vfio: Setup dma map for vfio device
For each guest memory region, setup the corresponding gpa to hva map
in the kernel vfio iommu table. Then the kernel vfio driver could
get the hpa through gpa. Device could use this gpa for dma also.

BUG=chromium:992270
TEST=none

Change-Id: I04008d68ab2ed182a789d6ee8c97a0ed9e1e4756
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581141
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2019-10-01 03:59:49 +00:00
Xiong Zhang
17b0daf88c vfio: Integrate VFIO device into pci device model
Create VFIO device and VFIO PCI device in create_devices() function, and
intergrate it into PciRootBridge, so guest could see this vfio device.

Add a vfio config parameter, this config point to passthrough or mdev
device sysfs path.

For passthrough case, first user unbind host device from its driver,
then bind host device to vfio-pci. Like:
echo 0000:00:02.0 > /sys/bus/pci/devices/0000:00:02.0/driver/unbind
ech0 8086 1912 > /sys/bus/pci/drivers/vfio-pci/new_id
Finally pass the sysfs to crosvm through
--vfio=/sys/bus/pci/devices/0000:00:02.0

For mdev case, user create a mdev device through
echo $UUID > mdev_type/create, then pass this mdev device to crosvm like
--vfio=/sys/bus/pci/devices/0000:00:02.0/$UUID

BUG=chromium:992270
TEST=none

Change-Id: I0f59d6e93f62f9ab0727ad3a867d204f4ff6ad2d
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581140
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2019-10-01 03:59:47 +00:00
Daniel Verkamp
71a6f0a790 sys_util: add write_zeroes_all() function
In the same spirit as write_all() for the standard io::Write::write()
function, add a write_zeroes_all() function with a default
implementation that calls write_zeroes() in a loop until the requested
length is met.  This will allow write_zeroes implementations that don't
necessarily fulfill the entire requested length.

BUG=None
TEST=cargo test -p sys_util write_zeroes

Change-Id: I0fc3a4b3fe8904946e253ab8a2687555b12657be
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1811466
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-09-25 00:06:27 +00:00
Gurchetan Singh
b2d4e11579 devices: modify get_device_bars(..) interface
Alloc::PciBar {..} is used as a key in the AddressAllocator's
hashmap, so inform the device about the pci bus/dev numbers.

BUG=chromium:924405
TEST=compile

Change-Id: Ib9d94e516269c1dc9a375c2ceb9775cf5a421156
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1811585
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2019-09-20 16:55:31 +00:00
Gurchetan Singh
aa781bafdf virtio-gpu: Use new + proposed virtio-gpu features
BUG=chromium:924405
TEST=compile

Change-Id: If7f2d35f66664a1a4e9a6e0883ea981b0ac3e87c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1591462
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
2019-09-20 16:55:30 +00:00
Gurchetan Singh
45f86fd548 virtio-gpu: add new + proposed kernel protocols
BUG=chromium:924405
TEST=compile

Change-Id: I550d5e60e8bde1378c226fc9da61eb60f1293811
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1591461
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
2019-09-20 16:55:29 +00:00
Gurchetan Singh
b7da549c7b gpu_renderer: move capset3 out of VMM
In terms of layer and encapsulation, it's better that capset3 is
filled by the host rendering library.  With gbm inside virglrenderer
now, use that instead.

BUG=chromium:924405
TEST=compile

Change-Id: I7eb554074da98ab5d40aa53389124b3fd749474d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1790830
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2019-09-20 16:55:27 +00:00
Xiong Zhang
9628f61e71 vfio: Implement PciDevice Trait for vfio device
According to kernel Documents/vfio.txt and
Documents/vfio-mediated-device.txt,user pass host assigned
device or mdev to crosvm through --vfio parameter, vfio module
open this device and get this device's information.

Implement PciDevice trait on this device, then vfio_pci
module could trap guest pci cfg r/w and mmio r/w,
and transfer this operation into kernel vfio.

Currently the relationship of vfio container:group:device are
1:1:1, in the future it could extend to 1Ⓜ️n.

BUG=chromium:992270
TEST=none

Change-Id: I8006ef65022d56197eaeb464811a59db2ce54b9a
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1580458
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2019-09-18 17:23:59 +00:00
David Riley
36cc5092fc gpu: Fix sandboxing support for ARM.
Two compounded issues broke GPU support on ARM:
1) A mistake when applying code review comments to the initial checkin
of this file and not correctly copying the updated policy when testing
to the DUT.
2) Iteration of the /dev/dri directory from libvirglrender.so uses
getdents instead of getdents64, likely due to some differences in the C
vs Rust runtime.

BUG=chromium:1002667
TEST=glxgears with virtio-gpu on kevin

Change-Id: I225b85998a6a611ebe2a25a75cd88aab9939feb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1799287
Tested-by: David Riley <davidriley@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-09-17 23:24:55 +00:00
David Riley
bca67ae7e3 devices: gpu: Use descriptor_utils helpers for virtio processing.
Switch to using Reader/Writer which allows buffers to be passed from
the guest as scatter gathers instead of requiring a single contiguous
buffer.

BUG=chromium:993452
TEST=apitrace replay

Change-Id: Ibe212cfa60eae16d70db248a2a619d272c13f540
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1775365
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: David Riley <davidriley@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Riley <davidriley@chromium.org>
2019-09-17 22:35:33 +00:00
David Riley
e5e30a705a virtio: Make Reader interface cloneable.
BUG=chromium:993452
TEST=apitrace replay

Change-Id: If7dc8ef93d9e6b9783f2f8f124fcee5e016b3eb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1775364
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: David Riley <davidriley@chromium.org>
Commit-Queue: David Riley <davidriley@chromium.org>
2019-09-17 22:35:32 +00:00
Daniel Verkamp
9dd75d0d3e devices: join worker threads in drop()
Make sure all devices join any threads they spawn before returning from
the drop() handler after signaling the exit event.

BUG=chromium:992494
TEST=crosvm exits without errors

Change-Id: I6bc91c32a08f568b041765044caa9aff6f7cf4a9
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1802156
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-09-17 22:32:22 +00:00
Daniel Verkamp
94c352752e linux: drop VM before exiting to allow cleanup
Clean up the `linux` object (which contains the devices) before the
control sockets passed to `run_control` are closed.  This allows crosvm
to shut down cleanly without any error messages about short reads from
the control sockets.

BUG=chromium:992494
TEST=exit crosvm without errors

Change-Id: I1040c2f9ecbd03f820c7082da3327962ecc445f1
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1802155
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-09-17 22:32:21 +00:00
Fletcher Woodruff
039b6727ba sync: add wait_timeout method to condvar wrapper
Adds a method wait_timeout to sync::Condvar which wraps
std::sync::Condvar's wait_timeout.

BUG=None
TEST=cargo test

Change-Id: I9888568b8bac779006080b505762016b6ca381e6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1789913
Tested-by: Fletcher Woodruff <fletcherw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Fletcher Woodruff <fletcherw@chromium.org>
2019-09-16 17:18:28 +00:00
Zach Reizner
506105dc0d use SharedMemory::{named, anon} to replace ::new
The new constructors are shorter and omit the bare `None` in the `anon`
call sites which gave no clues to the reader what the effect of that
`None` was. This should improve readability.

TEST=./build_test
BUG=None

Change-Id: I2e34e7df9a4ccc5da50edf4e963a6a42e3d84b22
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1797188
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-09-11 09:34:12 +00:00
Zach Reizner
532533dd39 sys_util: shm: make using names with shared memory more convenient
This change adds a string based constructor of `SharedMemory` as well as
adding a method for retrieving that name from the underlying file. This
change also includes a new anonymous constructor.

TEST=cargo test -p sys_util
BUG=None

Change-Id: Ibd7a28851c8a0f41e595ee35b35f0d06fef1e1d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1797187
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-09-11 09:34:10 +00:00
Daniel Verkamp
0b86007d3e Add usb_sys wrapper for usbfs
This wraps the Linux USBDEVFS ioctl interfaces.

BUG=chromium:987833
TEST=./build_test.py

Change-Id: Id855c66c4eb2ac01bb65073b5dd339c1c3d45c38
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1783600
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-09-09 18:20:41 +00:00
Daniel Verkamp
13eea9f028 usb: clarify transfer cancellation API
Rather than having a get_canceller() function on UsbTransfer, make the
submit function return the canceller.  This makes it clear that the
transfer can't be cancelled before it is submitted.

BUG=None
TEST=None

Change-Id: Ice36c3096a1f8a5aafe93b5d5e27eb371183c19f
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1783599
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-09-09 18:20:40 +00:00
Daniel Verkamp
f5a52516b1 fuzz: fix block fuzzer build after block API change
Block::new() now takes a Box of the underlying file; update the block
fuzzer accordingly.

BUG=chromium:1000065
TEST=`USE='asan fuzzer' emerge-nami crosvm`

Change-Id: Ib636e13da5dcd347dd33c40a11508e016ea73b70
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1780336
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-09-03 21:08:38 +00:00
Cody Schuffelen
30c5a9ef0b Replace "AsRawFd" with "AsRawFds" for disks.
This supports virtio disks that depend on multiple file descriptors. All
of the file descriptors are passed to the jail when relevant.

Bug: b/133432409
Change-Id: Idf2e24cd2984c0d12a47a523c13d24c1ba8d173e
Signed-off-by: Cody Schuffelen <schuffelen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1691761
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-08-30 16:08:58 +00:00
Cody Schuffelen
7d533e5952 Extract disk creation logic out of qcow and src.
Bug: b/133432409
Change-Id: Iba25d5f6bb5f60619bb2f5a3d72ddfd3a81650b4
Signed-off-by: Cody Schuffelen <schuffelen@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1691460
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-08-28 23:52:36 +00:00
Zach Reizner
971589f7ec docker: make using X11 gpu display easier with docker
This change makes using docker a bit easier when displaying on the hosts
X11 server. The biggest change was that build_crosvm.sh will install the
hosts NVIDIA proprietary driver if needed.

TEST=docker/build_crosvm.sh
     docker/crosvm_wrapper.sh
BUG=None

Change-Id: If64074715b0ad3a06727a4cc764d3ac06c4dfece
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1759139
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Zach Reizner <zachr@chromium.org>
2019-08-28 22:59:34 +00:00
Lepton Wu
373673c43a seccomp: add clock_gettime gettid to gpu policy.
Some code path of mesa requires clock_gettime:
08f1cefecd/src/egl/drivers/dri2/egl_dri2.c (L3189)

Also cxa_guard in llvm begin to call gettid from this CL:

https://llvm.googlesource.com/libcxxabi/+/57e82af58dd4515ab4885f32273268f34f757101

BUG=b:140078110
BUG=b:139318078
TEST=manual - boot arcvm

Change-Id: I258ae5b8d6f38886406acac6a0ac8ca8886a64af
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1773506
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Lepton Wu <lepton@chromium.org>
2019-08-28 01:11:09 +00:00
Daniel Verkamp
a445ae1fbe Remove remaining byteorder crate references
Remove the last (unused) reference to byteorder in vm_control/Cargo.toml
and remove it from the list of external crates in README.md.

BUG=None
TEST=./build_test

Change-Id: Ie70c0bc2f96c19b34ef1596885245eca7bc202f4
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1761156
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-08-26 23:41:54 +00:00
Daniel Verkamp
034f7a3a1c devices: pci: replace byteorder with from_le_bytes()
Use the standardized from_le_bytes() functions rather than the byteorder
crate.

BUG=None
TEST=./build_test

Change-Id: I07a062bf63c5d3ae1e25f403713bf9a1677e8cba
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1761155
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-08-26 23:41:53 +00:00
Daniel Verkamp
e7e7e51fb0 devices: virtio: replace byteorder with {to,from}_le_bytes()
Use the stabilized standard to_le_bytes() and from_le_bytes() functions
rather than the byteorder crate.

BUG=None
TEST=./build_test
TEST=cargo test -p devices virtio_pci_common_config

Change-Id: I4106a41484760b9e7e586de07135874238bcadb0
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1761154
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-08-26 23:41:52 +00:00
Daniel Verkamp
c2444305a9 devices: vsock: replace byteorder with from_le_bytes()
BUG=None
TEST=cargo test -p devices vsock

Change-Id: I9da35f894898198413737f9caa29a7f772e4f720
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1761153
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-08-26 23:41:52 +00:00
Daniel Verkamp
d1245509b2 x86_64: replace byteorder with {to,from}_le_bytes()
BUG=None
TEST=./build_test

Change-Id: Ic7873c6b70d9a0e9f34b7a2977845552144934ea
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1761152
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-08-26 23:41:51 +00:00
Daniel Verkamp
f8fc71a760 qcow: replace byteorder with {to,from}_be_bytes()
Use the standard byte order conversion functions rather than the
byteorder crate.

BUG=None
TEST=./build_test
TEST=cargo build -p qcow_utils
TEST=cargo test -p qcow

Change-Id: I9ff7368cc54c539db1996f81d4220cabf7e6e301
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1761151
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-08-26 23:41:50 +00:00
Daniel Verkamp
09430fe59e arch: fdt: replace byteorder with to_be_bytes()
Use the standard library u32 and u64 byteorder conversion functions (now
that they are stabilized) rather than the byteorder crate.

BUG=None
TEST=./build_test

Change-Id: I7d2b523c2df5f7cdf1cd7d5b760ede8e827e0517
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1761150
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-08-26 23:41:49 +00:00
Daniel Verkamp
afef8d7baf usb: clean up clippy unit_arg warning
Fix the last instance of this clippy warning:

  warning: passing a unit value to a function

... and remove this warning from the "To be resolved" list in
bin/clippy.

BUG=None
TEST=bin/clippy passes without warnings

Change-Id: Ic1d558e935366d80eeadb96bf1ff951ce50edd5b
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1766623
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-08-26 19:34:39 +00:00