Commit graph

5915 commits

Author SHA1 Message Date
Daniel Verkamp
2686efd337 devices: convert various devices to use WorkerThread
As much as possible, this patch retains the original behavior of each
device's worker thread, so there should be no observable differences in
behavior.

BUG=b:269187468
TEST=Boot Crostini and ARCVM on x86_64 and aarch64 machines

Change-Id: I3b839194ddc1e229a2bcca7c20beac6068790645
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237531
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-02-23 01:31:22 +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
d733be714d vm_control: refactor do_while_vcpus_suspended
do_while_vcpus_suspended() deeply depends on device snapshot feature.
It should be more generic.

The vmm-swap feature will need to execute enabling logic while vCPUs are
suspended.

BUG=b:270248453
TEST=cargo build

Change-Id: I4f1acb2cf9ad61ee0887c6c7bfa7f68ba1dfb3ed
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4279545
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Shin Kawamura <kawasin@google.com>
2023-02-22 23:41:55 +00:00
Idan Raiter
eda45f7648 crosvm_cli: Add missing Windows exit codes
A few codes were added downstream and are not here.

BUG=b:269174100
TEST=presubmit

Change-Id: I6599cbc356fe77b6b9094361a620aada2d173e5b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4246714
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
2023-02-22 20:02:20 +00:00
Idan Raiter
f1c283e4b6 metrics: Add missing process types
Downstream we've added the SPU + Broker process types, this should be
reflected here to avoid numbers going out of sync.

Also adds sound type.

BUG=b:269313507
TEST=presubmit

Change-Id: I5e3e269c9aca7bc9504e3e822302bcccf3bf377f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4246713
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
2023-02-22 20:01:38 +00:00
Idan Raiter
796bdd3752 vhost-user: snd: Make device command cross-platform
Adds cross-platform device command for sound. Also brings in config
structs for platform features.

BUG=b:269174100
TEST=downstream

Change-Id: Id5077a08cdf64b730732e35656eb4e37f38801bf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4246710
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2023-02-22 20:01:04 +00:00
Daniel Verkamp
0e06ebe15b data_model: fix IoBufMut references in comments
The standard library equivalent is called std::io::IoSliceMut, not
IoBufMut.

BUG=None
TEST=read it

Change-Id: I66956f403e762d84bd46b05e986415f319d5bcbf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4262436
Commit-Queue: Zihan Chen <zihanchen@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
2023-02-22 19:36:07 +00:00
Changyuan Lyu
ffe03dde6a virtio: vhost-net: support specifying MAC address
Booted a VM with `--net tap-fd=3,vhost-net=true,mac=14:c1:4e:e8:28:40`,
`ip addr` in the guest shows
```
3: eth0: <BROADCAST,MULTICAST> mtu 1500 state DOWN
    link/ether 14:c1:4e:e8:28:40
```

Tested that `cargo test -p devices` passes.

TEST=tools/presubmit
BUG=None

Change-Id: I9f85362579a73b978d963916577242ffc22ed312
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4273026
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Changyuan Lyu <changyuanl@google.com>
2023-02-22 17:20:21 +00:00
recipe-roller
c78636d4a6 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/8788500234170958897

depot_tools:
4756d7c420
  4756d7c (bsheedy@chromium.org)
      Add tryserver test_api method

