Commit graph

382 commits

Author SHA1 Message Date
Elliot Berman
9b2ea4f8a6 hypervisor: Allow for hypervisor-specific DT additions
Gunyah hypervisor requires some VM configuration to be described on the
devicetree. Add a trait to VmAArch64 to allow a hypervisor
implementation to provide the needed info.

BUG=b:253416076
Change-Id: I07091518b856add0c1644bf6a857460da7ff2b3b
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4379521
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-03-29 00:52:24 +00:00
Gurchetan Singh
61ee6744f2 rutabaga_gfx: nuke base dependency
The base crate has some nifty abstractions but also
pulls in things like minijail, audio_streams and
various random items.

This prevents true cross-platform interoperatibility,
which requires the ability to upload to crates.io
with relative ease.

This change removes the base crate.  The replacement
strategy is two fold:

- For things like SafeDescriptor which don't have
  adequate solutions on crates.io, just copy it
  internally.  I think SafeDescriptor in particular --
  since it works on bot Windows/Linux should probably
  be made into a separate crate long-term since it is
  generically valuable.  Similarly for the Event and
  WaitContext APIs.  For now, live with the duplication.

- Otherwise, the nix crate does most of the Linux
  specific items.

The cross-domain context type has a lot of dependencies
on Linux sockets / epoll.  This is refactored to look more
like the Fuchsia solution, which uses std::sync::mspc
channels to connect to an utility Wayland FIDL library.

The rest of Rutabaga mostly relies just on SafeDescriptor
and the ability to clone it.  rutabaga_gralloc allows
provides shared memory used via virtwl.

Another thing to call out is zerocopy is now strongly
versioned to the latest stable release on crates.io

I also got rid of #[cfg(feature = "virgl_renderer_next")]
on the renderer server fd, since it was complicating the
refactoring.  SafeDescriptor works everywhere and adding
the #ifdef should be reserved for the lowest-levels of
platform specific code when possible.

Overall, this makes compiling on Fuchsia hosts much
simpler.

BUG=b:273555494
TEST= - run cross_domain context type, see Wayland apps
      - note there is a previous bug in cross domain
        when resizing windows, it occurs before this CL.
        The reason seems to be raciness and can likely be fixed
        gfxstream-like seqno.
      - run gfxstream + virgl on Linux, verify everything works.

Change-Id: I7519f2b8ed0cd57c47980d4e76403057498cf064
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4353700
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-03-27 18:46:22 +00:00
Gurchetan Singh
ce5ff3e75e rutabaga_gfx: add log package
This tracks librust-log-dev, which is at version 0.4.17-3 in the
Debian package tracker.

It may be possible to use another version too.

BUG=b:273555494
TEST=rutabaga_test

Change-Id: Ib0aaca5800f22960dad89b4e138a0dd5fefcb9c2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4353699
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-03-27 18:46:07 +00:00
Daniel Verkamp
3667ece205 Cargo.lock: update minijail bindgen dependency version
crrev.com/c/4363328 updated the minijail version to one that requires a
new bindgen version, but it neglected to update Cargo.lock to match.

BUG=b:274724137
TEST=cargo check

Fixes: 1801f6fd1c ("third_party/minijail: Update to latest main")
Change-Id: I7b513cedf00a131485876b654184b4b91bf89951
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4363333
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-03-23 20:23:52 +00:00
Elie Kheirallah
9d214c1843 hypervisor: Add snapshot to vCPU x86_64
Add snapshot to vCPU for x86 and x86_64 arch.

BUG=b:266515147
BUG=b:232437513
Test=crosvm run && crosvm snapshot take img_name socket

Change-Id: I65d059a7537c713e9ef6c1456a7aeae2b6bc4728
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237759
Auto-Submit: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
2023-03-23 17:15:47 +00:00
Norman Bintang
32ca7e250a devices: virtio: snd: Implement file backend for VirtioSnd
File backend will write audio playback to files. Every PCM playback
stream will have its own file.
Changes:
* Add playback_path and playback_size to virtio::snd::Parameters
* Add new file_backend file in virtio::snd
* Add virtio-snd arg help.

