Commit graph

315 commits

Author SHA1 Message Date
Vikram Auradkar
45927eafc7 crash_report: refactor product specific code
BUG=b:286107739
TEST=none

Change-Id: I8aa0dd5335a6d85566a75afc2fc1245380dd6dcd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4605997
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-06-09 23:10:04 +00:00
Vikram Auradkar
e30a511986 anti_tamper: refactor generic code
Moves generic anti-tamper into its own crate under
'/vendor/generic/anti_tamper'

BUG=b:286107739
TEST=none

Change-Id: I47045ce9ffe690340cd1ba749bdb692bbd624f92
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4605893
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-06-09 23:09:35 +00:00
maciek swiech
fac9000051 balloon: use protos for registered events
since the RegisteredEvent model is effectively an external API, switch
to using protobuf as a more formal/stable means of communicating
messages. also introduces exporting the registered_events.proto file as
part of crosvm_control build, alongside the currently existing header
file.

this patch also introduces feature-gating for registered_events and
protos so as not to bring in too many third party dependencies for a
base build.

BUG=b/278117550
TEST=run bzImage locally
TEST=sidecar program available at https://x20.corp.google.com/users/dr/drmasquatch/socket-pinger-proto

Change-Id: I5d91d87f7807effc125352caf5c75eee2593f70d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4521604
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: maciek swiech <drmasquatch@google.com>
2023-05-22 19:28:45 +00:00
Alexandre Courbot
9ae485d979 video: decoder: vaapi: switch to external cros-codecs
Use the version of cros-codecs publishes on crates.io and adapt the code
to be able to use it. This results in a few simplifications as e.g.
frame ordering is guaranteed by cros-codecs and we don't need to handle
it anymore.

BUG=b:262824148
TEST=ffmpeg -codec:v vp9_v4l2m2m -i Big_Buck_Bunny_720_10s_1MB.webm Big_Buck_Bunny-%03d.png
TEST=cargo test --features "video-decoder,vaapi,ffmpeg" -p devices -- --include-ignored test_decode_h264

Change-Id: Ib694afe8206a4d85b307efaaf3f6669dfe4e18bb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4518093
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2023-05-17 00:52:34 +00:00
Dennis Kempin
981f304f84 fuzz: Move fuzzers to standard cargo fuzz location
This simplifies `cargo fuzz` usage. Fuzzers can be built with
`cargo fuzz build` without any other arguments.

BUG=b:279217867
TEST=`cargo fuzz build`

Change-Id: I11b8a8ba4c2b3e2d1a42973699e4d9c3920635b6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4540001
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-05-16 20:43:37 +00:00
Dennis Kempin
92dfea4131 fuzz: Move cros-fuzz into crosvm-fuzz
We no longer need to share cros-fuzz with ChromeOS. So we can
consolidate our fuzzing code and reorganize it to work well
with `cargo fuzz`.

BUG=b:279217867
TEST=cargo +nightly fuzz build --fuzz-dir=crosvm-fuzz -O

Change-Id: I75653961c6cbf251af9e54f894d6f20ea1218b53
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4539922
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-05-16 20:43:37 +00:00
Shintaro Kawamura
94217cc88b swap: make swap/enable not default
"enable" feature in swap crate was set as default to run
unit/integration tests of the crate. https://crrev.com/c/4486546

However missing `default-features = false` at non-root Cargo.toml cause
other crates (e.g. x86_64) installing userfaultfd always.

This makes the swap/enable non-default. CQ still runs unit/integration tests of the swap crate on aarch64 and x86_64.

BUG=b:281935498
TEST=cargo test -p swap --features=swap/enable

Change-Id: I57436c3cb8cbdfac04c3145cc599261b89cf4e0e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4518090
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-05-12 06:15:16 +00:00
Noah Gold
f7095ff46a Upstream the perfetto crate.
This is a step towards upstreaming Perfetto support (adding the
Perfetto Rust wrappers). These wrappers won't compile until we have
the Perfetto source & libraries in place.

BUG=b:277138899
TEST=n/a

