Commit graph

1193 commits

Author SHA1 Message Date
Jakub Staron
cc91fc8252 devices: Add separate seccomp policy for pmem device
This change adds separate seccomp policy for pmem device. Previously,
pmem device was using block device seccomp policy.

BUG=None
TEST=Boot VM and run xfstests on pmem device

Change-Id: I3f25d64d4da6ad8f0ff22b285e1a7e958f545c55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1652441
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jakub Staroń <jstaron@google.com>
2019-06-21 21:47:58 +00:00
Dylan Reid
b38bde9bd1 fuzz: Comply with new guest memory requirement for page alignment
When the input's length is not page aligned, round it up. This allows
the fuzzer to provide more random inputs without causing the `unwrap`
call to trigger false positives when creating guest memory.

BUG=chromium:972172
TEST=run fuzz case from the bug

Change-Id: Iaf8f2ba943f38b90e168301dbb8c15dee5ee45c8
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1659626
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-21 21:12:39 +00:00
Jakub Staron
d0bf5dc602 crosvm: Implement Reader/Writer interface over DescriptorChain.
This change adds a convinient interface over DescriptorChain. It hides
the complexity of DescriptorChain and allows to treat it as a pair
of read-only and write-only buffers. In the future, it will also allow
to easily support indirect descriptors.

BUG=chromium:966258
TEST=cargo test --package devices descriptor_utils
TEST=run crosvm without sandbox, share a directory, compare
checksum of shared file between host and guest

Change-Id: I9fb722ee2024c8d7d40f560571ec7d7c454bfc2b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1647370
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jakub Staroń <jstaron@google.com>
2019-06-21 20:27:08 +00:00
Dylan Reid
70d7bad284 qcow: disallow crazy l1 table sizes
Before this change, a corrupt or malicious qcow file could cause crosvm
to allocate absurd amounts of memory. The fuzzer found this case,
limit the L1 table size so it can't cause issues.

BUG=chromium:974123
TEST=run fuzzer locally, add unit test

Change-Id: Ieb6db6c87f71df726b3cc9a98404581fe32fb1ce
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1660890
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-21 19:22:33 +00:00
Dylan Reid
c9f254b192 qcow: Fix invalid_cluster_bits test
Start with a valid header so the invalid cluster bits field is tested in
isolation. Before this change the test would pass even if the cluster
bits check was removed from the code because the header was invalid for
other reasons.

BUG=none
TEST=this is a test

Change-Id: I5c09417ae3f974522652a50cb0fdc5dc0e10dd44
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1660889
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-21 19:22:31 +00:00
Jorge E. Moreira
0dfe1be88a crosvm: Ensure slices are the same size when copying.
Bug=b/135190799
TEST=run cuttlefish in debian host

Change-Id: I7f9343dd202da2a163b3e8aeb8fbde5eb4cfb1d3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1659144
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2019-06-21 19:12:40 +00:00
Daniel Verkamp
c62f41681c usb: update USBDEVFS_CONNINFO_EX value to new size
The layout of struct usbfs_conninfo_ex was changed in the final revision
of the patch, so the corresponding ioctl number needs to change to
match, since the parameter size is encoded in the ioctl.

The new size is 0x18 or 24, which matches the struct usbfs_conninfo_ex
layout with 7 ports.

BUG=chromium:977020
TEST=Attach Android device to Linux VM on nami

Change-Id: Iec60b4c04880d7d2c71fdea49cfdf7fb5a75f5c6
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1669530
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2019-06-21 09:13:29 +00:00
Trent Begin
923bab011f crosvm: default serial parameter num field to 1 if not provided
If multiple serial parameters do not have `num` fields, or a different
parameter has already defined serial num 1, then crosvm will show an
error.

BUG=chromium:974885
TEST=cargo test; emerge-sarien crosvm && cros deploy dut crosvm;
Manual testing with and without num field in --serial parameter