BUG=b:233542268
TEST=run crosvm with --virtio-snd backend=file and call aplay

Change-Id: Iaec01f52292f1181b0137fa3c8d8c2b2b9e7cc49
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4306260
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-03-21 07:46:05 +00:00
Norman Bintang
54f2727231 audio_util: Implement FileStream for AudioStream
FileStream can be used to output audio playback buffer to a file. It
receives a memory mapped file and makes it act as an audio buffer.

BUG=b:233542268
TEST=emerge crosvm

Change-Id: I2b013fe0422db8475145537adf9c36492f52ae26
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4306259
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-03-21 07:46:05 +00:00
Kameron Lutes
6c6966ecfc crosvm_control: Add Build Time C Compilation Check
Adds a build time compilation check for the generated crosvm_control.h

BUG=b:271789981
TEST=CQ, apply crrev/4237140 and observe build failure due to C compile
error

Change-Id: I57867894a975aa0a48f989051bb4243bf97f57e8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4333206
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-03-16 00:01:44 +00:00
Zihan Chen
abd53b6a1f crosvm: Trace seccomp filter usage precisely by filename
Add multiple log points to dump minijail's internal data structure
address, this allowes precise tracking of which minijail seccomp
filter is applied to which process/pid.

TESTED=CROSVM_CARGO_TEST_E2E_WRAPPER_CMD="strace -ff --output=/workspace/stracetest" CROSVM_CARGO_TEST_LOG_LEVEL_DEBUG=1 CROSVM_CARGO_TEST_LOG_FILE=/workspace/logtest.log ./tools/bench boot

BUG=b:258316090

Change-Id: Ibc2b66bf18b8af004bb30fd53523161bc9ca1ec4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4316958
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-03-14 23:18:39 +00:00
Federico 'Morg' Pareschi
8405abf7f5 devices: Add trace points for passthroughfs
This CL adds an initial implementation of trace points for
passthroughfs and also adds an initial stub for tracing our fuse server
implementation too.

BUG=b:261641906
TEST=ran crosvm with virtiofs and saw trace points being hit

Change-Id: I88502f33997db0030c53405b5f9fbed84aabc773
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4110129
Reviewed-by: Christian Blichmann <cblichmann@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Morg <morg@chromium.org>
2023-03-10 02:20:14 +00:00
Vaibhav Nagarnaik
fa557032b4 fix future incompatibilities
* upgrade `mio`to 0.8 to remove its dependency `ntapi`. `ntapi` 0.3 has
  future incompatibility warning.

Test: Compiled.
Change-Id: I59e0689ed526c5ea132669de406d7dde6c86c640
Signed-off-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4318426
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-03-08 21:57:36 +00:00
Maciek Swiech
d4565a3cf3 Revert "crosvm_control: split into inner and outer crates"
This reverts commit 821f544301.

Reason for revert: breaks builds and is not terribly important at the moment

Original change's description:
> crosvm_control: split into inner and outer crates
>
> since the crosvm_control crate is build as a cdylib, the functions are
> not able to be used from other rust code. this patch moves all actual
> implementation into an inner crosvm_control_rust crate, and has the
> outer crosvm_control crate import and expose all of the inner code.
>
> Change-Id: Ib05d5df8bb138680f3e77a8837b1103854c0b316
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4276641
> Commit-Queue: Maciek Swiech <drmasquatch@google.com>
> Reviewed-by: Dennis Kempin <denniskempin@google.com>

Change-Id: I2fb1b8b6337b58d69074e63b5ed81771402e616f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4305342
Auto-Submit: Maciek Swiech <drmasquatch@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-03-02 23:02:52 +00:00
Zihan Chen
9c9fbdc24c e2e_tests: Add strace and log settings to fixture
This allowes fixture to read these settings from env and thus allow
scripts to pass in desired testing configs without requiring a
custom-built rust test harness.
Test command below run in dev container with strace package installed
can produce debug level logs and separate per-process strace results
in designated files.