Change-Id: Ic9cc86285383b114cecf7cfe574b3e2511d7afeb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4428221
Reviewed-by: Steven Moreland <smoreland@google.com>
Reviewed-by: Morg <morg@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2023-05-11 18:12:36 +00:00
Dennis Kempin
2116c21637 Switch to current cargo resolver
We originally held this back when switching to the 2021 edition of rust
as it was causing issues in downstream projects. If this is still an
issue, I would recommend not merging this change downstream.

BUG=b:223855233
TEST=CQ

Change-Id: I4a3eb99ee34f4495dd42cd0dea0f4864002519c3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4517945
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-05-09 21:17:53 +00:00
Daniel Verkamp
7aacb523e4 crosvm: enable gdb feature on all architectures
Remove the architecture-specific requirements from the gdb config
checks. This enables gdb across every supported target_arch without
having to manually add new architectures to each cfg check.

For the specific case of target_arch = "arm", this patch will newly
enable gdb support. The gdbstub protocol will still send aarch64 state,
matching the guest.

This stubs out enough riscv64 gdb functions and types to make
`cargo build --features=gdb` compile, but gdb support will not be
functional on that architecture without additional work.

Change-Id: I63b079b7a3dca4aec2c13c775c0ccb8850625884
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4506285
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dylan Reid <dgreid@rivosinc.com>
2023-05-04 22:59:01 +00:00
Shintaro Kawamura
8590cdcc8a swap: expose Status interface to all variants
Status does not depend on any swap related feature. Exposing Status to
all variants is easy to implement swap status FFI at crosvm_control.

The new "swap/enable" feature switches the actual vmm-swap functionality
to be compiled. The feature is enabled by default on "swap" crate but
disabled on the root package for test dependency.

Vmm-swap feature is enabled by `--features=swap` flag on cargo build as
before.

swap/src/controller.rs is copied from swap/src/lib.rs.

BUG=b:265386761
TEST=tools/dev_container tools/run_tests2

Change-Id: Ifc2539a62d0f594fd5bbb41623c735ea2621f7b6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4486546
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2023-05-04 12:30:09 +00:00
Dylan Reid
965f99a72a tools: Add riscv platform
Allow running riscv unit tests only. This required filtering out some
workspace projects that can't yet build on riscv because the backing
packages aren't installed. Aside from that and passing the new
`--no-default-features` flag to `run_tests`, this is mostly copy/paste
of aarch64 support.

TEST=./tools/run_tests -p riscv64 --no-default-features
TEST=./tools/presubmit unit_tests

Change-Id: If0f74f1bb6eb42e1fe24ad31f4c1aa06f7822f8c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4500729
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-05-03 16:50:25 +00:00
Daniel Verkamp
a360baa819 Cargo.toml: upgrade protobuf 2.x -> 3.x
system_api bindings have been regenerated with protobuf 3.2; this should
be okay to land before the full ChromeOS system_api migration, since
crosvm always uses its own copy of the bindings rather than the ones
provided by the dev-rust/system_api package.

The protoc-rust crate is replaced with protobuf_codegen in 3.x.

BUG=b:277243607
BUG=b:279834784
TEST=tools/dev_container tools/presubmit

Change-Id: I6aad45ded2639d7506a7238800584bebab196455
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4405309
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-04-28 19:32:01 +00:00
Dylan Reid
38d1242859 Add riscv target to main crosvm build
Allows running crosvm on riscv64 devices.

Tested on a qemu host with `-machine virt,aia=aplic-imsic,aia-guests=4`

Change-Id: I9b369718bcb438f043e3342f1866c56fc4983304
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4460941
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-26 17:29:25 +00:00
Alexandre Courbot
17d3a8d0cf Update argh to 0.1.10
We want support for #[switch] on Option<bool> in order to support
specifying several configuration files. This feature has been merged in
0.1.10.

BUG=b:218223240
TEST=cargo build

Change-Id: I4f1a2474f797907fbd180b0ebe67d87ea7920b46
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4414501
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-04-21 05:21:02 +00:00
Daniel Verkamp
0bea3a3376 Cargo.toml: remove crosvm-direct binary
Remove the extra [[bin]] from Cargo.toml, as it is no longer used by the
chromeos-base/crosvm ebuild.

The "direct" feature is kept for now, since some of the functionality
behind that flag may still be useful (and should be moved to separate
features rather than "direct" eventually).

