Commit graph

2422 commits

Author SHA1 Message Date
Chirantan Ekbote
056a3ec8fe Use spawn_blocking() in DeviceReqHandler::run
This lets us offload the blocking accept() call to another thread so
that the main thread can continue handling other operations.

BUG=b:179755651
TEST=cargo test

Change-Id: I1372a13e662fe4ad5c99764788550a444d46170d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2987588
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-17 11:48:08 +00:00
Chirantan Ekbote
af9dccf591 Add try_clone() and FromRawDescriptor for Tube and UnixSeqpacket
BUG=b:179755651
TEST=cargo test

Change-Id: Icf77f7427972b940215a2a4d95aa09ae409e4ff0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2987590
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-17 11:48:07 +00:00
Chirantan Ekbote
e9778a0b59 pci: Derive Serialize and Deserialize for some types
BUG=b:179755651
TEST=cargo test

Change-Id: I9edbc3869659eb546dd5338c03192693e884c197
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2987589
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-17 11:48:06 +00:00
Chirantan Ekbote
e4b9f30e24 sys_util: Add UnlinkUnixListener
Like UnlinkUnixDatagram but for UnixListener instead.

BUG=b:179755651
TEST=cargo test

Change-Id: I874ba2c76f525ac6cbc86d16b45dc8ff43d0c7f4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2987587
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-17 11:48:05 +00:00
Dennis Kempin
b3ccebbf3d Improve build / test documentation
A lot of the information was outdated. The new guide prioritizes
building for linux and testing on linux as the default workflow
for crosvm.

BUG=b:194323235
TEST=None

Change-Id: Idb7cdb07151fc7d7d5466075e316015cf5f4c615
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3098391
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-16 20:43:22 +00:00
Dennis Kempin
faee6ce7fa Update setup_cros_cargo.sh to fix all paths for chromeos cargo builds
This allows ChromeOS developers to use cargo to build against the crates
provided by the ChromeOS source tree, instead of using the bundled
submodules.

BUG=b:196585250
TEST=./setup_cros_cargo.sh && cargo build

Change-Id: I02d38784f7a97657c37c267818499efed4ddab47
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3092414
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-08-16 19:31:58 +00:00
Peter Fang
218c8f313e devices: pci: mmap non-MSIX areas in MSIX-mappable BAR regions
A MSIX BAR can include both MSIX and non-MSIX registers. The non-MSIX
part of the BAR can be mmaped, eliminating unnecessary slow reads/writes
in userspace.

Add a new struct, VfioMsixAllocator, to keep track of the non-MSIX areas
of a mappable MSIX BAR. Page alignment is imposed to make sure mmap
succeeds.

BUG=b:184904868
TEST=boot Linux kernel and verify MSIX-capable passthru devices work
properly

Change-Id: I1fbf4c710f4bfaffe613d902f27e3bbb558c469e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2972489
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-13 23:24:03 +00:00
Peter Fang
9d614079d0 devices: pci: fix num_pba_entries in msix.rs
num_pba_entries should use rounding instead.

BUG=b:184904868
TEST=boot Linux kernel and verify MSIX-capable passthru devices work
properly

Change-Id: I406c033f59bc50bd767116947525058b74be054f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2972488
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-13 23:24:02 +00:00
Peter Fang
01527e39b3 devices: vfio: add support for VFIO_REGION_INFO_CAP_MSIX_MAPPABLE
For MSIX-capable PCI devices, some BAR regions are described using
VFIO_REGION_INFO_CAP_MSIX_MAPPABLE:

  The MSIX mappable capability informs that MSIX data of a BAR can be
  mmapped which allows direct access to non-MSIX registers which
  happened to be within the same system page.

Add support for this capability so that VfioRegion stores the correct
mmaps information.

Also, fix a couple break conditions to avoid breaking out early.

BUG=b:184904868
TEST=boot Linux kernel and verify MSIX-capable passthru devices work
properly

Change-Id: Ie451b154ccd4779f1694a1ffed0bd02127f5ecdb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2972487
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-13 23:24:01 +00:00
Joel Galenson
06392aabd4 Migrate to gdbstub 0.5.0.
BUG=b:191784608
TEST=Build and run atest in Android tree