TEST=CROSVM_CARGO_TEST_E2E_WRAPPER_CMD="strace -ff --output=/workspace/stracetest" CROSVM_CARGO_TEST_LOG_LEVEL_DEBUG=1 CROSVM_CARGO_TEST_LOG_FILE=/workspace/logtest.log ./tools/bench boot

BUG=b:258316090

Change-Id: I5b0eb373802722075242e33027585d702da77e59
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4297485
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-03-02 22:07:33 +00:00
Maciek Swiech
821f544301 crosvm_control: split into inner and outer crates
since the crosvm_control crate is build as a cdylib, the functions are
not able to be used from other rust code. this patch moves all actual
implementation into an inner crosvm_control_rust crate, and has the
outer crosvm_control crate import and expose all of the inner code.

Change-Id: Ib05d5df8bb138680f3e77a8837b1103854c0b316
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4276641
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-03-02 21:07:24 +00:00
Shintaro Kawamura
85a4efdbad swap: use create_sandbox_minijail for the monitor process
The monitor process uses the `jail` crate which devices use to create
sandbox.

The syscalls listed in the seccomp filter policy file is originally
generated from a profile by strace. Also there are additional syscalls
from common_device.policy:

* another variant of syscalls in the profile
  * clone, dup, readlinkat
* the basic set which will be added by minijail compiler anyway.
  * restart_syscall, exit, exit_group, rt_sigreturn
* syscalls appears only on DUT (not workstation).
  * set_robust_list, sigaltstack, rseq

Used `common_device.policy` as a reference for syscalls which require
detailed conditions (e.g. clone, mmap, openat, etc).

This adds seccomp filter policy only for x86_64. The policy files for
other architectures will be added later.

BUG=b:258351526
TEST=manually tested

Change-Id: I3e584449ed9330a57ae1d2bd6c56a7554b6584ef
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4253073
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
2023-03-02 00:42:35 +00:00
Dennis Kempin
b67eaca468 Use custom test harness for tests using fork
forking a process with multiple threads will lead to
undefined behavior. Unfortunately, newer versions of
libtest will spawn multiple threads even when running
a with --test-threads=1.

This change implements a custom, test harness using
libtest-mimic. It mimics the libtest CLI but enforces
a single threaded test process.

BUG=b:270167741
BUG=b:268496046
TEST=tools/run_tests --dut=host

Change-Id: Icef6a1b65bab7f5cd5021c01fbd94487fa0ca5fb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4295157
Reviewed-by: George Burgess <gbiv@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-03-01 21:46:16 +00:00
Zihan Chen
e670159c2e crosvm: Add seccomp_trace feature
Add a minijail's mode of operation where an always-allow seccomp
filter is attached to forked device processes. This facilitates
capturing seccomp filters used by each device process separately.

TESTED=./tools/build_release -- --features seccomp_trace && strace -ff crosvm --log-level debug run <args>

BUG=b:258316090

Change-Id: Ic4d3f5178e6a2dcbd748d101db43574f3224ff78
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4289510
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-03-01 19:18:12 +00:00
Daniel Verkamp
732b422bdc gpu_display: find wayland-scanner with which in build.rs
This allows us to print a more useful error message if the
wayland-scanner tool is not present.

BUG=None
TEST=cargo build # with and without wayland-scanner present

Change-Id: I8909e064621cb4d71bc8ec96d76df8a2b4c4fc88
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4294676
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-02-27 21:18:21 +00:00
Zihan Chen
2524a185b6 e2e_tests: Restructure for initial benchmark support
- Restructured to share fixture between tests and benches
- Add bench script to run benchmark target

BUG=b:257303497
BUG=b:258316090
TEST=cargo clean && ./tools/build_release && ./tools/bench boot

Change-Id: I0ea3295839889e570032e03eec033d99b7b8e553
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4064114
Commit-Queue: Zihan Chen <zihanchen@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-02-23 22:11:48 +00:00
Noah Gold
83f83f172e Move IRQ handling to its own thread.
What is changing in this CL?
* IRQ control tubes (aka MSI tubes used by devices to register new
  interrupts) and IRQ handling is moving out of run_control.