BUG=b:276993009
TEST=cargo build
TEST=tools/dev_container tools/presubmit

Change-Id: I78269d94913a216ebfb7f22ddc58d9cfdb6a6791
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4436629
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-17 23:54:48 +00:00
Daniel Verkamp
894e7ed13c vhost: only compile on unix platforms
The vhost kernel API is specific to Linux; it doesn't make sense to
build it on Windows.

Change-Id: I3b8f726f74389f2a3ff78eff43b0c4f312382004
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4437030
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-17 23:43:52 +00:00
Zihan Chen
c63777f559 crosvm: Set release profile to use O3
crosvm is built with O3 in cros tree (Thanks Daniel for pointing
it out). So we might as well use O3 in release profile too to make
our benchmark and binary size measurement more useful.

See https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/third_party/chromiumos-overlay/chromeos-base/crosvm/crosvm-9999.ebuild;drc=3ae24448490fa3f25eeff08169729faa58f799ed;l=79
which leads to https://source.chromium.org/chromiumos/chromiumos/codesearch/+/main:src/third_party/chromiumos-overlay/eclass/cros-rust.eclass;drc=064b610be853d370ccce1b2a4ba29a46bc9d89a1;l=524

Change-Id: I02cc3f2a0d9417ebe9f9bd510687a253cc90b8be
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4415369
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-04-11 21:46:11 +00:00
Daniel Verkamp
c87eb5209e Cargo.toml: rearrange gunyah and geniezone features
Move geniezone into the Linux-specific features section (it was
accidentally in the Windows-specific section instead) and alphabetize
the list for consistency.

This affects the generated feature flags documentation at
<https://crosvm.dev/doc/crosvm/#feature-flags>

No functional change.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: If53d2a470a69c35137d3dd2bd0ae159c8583fe9c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4404017
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-05 19:24:47 +00:00
Elliot Berman
ea5fab36a4 devices: irqchip: Implement GunyahIrqChip
Implement GunyahIrqChip.

Cherry-pick notes: Added license header + delete unused imports.

BUG=b:232360323

Change-Id: I11d32599f221b57974f9d942d1aa9f128fc14516
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4404218
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-04-05 18:32:18 +00:00
Elliot Berman
3cfc7c260b Cargo.toml: Enable Gunyah only for all-aarch64
Enable gunyah feature for all-aarch64. all-x86_64 inherits all-aarch64
and Gunyah does not support x86_64, so create a new meta-feature,
all-default to support the common features that need to be enabled in
aarch64 and x86_64.

Cherry-pick notes: This commit now adds the "gunyah" feature and is
moved earlier in the series so that changes later in the series can be
properly tested by presubmits.

BUG=b:232360323

Change-Id: Ibb3b0ad48017c2480498634d766aea162114b385
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4404216
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-04-05 18:32:18 +00:00
Junichi Uekawa
41cecab05d crosvm: Remove cros_asyncv2
We don't have the necessary dependency in Debian.

BUG=b:265082456
TEST=build

Change-Id: Ia6a38b0d9b5ce4e509a88f2b8e0790b605b47175
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4364560
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2023-04-05 02:07:07 +00:00
Junichi Uekawa
d03c99fc0c crosvm: Uprev uuid > 1
Uprev to version available in Debian.

This seem to end up doing uprev to 1.3 now.

BUG=b:265082456
BUG=b:229895468
TEST=build

Change-Id: I550778acb675c9034b9cfcea77f4ae847e2d2ea1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4364559
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-04-04 23:56:13 +00:00
Yi-De Wu
65d98b04f6 aarch64: MTK GenieZone hypervisor enablement as Crosvm backend
To support GenieZone (gz) hypervisor as a crosvm hypervisor backend:
- Implement GenieZone hypervisor
- Implement GenieZone’s irqchip
- Create config and feature for GenieZone
- Probe proper hypervisor backend with naive logic
- Inject virtual interrupts
- Bootup guest VM with linux kernel to shell

We still have other todos:

- Integrate with protected VM and pvmfw
- Support multi-core VM

Fixed bugs:
- Replace gz with geniezone in most cases for clarity
- Replace KVM’s ioctl number with GZVM’s ioctl in bindings

