Commit graph

2027 commits

Author SHA1 Message Date
Manoj Gupta
4029491dfe block_device.policy: Add arm time64 variants
Add time64 variants for crosvm.

BUG=chromium:1188714
TEST=no more crashes when installing Linux

Change-Id: I5bacb0436b6002aef059dd619ac0cc80995315aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2774389
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Auto-Submit: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
2021-03-19 01:40:03 +00:00
Dennis Kempin
ae447c4bc7 io_uring: Fix flaky test
The test has been failing every ~10 test runs. The removed check
can be racy since we cannot wait for all threads to complete.

BUG=None
TEST=./test_all passes consistently

Change-Id: I231ae0734bc1a0d0c0fc991448f6ebf63b11fc56
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2768678
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-18 22:12:59 +00:00
Keiichi Watanabe
d56a2f432d Fix formatting
Ran `cargo fmt`.

BUG=none
TEST=cargo fmt

Change-Id: I9b069c6b30724148be5d3e059e0a447615abeac9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2772679
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-03-18 22:12:57 +00:00
Tomasz Jeznach
eb1114ced7 crosvm-direct: support for variable IOAPIC irqs.
More recent Intel IO-APICs can support more than 24 interrupt
lines. This change enables variable size of IO-APIC lines for
user level IO-APIC emulation code (split-irqchip).

Reported version and supported IO-APIC registes matching ICH10
implementation of IO-APIC device.

BUG=b:181795297
TEST=boot and allocate irq from upper range.

Change-Id: I56480befb39c4c268266f04e4a93105402248772
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2733579
Tested-by: Tomasz Jeznach <tjeznach@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Jeznach <tjeznach@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-18 22:02:54 +00:00
Daniel Norman
5e23df7939 Adds a new input device for switches, with socket flag --switches.
Bug: 181664980
Test: Launch cuttlefish with crosvm, observe switches /dev/input
      device with `getevent -lp`.
Test: cargo test
Change-Id: I209b93421bcfcc4ab26efc8981fcd2d680717d59
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2765762
Reviewed-by: Zach Reizner <zachr@chromium.org>
Auto-Submit: Daniel Norman <danielnorman@google.com>
Commit-Queue: Daniel Norman <danielnorman@google.com>
Tested-by: Daniel Norman <danielnorman@google.com>
2021-03-18 04:28:54 +00:00
Chirantan Ekbote
8e80902ce3 cros_async: Fix circular reference memory leak
PollSource keeps a strong reference to the FdExecutor, which can lead to
a memory leak via a circular reference if the caller spawns a future
that owns a PollSource and then detaches it.  Avoid this by using weak
references instead.

With this change, we now only use weak references internally.  The only
way to increase the strong reference count is by cloning the FdExecutor.

BUG=none
TEST=unit tests

Change-Id: Ic58ff475a31c6fca831c3ced73b26b87ceeda028
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2760378
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-17 19:24:07 +00:00
Chirantan Ekbote
12d17e90b8 cros_async: Delete RunnableQueue::set_waker
Previously each executor had to call RunnableQueue::set_waker at the
beginning of every loop before it started executing futures, which was a
bit tedious.  This call was needed so that the RunnableQueue would wake
up the executor if a new future was scheduled.

Instead move responsibility for waking the executor when a future is
scheduled back to the executor.  This lets us get rid of the set_waker
method and is arguably a better separation of responsibilities.

BUG=none
TEST=unit tests

Change-Id: Ica46437f78c822d87096eaa215954d118c6578f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2760377
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-17 19:24:06 +00:00
Keiichi Watanabe
5dc0f60d44 kokoro: Add rust-vmm/vhost in manifest.xml
BUG=b:181227406
TEST=ci/kokoro/simulate_all

Change-Id: I65065963daa9e96457ed9a64f01e34ad93bd8667
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2762488
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-17 19:12:08 +00:00
Dennis Kempin
ebc0520d0b Enable integration_tests on Kokoro for X86
Increases the communication timeout to 10 secs since we are running
twice nested KVMs, and things get a bit slower.

BUG=b:181675114
TEST=./test_all

Change-Id: Ifa3ea05952cd8a4f7fbe4fefb12143098243c21a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2752341
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-17 00:04:27 +00:00
Daniel Verkamp
6485f8115d arch: fdt: minor documentation cleanups
Wrap the link to the FDT spec in <> so it becomes a clickable link in
the doc output.