* IRQ handling is moving to its own dedicated thread.
* To support this, SysAllocator is moving behind an Arc<Mutex<..>>. We
  already do this on Windows without ill effect.

Why are we making these changes?
* IRQ handling is about to get more complex due to the flushing
  operations needed by snapshotting. Attempting this with the IRQ
  processing coupled to run_control would be extremely messy.
* run_control is massive. Moving code out of it will help improve readability.
* Though most interrupts on KVM avoid this loop as a hot path, having it
  on a dedicated thread seems better than sharing it with everything
  else that runs on the run_control thread.
* On Windows, we moved IRQ handling out of run_control from necessity
  (it has to be delegated to a thread pool). By doing something similar
  on unix, our overall technique for IRQ handling no longer diverges
  between platforms.

BUG=b:269652166
BUG=b:266514201
TEST=ran the example vm & verified the kernel could boot.

Change-Id: I02b8bf60666cd67b76388cb8ccd04a7c21f2003c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4262525
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Steven Moreland <smoreland@google.com>
2023-02-23 01:15:15 +00:00
Shintaro Kawamura
8cdbfb3f02 jail: create jail crate from jail_helpers.rs
Creates the jail create and move all policy files and helper methods to
the crate to make jail helpers available to outside of the main crate
(i.e. swap crate).

This also move devices::Minijail and JailConfig to jail crate.

BUG=b:258351526
TEST=cargo build

Change-Id: If9a148bdb3b18f8b746875d47d1077fb17707c18
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4230456
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2023-02-14 00:24:55 +00:00
Zihan Chen
30f58a81aa crosvm: Partially convert DataInit to zerocopy (6/n)
This CL removed many uses of DataInit in devices. Some paddings
are manually added/fixed to allow AsBytes to derive without ABI
changes.

TESTED=CQ

BUG=b:204409584

Change-Id: I1f8c2d5304fc8e685cc3e5166c73481f6a3f78f7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4235224
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-02-10 01:52:24 +00:00
Zihan Chen
f5a0980efa vfio_sys: Update bindgen to derive zerocopy
TEST=CQ

BUG=b:204409584

Change-Id: I7ba94cfc1f61b9ef1ed13c1c1d775127ea18649e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4234070
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-02-09 23:07:28 +00:00
Zihan Chen
7cfc97d736 virtio_sys: Update bindgen to derive zerocopy
With uprev-ed bindgen, we can now customize derive directly.

TEST=CQ

BUG=b:204409584

Change-Id: Iba96cdb8329e9254249b247af55e11974620087c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4234067
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-09 22:59:10 +00:00
Shintaro Kawamura
832b1f0bef swap: create userfaultfd from /dev/userfaultfd
userfaultfd(2) syscall requires CAP_SYS_PTRACE of root user namespace.
For better permission control /dev/userfaultfd was introduced from Linux
6.1. Since ARCVM runs inside a sandbox user namespace and enabling
/proc/sys/vm/unprivileged_userfaultfd opens up userfaultfd to the entire
system, crosvm for ARCVM has to use /dev/userfaultfd to create a
userfaultfd.

For systems which do not have /dev/userfaultfd, the Factory falls back
to userfaultfd(2).

BUG=b:268145007
BUG=b:266642532
TEST=manual test

Change-Id: I44b657877093d2a75627432619c1233b7ac2464e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4196763
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-02-08 04:18:36 +00:00
Zihan Chen
a110d39ae6 crosvm: Partially convert DataInit to zerocopy (2/n)
TESTED=CQ

BUG=b:204409584

Change-Id: I659e31d229b70ae8e98426c253730b1e46b55adf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4219972
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-02-07 23:08:23 +00:00
Frederick Mayle
19f4b1243c devices: snapshot and restore for guest memory
`crosvm snapshot take ...` will write the contents of guest memory to a
file and `crosvm restore apply ...` will read that file to overwrite
guest memory.

