Commit graph

5895 commits

Author SHA1 Message Date
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
Keiichi Watanabe
60f7474799 e2e_tests: Add virtiofs test
BUG=b:269068100
TEST=./run in e2e_tests

Change-Id: I637a6362ebc846e773fbbc0fe8223044f9e0839d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4040654
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2023-02-14 02:09:35 +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
Clarissa Garvey
4b0a3d88f7 base/src: Fix and update mmap.rs doctests
Prior to this CL, the doctest for write_obj_volatile() was failing on
a Windows device, and the doctest for read_obj_volatile() called
read_obj() rather than read_obj_volatile(), not testing the correct
function. After this CL, both tests pass on Linux and Windows, and the
doctest for read_obj_volatile() correctly tests the volatile version of
the function.

TEST=cargo test --doc in base/src, CQ

Change-Id: I4d3fd77a7ededed12231c980899187d747b61234
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4247139
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Clarissa Garvey <clarissagarvey@chromium.org>
2023-02-13 23:42:21 +00:00
Dennis Kempin
6b549dc68c Migrate run_tests2 to run_tests
This CL replaces the old test runner at run_tests with the new one
from run_tests2. For compatibility, a symlink is maintained until
builders have updated their recipes.

The presubmit script is updated to use the new CLI interface while
running the same selection of tests.

Note: An alias --build-only is added for --no-run to ensure
compatibility with the windows builder.

BUG=b:269169405
TEST=CQ

Change-Id: Id1e664af250f53d797c2262e9ac54aa1d7a09e4b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4246704
Commit-Queue: Zihan Chen <zihanchen@google.com>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
2023-02-13 23:31:19 +00:00
Zihan Chen
4f7711c335 infra: Shorten path/to/binary in binary size report
TEST=https://ci.chromium.org/swarming/task/6065b21be366f310

BUG=b:257303497

Change-Id: Ic1f9f759f2f075fe2e9a8ed97c3582037415496d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4246702
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-13 23:08:06 +00:00
recipe-roller
645b49eaad 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/8789238227460782177

depot_tools:
e636a25853~..b2429ece99e265a453f177902e6a3446d017ca2a
  e636a25 (yiwzhang@google.com)
      split the config validation request into smaller requests
  c4efd8a (bentekkie@google.com)
      Set path based reproxy flags in autoninja to sandbox developer...
  b2429ec (iannucci@chromium.org)
      [recipes] Mark repo as py3 only.