Change-Id: Ia80247e8d055179adfd9e7471a98e8a2923cf1f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1662773
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Trent Begin <tbegin@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Trent Begin <tbegin@chromium.org>
2019-06-20 18:08:25 +00:00
Dmitry Torokhov
bb340d9a94 usb: update xhci policies to allow newer libusb
The updated version of libusb uses USBFS_CONNECTINFO and
USBFS_CONNINFO_EX ioctls, as well as readlink and lseek syscalls,
so let's enable them.

BUG=b:133773289
TEST=Try attaching a USB device to Crostini VM.

Change-Id: Ibdcab2da9abe1c0bb35c989d9d62b44ce403e268
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1650534
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dmitry Torokhov <dtor@chromium.org>
2019-06-13 15:23:44 +00:00
Dylan Reid
a094f91d2c qcow: Limit file setups that consume excessive RAM
qcow currently makes assumptions about being able to fit the L1 and
refcount tables in memory. This isn't necessarily true for very large
files. The new limits to the size of in-memory buffers still allow 1TB
files with default cluster sizes. Because there aren't any 1 TB
chromebooks available yet, limit disks to that size.

This works around issues found by clusterfuzz related to large files
built with small clusters.

BUG=972165,972175,972160,972172
TEST=fuzzer locally + new unit tests

Change-Id: I15d5d8e3e61213780ff6aea5759b155c63d49ea3
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1651460
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-12 01:31:54 +00:00
Dylan Reid
21c941786e qcow: Calculate the max refcounts as a u64
u32's get multiplied together and can overflow. A usize was being
returned, make everything a u64 to make sure it fits.

Change-Id: I87071d294f4e62247c9ae72244db059a7b528b62
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1651459
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-12 01:31:46 +00:00
Dylan Reid
cae80e321a qcow: better limits on cluster size
Add a lower limit because cases such as eight byte clusters aren't
practical and aren't worth handling, tracking a cluster costs 16 bytes.

Also put an upper limit on the cluster size, choose 21 bits to match
qemu.

Change-Id: Ifcab081d0e630b5d26b0eafa552bd7c695821686
Signed-off-by: Dylan Reid <dgreid@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1651458
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-12 01:31:44 +00:00
Xiong Zhang
44bb3dd909 src/linux.rs: Modify socket instead of add socket when remove other sockets
When an ill socket is detected, it will be removed from poll_context and
control_sockets, then the remaining good sockets should change their indices,
So modify should be used instead of add, as all of them have been added
into poll_context already, the add will return an error.

This change is merge of another change at
I977be57ea0898cc8226505f7d3da103a46ea626c that was identical to this one
except it contained the following similar commit message:

linux: when renumbering control sockets, use modify instead of add

In some circumstances, a VM control socket will get removed from the
list of control sockets in the run_control loop. Usually, the last
control socket in the list gets removed, but if that is not the case,
the control sockets will get reordered to fill in the gap in the list.
The `add` method of `PollContext` was used to change the token used for
a given control socket, when `modify` should have been used instead.
The problem with using `add` when a control socket is already part of a
`PollContext` is that it will return an error and terminate crosvm. This
CL fixes that issue.

BUG=none
TEST="crosvm run --vfio=$GVT_UUID", then run many gpu workloads in guest
TEST=crosvm run --gpu

Change-Id: Ic00a781d8839e652e2a8fd54ccd8e55849fa20bb
Signed-off-by: Xiong Zhang <xiong.y.zhang@intel.corp-partner.google.com>
Signed-off-by: Zach Reizner <zachr@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1581151
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Zach Reizner <zachr@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-06-10 17:09:03 +00:00
Jakub Staron
b6515a9167 crosvm: fix clippy warnings
Resolve a couple of minor clippy warnings:
 - unneeded return statement
 - use `if let` instead of `match` for single pattern destruction
 - use `values()` function to iterate over map values
 - supress warning about `ptr::null()` as expressed by the comment

BUG=None
TEST=./bin/clippy
TEST=cargo build

