Commit graph

6351 commits

Author SHA1 Message Date
Dennis Kempin
e577c91efc dev_container: Always run as root inside container
Since we default to podman, we can get rid of the _user container and
run as root inside the container, which greatly simplifies the tooling.

This also allows us to provide a single, default devcontainer.json
for local development as well as codespaces.

podman can be used with this devcontainer.json as well, e.g. in
VSCode by setting:

"dev.containers.dockerPath": "podman"

The with_kvm/devcontainer.json can be used to add access to kvm, which
may not be available on all machines. So it's an optional config.

BUG=b:273529620
TEST=Open with devcontainer in VSCode with both docker and podman,
run `presubmit --no-delta`
TEST=tools/dev_container tools/presubmit --no-delta

Change-Id: I10e04898a0e1adb6e4939f6f2e0259dc9b9aa62d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4419666
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-04-25 21:33:42 +00:00
Lepton Wu
b53382b3d6 Revert "devices: Add some log for debugging purpose."
This reverts commit 1262d0a735.

Reason for revert: Reduce log spam. Change to better version.

Original change's description:
> devices: Add some log for debugging purpose.
>
> This will be reverted after we collected some samples from production.
>
> BUG=b:183540186
> TEST=emerge-$BOARD crosvm
>
> Change-Id: Iae849cb63624babe53872e949f2cfad31a3a1d50
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4368978
> Commit-Queue: Lepton Wu <lepton@chromium.org>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

BUG=b:183540186
TEST=emerge-$BOARD crosvm

Change-Id: Ia8140b3fff8c66f904902a3501c13129e6f0f81c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4476584
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Auto-Submit: Lepton Wu <lepton@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-25 19:33:50 +00:00
Gurchetan Singh
d18ff41fad rutabaga_gfx: nuke unnecessary gfxstream flags
gfxstream has transitioned to simpler ways to configure the renderer,
use them.

BUG=278138335
TEST=launch_cvd

Change-Id: If0918495c2683cd2d99ed5c49c6bf01dd2edfe5f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4470287
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-04-25 17:32:51 +00:00
Alexandre Courbot
70715a0828 crosvm: cmdline: allow cfg to be used in configuration files
Allow the `cfg` field of RunCommand to be used in configuration files,
providing a mechanism for configuration inclusion.

Configurations are merged in the following order: first the included
files by order of specification (recursively), then the parent file,
then finally the other command-line arguments.

BUG=b:218223240
TEST=booted a VM with a configuration file that included another one and
confirmed both settings were applied.

Change-Id: I0c1e1b12b7c329510d450069e2e9de5b52af7734
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4414504
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2023-04-25 06:30:48 +00:00
Dylan Reid
b5ddb52d8a kvm: Add some riscv cfg guards
Some features present on aarch64 and x86 aren't yet on riscv, add
conditional compile checks.

Change-Id: Ie29e0b7b78af1cb43c04fa1e22c48645c2de8386
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4460934
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-25 00:13:57 +00:00
Dylan Reid
94f82931a4 kvm_sys: initial riscv64 bindings
Add initial KVM bindings generated from a 6.2 tree with the AIA patches
applied.
See the riscv_kvm_aia_v1 branch here: https://github.com/avpatel/linux
The AIA changes should land soon upstream, but pulling them in early
won't hurt other arches and will allow riscv to get started.

Change-Id: I9e20c968e6c044100bc6ec1b2fb5f441f0276f77
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4460933
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-25 00:13:57 +00:00
Dylan Reid
095e8ef207 rutabaga_gfx: Re-add supported arch checks
Later commits add basic support for riscv64 builds. This commit re-adds
the checks for compilation of debug output that were present before
aarch64 was ready. This allows unsupported architectures to build, even
if they don't have graphics support yet.

Change-Id: I42f2aadfed709378173ff6a6414c2896cc685baf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4460932
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-24 23:57:40 +00:00
Dylan Reid
79b959f6cf kvm_sys: Remove KVM_SET_MEMORY_REGION
This ioctl has been long deprecated and is removed from 6.2+ kernels.
It's not used by crosvm so this change should have no affect.