Also fix a parenthesized abbreviation of Devicetree Blob to be DTB
rather than FDT.

BUG=None
TEST=cargo doc

Change-Id: Ie607acb6388820e7dfdb436bdad34ff077289666
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2763204
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-16 23:47:37 +00:00
Daniel Verkamp
2cce1a271b devices: virtio: video: mark non-Rust code block
Indicate that the code block with instructions for running bindgen is
not Rust code to avoid this warning:

  warning: could not parse code block as Rust code

BUG=None
TEST=cargo doc --all-features

Change-Id: I38a9d49487dc1da8e41d3fca5dfa1b8bc8ae5e84
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2762064
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-16 23:24:45 +00:00
Daniel Verkamp
89e64c0d2e src: escape non-link [] in rustdoc
Fix a broken_intra_doc_links warning:

  warning: unresolved link to `ARGUMENTS`
  the module `argument` contains no item named `ARGUMENTS`

BUG=None
TEST=cargo doc --all-features

Change-Id: I678aa5dd9ede33879b2725e5a53411cad38d8a65
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2762063
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-16 23:24:43 +00:00
Noah Gold
2494889d28 Move libchromeos::sync to cros_async::sync.
To allow for porting to non POSIX platforms, we've brought the
libchromeos::sync module into cros_async (which was the only
consumer).

BUG=b:180978556
TEST=builds

Change-Id: I97256b1dc37124cebc693c035e63d2c5b29e94b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2757280
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-03-16 18:12:03 +00:00
Manoj Gupta
19ad688208 add getdents64 to policies
glibc 2.32 is using getdents64 syscall instead of getdents.
So add getdents64 to policies that already have getdents.

BUG=chromium:1171287
TEST=CQ

Change-Id: Icbe1da7cbf669432c8160779a9cbfdeb04db57c0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2760299
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
2021-03-16 05:25:16 +00:00
Jorge E. Moreira
6a88a5d986 Allow VioS backend in android OS too
Change-Id: I3eaa744054e83a3f6b91227a0c8030a6cb2d049b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2757270
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
2021-03-16 02:05:47 +00:00
Daniel Verkamp
cef22bc39f run_tests: enable rutabaga_gfx and vm_memory tests
Add the privileged requirement so that these tests run in a VM and can
successfully call memfd_create().

BUG=b:181672913
BUG=b:181675101
TEST=./test_all

Change-Id: Ic0eadade4e625e50e73682771a9c6fbb92468af2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2754487
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2021-03-16 00:52:23 +00:00
Chih-Yu Huang
44f1ffd5de video: do not clear output resource when getting QueueClear command
When the V4L2 output queue is streamoff, crosvm gets QueueClear
command. All the V4L2 output buffers are dropped, but VDA doesn't drop
output buffers at this point. We should only clear the enqueued
resource ids, and not clear the whole output resources.

BUG=b:181541291
TEST=android.media.cts.AdaptivePlaybackTest
TEST=com.google.android.exoplayer.gts.DashTest

Change-Id: I343b809e80d5bc56679b76baa5593aebb4558a74
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2756068
Tested-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2021-03-15 09:49:26 +00:00
Dennis Kempin
84b2d93c70 Fix io_uring tests for running on Kokoro
Some of the multi-threaded tests had race conditions that show up when
running inside the Kokoro Test VMs.

To wake up and complete all running threads, no-ops are inserted into
the uring. However, each thread can grab a list of results. On the
test VMs, all no-ops are read by one thread, leaving the others running,
blocking the test from completing.

Since this is just a test.. let's just leave the threads hanging and
let the OS take care of them.

BUG=b:181673923
TEST=./test_all

Change-Id: I504b6db9cf934e2454d27c1155667b4b0f7fbc77
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2750783
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-12 23:36:14 +00:00
Dennis Kempin
dcf540be92 Add SEPARATE_WORKSPACE requirement for run_tests
The io_uring and fuzz crate cannot be tested in the same workspace
via `cargo test -p io_uring -p fuzz`.
This change allows test_runner.py to run tests independently by
cd'ing into the crates directory and running cargo test in there.

BUG=b:181672910
BUG=b:181673923
TEST=Tests for the above mentioned crates can be enabled and run, but
test failures prevent them from being enabled so far.

Change-Id: Ia03868d53e508549fe2f071da399b982359a8834
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2749772
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-12 23:36:13 +00:00
Dennis Kempin
f217c0fb46 integration_tests: Add prebuilts for aarch64
Updates the guest_under_test Makefile / upload script to build
for aarch64 as well.