To start with, the file is chosen by adding a ".mem" extension to the
snapshot file path. We should consider a better approach in the future,
maybe put them both in a tar file or have the user supply a directory
instead of a file path.

BUG=b:266514791

Change-Id: Ic05f94223fb74674bd57dcd2f848055b31eb5fdc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4215313
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-02-06 22:44:17 +00:00
Zihan Chen
8a7550c40a crosvm: Partially convert DataInit to zerocopy (1/n)
Thie effort is splitted into multiple CLs, to reduce change size
and also make bisecing breakages easier.

TESTED=CQ only

BUG=b:204409584

Change-Id: Ie90f171bd5f74b732df3129e94733f3b34621092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4210751
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-02 19:28:57 +00:00
Gurchetan Singh
22a2dce38a crosvm: revbump for rutabaga_gfx
- Revbum to 0.1.1, 0.1.0-{anything} causes data_model
  0.1.0 to be downloaded since it's a higher release number.

- Also, add include LICENSE in the package includes for
  data_model.

- Also, use the correct version when not using path in rutabaga_gfx.

BUG=b:173630595
TEST=compile

Change-Id: I68af3eb1fa4ab89a77968f784e388b10c94d8b97
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4209693
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-02-01 23:22:03 +00:00
Shintaro Kawamura
b5a9833d97 swap: send userfaultfd via Tube on device process fork
This implements the equivalent logic on crosvm as
UFFD_FEATURE_EVENT_FORK. When each device process forks, the ProxyDevice
creates userfaultfd and send it to the monitor process by
SwapController::on_process_forked().

Crosvm does not have any child processes which may access the guest
memory except device processes as of now. Crosvm forks
virgl_render_server, but the mmap is not preserved in the process on
execve(2) since it is a different binary. Also no device process forks
grandchild processes according to the seccomp policy.

We actually can't use UFFD_FEATURE_EVENT_FORK because the feature does
not support non-root user namespace (go/uffd-fork-user-ns) and ARCVM
runs in a non-root user namespace.

This also adds syscalls to seccomp policies for devices to allow the
processes to create and setup a userfaultfd.

BUG=b:266641923
TEST=manually tested

Change-Id: Ide3088e1e95ae3c8259e3f4324124b3376e760b7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4194228
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-02-01 00:47:52 +00:00
Dennis Kempin
210a0a01a3 Enable parallel execution of plugin and e2e tests
In cargo nextest, tests will be executed in a separate process for
each test.
This means we cannot use in-process locks or counters to ensure
tests will not conflict with each other.

BUG=b:261600801
TEST=CQ

Change-Id: Ifb5d16295fa2ec76a4036222961769dfaea18a32
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4190035
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-01-26 20:38:57 +00:00
Shintaro Kawamura
f05ef071ae swap: move guest memory to staging memory on multi thread
Enabling vmm-swap copies all the guest memory to the staging memory
while freezing whole the crosvm. Reducing the latency of it is
important.

The most time consuming part of enabing vmm-swap is pure memory copy
which easily can be executed on the multi-thread.

BUG=b:263830401
TEST=cargo test -p swap

Change-Id: I307ad1c459158113cc654e7ba1541381a38b65bb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4142083
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-01-23 04:52:02 +00:00
Dennis Kempin
a6e7d6f139 Enable compilation of fuzzing targets
Adds a fall-back to cros_fuzz when compiled without
fuzzing enabled that will just produce a main fn entrypoint
with the fuzzing code.
This allows the fuzzing code to be compiled, but won't produce
functional fuzzing binaries.

BUG=b:265829867
FIXES=b:244631591
TEST=crosvm CQ
cargo +nightly fuzz run --fuzz-dir crosvm-fuzz --features upstream-fuzz crosvm_block_fuzzer

Change-Id: Ib2602aab5c5373cb2a71dca0d8419640a00c6725
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4167143
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
2023-01-17 23:18:22 +00:00
Gurchetan Singh
780c2727f7 rutabaga_gfx: build for Fuchsia
- Don't build cross-domain -- uses too many Unix like features.
  Once we have a good idea on which abstractions display integration
  should use, we can start incrementingly re-enabling it.