Change-Id: Ieb1b7c1772643d221356ca1ecb8f6a32095febba
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4460931
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-24 23:20:41 +00:00
recipe-roller
eec6fffdb9 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools, recipe_engine) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8782895181033062113

depot_tools:
183769121f~..7a0fe8bf3cf3f51531827e5c02f7b7aff27e3937
  1837691 (iannucci@chromium.org)
      [lucicfg] Roll out lucicfg 1.39.5
  407e5e7 (brucedawson@chromium.org)
      Show error on Fixes: and suggest Fixed:
  34f62b4 (sokcevic@chromium.org)
      Run post submit hooks on vpython3 if vpython is unavailable
  48fcabe (jwata@google.com)
      [autosiso] suggest using siso command direclty for non build co...
  dec6fdd (yoshiki@chromium.org)
      Revert "[lucicfg] Roll out lucicfg 1.39.5"
  b5cec8c (machenbach@chromium.org)
      Fix Python2 fallback in git-cl post-upload hooks
  7a0fe8b (bentekkie@google.com)
      Move reclient cache dir to gclient root to avoid wipeout on gn...

recipe_engine:
8389d65c78
  8389d65 (flowerhack@google.com)
      [docs] Update incorrect docstring.

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: I9bc9497c68e8b7eef731ab8f79440906c427d373
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4470850
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2023-04-24 22:44:23 +00:00
Daniel Verkamp
e7c26c37ed p9: account for header in maximum message size
The previous maximum size was 64K minus 1 byte; this also did not leave
room for the request/response header, so the actual maximum transfer
size in a single request was slightly smaller.

Use 64K + 24 bytes, since this matches the P9_IOHDRSZ subtraction used
by the Linux 9p client to calculate the maximum I/O size.

BUG=b:265610073
TEST=strace 9s on host and verify larger read()/write() syscalls

Change-Id: Ia606222d3c52a7a6e3f6cfca1a9fcbd78e223855
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4455812
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-24 19:25:36 +00:00
Daniel Verkamp
de92350a06 p9: report iounit as 0 in create/open
The iounit value is meant to be an upper limit on the size of each I/O
sent by the client: <https://9p.io/magic/man2html/2/iounit>

Previously, we used the stat() st_blksize value for iounit; this caused
the Linux 9p client to split up every read/write request into 4096-byte
chunks in the usual case of an ext4 host filesystem, which causes very
low performance.

Report iounit=0 instead, which will allow the client to send Tread and
Twrite requests up to the negotiated msize (maximum message size).

BUG=b:265610073
TEST=strace 9s on host and verify larger read()/write() syscalls

Change-Id: I86341998f440ac1c567da7d8fc6e740189ccb44a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4455811
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-04-24 19:22:05 +00:00
recipe-roller
6ec92bb2f5 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools, recipe_engine) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8782910281399949041

depot_tools:
59ebbc12eb~..2d1c655c2cefe38bfbdeb26b8937600ed1eb30d9
  59ebbc1 (chanli@chromium.org)
      [depot_tools] Roll led
  9e36ef6 (bentekkie@google.com)
      Add convenience wrapper for reclientreport for autoninja users
  54762c2 (sokcevic@chromium.org)
      Handle 401 from gsutil
  e4ff80f (lokeric@google.com)
      Update version of reclient
  fd9cea7 (jojwang@google.com)
      Use --upstream when calling bot_update (passed to gclient sync).
  af20d7c (chanli@chromium.org)
      [depot_tools] roll bb
  607284d (jwata@google.com)
      [siso] add autosiso wrappers
  6b62f42 (bentekkie@google.com)
      Fix reclientreport after functions moved to reclient_helper
  2d1c655 (arielzhang@google.com)
      Add CL description getter