recipe_engine:
4b7bc24b24~..29c7df628b1b7ea7510b91ca80eebf66953727b5
  4b7bc24 (machenbach@chromium.org)
      [led] Retain fluency with inject_input_recipes
  73273ae (olivernewman@google.com)
      [test] Avoid creating empty expectation file dirs
  e12221e (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from fca00f1dc785 to 7fdf5527267e
  9529a65 (iannucci@chromium.org)
      [warnings] Fix error on py3 where str is not comparable to None.
  0caaa20 (iannucci@chromium.org)
      Fix typo in warn/escape.py
  29c7df6 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 7fdf5527267e to a4b0cf91f9d6

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: I143c93ace42baefae88dccc20d4226e34cce0379
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4247138
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-13 22:25:32 +00:00
Daniel Verkamp
25295934dc x86_64: initialize boot_params::ext_cmd_line_ptr
The crosvm kernel loader failed to set the high 32 bits of the command
line address, so it would use whatever value was originally loaded from
the bzImage header. Set the ext_cmd_line_ptr to the high 32 bits of the
address where crosvm loads the command line (usually 0) so the kernel
can correctly locate the cmdline in guest memory.

This fixes booting kernels with CONFIG_X86_5LEVEL=y enabled. The 5-level
paging code checks for the "no5lvl" option in early boot using the
cmdline_find_option_bool() function, which eventually calls the
get_cmd_line_ptr() function and builds a command line pointer by
combining cmd_line_ptr and ext_cmd_line_ptr. Without this patch, this
will potentially access data outside of guest memory and crash.

BUG=b:269162598
TEST=boot x86-64 Linux with CONFIG_X86_5LEVEL=y in crosvm

Change-Id: Ic59a3143529333e21ba2c37c45967314cbb0f1f5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4246699
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
2023-02-13 22:25:01 +00:00
Dennis Kempin
70e4b96fa2 infra: Fully commit to python3
We never used python2 in our recipes, but now that Luci is migrated,
we can truly run in python3 only.
See: http://go/luci/migrations/recipe_py3#phase-5-fully-committing-to-python-3

This should fix issues with the recipe bundler.

BUG=b:269149141
TEST=health-check

Change-Id: Iaf8a63b3ca9114acd0e5f0fbc13696367a1ab116
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4245443
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-02-13 22:06:44 +00:00
Elie Kheirallah
f7aa9cf750 devices: virtio: rng: add stop impl for Rng
Add stop() impl for Rng virtio device to return state.

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

Change-Id: I8db90d472e5acfb79996b5ab2bcd192f06196226
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4190019
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
2023-02-13 19:42:03 +00:00
Zihan Chen
4acc0186ad devices: Clean up DataInit (7/n)
With the previous CLs migrating many functions and types to use
zerocopy, finally we can do a big clean up of`unsafe impl DataInit`.
We are down to 93 instances now from 230 at 5th CL in this series.

Also fixes a bug introduced previously in this series where I set
the trait bound of a few write_at_addr unsafe functions to
`FromBytes` when `AsBytes` should also be required.

TEST=CQ

BUG=b:204409584

Change-Id: I6658dd246a8932493ef6a652054a23ecfde76198
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237765
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-13 19:26:45 +00:00
Dennis Kempin
90d45576d2 infra: Stop generating dry runs for ChromeOS merges
Merges have been running smoothly enough that we no longer need these.

BUG=None
TEST=None

Change-Id: If4100966eba25038dda15dded158438a5a3824d2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4240538
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-02-10 20:49:13 +00:00
Dennis Kempin
0ef6a9a6c4 rust-toolchain: Add llvm-tools-preview
The llvm tools provide access to commonly used llvm tools through
cargo - specifically we need llvm-strip for stripping debug data
before packaging tests for remote execution.

This is already installed by install-deps. But having it part of the
toolchain file will automatically install it on toolchain updates
as well.

BUG=None
TEST=None

Change-Id: I433ebccb5d7a2c419c5cab7476146a142967e439
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4240537
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-02-10 20:47:41 +00:00
Noah Gold
b90d7d607e devices: fix virtio-input not interrupting statusq.
virtio-input has a queue processing thread that handles multiple queues.
Unfortunately the thread collects all of the `needs_interrupt` booleans,
together and then only sends an interrupt for one of the queues (the
eventq). This means that the statusq will never receive its interrupt.
This means we never tell the driver that we have more buffers for it,
and so the device starves and stops sending us guest -> host input
events.

This CL splits up the interrupt tracking so that we interrupt the right
queues as needed.

BUG=b:268572174
TEST=ran emulator with a workload that uses the queue & verified that it
doesn't stall out anymore.

Change-Id: I8a5eb09caff5186a111450da29fcdf0a67087161
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4240542
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2023-02-10 20:04:59 +00:00
Alexandre Courbot
72692d0b65 devices: vhost: user: move run_handler method from handler to listener
This method was taking ownership of two objects (the handler and the
listener) without one being more eligible to being called `self` than
the other, so it makes sense to make it a regular function of the
listener, as moving it there allows us to make it private.

BUG=b:217480043
TEST=send data between the host and a VM connected to a vhost-user vsock device using socat.
TEST=send data between a VVU vsock device inside a device VM and another guest using socat.

Change-Id: I0e212f91bc488faf88730717dd67450fda420c9d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4222842
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Ryuichiro Chiba <chibar@chromium.org>
2023-02-10 04:08:38 +00:00
Daniel Verkamp
6921e45ccb devices: add SleepGuard abstraction for snapshot/restore
This object temporarily owns the list of Bus objects to sleep/wake and
allows the snapshot/restore code to be simplified by removing the manual
cleanup on error exits.

BUG=None
TEST=crosvm run ... -s /tmp/crosvm bzImage
TEST=crosvm snapshot /tmp/snapshot/tmp/crosvm

Change-Id: I7147d5145f49fa149eefcc518dfe03dec3499d97
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4226504
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
2023-02-10 02:11:05 +00:00
recipe-roller
4a7c1dbce8 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/8789588031425705745

recipe_engine:
d82cf3c7fd
  d82cf3c (godofredoc@google.com)
      Use python3 instead of python in file module.

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: I833b8a719761f4aa104cf388bbccfbc9d241187a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4237529
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-10 01:58:32 +00:00
Zihan Chen
30f58a81aa crosvm: Partially convert DataInit to zerocopy (6/n)
This CL removed many uses of DataInit in devices. Some paddings
are manually added/fixed to allow AsBytes to derive without ABI
changes.

TESTED=CQ

BUG=b:204409584

Change-Id: I1f8c2d5304fc8e685cc3e5166c73481f6a3f78f7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4235224
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-02-10 01:52:24 +00:00
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
Dennis Kempin
95e3b60beb infra/config: Update builders to use test profiles
The repeat_tests/coverage/retry_tests options have been replaced
with profiles for pre/post-submit in https://crrev.com/c/4234898

BUG=b:261600801
TEST=lucicfg validate main.star

Change-Id: Ie55793b722a0d374996d63053d7be59a31a5ced2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4234905
Reviewed-by: Zihan Chen <zihanchen@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-02-09 23:42:18 +00:00
Elie Kheirallah
8793c52268 devices: virtio: add sleep_virtio_devices and impl
Add sleep_virtio_devices which let's use get back the queues and mem
from the virtio device, to preserve state.
Add implementation for Wl.

BUG=b:232437513
Test=./tools/presubmit --all

Change-Id: Id7f652f5ae6409c65cff87e0f9458a84f0e8b370
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4184261
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Elie Kheirallah <khei@google.com>
2023-02-09 23:27:19 +00:00