Cq-Depend: chromium:3073700
Change-Id: I5fcfa166caf8c5a5f759a8f62ef78a293db95f1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3071900
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2021-08-13 18:30:47 +00:00
Will Deacon
c48e78344e crosvm: arm64: Populate restricted DMA node based on 'swiotlb=' option
Protected VMs require all virtio data to be bounced through a memory
window shared between the host and the guest. Although this can be
achieved by forcing the guest to use swiotlb bouncing for all DMA
transfers, the recent introduction of "Restricted DMA" in Linux allows
these buffers to be sized and allocated on a per-device basis.

Remove the 'swiotlb=force' option when '--protected-vm' is set in favour
of describing a reserved memory region to be used as the swiotlb buffer
for all virtio-pci devices, adjustable via the new '--swiotlb' option.

BUG=b:190593703
TEST=cargo test on x86 and arm64 machines
Cc: David Brazdil <dbrazdil@google.com>
Cc: Claire Chang <tientzu@chromium.org>
Cc: Quentin Perret <qperret@google.com>
Cc: Andrew Walbran <qwandor@google.com>
Cc: Marc Zyngier <mzyngier@google.com>

Change-Id: I2d48a7c77740e7f3ad996ad33592f0acd53b7144
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3064198
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Will Deacon <willdeacon@google.com>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-13 16:12:35 +00:00
Keiichi Watanabe
6ce3da3b42 vhost_user_devices: Remove unused error enum values
BUG=none
TEST=cargo build

Change-Id: I536ac76076f1340443f7efea53915e8628365239
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3070727
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-13 09:44:05 +00:00
Chirantan Ekbote
47fdc8e5a0 gpu: Remove unused parameter
BUG=b:179755651
TEST=cargo test

Change-Id: Ifc5e2619cec690ccfc8a5f03dee441fabb3d2be8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2987593
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-13 06:34:20 +00:00
Jason Macnak
84b0978847 rutabaga_gfx: Handle rutabaga gfx update
Having both renderers running at the same time can work,
but not without changes.  For now, allowing building both
at the same time.

BUG=b:181869105, b:182174209
Test: launch_cvd --gpu_mode=gfxstream
Test: launch_cvd --gpu_mode=virgl_renderer

Change-Id: Ib8a3fd4927401b9f7ebc4a4425a3ddba6621a3e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3092405
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-08-13 03:43:01 +00:00
Junichi Uekawa
3001c2fc73 integration_test: Do not throw away stdout/stderr.
When nothing fails, output is ignored, but when something fails, you'd
want to look at the error messages.

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

Change-Id: If6e73588b33714dea1e7f097a91c80f7c249be48
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3083207
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-08-12 23:58:33 +00:00
Daniel Verkamp
ca0aed3daa hypervisor: kvm: replace mem::transmute with safe loops
The conversion code for KVM <-> hypervisor representation of the Local
APIC state used the unsafe mem::transmute() function to view an array of
i8 as u8 instead for use with the Rust endian conversion functions.
Casting between integer types of the same size with `as` is defined in
Rust as a "no-op" (the bitwise representation is preserved), just like
in C, so transmuting at the slice level is not needed. These can instead
be written as simple loops to avoid the unsafe code.

To ensure this does not regress code quality, I have compared the code
generated for the x86-64 release build.  The kvm_lapic_state to
LapicState conversion compiles to identical code, and the reverse
compiles to slightly different code (the compiler decides to emit a loop
instead of unrolling the 64-element copy), but the conversion of each
element still compiles down to a pair of MOV instructions.

The corresponding unit test has also been updated to avoid transmute, as
it was unnecessary there - the individual array element can be cast with
the `as` operator rather than transmuting the whole array.

BUG=None
TEST=cargo test -p hypervisor

Change-Id: I7e792b5507235e5234afe114a1ca744931e047d5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2947934
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-12 19:27:06 +00:00
Daniel Verkamp
a6aeccc679 devices: usb: log unknown control transfer types
Improve the log message for unexpected commands received on control
endpoints to include the type of command.

BUG=chromium:1231779
TEST=./test_all

Change-Id: I29963739bf5c5cb9fa427011fe5468a7378b67e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3083225
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2021-08-12 16:54:25 +00:00
Gurchetan Singh
231a54f36f rutabaga_gfx: cross_domain: an idea whose time has come
Cathedral enthusiant Victor Hugo once said:

“Nothing else in the world ... not all the armies ... is so
powerful as an idea whose time has come.”

He was talking about republicanism vs. monarchy.  My friends,
we are on the verge on a change quite possibly bigger than
that: seamless wayland windowing!!

The revolution started by the virtio_wl device is finally making
it's way to virtio_gpu, bringing best-in-class display
virtualization to a wider audience.

The overall approach is described here:

goto.google.com/virtio-gpu-wayland-context

At it's core, virtio-gpu wayland windowing uses the same mechanisms
that another virtio-gpu consumer (say gfxstream or virglrenderer)
uses to submit an opaque command stream to the host.  A response
page is allocated by the guest where host commands are place
(gfxstream has been using this mechanism for years).

There are various tables to track the internal context state and
resources.  A thread is spun up to poll the Wayland socket.  The
asynchronous callback and upcoming virtio-gpu multiple timelines
feature is used to make 3D consumers (gfxstream, virglrenderer)
don't interfere with the Wayland signalling.

In the future, virtio-gpu may be further modifed to perform
multi-queue virtio in-case the single virtio-queue turns out to be
a bottleneck.

As always, look forward to your feedback & questions.

BUG=b:150239451
TEST=Launch Sublime text + weston-terminal with Sommelier changes
     Copy + paste into VM window
     Copy + paste out of VM window

Change-Id: Ifb74644cc71a561fd278700d91e4bc66d16107a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3055850
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-12 14:38:32 +00:00
Chirantan Ekbote
5590a24b1b cros_async: Add a deadline to BlockingPool::shutdown
Add an optional deadline to BlockingPool::shutdown.  Any worker threads
that have not yet exited once the deadline expires will be detached.
This ensures that we don't end up blocking indefinitely while waiting
for worker threads to exit.

BUG=none
TEST=unit tests

Change-Id: I6d7e73e1c95a934a4fd80825a9d44187532408b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3058842
Auto-Submit: Chirantan Ekbote <chirantan@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-12 04:29:18 +00:00
Xiong Zhang
5a223d1f2f devices:pci: Correct pci bridge config register writable bits
According to pci bridge spec, some registers are writable and should
be marked correctly.

BUG=b:185084350
TEST=Boot a guest with pcie root port

Change-Id: I501fa05cc9ea6b6ea02d5d8bcbb29ba291a4b49e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2954675
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-12 01:03:06 +00:00
Xiong Zhang
12274bf287 devices:pci: Add pci capability writable bits
Some pci capability register is writable, and guest could write it
and control it(like msix control and pcie cap control), let each
pci capability returns its writable bits, so guest could write the
value into config register.

BUG=b:185084350
TEST=Boot a guest with and without passthrough device

Change-Id: Ic98a569823c762e7165f83d29ee90d2ba762dead
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2954674
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-12 01:03:04 +00:00
Suleiman Souhlal
2ac78b9ea0 Add "make_rt" command.
This is used to finally make a "delay-rt" VM's RT VCPUs RT.

BUG=b:142777321
TEST="grep policy /proc/<pid of rt vcpu>/sched" to make sure RT vcpu
    isn't RT until "make_rt".

Change-Id: I73177f8adadf3d1099c2b09871ee9d5feab82587
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2703225
Auto-Submit: Suleiman Souhlal <suleiman@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Suleiman Souhlal <suleiman@chromium.org>
2021-08-11 11:39:31 +00:00
Suleiman Souhlal
63630e8dce Add --delay-rt flag.
This flag is intended to be used to delay making a VM's RT VCPUs
RT until "make_rt" is called, in order to avoid boot time
regressions with RT.

BUG=b:142777321
TEST="grep policy /proc/<pid of rt vcpu>/sched" to make sure RT vcpu
    isn't RT until "make_rt".

Change-Id: I1b9132e11f0acc626434c60cecc2f4afe350961a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2703224
Auto-Submit: Suleiman Souhlal <suleiman@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Suleiman Souhlal <suleiman@chromium.org>
2021-08-11 11:39:30 +00:00
David Staessens
8fe6d5f963 virtio: video: Remove empty value from ForceKeyFrame.
The ForceKeyFrame control is a button control, which means that it
doesn't have a value. This CL performs some minor cleanup and removes
the empty parentheses after the ForceKeyFrame CtrlVal as these are not
required.

BUG=None
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420_vm

Change-Id: Ic86eb92e097de46ce68ed71bfe24299e07f8b78e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3064155
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-11 07:46:12 +00:00
Junichi Uekawa
7cbd02f109 crosvm: Add integration test case for O_DIRECT.
Make sure we keep booting.

BUG=b:190435784
BUG=b:184204645
TEST=boot tests (boot_test_suspend_resume, boot_test_vm) pass.