recipe_engine:
3bd372a45d
  3bd372a (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from df03dcec6a49 to 8a8b4f2ea65c

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: I6c1d2cb163ada82f779019d4a7ebf8e012b7da52
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4279267
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-02-22 02:01:24 +00:00
Shintaro Kawamura
b9bf0798fd swap: punch a hole to swap file if the pages are removed
If the pages on the guest memory MADV_REMOVEed, the pages are likely not
be accessed for a long time. Keeping those pages is not good use of
resources.

This also fix the minor bug that staging memory is not cleared by
MADV_REMOVE.

BUG=b:269981962
BUG=b:269531558
TEST=cargo test -p swap

Change-Id: Ic43e21104becd8a1dfca32a2cd0733bf40154fa1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4269719
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-02-22 01:53:38 +00:00
Shintaro Kawamura
fc3e5c9b80 disk: add PunchHoleMut trait
PunchHole should be originally immutable method since the
file_punch_hole() for both unix and windows are immutable function which
do not change the underlining file offset.

QcowFile is the only object which requires mutability to punch a hole to
its file.

This commit introduce a new PunchHoleMut and the existing PunchHole
traits and make PunchHole trait immutable. This unblocks b/269981962
which tries to punch a hole to non-mut reference File.

This also remove useless top level defined functions in base crate.

BUG=b:269981962
TEST=cargo build --feature=qcow
TEST=./tools/run_test2

Change-Id: I8333d13f4adc6dff319c0ddababe400d5e995141
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4269718
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Shin Kawamura <kawasin@google.com>
2023-02-22 01:53:38 +00:00
Dennis Kempin
a54a5bc81a e2e_tests: Make prebuilt version part of the file name
This prevents us from using an older version of the image if a newer
version is specified.

BUG=b:269137600
TEST=run_tests

Change-Id: I9962feebb13c69b9fb9c5fb0fba64f265d46d08e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4277626
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-02-21 23:21:45 +00:00
Dennis Kempin
2b30441772 e2e_tests: Add sleep after creating vhost user backend
If crosvm launches quickly after starting the backend, it may
find that the device socket does not exist yet. This causes
occasional test failures.

Adding a sleep stabilizes the test a little, but should be replaced
with a proper wait loop while checking for the device socket to
become available.

BUG=b:269174700
TEST=./tools/run_tests --dut=host -E"package(e2e_tests)" \
  --no-unit-tests --repetitions 10

Change-Id: Ifaba81a5fb3628d07793b1310229de4a43d2a7b6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4258306
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2023-02-21 22:54:30 +00:00
Dennis Kempin
b2ec37b33f e2e_tests: Do not capture crosvm stdout
This was useful since the libtest harness could not capture stdout
for subprocesses and we would get very noisy test results.

However, with nextest, each test is run in a separate process and
will be hidden unless the test fails.

The test log will then contain an host and guest messages interleaved,
which greatly helps debugging.

Also switches the main serial output from syslog (which prints to
stderr) to stdout.

BUG=None
TEST=None

Change-Id: Ie3b377aeaef3ef575f9232430ac7392c83060d98
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4256511
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-02-21 22:54:30 +00:00
Dennis Kempin
a5312895e7 e2e_tests: Extend exec_in_guest functionality
This is a refactoring that adds the following functionality to
exec_in_guest:

- Receive exit codes from executed commands and by default check
  if they are zero.
- Add timeouts to all communication with the guest
- Allow commands to be executed asynchronously, to allow the test
  code to perform actions while the guest command is running.
- Add anyhow error handling with contexts for more helpful error
  messages

BUG=b:269137600
BUG=b:268539201

Change-Id: Ic069c3ccae363790a124db10a0db76e4ad4384c3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4251717
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
2023-02-21 22:54:30 +00:00
Daniel Verkamp
770edd4c88 devices: virtio-balloon: replace Tube::try_clone() usage
The "failable update" option relied on being able to clone the Tube and
leave an instance of it in the main Balloon object while the worker
thread also had a clone of it. To avoid the need for this, create an
extra async function to monitor a queue of pending adjusted responses
that can be written from the write_config() function, along with an
Event to trigger the async function to check the queue and send Adjusted
responses on the command tube.

This also means that all command tube senders can be migrated to the
async version of the function, which is now identical between unix and
win versions and can be moved out of sys.

BUG=b:222588331
TEST=tools/presubmit --all

Change-Id: I1ec384087b69fc28314ff66bff4b0a9560eaba9f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4265534
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-02-21 22:17:47 +00:00
Daniel Verkamp
ad7e0ad740 cros_async: add select9 and select10
These will be used to wait on larger numbers of futures simultaneously.

BUG=None
TEST=tools/presubmit --all

Change-Id: I9dd632c3e3971d47b9c393e06c98b2b77ecc5c86
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4265533
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-02-21 22:03:59 +00:00
recipe-roller
59b629a0af 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/8788514709912996465

depot_tools:
30136f0cb7
  30136f0 (lokeric@google.com)
      Reinstate reclient

recipe_engine:
6b5bebd202
  6b5bebd (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 692be227c775 to 5b086ea152ab

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: I35878d4f5b6fa9946b7f5d6a4dcd03b9a778ab06
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4277830
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-02-21 22:03:04 +00:00
Zihan Chen
3c7ee29e9e crosvm: Convert DataInit to zerocopy (8/n)
TEST=CQ

BUG=b:204409584

Change-Id: I7942a483ba06166026a5b9b81580b98209a0da5e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4262514
Auto-Submit: Zihan Chen <zihanchen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-02-21 21:12:31 +00:00
Daniel Verkamp
df67a1207d cros_tracing: do not print errors in push_descriptors()
If the trace_marker feature was enabled but the sysfs file could not be
opened, cros_tracing::push_descriptors() would log an error message each
time it was called. We already log an error when tracing can't be
initialized, so the extra logs aren't necessary and can be removed.

BUG=b:256052372
TEST=cargo build --features=trace_marker and run crosvm

Change-Id: If7737cf3f27d7815536310eb995b9fad7669df5d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4262324
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-02-21 20:31:28 +00:00
Daniel Verkamp
1445ac1b93 cros_tracing: simplify trace_marker file checking
Rather than checking if the trace_marker file in sysfs exists and then
immediately proceeding to open it, we can just try to open it and handle
the resulting error if it doesn't exist.

Additionally, log the filename if the file can't be opened to make the
debugging process easier.

BUG=b:256052372
TEST=cargo build --features=trace_marker

Change-Id: I117324b0903afdbd351d03a18755321cacf1f42c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4262323
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2023-02-21 20:31:04 +00:00
Judy Hsiao
66d2ee3c12 audio_streams_conformance_test: add debug mode
Add --debug to print the records of sample rate linear
regression.

BUG=b:238038707
TEST=emerge-${BOARD} audio_streams_conformance_test
TEST=audio_streams_conformance_test -P cras --debug

Change-Id: I847f95c75c4002700abc7f3f7fb1e57bc438df1e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4241035
Auto-Submit: Judy Hsiao <judyhsiao@google.com>
Reviewed-by: Pattara Teerapong <pteerapong@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2023-02-21 14:50:38 +00:00
Takaya Saeki
db8179a497 devices: virtio: block: replace TempDir with TempFile in tests
Many tests for virtio-blk is using TempDir just to create a temporary
file. These usage can be simplified with TempFile. So, this change does
that simplification.

BUG=None
Test=`cargo test -p devices`

Change-Id: I2b3bbd66894cc4a8f88cbf8faeb6e06dda600f30
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4272805
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
2023-02-21 08:29:41 +00:00
Shin Kawamura
a0d14ce819 Revert "x86_64: place setup_data immediately after cmdline"
This reverts commit e5aec1e53d.

Reason for revert: The android fstab which is capped limited up to `X86_64_FDT_MAX_SIZE` exceeds the `SETUP_DATA_END` at least on an octopus DUT. 

Original change's description:
> x86_64: place setup_data immediately after cmdline
>
> This moves the setup_data out of the way of the bzImage decompression
> stub, so it won't get overwritten.
>
> Fixes a regression with some kernel configurations introduced in commit
> 5bedfa3408 ("x86_64: add SETUP_RNG_SEED setup_data entry"), which
> unconditionally adds a setup_data entry.
>
> BUG=b:268397895
> TEST=boot x86-64 bzImage in crosvm that previously failed
> TEST=cargo test -p x86_64
>
> Change-Id: Ie5efc19d607aad16c1ca80bcdd2fb62933dd73e1
> Fixes: 5bedfa3408 ("x86_64: add SETUP_RNG_SEED setup_data entry")
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4233967
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Dmitrii Osipenko <dmitry.osipenko@collabora.corp-partner.google.com>
> Reviewed-by: Zihan Chen <zihanchen@google.com>

Bug: b:268397895
Change-Id: Ie430caa38b745cb1d5e69ac644a2c76813069221
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4272810
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2023-02-21 05:37:18 +00:00
Shin Kawamura
935ad063c6 Revert "docs: book: fix memory layout source links and line numbers"
This reverts commit 4a740f3801.

Reason for revert: Revert https://crrev.com/c/4233967

Original change's description:
> docs: book: fix memory layout source links and line numbers
>
> The crosvm-upstream repository in the ChromiumOS git host was removed,
> so use crosvm instead.
>
> BUG=None
> TEST=mdbook build # and click through links
>
> Change-Id: Ib35d930505c1a3381ce4f4fc53f54d626c810d1e
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4233968
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Zihan Chen <zihanchen@google.com>

Bug: None
Change-Id: I4c4d72f54bbfc58a127b3831b2d658c2472fffff
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4272809
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2023-02-21 05:33:20 +00:00
Shintaro Kawamura
3af5ea8294 crosvm: plugin: use create_sandbox_minijail() for plugin
create_plugin_jail() and create_sandbox_minijail() do the same settings
except (1) `RLIMIT_NOFILE` and (2) plugin jail does not support embeded
bpf seccomp filter. But both difference won't be a problem.

(1) Given that Parallels plugin is closed source we will not be able t
ocame up with a reasonable limit, so it might need to go the way GPU
device does it and set the limit to 32K.

(2) We validate seccomp_policy_dir in jail_config is not none.

The fallback logic for the pivot root path for plugin is a bit changed,
but it should not be a problem.

* before: cfg.plugin_root > DEFAULT_PIVOT_ROOT env > "/var/empty"
* after: cfg.plugin_root > jail_config.pivot_root > DEFAULT_PIVOT_ROOT
  env > "/var/empty"

This migration also introduce minor updates to jail helpers.

* create_base_minijail() validates root path to be absolute path.
  * otherwise, chroot fails and minijail fails.
* The source for mounting proc is changed ("/proc" -> "proc").
  * "proc" looks the proper source to mount according to proc(5) man
    page.
  * "/proc" as the source was introduced by https://crrev.com/c/1717739,
    but it looks they didn't have any concrete reason for it.

BUG=b:268281422
TEST=./tools/run_tests2
TEST=tast run $DUT arc.PlayStore.vm

Change-Id: Ie014cadf3cec4a049ef783546782209e26d9902a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4262049
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
2023-02-21 01:07:20 +00:00
Junichi Uekawa
7571b291e0 crosvm: Use / instead of /usr/local/bin
Path may not exist on Android devices.

BUG=b:269184617
TEST=unit test

Change-Id: Ie4757890a324dfd784e2f2e731d8fc7577956ce7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4262048
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2023-02-20 23:45:15 +00:00
Daniel Verkamp
4a61fb87bb base: add WorkerThread abstraction
WorkerThread provides a mechanism to start a thread that can be stopped
by sending an event from another thread. It also handles automatically
stopping the thread if the WorkerThread object is dropped.

BUG=b:269187468
TEST=tools/presubmit --all

Change-Id: Ifeef3f34f75fcd0496e87e038b60fa9e5e60a681
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237530
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-02-17 22:47:37 +00:00
recipe-roller
2b5f4c3236 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/8788887791682118417

depot_tools:
3879bd830c
  3879bd8 (aravindvasudev@google.com)
      Reland "Warn users when .boto might be outdated"

recipe_engine:
b74a15e57b
  b74a15e (olivernewman@google.com)
      [cas] Forward kwargs to api.step()

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: Ifb91f888af71d1b679dd7ea8a82bfa26fac82913
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4265335
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-02-17 19:12:57 +00:00
Bartłomiej Grzesik
653e4ae535 virtio: video: Don't reuse picture buffer if response is pending
This CL addresses lack of clear output queue command on VDA. It omits queueing
output buffer to backend if a PictureReady response is pending.  This
eliminates double enqueueing of buffers and double ownership for buffers.
However in the event of clearing queue with output buffers while VDA owns
output buffers, the double ownership still occurs until a specific
buffer is enqueued again.

BUG=b:252950991
BUG=b:269093605
TEST=CtsMediaV2TestCases android.mediav2.cts.CodecDecoderSurfaceTest
TEST=CtsMediaTestCases android.media.cts.DecoderTest

Change-Id: I2f2560dc9d23077e6b6c523a1e6efa837d2d3184
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4254766
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Bartłomiej Grzesik <bgrzesik@google.com>
2023-02-17 15:50:03 +00:00
Shintaro Kawamura
bd8d3cc856 swap: open swap file before forking the monitor process
Opeing a file on the monitor process is blocking the upcoming minijail
migration. Open the swap file on the main process and pass the file
descriptor to the monitor process.

Using a single swap file and mmap different ranges of it for different
regions is efficient.

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

Change-Id: I4be150419d263ebe76ad00dae2cafce6e8660cbd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4253294
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
2023-02-17 02:18:39 +00:00
recipe-roller
1329f08152 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/8788963905209355841

depot_tools:
9ae55e5d77~..0074158bf6b73459ee93faffaa7853ca7ba931db
  9ae55e5 (aravindvasudev@google.com)
      Cleanup GSUTIL_ENABLE_LUCI_AUTH flag
  e2f3537 (aravindvasudev@google.com)
      Warn users when .boto might be outdated
  78db513 (chanli@chromium.org)
      [depot_tools] Roll led
  6b98cdc (jojwang@chromium.org)
      Check for detached HEAD state.
  f15baea (aravindvasudev@google.com)
      Revert "Warn users when .boto might be outdated"
  0074158 (pkasting@chromium.org)
      Fix various lint false positives.

recipe_engine:
6bfbee5c8c
  6bfbee5 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 2321089ab31a to c543f47ae455

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: Ieff156d5e16902468524861579879120779781e6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4260159
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-02-16 23:06:40 +00:00
Daniel Verkamp
41654c9b59 devices: virtio: remove mem from VirtioDeviceSaved
The GuestMemory type is cloned to create the instance used in the virtio
device worker threads, so it is not necessary to replace the one stored
inside VirtioPciDevice when sleep() is called; it will already be
another clone of the same GuestMemory.

BUG=b:232437513
TEST=tools/presubmit --all

Change-Id: I6c047f9ab42922c45194c4940fb0f7261c3e5fc6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4257208
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
2023-02-16 18:59:48 +00:00
Frederick Mayle
85eda99bd4 vm_memory: option to set MADV_DONTFORK on guest memory
This is admittedly an odd feature with a narrow use case. It will lower
the risk of crash analysis tools accidentally trying to read guest
memory that has been unshared from the host (i.e. in a protected VM).

Hoperfully we'll eventually have a better solution, where we only mmap
the memory regions that are shared with the host. There is no hypervisor
support for that yet.

BUG=b:238324526

Change-Id: Iac7ed38aa52778a43ac5ba22bab5a3df7a554ee6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4251719
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-02-16 18:23:47 +00:00
Daniel Verkamp
4a740f3801 docs: book: fix memory layout source links and line numbers
The crosvm-upstream repository in the ChromiumOS git host was removed,
so use crosvm instead.

BUG=None
TEST=mdbook build # and click through links

Change-Id: Ib35d930505c1a3381ce4f4fc53f54d626c810d1e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4233968
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
2023-02-16 00:32:51 +00:00
Daniel Verkamp
e5aec1e53d x86_64: place setup_data immediately after cmdline
This moves the setup_data out of the way of the bzImage decompression
stub, so it won't get overwritten.

Fixes a regression with some kernel configurations introduced in commit
5bedfa3408 ("x86_64: add SETUP_RNG_SEED setup_data entry"), which
unconditionally adds a setup_data entry.

BUG=b:268397895
TEST=boot x86-64 bzImage in crosvm that previously failed
TEST=cargo test -p x86_64

Change-Id: Ie5efc19d607aad16c1ca80bcdd2fb62933dd73e1
Fixes: 5bedfa3408 ("x86_64: add SETUP_RNG_SEED setup_data entry")
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4233967
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dmitrii Osipenko <dmitry.osipenko@collabora.corp-partner.google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
2023-02-16 00:28:26 +00:00
Daniel Verkamp
3d126b7976 x86_64: limit kernel command line to 2 KB
This is the limit used by Linux kernels since the 2.6 era, as reported
in the bzImage header as well as the COMMAND_LINE_SIZE definition in
setup.h.

The previous allocation of almost 2 MB was excessive and would have
also overlapped the memory region used for ACPI tables had a long
enough command line been provided.

We will use the area freed up by this change for the setup_data in the
next change.

BUG=b:268397895
TEST=boot x86-64 bzImage in crosvm

Change-Id: I3b5a3771549c3352e609a9685f591be38ae9fa63
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4233966
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Zihan Chen <zihanchen@google.com>
2023-02-16 00:28:26 +00:00
Daniel Verkamp
4ea3373501 devices: virtio-snd: use Event to stop vios worker thread
The shm_vios backend for virtio-snd has a worker thread that needs to be
stopped when the device is shutting down. Before this change, it kept a
separate `running` value in a shared mutex-protected field, using an
Event to signal the thread to observe the new value of `running`.
However, it is sufficient to just exit the worker when the Event is
signaled, so we can remove the extra `running` field. The previous
behavior of handling all events returned from the latest WaitContext
wait() call is preserved (rather than breaking out of the loop directly)
to ensure behavior is not changed due to this patch.

BUG=b:269187468
TEST=tools/presubmit --all

Change-Id: I7c053d2d3e05c05d4e71dacf1b45836a2dc6d618
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4252080
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Pattara Teerapong <pteerapong@chromium.org>
Reviewed-by: Jorge Moreira Broche <jemoreira@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-02-15 23:58:22 +00:00
Zihan Chen
b3b7d63358 infra: fixup: Upload to dashboard in postsubmit only correctly
TEST=https://ci.chromium.org/swarming/task/60702c1c126dc210

BUG=b:257303497

Change-Id: I1fce3a5bc4634e82769ddd40e2b51c9a63c738b4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4258125
Commit-Queue: Zihan Chen <zihanchen@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-02-15 23:32:48 +00:00
Zihan Chen
edc1265c07 infra: Upload binary size to dashboard in postsubmit
Finally all pieces are together and we can start uploading the
metrics.
There's also a typo in catapult converter that's fixed.
Tested via led presubmit with few modifidcations to allow upload
happen in a presubmit runner.

TEST=https://chromeperf.appspot.com/report?sid=a7f57b2395b43aeaa65009589e17bc31548b78cb58daae21f12f70ee24ed9578

BUG=b:257303497

Change-Id: I351586f52ef18be95b14cc3310bb05db4f49a101
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4249502
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-15 22:41:49 +00:00
Frederick Mayle
3379ab7e92 e2e: disable suspend_resume tests
They are flaky and that is expected since the feature is incomplete.

BUG=b:269174979

Change-Id: I929e822b7f81742a5dba0fef637d6143f18302b1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4256510
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-02-15 19:23:01 +00:00
Daniel Verkamp
2c1fcd8dc2 windows: set stdin to raw mode while running a VM
This makes the terminal behave appropriately when using a serial console
connected to stdin/stdout. In particular, there is no extra buffering of
input, and echo is disabled so input is not printed twice.

Attempting to set the terminal mode when running without an attached
console (e.g. within a GUI app where the standard handles are not
connected) will fail silently, which is fine.

BUG=b:264428954
TEST=Use bash running in crosvm from Windows command prompt

Change-Id: I2a267748401ea7d792196f5722c817ba22e1707c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4200972
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-02-15 18:14:46 +00:00
Daniel Verkamp
232406ee94 base: windows: implement terminal raw mode
This roughly matches the unix::terminal interface and can be used
to configure the terminal for use with a serial console (no line
buffering, interpret ANSI escapes, and so on).

BUG=b:264428954
TEST=tools/presubmit --all

Change-Id: I7efa8c405b44dadec55e08993b5f7a4c0236cf69
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4200971
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-02-15 18:14:46 +00:00
Shintaro Kawamura
7654908fec swap: switch page fault logger with compiler feature flag
page fault logger is only for debugging purpose. It has a security
concern about exposing the trigger to enable the logger. The logger will
make the page fault handling slower and consumes disk resources.

Instead, the page fault logger is only enabled by compiler feature flag
like:

```
cargo build --features=swap,swap/log_page_fault
```

Opening a file on the monitor process is blocking the upcoming minijail
migration. Open the log file on the main process and pass the file
descriptor to the monitor process.

BUG=b:269372016
TEST=manual test

Change-Id: I5df2a32da7fb149680fa24617ffd905b2483108b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4253287
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
2023-02-15 07:06:22 +00:00
Junichi Uekawa
0fa4db007c crosvm: test shared_dir parsing.
This is a public facing API that concierge depends upon, we should add
some test.

BUG=b:269184617
TEST=unit test

Change-Id: Ia340b6c2e89689d783a4a1e69cbfa9702a26ad83
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4248037
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2023-02-15 06:33:47 +00:00
Shintaro Kawamura
655b5d03b5 swap: fix a bug of parsing transparent hugepage size
On some Linux hpage_pmd_size returns the size with a line break which
cause failure on parse.

BUG=b:258351526
TEST=manual test

Change-Id: If8b9a43022bd0dee5035069b9aaa68114ebaaa86
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4252438
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
2023-02-15 06:17:07 +00:00
Zihan Chen
94cea0a654 infra: fixup: Move --strip to correct command
crrev/c/4251718 added `--strip` to wrong location of recipe.

TEST=https://ci.chromium.org/swarming/task/606b3904862d5a10 via led

Change-Id: I0a1e8f4b56ad3cd6927567a6488f12f0cd8111db
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4252078
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Zihan Chen <zihanchen@google.com>
2023-02-15 00:20:47 +00:00
Zihan Chen
2518440768 infra: Strip release binary for size measurements
Cargo by default does not strip symbols for release profile builds.
Specify strip symbols for binary size measurements make it more
meaningful (chromeOS builds are already doing so). We don't want to
make this the default for all release builds as that will hinder
user's ability to report bugs and crashes.

TEST=./tools/dev_container ./tools/build_release --strip

BUG=b:257303497

Change-Id: Ic46393fbb4176bd7631dd838d72ddbead9626774
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4251718
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-14 23:43:53 +00:00
recipe-roller
b4c52e3324 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/8789153292825890977

recipe_engine:
086386d9ca
  086386d (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from e2d67b2cb935 to d120042f61f6

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: Ifa8e3b484f08b90f84005f239e8ce5ba435c6b27
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4249503
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-02-14 20:57:35 +00:00
Idan Raiter
65562c6a1f vhost-user: snd: Add Windows backend
Make vhost-user sound Windows compatible following the other devices.

BUG=b:269174100
TEST=downstream

Change-Id: I87ebf9a34abcac3c1d2dbbc3eecf1312c01e4c48
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4246703
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
2023-02-14 18:13:19 +00:00