Change-Id: Ic4cea94cd3a25a9edf6ef38119de8c46dcfec563
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1646739
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Commit-Queue: Jakub Staroń <jstaron@google.com>
2019-06-08 04:27:37 +00:00
Jakub Staron
d879219ac0 serial: fix clippy warnings
Resolve couple of minor clippy warnings:
 - unneeded return statement in last expression of the function
 - redundant closure

BUG=None
TEST=./bin/clippy
TEST=cargo build

Change-Id: I602e56289315cb88779c0029d400b24a8180b899
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1646738
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jakub Staroń <jstaron@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-06-08 04:27:37 +00:00
Jakub Staron
4197d3a3a1 crosvm: add license blurb to bin/clippy and bin/fmt files
bin/clippy and bin/fmt were missing license blurbs at the top,
so update them to include the license blurbs.

BUG=None
TEST=None

Change-Id: Ic6bb5af3885d3735dcad42614aff7ac3dd33d638
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1646736
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jakub Staroń <jstaron@google.com>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-06-08 04:27:35 +00:00
Daniel Verkamp
0e94e3c1ea fuzz: adapt zimage fuzzer to new kernel loader API
After CL:1636685, the kernel_loader API is different - we need to pass a
File instead of just a slice to load_kernel().

Borrow and adapt the make_elf_bin() function from the kernel_loader
tests to create a shared memory file from a slice of bytes to fix the
fuzzer.

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

Change-Id: Ic17f6479fb355d45063ce6292552cb1e5664831a
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1645039
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-06 16:38:24 +00:00
Daniel Verkamp
3bebfa29dc usb: reset backend device on port reset
This enables the full firmware update/reset/use device in application
mode sequence for Edge TPU USB Accelerator.

There is a bit of a UI hiccup: once the firmware update and reset is
complete, the device re-enumerates with a different VID/PID, and the
"Connect to Linux" prompt shows up again.  The user must re-affirm that
the device should be connected to Linux to proceed with using the Edge
TPU.  This may be unavoidable - I'm not sure if we can tell the
difference between a newly-inserted device and a reset one.

Allowing USBDEVFS_DISCONNECT_CLAIM should be safe, since it can only
operate on file descriptors passed into the xhci device jail.

BUG=chromium:831850
TEST=Run Edge TPU Accelerator demo and verify that it can update FW

Change-Id: I3d61c7bd914830ce25448b1ae4d60e1c16f10aed
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1599881
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-05 19:19:10 +00:00
Jakub Staron
a3411eaac1 crosvm: virtio-pmem device
Adds support for virtio-pmem device as an alternative for virtio-blk.

Exposing disk image to guest as virtio-blk device results in both guest
and host independently caching the disk I/O. Using virtio-pmem device
allows to mount disk image as direct access (DAX) in the guest and thus
bypass the guest cache. This will reduce memory foodprint of the VMs.

BUG=None
TEST=cargo test
TEST=Boot patched termina kernel in crosvm; mount virtio-pmem device as
DAX and run xfstests.

Change-Id: I935fc8fc7527f79e5169f07ec7927e4ea4fa6027
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1605517
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Jakub Staroń <jstaron@google.com>
2019-06-05 07:28:54 +00:00
Zach Reizner
127453d7ec eliminate mut from non-mut references
This manifested itself in a couple places that were turning shared
memory buffers into slices for the purposes of passing these slices to
`Read` and `Write` trait methods.

However, this required the removal of the methods that took `Read` and
`Write` instances. This was a convenient interface but impossible to
implement safely because making slices from raw pointers without
enforcing safety guarantees causes undefined behaviour in Rust. It turns
out lots of code in crosvm was using these interfaces indirectly, which
explains why this CL touches so much.

TEST=crosvm run
BUG=chromium:938767

Change-Id: I4ff40c98da6ed08a4a42f4c31f0717f81b1c5863
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1636685
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>
2019-06-04 20:29:25 +00:00
Zach Reizner
6a0bfb037a docker: add adhd to checkout_commits.env and update all commits
This change also includes some code that was missing from
upgrade_checkout_commits.sh that actually generated the new
checkout_commits.env.