BUG=b:176748319
TEST=Unfortunately KVM is not fully functional in our arch64 VM, so I have
not been able to test the prebuilt yet.

Change-Id: I554da6a620b26ffa1db34baa13d529f0b1de1616
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2676994
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-12 22:50:30 +00:00
Zach Reizner
fdf87d8827 update Cargo.lock and conditional compile certain modules
This change is to cleanup some dead_code warnings that appear if certain
features aren't enabled.

This also updates the Cargo.lock when changed due to zeroize being added
to libchromeos-rs.

TEST=cargo check --all-features
BUG=None

Change-Id: I5347b584a7426dc37f3933b1e907b23a71145749
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2753128
Reviewed-by: Allen Webb <allenwebb@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@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>
2021-03-12 21:44:49 +00:00
Christian Blichmann
2f5d4b64a3 Make vhost-vsock and vhost-net paths configurable
This change is similar to http://crrev.com/c/2736520, which made the
path of the KVM device configurable. Similarly, most users will want
to keep the default paths of `/dev/vhost-vsock` and `/dev/vhost-net`.
In certain environments, namely Borg, those device nodes may be located
elsewhere.

BUG=None
TEST=./ci/builder --vm ./run_tests

Change-Id: I4bd7944d8f84fc0e7d255a3930c27f48a980e617
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2749235
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-12 19:26:35 +00:00
Chirantan Ekbote
7b98502972 fs: Don't drop caps when changing UID
Set the SECBIT_NO_SETUID_FIXUP securebit so that we don't lose
capabilities when changing the thread uid/gid.  This allows us to
simplify the create and mkdir functions so that all the checks we
currently carry out are only done once by the host kernel.

To ensure that the setuid and setgid bits still get dropped when a file
is modified by a process that doesn't hold CAP_FSETID, check for
WRITE_KILL_PRIV in the write flags and temporarily drop CAP_FSETID when
it is set.

BUG=none
TEST=Check that default posix acls, setgid bits, and file/directory
     creation via membership of a supplementary group all work as
     expected.

Change-Id: I420484e357a970e997cb3e968a433278e82d8ad4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2684067
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-03-12 04:11:58 +00:00
Dylan Reid
2320fc7a83 sys_util: sock ctrl - add send/recv flexibility
For historical reasons, crosvm switched to sending `IntoIobuf`, this
isn't implementable for a slice of slices as it would require an
allocation. The rust-vmm fork of sys_util still supports sending
`&[&[u8]]`. Adding that ability back makes it easier to use their
crates.

In addition crosvm allows receiving to slices by not iovecs, again the
opposite of the rust-vmm version. Add that ability as well.

Change-Id: I4566f232adb47a0802e39e3f6c09c03f97190eb3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2740533
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-03-11 08:06:27 +00:00
Daniel Verkamp
5b562bf878 disk: composite: fix into_iter warnings
Convert into_iter() calls into iter() where appropriate:
https://github.com/rust-lang/rust/issues/66145

BUG=b:181674168
TEST=cargo test -p disk --features=composite-disk

Change-Id: I9c82a7b956598628010a3dbb33db6e425bbc4e2c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2743402
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-03-10 21:25:44 +00:00
Daniel Verkamp
b8c64b6df1 disk: composite: switch tests to tempfile
Use tempfile rather than SharedMemory for temporary files in the
composite disk unit tests.  This fixes an API incompatibility that was
missed because these tests are only enabled with the composite-disk
feature.

This also enables the disk tests in test_all with the privileged option
so that they run in the VM; this allows the memfd_create syscall used in
the async_read/write tests to work.

BUG=b:181674168
TEST=cargo test -p disk --features=composite-disk
TEST=./test_all

Change-Id: I869b5daa29904b3558440e7b650713e8e5085d81
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2743401
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-03-10 21:25:43 +00:00
Daniel Verkamp
13b95d2b60 devices: proxy: set thread name to debug label
Make the forked child processess easier to distinguish.

Also tweak the debug_label for virtio-pci devices so that more of the
name can fit into a limited-length thread name.

BUG=None
TEST=pstree

Change-Id: I74a8c1f5ab869e814bed4f2bd71c3de5179f7855
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2740526
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-10 20:48:48 +00:00
Dennis Kempin
f248a8ec2b Fix Kokoro build with manifest uprev
Kokoro was failing since http://crrev.com/c/2744968 depends on recent
cras changes that were not included in the current Kokoro manifest.