recipe_engine:
618bc26448~..5a794c03981b2750ddc6a76c80e303832eae0a93
  618bc26 (yiwzhang@google.com)
      change the package and version for legacy copyright tricium fun...
  f12826f (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 8221a7a30ba2 to 265d6513a697
  1548506 (ddoman@chromium.org)
      [recipes-py] remove api.resultdb.get_test_result_history()
  d3d4e72 (ddoman@chromium.org)
      [recipes-py] roll recipe_proto
  2239570 (iannucci@chromium.org)
      Adjust racy test in run_test.py
  162ea7d (yiwzhang@google.com)
      use simple tricium functions built by builder
  114bdbd (yiwzhang@google.com)
      use the version defined in tricium analyzer instead of live
  6ab407d (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 2293629b4919 to 56489f37e8ef
  5a794c0 (yiwzhang@google.com)
      use tricium spellchecker generated by the builder

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: I8b9626045dc3ba40457106aca84bf34130683dc6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4469107
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2023-04-24 18:49:06 +00:00
recipe-roller
5749ce1dd2 Roll recipe dependencies (nontrivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8783803038271843633

Please review the expectation changes, and LGTM+CQ.

depot_tools:
e718a91487~..97dadd025f541f67af48417cc12ebdc00c1ad29c
  e718a91 (meiring@google.com)
      [ResultDB] Roll RDB CLI.
  3ca8d0d (ukai@google.com)
      add siso wrapper
  0418255 (bpastene@chromium.org)
      Don't put a timeout on 'CreateChange' gerrit rest calls
  4a22431 (jojwang@google.com)
      Use shutil.copytree instead for migration script instead.
  9a285c2 (sokcevic@chromium.org)
      Fix infra_to_superproject for Linux
  97dadd0 (bpastene@chromium.org)
      Apply the gerrit REST timeout to only 'GetChanges' calls

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: I8409f8a06fffb8fc01665069eb86741246ec7d52
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4428224
Auto-Submit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-04-24 18:18:44 +00:00
Keiichi Watanabe
4665feed50 OWNERS: Add takayas@ to OWNERS
BUG=none
TEST=CQ

Change-Id: I3a943a3e1c5f7dddb76a10ce49b83faebacdf566
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4457834
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2023-04-24 11:15:25 +00:00
Gurchetan Singh
3f22365fec rutabaga_gfx: consistent stream_renderer_* API
gfxstream has transitioned to consistent APIs and a simpler
fence API.  Use it.

BUG=b:278138335
TEST=launch_cvd

Change-Id: I91a55021b79c65e057fca5891e64c023ba5cab0b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4428537
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-04-21 22:28:22 +00:00
Noah Gold
31ee64ebee vm_control: refresh Irqchip Event tokens on restore.
When we restore a snapshot, we need to refresh the set of Events that
the IRQ handler thread is listening on, otherwise it won't forward IRQs
from the restored/re-created events.

BUG=b:277651574
TEST=tools/dev-container e2e_tests/run

Change-Id: Icd61112c23f063af0f6f217efe2b3359f884e351
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4416558
Reviewed-by: Steven Moreland <smoreland@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
2023-04-21 18:18:12 +00:00
Alexandre Courbot
23272fca8e crosvm: cmdline: allow to use the --cfg argument several times
Now that RunCommands can be merged several times without ambiguity,
allow the `--cfg` argument to be used several times, allowing to augment
a base configuration with others. Configurations are merged in their
order or specification, with the other command-line arguments being
merged last.

BUG=b:218223240
TEST=added test passes, booted a VM while specifying `--cfg` several
times.

Change-Id: I94d4f02e403db0203a2757e78a5932805c6d8387
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4414503
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2023-04-21 05:30:22 +00:00
Alexandre Courbot
b5fee4bf60 crosvm: cmdline: convert bools to Option<bool> in RunCommand
We recently enabled configuration files with the limitation that only
one file could be specified, and configuration files cannot include
further files. This limitation was due to the fact that the argh crate
could not handle Option<bool> as switches, which forced us to use bool,
which cannot be merged unambiguously more than once.

argh 0.1.10 now allows to use Option<bool> for switches, which will
allow us to lift these limitations. Start by converting all bools in
RunCommand into Option<bool>, and mandating that all members of
RunCommand are either Option or Vec. Following CLs will implement the
features that doing so enables.

BUG=b:218223240
TEST=presubmit

Change-Id: Ica19c94b9509aec7145a6af954d3ebe04a73bc3d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4414502
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-04-21 05:21:29 +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
Elie Kheirallah
ea6eb3adf4 docs: book: docs update and improvement
Add Podman as an option in building crosvm.
Have `Example Usage` point to `Custom Kernel/Rootfs` for preparing a
custom kernel/rootfs, instead of building crosvm.

BUG=N/A
TEST=mdbook build && check the html page

Change-Id: I920526c01140439c416e929d4711ae996bb0831e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4455448
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Elie Kheirallah <khei@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-04-20 22:04:37 +00:00
Daniel Verkamp
ab668edb0d devices: virtio-pci: defer ioevent registration until activate
The virtio-pci device uses ioevents to monitor the notification region
of its BAR for guest-initiated kicks. This is not necessary until the
queues are actually started, so we can remove the ioevents() function
and instead use the existing VmMemory requests to add and remove the
ioevents when the device is activated or stopped/reset.

This avoids the need to remove and re-add the ioevents for the queues
during PCI device initialiation, where the guest may repeatedly disable
and re-enable memory decode.

BUG=b:278130202
TEST=Boot Crostini and ARCVM on x86_64 and aarch64
TEST=tools/dev_container tools/presubmit

Change-Id: I22e0b5a84c8cc9c4f60807624610dbbcabf982cc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4425869
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Ningyuan Wang <ningyuan@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-20 20:23:32 +00:00
Pierre Labatut
67b36de49a Also build rutabaga as a ststic library.
This is useful to create monolithic portable binaries.

Change-Id: I7de6b20fbc5ab85f588cd2711d7e99d0183d9f15
Bug: b/276425028
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4450988
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2023-04-20 17:22:38 +00:00
Andrew Walbran
fc8bb6efbf aarch64: Merge adjacent regions in FDT memory node.
BUG=b:244553205
TEST=Patched into AOSP and ran some VMs.

Change-Id: I95710fdb264a3bd1e8e69ed6dfad77bbc05b3043
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4440589
Reviewed-by: Jiyong Park <jiyong@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Pierre-Clément Tosi <ptosi@google.com>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2023-04-20 10:23:20 +00:00
Daniel Verkamp
03c4671233 infra/recipes: clean up leftover crosvm_direct support
Deprecate the crosvm_direct field in build_linux.proto and remove the
code that used it in build_linux.py.

BUG=b:276993009

Change-Id: I1c48064391f3201ad6e27bf9dbfe33e705477672
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4437033
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
2023-04-19 22:57:31 +00:00
Daniel Verkamp
2ed4a856c7 rutabaga_gfx: remove unnecessary casts
Fixes clippy warnings in Rust 1.68.

BUG=b:276487055
TEST=tools/clippy # with rust 1.68

Change-Id: I6f6d0e85bcf6489ca321d0ca47c431ed33aadab5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4391109
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-19 20:35:49 +00:00
Frederick Mayle
91d4d643ed cros_async: rename TimerAsync::next_val to TimerAsync::wait
Change-Id: Ibc3c4ee9584062ed77d60c947751d3a83c2fc6ee
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4409941
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-04-19 08:44:15 +00:00
Frederick Mayle
a3750e1c07 cros_async: return () from IoSource::wait_for_handle and Timer::next_val
wait_for_handle always returned 0.

Timer::next_val's return wasn't used and its meaning was platform
dependent.

Change-Id: I2278859c19505398c3dd01b90e69e20894c38e25
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4409940
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-04-19 08:44:15 +00:00
Frederick Mayle
e6c584f08d cros_async: trim IoSource API
`wait_for_handle` only makes sense on Windows.

`read_u64` can be implemented in terms of the other read methods. We now
have to allocate a `Vec` which shouldn't technically be needed for the
epoll backend. We do this for all other kinds of IO and timers/events
are generally low throughput, so expect the performance loss won't be
noticable.

Change-Id: I1c1f1d5d1fc84073b940bc71425fe150196c4441
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4405314
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-04-19 08:44:15 +00:00
Keiichi Watanabe
b7f68c5351 devices: fs: passthrough: Use time-expiring cache for casefolded files
If a guest wants to lookup() a file on virtiofs with ascii_casefold
enabled, ascii_casefold_lookup() in PassthroughFs collect file names in
a directory by calling getdent64() repeatedly. This operation is
expensive especially when many files are contained in the directory.
To improve performance of this operation, this CL add a cache for
dentries, will be invalidated after a certain time.
This cache is especially useful when the guest lookup() files repeatedly
in a directory containing many files.

Here is the results of "vm.ManyFiles.virtiofs_casefold" with and without
this CL. We observed significant improvements on create() and nagative
lookup() against huge number of files.

(millisecond)   | current | w/ CL
-----------------------------------
create          |  223506 |  11794
open            |    7559 |   7526
negative lookup |  208102 |   3702
remove          |   15173 |  15063

We didn't observed performance changes for vm.ManyFiles.virtiofs (no
casefold) and arc.RuntimePerf.sniper3d_virtiofs_vm.
See go/crosvm-virtiofs-casefold-cache-evaluation for the detailed
results.

BUG=b:263475037
TEST=cargo nextest run
TEST=tast run vm.ManyFiles.*
TEST=tast run arc.RuntimePerf.sniper3d_virtiofs_vm

Change-Id: Ida191a96d63ef3a95ae3dcae12a973870fafa2a0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4160474
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2023-04-19 06:37:06 +00:00
Zihan Chen
d3a0d2a285 infra: Run cros container builder with privileged docker
Podman can't correctly pull cros container, use docker instead

TEST=https://ci.chromium.org/swarming/task/61aee0e137732b10

Change-Id: Ida7b0b3c760ff20034a95168c7c39544322a8100
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4443346
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-04-18 21:41:26 +00:00
Daniel Verkamp
12ca276a1e devices: bus: avoid potential add overflow in BusRange
Avoid potential overflow when adding the base and length of a range by
using saturating addition.

If the total of range base and length exceeds the size of a u64, this
usually indicates an incorrect range, but using saturating adds allows
us to handle this gracefully rather than causing a panic when checked
arithmetic is enabled.

BUG=b:274366589
TEST=tools/dev_container tools/presubmit

Change-Id: I358d906718d3e8c2d7a5c72721b095199fc785cb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4356903
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-18 18:03:36 +00:00
Maciek Swiech
77ae1da9ab cmdline: add balloon_wss command
basically the same as the existing balloon_stats command, allows for
querying of a balloon working set size from the command line using the
crosvm binary and the control socket of a running vm.

TEST=run bzImage, issue command
BUG=b/278120533

Change-Id: I1fc41f91622aebd8a413fd029d84da4cf651daec
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4434049
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
2023-04-18 15:24:27 +00:00
Maciek Swiech
c10e83c576 balloon: remove wss_op_tube
since run_control is single threaded, we should be able to always
discard stale wss/stats messages in the handlers in vm_control,
obviating the need to keep a separate tube for wss crosvm_commands.

BUG=None
TEST=run bzImage

Change-Id: I7de192a08ae7a42641cbabe183dbad1c6ef627a4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4428055
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Maciek Swiech <drmasquatch@google.com>
2023-04-18 15:20:13 +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
2c1d17fe41 tree-wide: remove unnecessary casts
Fixes clippy lint in Rust 1.68

BUG=b:276487055
TEST=tools/clippy # with rust 1.68

Change-Id: Ib9d83b8dc15a93e815600391e93b8bb1788f7dc4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4391107
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-17 23:43:59 +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
Maciek Swiech
f4c5cd8e42 balloon: return balloon_actual with wss
balloon size is useful for balloon policies using working set size, so
we return the balloon-device cached balloon size. unless there is some
error in adjustement of the balloon, this should reflect that real
balloon size and saves having to query the guest an additional time.

BUG=b/278119213
TEST=run bzImage

Change-Id: I7c6b558358b8db099a737430e8431997bb110b2b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4428532
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: T.J. Alumbaugh <talumbau@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Maciek Swiech <drmasquatch@google.com>
2023-04-17 21:32:23 +00:00
Daniel Verkamp
99e8506da6 base: remove redundant &format!() reference
Fixes clippy lint in Rust 1.68

BUG=b:276487055
TEST=tools/clippy # with rust 1.68

Change-Id: I6754dc4f93c7c2fadfa03f240cae3e2e4a86e225
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4391103
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-17 21:20:57 +00:00
Daniel Verkamp
87134857f0 base: clean up redundant casts
Some `as usize` casts are necessary on non-glibc C libraries, since the
type of `cmsg_len` and `msg_controllen` may not be usize in the libc
bindings, so these warnings are suppressed instead of removing the
casts.

BUG=b:276487055
TEST=tools/clippy # with Rust 1.68

Change-Id: I30d9a16d37710b1356cffc183a03f8c8f6f35680
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4391102
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-17 21:20:57 +00:00
Daniel Verkamp
37f2a7be71 devices: virtio-snd: vios: box StreamMsg across Sender
The StreamMsg type contains a DescriptorChain, which is large enough to
cause clippy warnings about large Result values. Box the StreamMsg so it
is heap allocated instead to silence the warnings.

BUG=b:276487055
TEST=tools/clippy # with rust 1.68

Change-Id: I0e6ebd6e0e33d8fba2396f0923aed1ed8e99c13b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4412659
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-17 21:20:57 +00:00
David Stevens
df2625c599 Reland "vm_control: reduce user memory region modifications"
This is a reland of commit 22c212d54f

This reland avoids using the new pre-mapped memory regions on arm
devices, since there is insufficient address space. The new path is
still used on aarch64.

Original change's description:
> vm_control: reduce user memory region modifications
>
> Reduce how often KVM_SET_USER_MEMORY_REGION is called when the tdp mmu
> is enabled. With the tdp mmu, there is no memory overhead from creating
> large memory regions (at least until a nested VM is started). Simply
> mmap'ing/munmap'ing fds within a pre-created memory region is more
> efficient. It also addresses audio jank caused by removing a memory
> region.
>
> Adding this support to VmMemoryRequest will allow FsMappingRequest to be
> removed in a later change.
>
> BUG=b:274037632
> TEST=tast run arc.Boot.vm
> TEST=manually launch gedit in crostini
>
> Change-Id: I2ac02454ecb734c9707b6d67546135134b887527
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4402068
> Reviewed-by: Dennis Kempin <denniskempin@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: David Stevens <stevensd@chromium.org>

Bug: b:274037632
Change-Id: I5deedfd3a030640f9af950cee675fac0d9a411a0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4421352
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-04-17 20:16:39 +00:00
Noah Gold
307b57809a hypervisor: snapshot interrupt state for WHPX.
When snapshotting, the interrupt state (pending or otherwise) needs to
be saved from the VCPU. Every hypervisor has its own implementation
of how this is exposed to VMMs (KVM uses vcpu_events). This CL adds
an implementation for WHPX's VCPU.

BUG=b:270734340
TEST=builds (we can't test the full WHPX snapshot flow yet; need to
reach critical mass on implementation first).

Change-Id: Ic97ad15391f277967bd7b19a7ff6b55c57f3a00b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4428057
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2023-04-17 18:18:32 +00:00
Noah Gold
f897fb4f54 hypervisor: fix error codes for WHPX xsave.
EIO is more appropriate than unsupported for this error.

BUG=b:270734340
TEST=builds

Change-Id: Idaf8c291c7301f1ee929aafc12bf032f19d71e35
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4425875
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2023-04-17 17:40:26 +00:00
Noah Gold
22121cdb0b hypervisor: migrate VcpuEvents to a generic hypervisor blob.
Originally VcpuEvents was modeled on KVM's vcpu_events struct. Other
hypervisors like WHPX represent the sort of data that's in KVM's struct
very differently. This CL moves us to use a json blob that each
hypervisor can define for itself, which unblocks implementing for WHPX.

BUG=b:270734340
TEST=tools/dev-container e2e_tests/run

Change-Id: I1600f4303ee5bf2aebeaeb92a215edaea2f69a87
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4421490
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2023-04-17 17:40:26 +00:00
Daniel Verkamp
3ef88c31dd devices: virtio: add notification region fallback in write_bar()
Normally, writes to the virtqueue notification region should be handled
via ioevents and not make it into the write_bar() handler. However, in
an upcoming change, ioevent registration will be deferred until
activate(), and in this case, it is possible that a queue is notified
while the ioevent registration is still in progress. To handle this
case, add a fallback to the VirtioPciDevice::write_bar() function to
signal the corresponding queue event. (These processes can overlap
because the BAR writes used to configure the virtio-pci device are
posted, meaning the guest does not need to wait after writing the
configuration register to activate the device and writing to a queue
notification region to start using a queue.)

BUG=b:278130202
TEST=crosvm run bzImage # observe working virtio devices

Change-Id: Ic1b19ac54f6dace29705b9d190d280eb5e962b5e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4422465
Reviewed-by: Ningyuan Wang <ningyuan@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-14 20:46:43 +00:00
Daniel Verkamp
c8877230eb devices: virtio: preserve queue_evts when sandboxing
I'm a bit baffled how this worked before - queue_evts is filled at
device creation time (before sandboxing) and used during activate()
(after sandboxing), so their file descriptors need to be preserved when
forking for the sandbox jailing process.

BUG=b:278130202
TEST=crosvm run without --disable-sandbox; observe /proc/N/fd of devices

Change-Id: Icde695fba5b015c84769e3dadedfe509c3fbaf19
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4422464
Reviewed-by: Ningyuan Wang <ningyuan@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-04-14 20:30:23 +00:00
Gurchetan Singh
18472b0b0a rutabaga_gfx: match gfxstream declarations
This matches the latest gfxstream declarations.  Having
everything as a single enum without separation between
fence/mem isn't too bad since adding a new type essentially
means creating a new OS (which happens rarely).

BUG=b:273555494
TEST=compile

Change-Id: I6c6dd957e443cb51c3c8109d514d15985636a2b3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4425451
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-04-14 20:27:49 +00:00
recipe-roller
0bdc93e17a Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (recipe_engine) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8783824428625049729

recipe_engine:
56bdc99272
  56bdc99 (ddoman@chromium.org)
      [recipes-py] add validate.proto for pgv

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: I721c535c5457dadbc2b7c61db350643574d34fd0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4428531
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2023-04-14 16:39:41 +00:00
recipe-roller
53e22cadd1 Roll recipe dependencies (nontrivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8783982974615932817

Please review the expectation changes, and LGTM+CQ.

depot_tools:
8d19d8641b~..9519fc130068cc19ff38489a069436a88e8516ec
  8d19d86 (bryner@google.com)
      Add newlines to info message so words aren't squashed together.
  9519fc1 (bpastene@chromium.org)
      Add timeouts to the actual http calls in gerrit_util.py

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: Ibd8c2b4a39757803f29f311aa5cc804ac809043c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4420617
Auto-Submit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Reviewed-by: Ben Pastene <bpastene@chromium.org>
Commit-Queue: Ben Pastene <bpastene@chromium.org>
2023-04-14 16:01:31 +00:00
Dennis Kempin
e0c9e789d0 Revert "vm_control: reduce user memory region modifications"
This reverts commit 22c212d54f.

Reason for revert: Suspected to break crostini http://go/bbid/8783938922329906785

Original change's description:
> vm_control: reduce user memory region modifications
>
> Reduce how often KVM_SET_USER_MEMORY_REGION is called when the tdp mmu
> is enabled. With the tdp mmu, there is no memory overhead from creating
> large memory regions (at least until a nested VM is started). Simply
> mmap'ing/munmap'ing fds within a pre-created memory region is more
> efficient. It also addresses audio jank caused by removing a memory
> region.
>
> Adding this support to VmMemoryRequest will allow FsMappingRequest to be
> removed in a later change.
>
> BUG=b:274037632
> TEST=tast run arc.Boot.vm
> TEST=manually launch gedit in crostini
>
> Change-Id: I2ac02454ecb734c9707b6d67546135134b887527
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4402068
> Reviewed-by: Dennis Kempin <denniskempin@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: David Stevens <stevensd@chromium.org>

Bug: b:274037632
Change-Id: Id5caebd0bd33f4984567ff604f117ae4d95a71ab
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4422453
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-04-13 21:39:27 +00:00