BUG=None
TEST=kokoro/kokoro_simulator.sh
     docker/build_crosvm_base.sh
     docker/build_crosvm.sh

Change-Id: If2505dd9af060d15c36eaf54741d4ae371f6a3c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1641585
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-06-04 00:46:18 +00:00
Cody Schuffelen
6d1ab50943 Initial BIOS support.
The --bios argument is added as an alternative to the kernel positional
argument. The BIOS runs in unreal mode (16-bit cs selector set to the
end of 32-bit address space), which matches the default state KVM puts
the segment and data registers into.

Example usage:
Build u-boot with "make qemu-x86_defconfig && make"
Run crosvm with "crosvm_wrapper.sh run --bios=u-boot.rom"

This produces the following message:
"""
U-Boot 2019.01-00017-gdc76aabe6a-dirty (May 21 2019 - 12:17:02 -0700)

CPU:
DRAM:  16 MiB
unable to get online cpu number: -19
Warning: MP init failure
Model: QEMU x86 (I440FX)
Net:   No ethernet found.
error: can't find etc/table-loader
Hit any key to stop autoboot:  0
=>
"""

At this point the u-boot shell works with stdin/stdout, but virtual
disks passed with --rwdisk weren't immediately visible from running
"virtio scan" and "virtio info".

This change puts the bios loading together with the linux kernel loading
code since there is a lot of overlap in functionality.

Bug: b/133358982
Test: ./crosvm_wrapper.sh run --mem=4097 --bios=u-boot.rom
Change-Id: I65b0e1044233af662a642c592d35b106217f3c13
Reviewed-on: https://chromium-review.googlesource.com/1622648
Commit-Ready: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-05-31 17:21:46 -07:00
paulhsia
580d418656 linux: Add cras-capture option for cras-audio device
The flag can enable capturing audio from CRAS server to the cras-audio
device.
We'll re-enable capture function on Crostini after finishing capture
permission works.

BUG=chromium:932268
TEST=Boot vm with crosvm --cras-audio --cras-capture to check recording
     functionality.

Cq-Depend: chromium:1628633
Change-Id: I7502cbd668cbc722224164d9f69e50a16b0ab86b
Reviewed-on: https://chromium-review.googlesource.com/1628687
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2019-05-31 02:56:41 -07:00
Daniel Verkamp
d7738ec486 enumn: fix duplicate fn in doc tests
Two parts of the documentation mention the generated `fn n`, which (as
of Rust 1.35) causes a doc test failure.  Change these code blocks to be
ignored instead of executed to avoid the problem.

BUG=None
TEST=cargo test --doc -p enumn

Change-Id: I9d08d2a35d65930bd2fa899256c00e1da643ba4f
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1632035
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-05-30 01:11:16 +00:00
Daniel Verkamp
99c65d41f8 rust-toolchain: upgrade to Rust 1.35.0
BUG=None
TEST=docker/wrapped_smoke_test.sh

Change-Id: I0a159d9b54d97098d633ce80b92eeb48eb5c4b55
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/1632036
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2019-05-30 01:11:13 +00:00
Dmitry Torokhov
ee42b8cab0 crosvm: fix unused variable warning in create_virtio_devices
The gpu_device_socket is not used when GPU support is disabled.

BUG=chromium:967436
TEST=cargo build --no-default-features

Change-Id: I5c0ef0ecf27349bcfbc19474879a282c9f6fb8ef
Reviewed-on: https://chromium-review.googlesource.com/1631292
Commit-Ready: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Dmitry Torokhov <dtor@chromium.org>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2019-05-29 06:27:40 -07:00
Daniel Verkamp
ca39ac0a95 devices: block: issue fsync when FlushTimer expires
The RequestType::Flush handler correctly uses fsync(), which issues an
fsync to the underlying disk image file.  However, the flush timer
(started on write and cancelled if a flush request is executed) was only
calling flush(), which is insufficient when the disk image is a raw file
- it just flushes in-memory buffers and does not issue an fsync.

BUG=None
TEST=Issue writes in crosvm; verify fsync in strace output