BUG=None
TEST=./ci/kokoro/simulate_all passes

Change-Id: I470844af73b9f89ac8cbf9f5fcf8706d01924279
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2746014
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-10 06:16:25 +00:00
Dennis Kempin
3682372764 ci: Upgrade test-vm to debian bullseye
This change updates the test VM to debian bullseye, primarily to enable
io_uring features that are not available in the 4.16 kernel shipping
with debian buster.

We are not updating the builder containers to bullseye, as newer
versions of qemu fail to start on kokoro. See b/181359683

Since it was needed for debugging this CL, it includes a feature to
debug kokoro builders via SSH. It can be enabled by setting
DEBUG_SSH_KEY from the fusion2 UI.

BUG=b:178228512
TEST=./test_all passes

Change-Id: I22f1678577183a0aace80245a87c31907221cc09
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2721062
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-03-10 03:37:00 +00:00
Lepton Wu
e0598548aa seccomp: arm: Allow getrandom for video device.
libvda depends on libchrome and libchrome changed to use
getrandom since http://crrev.com/c/2380673

BUG=b:182223105
TEST=manual - Push updated policy file to kukui and run ARCVM.

Change-Id: I135121fc824ab07f114dd84e1a2a36fc9b8d5896
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2745819
Tested-by: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-03-10 03:01:09 +00:00
Xiong Zhang
ec53b41ac5 pci_configuration: Enable memory or IO space at add_pci_bar()
Crosvm pre-allocate mmio for device, but it doesn't enable memory/io
space in pci command config register, then OVMF doesn't use the pre-allocated
mmio and reallocate device mmio.

BUG=b:179053182
TEST='crosvm run -bios OVMF.fd' and check device info in efi shell

Change-Id: I7176e7f9716d829efff1ea023666eb705b525e5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2741920
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-10 00:41:07 +00:00
Xiong Zhang
20e8aeb71f Virtio-pci: Add version id for virtio device
All virtio devices have virtio version 1.0 as base feature, but this revision
id isn't in pci configuration register, then OVMF won't start virtio 1.0
driver, and virtio device couldn't be used in OVMF.

BUG=b:179053182
TEST='crosvm run -bios OVMF.fd' and check virito blk device in EFI shell.

Change-Id: I8cbcd71b9b6ccef07b56853b7450b74e4dcbae1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2741919
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-10 00:41:06 +00:00
Xiong Zhang
9a74168e29 x86_64:Add smbios end entry
Ovmf goes through all entries in smbios table, without end entry,
assert() failure occurs.

BUG=b:179053182
TEST='crosvm run -bios OVMF.fd' and boot OVMF into efi shell

Change-Id: I0068133c75583dc4a3477d01a58f0ee8775b509e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2741918
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-10 00:41:05 +00:00
Mike Gerow
ec618a53e6 crosvm: accept pmem disks via FD
This essentially duplicates the same implicit fd-passing support in
create_block_device. By accepting the FD directly instead of opening the
file under `/proc/self/fd/...` we can inherit the same permissions that
a caller to concierge, for example, gets. This simultaneously allows
crosvm to access files it might not otherwise be able to, and prevents
it from misusing its privileges to potentially elevate a read-only FD to
wa read/write FD.

BUG=b:181347894
TEST=Start pmem VM passed from concierge via FD. Ensured the FD itself
was used instead of crosvm re-opening the file under `/proc/self/fd...`.

Change-Id: Ic4d4e6155a1978b45e82141609fdadff45ca987b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2724473
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Mike Gerow <gerow@google.com>
2021-03-09 22:56:07 +00:00
paulhsia
83d5160076 ac97: Add client_type option for the ac97 devices
To track arc in VM in UMA and to separate it
from other linux VMs.

Changes:
- Add client_type options to Ac97Parameters.
- Add client_type option for the ac97 devices with CRAS backend.

BUG=b:177393225
TEST=Apply full patch set and start audio in ARCVM with
     `cras_test_client --dump_a`

Cq-Depend: chromium:2744525
Change-Id: I27201aa65baed0ee59cf689dd7f22b5b91f00946
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2744968
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2021-03-09 18:12:45 +00:00
Christian Blichmann
33d5677804 Make KVM path configurable
Most users will want to keep the default `/dev/kvm` path. However, in
certain environments, namely Borg, the KVM device node may be located
elsewhere.