Change-Id: I586e555ae83759c88759e1aeb96a728785d0cf5f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3055557
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-11 02:22:41 +00:00
Junichi Uekawa
74b18b8ccb vm_tools: Use /var/tmp instead of /tmp.
/tmp is mounted as tmpfs, and tmpfs does not provide O_DIRECT capabilities. Try
using a ext4 file system.

BUG=b:190435784
TEST=time ./ci/builder --vm #    boot_test_vm_odirect passes

Change-Id: I3f8245052ed06c703cc3aa320d300d5f21254e90
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3083206
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2021-08-11 02:22:40 +00:00
Jorge E. Moreira
8be8486d05 virtio-snd: Add event_notifier to the list of file descriptors
BUG=b:174713663

Change-Id: I534818cf4cc90bc5957fcc17c1d273e7d4be9846
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3064651
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
2021-08-06 19:38:48 +00:00
Charles William Dick
5404501966 crosvm fix stale balloon stats
Stale balloon stats results can be returned from a stats request for the
following reasons:
* The initial stats buffer from the guest is posted to the
  balloon_host_tube without a request.
* Balloon stats requests can fail because the balloon device isn't
  completely set up yet; writing a stats request to the tube without
  reading the response.
* Balloon stats requests can time out, returning an error. When the
  balloon stats are eventually computed, they will be queued to the tube
  without a read to consume them.

Possibly other reasons too.

This CL fixes this by adding an id to the balloon stats request. The id
is then returned with the computed stats. When consuming stats results
from the balloon_host_tube, we check that the ID is the one we expect,
if not, we keep reading from the tube until we do.

BUG=b:189282316
TEST=tast run dut multivm.Lifecycle.arc_host

Change-Id: I08e50196a45383b30c9e510b3bacbe32888aef80
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3056310
Auto-Submit: Charles William Dick <cwd@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Charles William Dick <cwd@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Hikaru Nishida <hikalium@chromium.org>
2021-08-06 15:39:15 +00:00
Dennis Kempin
42b825f740 Switch to submodules based workflow
Instead of requiring crosvm to be checked out via the chromeos manifest
to access dependencies in the ChromeOS monorepo, this change adds
git submodules to third_party/.

The CI scripts and Cargo.toml are updated to use the new paths.

BUG=b:194336213
TEST=git clone --recursive https://chromium.googlesource.com/chromiumos/platform/crosvm
     cd crosvm
     cargo test
     ./test_all
     ./ci/kokoro/simulate_all

Change-Id: I9859d18176e21909ac3a140976fbd67cc14129bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049003
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-05 18:32:32 +00:00
Chirantan Ekbote
eaa95e9cad vhost_user_devices: Ack queue features
We need to call Queue::ack_features to actually enable virtqueue specific
features like VIRTIO_RING_F_EVENT_IDX.

BUG=none
TEST=start a vm with a vhost-user block device

Change-Id: I82d04ad940850b53e17cfaf3ee5cdb4318190424
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3070721
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chirantan Ekbote <chirantan@chromium.org>
2021-08-05 17:53:12 +00:00
Peter Fang
60e4515e61 devices: virtio: iommu: remove VIRTIO_IOMMU_F_TOPOLOGY
VIRTIO_IOMMU_F_TOPOLOGY is not needed as DT/VIOT are the preferred
methods for vIOMMU discovery.

BUG=b:181736020
TEST=boot Linux kernel and verify passthru devices work properly with
iommu=on

Change-Id: I07b2924a8a903ccd5def817af6f7e74c8eb91162
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2976056
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2021-08-04 07:49:18 +00:00
Peter Fang
ad3b24e8eb devices: virtio: iommu: implement VIOT table
Implement VIOT table for vIOMMU discovery. This is a preferred method
over VIRTIO_IOMMU_F_TOPOLOGY on x86. [1][2]

Make sure the vIOMMU device already has a valid PCI address during
generate_acpi().

[1]
https://lore.kernel.org/linux-iommu/20200821131540.2801801-1-jean-philippe@linaro.org/
[2] https://jpbrucker.net/virtio-iommu/viot/viot-v9.pdf

BUG=b:181736020
TEST=boot Linux kernel and verify passthru devices work properly with
iommu=on

Change-Id: I717a6d5ba2836420af9cd54b3459776b57bfb68e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2976055
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2021-08-04 07:49:17 +00:00
Peter Fang
c2bba08c34 devices: pci: add generate_acpi() to traits
Add generate_acpi() to traits PciDevice and VirtioDevice to allow each
device to generate its ACPI table elements. The default implementation
is to generate nothing.

BUG=b:181736020
TEST=boot Linux kernel