Change-Id: I1de8a35615031b5fdf5599dd6b49015d0b245c31
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1632876
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-05-29 06:27:33 -07:00
Gurchetan Singh
7ec58fafba virtio-gpu: add gpu control socket
The GPU process will need access to KVM.

BUG=chromium:924405
TEST=compile

Change-Id: I9e454d79a36a40a20c6c4b3a62ea367f339e526b
Reviewed-on: https://chromium-review.googlesource.com/1626793
Commit-Ready: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
2019-05-28 21:11:21 -07:00
Jingkui Wang
6c1e23eee3 crosvm: update xhci abi to use new bit_field features
We don't need schema anymore. Will use bool and custom enums.

BUG=None
TEST=local build and run crosvm

Change-Id: I1396916878f2903b17a75f375aee4eec1ced0583
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1564780
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-05-25 02:31:16 -07:00
Dylan Reid
a27f3a74d3 Add an OWNERS file
Per new cros policy.

Signed-off-by: Dylan Reid <dgreid@chromium.org>
Change-Id: I57c6b4bb5465c5fcdd9477c23547a835c0cfaf33
Reviewed-on: https://chromium-review.googlesource.com/1627218
Commit-Ready: Chris McDonald <cjmcdonald@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-05-25 02:31:07 -07:00
Jakub Staron
0854c168df devices: input: Removes used_desc_heads array.
Removes last usage of used_desc_heads/used_count pattern from crosvm.

BUG=None
TEST=cargo check

Change-Id: Ib80a22538f5d1e1c1055e0ea13156eb0ced15503
Reviewed-on: https://chromium-review.googlesource.com/1626327
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-05-24 15:10:46 -07:00
Gurchetan Singh
96beafc1c1 linux.rs: create a socket between gpu device and host
The GPU process needs to access KVM from host coherent
memory.

BUG=chromium:924405
TEST=compile

Change-Id: I3db9dce044e2a5cc816f48f28d943024dad7e7eb
Reviewed-on: https://chromium-review.googlesource.com/1626792
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-05-24 15:09:26 -07:00
Gurchetan Singh
53edb817da crosvm: {WlDriverRequest, WlDriverResponse} --> {VmMemoryRequest, VmMemoryResponse}
These type of requests are not necessarily specific to the virtio-wl,
and other devices (virtio-gpu) may want to use them.

BUG=chromium:924405
TEST=compile

Change-Id: Iad0889da8ab3d23bb2378448fc05e3c840a93d93
Reviewed-on: https://chromium-review.googlesource.com/1626791
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-05-24 15:09:26 -07:00
Gurchetan Singh
56ebd12380 virtio-gpu: add plane size
This is useful if the guests wants to map a host GBM
buffer.

BUG=chromium:924405
TEST=compile

Change-Id: I7fb68aa49c4ce4f2a020b8ce96ad558290380b5f
Reviewed-on: https://chromium-review.googlesource.com/1591460
Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-05-24 15:09:25 -07:00
Daniel Verkamp
cf68e76280 aarch64: use 64-bit memory space for PCI MMIO range
This makes the PCI root bridge's MMIO range consistent with the
newly-added device memory range.  We already fill out the full 64-bit
address/size fields, so we might as well use the corresponding bus range
type.

BUG=None
TEST=boot termina on kevin

Change-Id: I9ecad38c76dac764853c6232cc486cfc7737a269
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1579327
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-05-23 07:35:19 -07:00
Zach Reizner
3e0fa36886 eliminate usage of uninitialized
uninitialized is deprecated and considered too dangerous to use for any
of the use cases we were using.

BUG=None
TEST=passes smoke_test

Change-Id: I5392cb8ec132f374d9b5590f72eb2cb329a82421
Reviewed-on: https://chromium-review.googlesource.com/1626795
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-05-23 07:35:18 -07:00
Jakub Staron
6b7373af98 crosvm: Removes used_desc_heads arrays from various virtio devices.
BUG=None
TEST=tast run ${IP} vm.CrostiniStartEverything