Bug: 264630327
TEST:
$ taskset 10 ./crosvm run --disable-sandbox -m 512 -s s1 \
  --rwroot alpine-rootfs.img -p 'init=/bin/sh rodata=off' \
  --display-window-keyboard Image_515_41_no_numa_20230130 \
  --serial type=stdout,hardware=serial,earlycon \
  --serial type=stdout,hardware=virtio-console,console,stdin

Change-Id: Ia5d92ba5cbb4198ab7f9f2a778da03b2199892cd
Signed-off-by: Ze-yu Wang <ze-yu.wang@mediatek.com>
Signed-off-by: Yi-de Wu <yi-de.wu@mediatek.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4170415
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-03-22 18:04:47 +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
Dennis Kempin
19dc53d9f1 presubmit: Add --features=default build to all platforms
To enable this on windows, make the slirp feature a default.
The feature will be a no-op on non-windows platforms.

BUG=b:266129169
TEST=tools/presubmit all

Change-Id: I7c008686937382c07743457fa737022a3fa97c78
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4303077
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
2023-03-07 18:01:47 +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
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
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
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
Dennis Kempin
3623bc2993 Make libvda-stub the default
libvda is only used on ChromeOS, which compiles with
--no-default-features.

Even though libvda may not be enabled by default, it is still
part of the workspace and will be compiled (and fail without
libvda-stub).

This enables crosvm builds with the default feature set on plain
linux.

BUG=b:266129169
TEST=cargo nextest run --workspace

Change-Id: I521bb5e715852aa6be69484db04e2cf4dbc3684e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4235223
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2023-02-10 01:16:41 +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
Daniel Verkamp
3735b140f4 Cargo.toml: add android-sparse feature
This feature is present in the disk crate, but there was no way to turn
it on from the top-level crosvm Cargo.toml.

BUG=None
TEST=cargo build --features=android-sparse

Fixes: 44762216cf ("disk: Turn Android Sparse format into a feature")
Change-Id: I8cb725598b006cb2c3c4e8fedc45442de4af250c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4167140
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-13 22:48:42 +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
c9f38b428c Cargo.toml: move trace_marker to linux-specific flags
This was grouped under the Windows-specific section, but it is only
relevant for Linux.

BUG=None
TEST=tools/cargo-doc

Change-Id: Ibcff9488a1eb8f13b016771d8eb692c4560b007e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4133832
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-04 18:39:07 +00:00
Daniel Verkamp
3845cb6503 Cargo.toml: add links to some features
Link from the feature descriptions to the corresponding book pages for
more information.

Also clean up a few strings that look better as code blocks.

BUG=None
TEST=tools/cargo-doc