This is the first of a set of related changes that will make hard-coded
device paths configurable.

BUG=None
TEST=./ci/builder --vm ./run_tests

Change-Id: I6087879c535be3779e20eff1f8fb5080f80cf020
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2736520
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
2021-03-09 07:08:23 +00:00
John Bates
d854217d99 ac97: null audio device also needs sched_setscheduler
Updating seccomp for null audio device.

BUG=None
TEST=run crosvm with null audio device fallback

Change-Id: Iadcbd5b68fa36427782a66f66046fe5a907c2470
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2740644
Tested-by: John Bates <jbates@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: John Bates <jbates@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: John Bates <jbates@chromium.org>
2021-03-08 22:29:31 +00:00
Adrian Ratiu
f19933bfb0 tree-wide: seccomp: allow clock_nanosleep syscalls
Starting with 2.32 glibc nanosleep() was refactored to use the
clock_nanosleep syscall so various software will fail unless
the new syscall is allowed. We can't just drop the old nanosleep
syscall because it will break glibc 2.27 which is still used.

See glibc commits:
807edded25 nptl: Refactor thrd_sleep in terms of clock_nanosleep
3537ecb49c Refactor nanosleep in terms of clock_nanosleep
79a547b162 nptl: Move nanosleep implementation to libc

This is a bulk edit done with the following command:
git grep -rl 'nanosleep: 1' | xargs sed -i \
                           '/^nanosleep: 1/a clock_nanosleep: 1'

BUG=chromium:1171287
TEST=Local builds and booting on kevin/64/eve/minnie.

Change-Id: I975535078d88200f52319c7eea3a4c7ebf299933
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2735575
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Manoj Gupta <manojgupta@chromium.org>
Commit-Queue: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Stephen Barber <smbarber@chromium.org>
2021-03-07 01:53:10 +00:00
Chia-I Wu
3c6367b98c seccomp: gpu: allow sched_yield
It will be needed by virglrenderer with venus enabled.

BUG=b:180621453
TEST=vulkan-smoketest

Change-Id: I3c3b4f38901d278c137b26f8801a3417d88b4533
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2728307
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Chia-I Wu <olv@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: David Riley <davidriley@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2021-03-05 05:13:36 +00:00
Keiichi Watanabe
4d343bbf55 devices: virtio: Skip setting up unused virtqueues
While a host virtio device provides |num_queues| virtqueues, a guest virtio driver doesn't necessarily use all of them. For example, the virtio-blk driver uses only |nr_cpu_ids| virtqueues at most [1].

To avoid checking whether each queue is ready in each device implementation, we can filter them before starting device activation.

[1]:
https://patchwork.kernel.org/project/linux-block/cover/1553682995-5682-1-git-send-email-dongli.zhang@oracle.com/

BUG=b:179671351, b:181753022
TEST=CQ

Change-Id: I29d21d8d9db2d99aa9591ca55c18d06d2368797e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2732735
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-03-05 02:10:33 +00:00
Keiichi Watanabe
19bfe410fa devices: virtio: blk: Fix alignment of config struct
Add #[repr(packed)] to struct virtio_blk_config to make its size same with the
the origianl C struct. The packed annotation will remove 4-byte padding at the
end of the struct and make the size of the struct smaller. (64 bytes -> 60 bytes)

Since it won't affect offsets of any fields, it shouldn't change any behavior
when the guest reads a config field. But, it can matter when the entire config
struct is passed via vhost-user protocol.

BUG=none
TEST=run a VM

Change-Id: I4dca9f1bdd93166192eca4d05d542ce851852aa7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2726059
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-03-05 02:10:32 +00:00
Keiichi Watanabe
0074b288ef sys_util: Fix clippy errors and warnings
BUG=chromium:1111728
TEST=cargo clippy --all-features --all-targets in sys_util
TEST=./test_all

Change-Id: Ib544bd1f87fa8a3244b4e6643f54eae265ef55bd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2717905
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-04 20:23:12 +00:00
Chih-Yu Huang
41a3da9729 video: drop decoded frames during VDA::Reset()
After the userspace streamoff the input queue, the crosvm should not
return the previous frames. However, VDA might still return frames
before notifying reset is done. This CL drops the decoded frames after
calling VDA::Reset() until reset is completed.