Change-Id: I14bdc330bff23ef3397251a81bdf63e37c1e1dfd
Reviewed-on: https://chromium-review.googlesource.com/1611014
Commit-Ready: Jakub Staroń <jstaron@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-05-23 07:35:16 -07:00
Zach Reizner
b42b645cfa x86_64: regenerate bootparam bindings without unions
TEST=crosvm run still works
BUG=chromium:761517

Change-Id: I6e95dde573febb5e498107b84b574373d1685c9a
Reviewed-on: https://chromium-review.googlesource.com/1625947
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-05-23 07:35:15 -07:00
Jakub Staron
e6c9558998 crosvm: Moves logic of consuming a DescriptorHead to Queue.
Moves logic of consuming available descriptor heads from AvailIter
to Queue. Adds pop() function to the public interface of the Queue.

This will let us remove the used_desc_heads arrays from various virtio
device implementations because pop() is not borrowing the queue for
the whole loop scope.

BUG=None
TEST=tast run ${IP} vm.CrostiniStartEverything

Change-Id: I8eda48e41b5ec1b2d59f3177435abafb9ad5f3a3
Reviewed-on: https://chromium-review.googlesource.com/1611013
Commit-Ready: Jakub Staroń <jstaron@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-05-23 02:14:58 -07:00
Zach Reizner
cf0d298223 wl: limit vfd recv size to leave room for VFDs
The IN_BUFFER_LEN variable limits the amount of data that will be read
into a single page sized descriptor. The old value for it left room for
the 16 byte header but reserved no space for VFDs. This happens to work
fine if the size of the read data and VFDs did not exceed the buffer
size, but, in rare circumstance, the maximum amount of data would be
read along with a FD getting received, spilling the descriptor and
causing it to fail to write to it. The guest driver does not handle this
gracefully and usually panics due to corruption.

The new value reserves room for the max number of VFDs so that the
descriptors will not end up with too much data.

BUG=chromium:951576
TEST=while true; do
         (/opt/google/cros-containers/bin/wayland_demo&);
         pkill -f /opt/google/cros-containers/lib/ld-linux-x86-64.so.2;
     done

Change-Id: Ic0c1c10f81a91b5e5cd076e3ded8d3cc0564b614
Reviewed-on: https://chromium-review.googlesource.com/1623558
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-05-23 02:14:57 -07:00
Daniel Verkamp
1acf7b65bf usb: implement Interrupt on Short Packet bit
Transfer requests have a flag called Interrupt on Short Packet (ISP)
that we have been totally ignoring.  Now that the control request
execution phases have been rearranged in previous changes, we can
correctly trigger an event when a transfer fills fewer bytes than
requested.

This fixes firmware update on the Edge TPU USB Accelerator (Coral):
https://coral.withgoogle.com/docs/accelerator/get-started/

BUG=chromium:831850
TEST=Run Edge TPU test model from get-started page

Change-Id: I0d21e408a19c2e2eba562362bfe636c75dbb7160
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1593716
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-05-23 02:14:37 -07:00
Daniel Verkamp
ced74e6f2f devices: cmos: report memory size in CMOS
This matches the QEMU CMOS implementation and is used by BIOSes to
determine the valid memory regions to add to the e820 map.

BUG=b:133358982
TEST=Boot u-boot qemu build; observe memory size

Change-Id: I27956bc05738b5dd5b84240d5137cb06846aaab9
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1625330
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-05-23 02:14:28 -07:00
Zach Reizner
2b570f698a net_sys: regenerate if.h bindings using Rust native union
TEST=crosvm run, network still works
     cargo test -p net_util
BUG=chromium:761517

Change-Id: I3ee0e43376ff7f2ba76202138e47505c73958087
Reviewed-on: https://chromium-review.googlesource.com/1623557
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2019-05-23 02:14:24 -07:00
Zach Reizner
90c3271ce5 kernel_loader: regenerate bindings without unions
TEST=crosvm run <snip> vmlinux, kernel loads properly
BUG=761517