- Stub out common base things for now.  First we probably want to
  fill out the stub before we determining a long-term soluton.

BUG=b:173630595
TEST=build rutabaga using Fuchsia SDK

(context: https://fxbug.dev/114169)

Change-Id: I21db796f59ba7dbf1101a50ae0be482a32e69cc8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4081627
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-01-14 02:04:57 +00:00
Daniel Verkamp
04e36b573d aarch64: switch rng seed generation to rand crate
Replace the OS-specific /dev/urandom with the cross-platform rand crate.

BUG=b:265031416
TEST=Boot aarch64 Linux kernel on lazor

Change-Id: I6eb3ab4c5b45bc8296ade92b5b5e30da78d039d2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3855345
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-01-13 23:43:44 +00:00
Daniel Verkamp
c116518b50 aarch64: clean up unix-only dependencies
Drop a few unused kvm dependencies and only require minijail on unix
platforms.

The aarch64 platform won't be functional on Windows yet, but it's at
least possible to drop it from the WIN64_DISABLED_CRATES list.

BUG=None
TEST=tools/dev_container tools/run_tests --platform=mingw64
TEST=tools/dev_container tools/run_tests --platform=aarch64

Change-Id: If48b935afe1295820b6d78cfde3e8634a3e397db
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4167144
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-01-13 23:25:19 +00:00
Gurchetan Singh
32ec615426 crosvm: pre-release alpha for data_model
data_model is probably going away in the future, but
until we can release it as pre-release alpha for internal
efforts.

(context: https://fxbug.dev/114169)

BUG=b:173630595
TEST=compile

Change-Id: Ie13ec3ab9083d315c78a035b532132296a8fb651
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4082333
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-01-13 17:23:23 +00:00
Gurchetan Singh
641ac8a26a rutabaga_gfx: match Fuchsia releases of various crates
BUG=b:173630595
TEST=compile

Change-Id: Ia8c34e30059a8308260a8a2682a96504487c32a4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4151813
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-01-13 17:13:39 +00:00
Daniel Verkamp
8811136ed7 third_party/minijail: update to latest main
Update minijail submodule to commit 4b0a832 ("rust: update bindgen
dependency to 0.60").

BUG=None
TEST=tools/dev_container tools/presubmit --all

Change-Id: I3312ae173dda92a7dd5cf74ee6f40be3918dbd87
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4133824
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-12 22:07:31 +00:00
Daniel Verkamp
77f645b924 Cargo: update cbindgen and argh
This avoids duplicate versions of clap in the upcoming minijail update.

BUG=None
TEST=tools/presubmit --all

Change-Id: I61a5ee4268dff53b71b2a1f2140b2d00c0e269ba
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4133839
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-01-12 22:05:11 +00:00
Junichi Uekawa
e63cd8e8cb Revert "argument: Use terminal_size crate for getting terminal size."
This reverts commit 3c9351b446.

We no longer use argument.

BUG=b:265082456
TEST=build

Change-Id: I58f6b2807f7abd37b212d6e961667b035bb8061b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4157753
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2023-01-12 21:19:50 +00:00
Daniel Verkamp
5bedfa3408 x86_64: add SETUP_RNG_SEED setup_data entry
This provides the kernel with an early source of entropy for its random
number generator.

The kernel supports for this was added in commit 68b8e9713c8e
("x86/setup: Use rng seeds from setup_data"):
<https://lore.kernel.org/all/20220710172921.51545-1-Jason@zx2c4.com/>

Earlier kernels will ignore the unknown setup_data entry.

BUG=b:265031416
TEST=Boot x86-64 Linux bzImage with added printk in rng seed init

Change-Id: I627aa8663bd61b04ca311d4d095e1c121fda8543
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3855344
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2023-01-12 19:28:35 +00:00
Alexandre Courbot
fd699f1277 media: cros-codecs: remove dependency on downcast_rs
We only use this for testing, and this can be replaced at low cost by a
method returning a &dyn Any and having the tests perform the cast on it.
Since downcast_rs gets in the way of some of the refactoring we want to
do, let's remove it.

BUG=b:214478588
TEST=cargo test --features vaapi -p cros-codecs

Change-Id: I343e0a8e0f219f6bcf3cbc5efac82a1ed999a9a0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4123651
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-01-10 03:20:10 +00:00
Shintaro Kawamura
0ee28131a2 swap: add helpers for pagesize
Using the cached page size shift has several performance benefits listed
at the comment of the file.

BUG=b:260543132
TEST=cargo test -p swap

Change-Id: Ic7a19135b7a2e29c032c73fa7dca1d853cdb5e48
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4125177
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Shin Kawamura <kawasin@google.com>
2023-01-10 03:10:00 +00:00
Alexandre Courbot
92bc8f9697 media: libva: use log crate for logging
Use the log crate instead of base for logging. This resolves to the
same, and allows us to remove the dependency to base and to make this
crate an independent project.

BUG=b:214478588
TEST=libva decoder can successfully be used from a Linux guest.

Change-Id: I795f1661704b0985b4e11966d204486579bb0d59
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4111638
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.corp-partner.google.com>
2023-01-06 06:30:05 +00:00
Daniel Verkamp
9e2494f7e0 devices: serial: implement out_timestamp for all platforms
This feature has nothing specific to Windows in its implementation, so
pull it up to the portable part of the Serial device.

The unit test is slightly modified to avoid the need for the regex
crate. This was the only use of regex in devices, so it can be dropped
from Cargo.toml.

BUG=None
TEST=cargo test -p devices serial
TEST=tools/run_tests --platform=mingw64

Change-Id: I3073e90d71bda3c9f6da1df3a3b657e62e087302
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4126251
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-04 06:21:02 +00:00
Daniel Verkamp
a8991bf251 power_monitor: switch to proto_build_tools
BUG=b:256951877
TEST=cargo build
TEST=cargo build --features=power-monitor-powerd
TEST=emerge-brya crosvm

Change-Id: I7e60531eb8c67b967a7935098245fa6006fc252b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4122806
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-03 22:22:11 +00:00
Federico 'Morg' Pareschi
912b70b741 cros_trace: Add initial trace_marker backend
This CL adds a new backend for the cros_tracing crate. This backend can
be enabled by building crosvm with the trace_marker feature enabled.
When the feature is not enabled, no extra overhead incurs as the default
NOOP cros_tracing crate will be compiled in instead.

BUG=b:259501910
TEST=compiled and ran crosvm with and without `--features trace_marker`

Change-Id: Ia4b929b042712a458b7d54c0362d6fda90db9e9f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4075413
Reviewed-by: Christian Blichmann <cblichmann@google.com>
Auto-Submit: Morg <morg@chromium.org>
Commit-Queue: Morg <morg@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-12-23 06:21:24 +00:00
Alexandre Courbot
1a2d0fb8f1 media: libva: remove udev dependency and make DRM device opening more flexible
Currently the only way to open a DRM device for libva is to scan the
list of DRM render nodes using udev. This works nicely for the general
case, but requires a few extra ioctls that are not currently added in
the video device process seccomp allowlist so we would like to get rid
of it.

One can also argue that how to detect the DRM device should be left to
the application, so this CL allows users to explicitly specify which DRM
device they want to open. As a helper, it also adds an iterator over
standard DRM render nodes locations to provide similar functionality
without requiring extra ioctls.

BUG=b:262824148
TEST=ARCVM can start and create a VAAPI-backed video device without
triggering seccomp policy failures.

Change-Id: I241c4834361ec1e8455a4307093850a7b3cef276
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4112728
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Almeida <daniel.almeida@collabora.corp-partner.google.com>
2022-12-22 03:07:55 +00:00
Frederick Mayle
5a1ec7eb29 crosvm: remove unused dev dep on "prebuilts"
BUG=b:261486161

Change-Id: I20bcf361dd48580f3f43b31fe023efe81beee32b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4081628
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-12-13 23:36:18 +00:00