BUG=b:181087034
TEST=android.media.cts.AdaptivePlaybackTest

Change-Id: Ieaa40ef27f1b37a262c80f9f30698c03ef16bdb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2728584
Tested-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2021-03-04 16:04:14 +00:00
Chih-Yu Huang
c536389013 video: postpone sending the decoded frame until receiving the buffer
When the video is flushed, V4L2DecodeComponent streamoff V4L2 output
and input queue. Then crosvm releases all output buffers and calls
VDA::Reset(). However, VaapiVDA implementation doesn't release output
buffer at Reset(). If Vaapi decodes the following frame before
V4L2DecodeComponent QBUF any output buffer, then crosvm will drop the
decoded frame.

This CL makes crosvm postpone sending the decoded frame if this
situation happens. Crosvm would sends the decoded frame when receiving
the buffer again.

BUG=b:181087034
TEST=emerge-hatch-arc-r crosvm
TEST=android.media.cts.AdaptivePlaybackTest
TEST=seek video many times and check no error occurs at the end of video

Change-Id: I0c8e59e2a206d6b2cd2009fd70380e7d5a366953
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2719245
Tested-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2021-03-04 16:04:13 +00:00
Chih-Yu Huang
7a4861a6e1 video: make Device::process_cmd() can return responses of events
Originally, process_cmd function can only return the response of the
procesesed cmd. However, we need to return the response of events for
some commands. This CL makes the process_cmd function could return
the responses of both command and event.

BUG=b:181087034
TEST=emerge-hatch-arc-r crosvm

Change-Id: Ie781795f8cee1c66e8462c602f876043b0dea9bc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2719244
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2021-03-04 16:04:13 +00:00
Chih-Yu Huang
945cfbcf29 video: make process_cmd() return VideoCmdResponseType directly
Originally process_cmd() return VideoResult<VideoCmdResponseType>.
However, VideoCmdResponseType could return the error result by
Sync(CmdResponse::Error). VideoResult is not needed.

This CL change the returned type of process_cmd() to
VideoCmdResponseType to reduce code complexity.

BUG=b:181087034
TEST=emerge-hatch-arc-r crosvm

Change-Id: I1795a3eb09fe36076f5ad43fdd8d1eb9e21ffcd9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2731607
Tested-by: Chih-Yu Huang <akahuang@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Chih-Yu Huang <akahuang@chromium.org>
2021-03-04 16:04:11 +00:00
Zach Reizner
4f3f332209 data_model: make endian types Serialize and Deserialize
By using these traits in crosvm, we also add serde as a dependency.

BUG=b:176847362
TEST=run_tests

Cq-Depend: chromium:2729637
Change-Id: Icd16a6e163d9e1dedbe3924cb94f29d777eb2216
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2613690
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>
2021-03-04 11:26:31 +00:00
Dennis Kempin
4f41c7ebc7 crosvm: Remove old test infrastructure
This is replaced by test_all and the new builders for kokoro.
See ci/README.md for details.

BUG=b:178233937
TEST=None

Change-Id: Id8bf721e026e71d9f284f920ef8287beb414c621
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2705292
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2021-03-03 07:05:03 +00:00
Andrew Walbran
ce10855e91 enable_raw_capability and kvm_enable_cap are unsafe
The args may be interpreted as pointers for some capabilities, so the
caller must ensure that any such pointers are allocated appropriately.

BUG=b:181564686
TEST=cargo test

Change-Id: I244f4d9417e588a6be5681f4718bb9ad7b262c3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2726709
Auto-Submit: Andrew Walbran <qwandor@google.com>
Commit-Queue: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
2021-03-03 02:20:49 +00:00
Daniel Verkamp
0a91c96437 arch: rewrite FDT writer in native rust
This removes some unsafe code, improving the interface so that it cannot
be misused (e.g. previously, different Vec<u8> instances could be passed
to fdt functions that did not validate the contents).

The new implementation also adds some extra error checking to catch
invalid string values in all API entry points that accept strings, as
well as out-of-order node nesting that would result in DTB data that did
not conform to the spec.

BUG=b:175729255
TEST=cargo test -p arch
TEST=Boot Crostini on kevin (arm)
TEST=diff old and new dts from `dtc -I fs -O dts /proc/device-tree`

Change-Id: I567d562ed1b447aa0d282b68c71758edea13ffc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2713569
Reviewed-by: Zach Reizner <zachr@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-03-03 01:29:15 +00:00