Change-Id: I2c1ce6f89c1a4d3a03df87b4e1931f63a7f5e569
Reviewed-on: https://chromium-review.googlesource.com/1623456
Commit-Ready: Zach Reizner <zachr@chromium.org>
Tested-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-05-23 02:14:24 -07:00
Daniel Verkamp
85691d3406 aarch64: add DT entries for multiple serial ports
Add device tree entries for all four serial ports to make arm match the
x86_64 behavior.

BUG=chromium:953983
TEST=`echo test > /dev/ttyS1` etc. from termina on kevin

Change-Id: I334f7ad3e2ee9bc2599b0e8195e51140e8001e51
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1620893
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-05-23 02:14:11 -07:00
Daniel Verkamp
207b1fd2b5 devices: serial: implement MSR loop behavior
This fixes the Linux serial driver loopback test for the 4th serial port
(COM4, aka /dev/ttyS3).

The default value of the modem status register is always returned in the
current crosvm implementation; however, this doesn't match the expected
value in the loopback mode test used by the Linux kernel 8250 serial
driver.  The other 3 serial ports (/dev/ttyS[012]) skip this test
because of the UPF_SKIP_TEST flag in STD_COMX_FLAGS, but the 4th port
uses STD_COM4_FLAGS instead, which doesn't have UPF_SKIP_TEST.

The mapping of MCR to MSR bits is defined in the 16550 UART data sheet:
http://www.ti.com/product/pc16550d

BUG=chromium:953983
TEST=`echo test > /dev/ttyS3` in crosvm

Change-Id: I1b52111235a500fef2dee00c5803a2221a25e0c6
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1620704
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2019-05-23 02:14:11 -07:00
Daniel Verkamp
af00eb7e26 arch: initialize 4th serial port
Fix an off by one in the loop range so that all 4 UARTs are initialized.

Note that the 4th serial port (/dev/ttyS3) still doesn't work in Linux;
this is because our UART doesn't correctly emulate the loopback mode,
which is tested by the Linux serial driver.  This test is skipped for
the first three ports due to the UPF_SKIP_TEST flag in STD_COMX_FLAGS,
whereas STD_COM4_FLAGS does not set UPF_SKIP_TEST (and fails the test).
This will need to be resolved separately.

BUG=chromium:953983
TEST=`echo test > /dev/ttyS3` inside VM

Change-Id: Ic768584820e8b532ee4241df79ef8b9c17c4657a
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1620703
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Trent Begin <tbegin@chromium.org>
2019-05-23 02:14:10 -07:00
Daniel Verkamp
03b238bcc0 smbios: fix clippy warnings
Resolve a couple of minor clippy warnings:
- const implies static lifetime, so it can be omitted
- dereference bytes of str instead of clone()

BUG=None
TEST=bin/clippy
TEST=cargo build; boot vm_kernel+vm_rootfs.img

Change-Id: I29ff9bf7fdecd64286c2199e8e45c21103de9ce1
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1618284
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-05-22 20:57:04 -07:00
Jorge E. Moreira
9c9e0e71bd crosvm: Implement the file type for serial ports
BUG=chromium:953983

Change-Id: I0c1dc6216ebfdb61db85d3d9665f88f7231d99c8
Reviewed-on: https://chromium-review.googlesource.com/1618281
Commit-Ready: Jorge Moreira Broche <jemoreira@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2019-05-22 20:57:00 -07:00
Daniel Verkamp
3007ff3cf4 x86_64: load initrd at max address
This matches behavior of other bootloaders (grub2, iPXE), and the kernel
seems to be relying on this; decompression of the initrd fails if the
initrd is loaded right after the kernel as before, but succeeds if
loaded at the maximum address.

BUG=None
TEST=Boot Debian kernel + initrd on workstation

Change-Id: If7712efb05f55ef413a419dfe276ed3f68c335b7
Signed-off-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/1616989
Tested-by: kokoro <noreply+kokoro@google.com>
Legacy-Commit-Queue: Commit Bot <commit-bot@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2019-05-20 15:47:23 -07:00