Change-Id: Ibe23cf557a43da3b8a27695ee511d7f642b10a3a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4133830
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-04 01:44:10 +00:00
Daniel Verkamp
ac0fc378a3 Fix remaining Chrome/Chromium OS instances
These should be written as ChromeOS and ChromiumOS (without the space)
to match the updated branding. The copyright headers were already
migrated to the new style (https://crrev.com/c/3894243), but there were
some more instances left over.

BUG=None
TEST=tools/cargo-doc

Change-Id: I8c76aea2eb33b2e370ab71ee9b5cc0a4cfd00585
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4129934
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-03 22:14:30 +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
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
Zihan Chen
03b1653276 tools: Add catapult converter
This tools allow us to convert fuchsiaperf formated benchmark
results to catapult dashboard's HistogramSet format.

BUG=b:257303497
TEST=Generate LGTM result from sample fuchsiaperf file in their doc

Change-Id: Iae7ce36a8444bdb436a6126939f6d50997dedf5e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4084425
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2022-12-13 21:48:49 +00:00
Frederick Mayle
e39dde63eb crosvm: Make document-features dependency optional
The document-features crate doesn't work in Android's build system (it
can't find the Cargo.toml file), so it would be convenient if it could
be easily turned off.

BUG=b:255384162
TEST=presubmit

Change-Id: If1b27c0d3e5783c5c1f9840bd2ccd20cc0f91849
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4062838
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2022-12-01 07:04:56 +00:00
Alexandre Courbot
4cbd1cf16e crosvm: add JSON configuration file support
Add a new `--cfg` command-line parameter, which allows a single (for
now) JSON configuration file to be specified and loaded as the base
configuration for the VM, if the `config-file` feature is enabled (the
default).

Configuration options in the file can be overriden or extended by the
regular command-line arguments. Typically, options that can be specified
only once are overriden, and options that can be specified several times
(like `--block`) are extended, allowing some devices of the same type to
be declared in a configuration file and some more on the command-line.

Due to a limitation in argh, which does not yet allow `Option<bool>`
fields to be used as switches, merging more than a single configuration
file is not reliable so we only support a single configuration file for
now. This has been addressed upstream but not yet in a released version.

Configuration file support for all the options of RunCommand increases
the crosvm binary size compiled with the `chromeos` profile by 250KB.
However, due to the currently limited set of options in the
configuration file, the present CL increases the binary size by just
78KB. Without the `config-file` feature, this CL does not incur any
binary size increase.

Supported parameters as of this commit:

* battery
* block
* executable-path
* initrd
* net
* params
* serial
* socket

BUG=b:218223240
TEST=`cargo run --features config-file -- run --cfg vm.json` boots the
VM with parameters defined in vm.json.

Change-Id: Ibb27556144ee766af81c178e5b94bd5117e102da
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3970368
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-11-17 15:08:54 +00:00
Hikaru Nishida
2b35bf353b swap: add commands for vmm-swap out
Added new crosvm commands "crosvm swap enable" and "crosvm swap status".

swap crate exposes SwapController to control the vmm-swap feature.

When vmm-swap is enabled, all the pages on the GuestMemory are swapped
out to a file and are freed to give a lot of memory back to OS.

design document: go/tanooki-phase1-dd

BUG=b:215093219
TEST=manually tested

Change-Id: Ideb10b0119edd9f47b66c8ac61add21ac08181d4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3871758
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
2022-11-17 02:39:55 +00:00
Shintaro Kawamura
67390a05fb Reland "swap: add userfaultfd wrapper"
origin:
https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3895235

userfaultfd enables applications to handle page faults on designated
memory area.

vmm-swap feature uses userfaultfd to catch page fault event and swap
in the guest memory from the swap file.

design document: go/tanooki-phase1-dd

BUG=b:215093219
TEST=cargo build --features=swap

Change-Id: I36ecfe9be988a4bc451f8edaf2ab48e25c6600f4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4016142
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-11-14 06:14:07 +00:00
Noah Gold
232d47446c proto_build_tools: add crate for proto build tools.
In addition to DRYing out our proto code, we're switching to using
PathBufs to reduce the potential for cross platform errors.

BUG=b:256951877
TEST=builds

Change-Id: Ib7588de231afe67853c099e4f81683731b9439de
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4021590
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2022-11-12 01:02:23 +00:00
Dennis Kempin
38bb5aef4e Revert "Remove crosvm-fuzz from workspace"
This reverts commit e2171ea4b7.

Reason for revert: Breaks crosvm-fuzz builds

Original change's description:
> Remove crosvm-fuzz from workspace
>
> The fuzz binary targets do not compile upstream.
> This allows us to run all unit tests via cargo.
>
> BUG=None
> TEST=cargo test --workspace --lib --bins
>
> Change-Id: I3923c79a8d622824956599b9b8552c7d1a610b70
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4015006
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

Bug: None
Change-Id: Iedc1a8e8335e82cf543650ae811c1e0a83668b76
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4021756
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-11-11 00:55:23 +00:00
Dennis Kempin
b4ffe3d0d5 Add media crates to workspace
They were missing before and would prevent some tests from being run.

BUG=None
TEST=cargo test --workspace --bins --lib

Change-Id: Iec9db80a15d8ddc2f4c83e6b272eae8a99f138d0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4015007
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-11-09 18:39:33 +00:00
Dennis Kempin
e2171ea4b7 Remove crosvm-fuzz from workspace
The fuzz binary targets do not compile upstream.
This allows us to run all unit tests via cargo.

BUG=None
TEST=cargo test --workspace --lib --bins

Change-Id: I3923c79a8d622824956599b9b8552c7d1a610b70
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4015006
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-11-09 18:39:33 +00:00