Change-Id: I9d8d2cb81d571e608a45e7fecb82c3f0922d0898
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2846423
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-04 07:49:15 +00:00
Allen Webb
87b96033b7 sys_util: Add wrappers for fchmod and fchown.
This wrappers allow for permissions and ownership changes that are less
sensitive to time-of-check-time-of-use vulnerabilities.

BUG=None
TEST=CQ passes

Change-Id: I6d5e4809a0b0113f3a95b0395d3cfb82431a3fd8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049330
Auto-Submit: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-04 05:20:21 +00:00
David Staessens
8bf5dcade3 virtio: video: Add support for prepending SPS/PPS to IDR frames.
This CL adds support for the VIRTIO_VIDEO_CONTROL_PREPEND_SPSPPS_TO_IDR
control to the virtio encoder. When this control is enabled SPS and PPS
NAL units are prepended to IDR frames, to improve the resilience of
encoded video streams.

Note: Currently the libvda backend always prepends SPS and PPS NAL
units to IDR frames. This behavior can not be disabled, so when
querying this control it will always be reported as enabled. Trying to
set the control to disabled will result in an error.

BUG=b:161495502
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420_vm

Cq-Depend: chromium:3058721
Change-Id: I2a53b635553cfbdbc483c4d678f124953721dba0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3060098
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
2021-08-04 01:58:10 +00:00
Allen Webb
1919f432c2 sys_util: Add Ord, and PartialOrd so VsockAddr can be used in BTreeMap.
BUG=None
TEST=sirenia builds with the BTreeMap CL.

Change-Id: I8575484574d03e17cd7810f52fef10a31f0bff67
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3068875
Auto-Submit: Allen Webb <allenwebb@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Allen Webb <allenwebb@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-08-03 21:47:14 +00:00
Dmitry Torokhov
a041068353 Log offending port numbers when port IO read or write fails
To assist in analyzing IoIn/IoOut failures let's log offending IO port
numbers in addition to the IO size.

BUG=b:187772788
TEST=Build

Change-Id: I4d254e26d0a227c188a4a2a965e8f7c738f2eafc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3066142
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2021-08-03 21:34:42 +00:00
Woody Chow
5b9d6d02fa audio_streams: Add [async_][write_playback/read_capture]_buffer
and trigger the callback function for the buffer automatically
without relying on Drop. There is no drop guarantee in rust.
Moreover, the callback function is also async in the async code.
We cannot block wait in the callback function.

BUG=b:192912354
TEST=cargo test

Cq-Depend: chromium:3007841
Change-Id: I57902cdb0e083f61349f7124602e957ffa84b3c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3062163
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
2021-08-03 10:09:58 +00:00
Jordan R Abrahams
b785cf2bae seccomp: Mass fstatfs change for glibc for Arm
On trogdor devices, fstatfs64 is not used. Instead, 32bit
fstatfs is used. We need to add both to all 32bit Arm
policy files which were originally determined to be
problematic.

This adds fstsatfs to all 32bit Arm policy files which
were modified for the original glibc security change.

Additionally, this commit sorts the syscalls lexicographically
if the policy file was already sorted.

BUG=chromium:1182687
TEST=CQ of http://crrev.com/c/2910526

Change-Id: I42eb12456625d400ee3422af08d56d648e3f9075
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3066144
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Jordan R Abrahams <ajordanr@google.com>
2021-08-03 08:08:58 +00:00
Dennis Kempin
6a584d6f99 Integrate p9 and cros-fuzz into crosvm build
Updates path and includes the libraries in the test runner.

BUG=b:193243281,b:191509642
TEST=./run_tests passes and executes the new tests

Change-Id: If38126fa6bdf2a0a3dca5a79c6e4d76857617fd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049671
Tested-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-03 02:25:02 +00:00
Dennis Kempin
a5b7caa506 Import cros-fuzz and p9 into crosvm/common
This CL contains a 1:1 copy of the code from the platform2 repo.
The follow-up CL will integrate them with the crosvm build.
History of these files is available at:
267497a7f7/cros-fuzz
267497a7f7/vm_tools/p9

This is a prerequisite for the externalization of crosvm.

BUG=b:191509642,b:193243281
TEST=None. This is dead code.

Change-Id: Ia25d9642f2de1febc83bcd48b4b81fcd805c7c1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3049670
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-08-03 02:25:01 +00:00
David Staessens
636b0fb468 virtio: video: Add support for dynamically changing the peak bitrate.
This CL adds support for dynamically changing the peak bitrate in
addition to the target bitrate. This is done by adapting the
request_encoding_params_change function to use the new Bitrate data
structure, similar to the changes done in the Chrome
VideoEncodeAccelerator.

BUG=b:190336806,b:181514834
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420_vm

Cq-Depend: chromium:3032331
Change-Id: Id0fd3fa2b3d818c8880d4a02a96f84b218b19cef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3033225
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2021-08-03 00:48:45 +00:00
Dennis Kempin
62770b484a Remove trunks proto from crosvm build
The feature was never finished (crbug.com/911799), but adds a
build-time dependency on the trunks proto in platform2.

BUG=b:193267897
TEST=cargo build with and without tpm feature

Change-Id: I7299ba0779bb04ebca6284cfd11873e99500c993
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3043491
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-31 03:01:21 +00:00
Jooyung Han
2e14c730b8 Add create_zero_filler for composite disk images
Previously, gaps(or holes) between component disk images were filled
with "GPT header". Rather than relying on arbitrary filler, it'd be nice
those gaps are filled with zeros.

BUG=b:190503456
TEST=cargo test

Change-Id: Ie7bcec5049ddc6c2e852bac6cd9bffc61f9d79d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3058836
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Commit-Queue: Jooyung Han <jooyung@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Jooyung Han <jooyung@google.com>
2021-07-31 02:26:57 +00:00
Jooyung Han
d7e56bab2e composite disk: no support for multi-file partition
We don't need to support multi-file partition for composite disk images.
This will make the code simpler.

BUG=b:190503456
TEST=cargo test

Change-Id: I9e115ec73ad451ea46fe91c0d0a3c2e85aa1f010
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3058835
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Jooyung Han <jooyung@google.com>
Auto-Submit: Jooyung Han <jooyung@google.com>
2021-07-31 02:26:57 +00:00
Junichi Uekawa
7bea39fef5 crosvm: O_DIRECT for opening disk image.
Introduce a new disk flag o_direct=true, which uses O_DIRECT for open.
Block access and memory buffer needs to be aligned to 512 bytes.

BUG=b:190435784
BUG=b:184204645
TEST=boot tests (boot_test_suspend_resume, boot_test_vm) keep running with o_direct=true.

Change-Id: I17888f8a6ef2a38baba2c17dbb0d7aa18b70dbfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2821112
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-30 06:34:11 +00:00
Federico 'Morg' Pareschi
9d1d7d9d48 devices: virtio: Update fs code to use sync::Mutex
fs/worker.rs and fs/mod.rs were still using the old std::sync::Mutex
version instead of the crosvm-specific wrapper sync::Mutex

BUG=b:179636297
TEST=build crosvm and run shared-dir with virtio-fs

Change-Id: I773a885fd0ef35e25bc7a090f067d8a6f60636da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3058837
Auto-Submit: Morg <morg@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Morg <morg@chromium.org>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-30 06:06:40 +00:00
Vikram Auradkar
ed4bd118bc cros_async: name threads + doc fix
BUG=b:191488633
TEST=cargo test && cargo doc && cargo clippy

Change-Id: I61cfb4b547e7ca280ad1726300fd145617a27d69
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3059870
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
2021-07-30 04:41:36 +00:00
David Staessens
a27e035aa2 virtio: video: Add support for configuring the peak bitrate to encoder.
This CL adds support for the VIRTIO_VIDEO_CONTROL_BITRATE_PEAK control
to the crosvm encoder. This control allows configuring the peak bitrate
used when encoding a video. The peak bitrate is only used when the
bitrate mode is set to VBR (variable bitrate), and is ignored for CBR
(constant bitrate).

BUG=b:190336806,b:181514834
TEST=tast run DUT arc.VideoEncodeAccel.h264_192p_i420

Cq-Depend: chromium:2946469
Change-Id: Ie513b474f48f09a710a68c9f06111e0fc6627aa6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2944321
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Staessens <dstaessens@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2021-07-30 02:10:14 +00:00
Jorge E. Moreira
9e7cd5bbd3 vios_backend: Reduce lock contention in the IO buffer queue
... by not holding locks while data is being copied around, but only
when the buffers are being allocated.

BUG=b:174713663

Change-Id: I558e14422eeff690c09f031f6c5564ee7de21e39
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2994806
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Jorge Moreira Broche <jemoreira@google.com>
Commit-Queue: Jorge Moreira Broche <jemoreira@google.com>
Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-07-29 19:13:41 +00:00