Commit graph

7885 commits

Author SHA1 Message Date
Mike Gerow
dea38e7552 smbios: add support for setting UUID in SysInfo
TEST=booted test kernel, ensured uuid is correctly returned at
/sys/class/dmi/id/product_uuid.
BUG=b:249382713

Change-Id: I444adebcea4b374b8c2744afba32cad5ff794ce0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5010881
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Mike Gerow <gerow@google.com>
2023-11-13 23:42:14 +00:00
recipe-roller
9affcb75d5 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/8764507141652775169

recipe_engine:
20788e5b9b
  20788e5 (mohrr@google.com)
      [recipe_engine] Always show full stacks

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: Ia12fd03d50adc8745992cdbd61abe2f69f213d58
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5026247
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-11-13 21:59:03 +00:00
Jakob Vukalovic
138ecc7e67 crosvm: Filter VFIO devices in DT overlays
This change uses the overlay filtering mechanism to only apply nodes
pertaining to the VFIO devices given to crosvm.

For each VFIO device, define its device tree symbol by passing a
`dt-symbol` option in addition to the sysfs path. The DT symbol must
match the label of the device node in the FDT. In addition, specify
which device tree files will be filtered using these symbols by passing
a `filter` option in addition to the device tree overlay path.

As the device nodes are applied to the base FDT, update the `reg` and
`interrupts` properties with correct values for each VFIO device.
Since these values are allocated by crosvm, they are not known ahead of
time and even if written to the overlay file, are unlikely to be
correct. This change will set the correct values for each VFIO device.

Bug: b/296796644
Test: tools/run_tests
Change-Id: I1ca38b5ef223e551b91a831093b9ae790962aa5b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4855969
Commit-Queue: Jakob Vukalović <jakobvukalovic@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-13 20:29:48 +00:00
recipe-roller
96aa7b167c Roll recipe dependencies (trivial).
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/8764521613341106257

depot_tools:
8672d51b79
  8672d51 (philwo@google.com)
      gclient: Add skip-git experiment.

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: I1e6585316c8d51e1a2e2731b38f1c531fb810c7f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5024437
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-11-13 18:15:11 +00:00
Daniel Verkamp
fb19a6c304 dev_container: check if /dev/kvm is a char device
/dev/kvm is not a normal file, so os.path.isfile("/dev/kvm") returns
False. Use pathlib's is_char_device() check instead.

TEST=tools/dev_container --stop; tools/dev_container

Fixes: 0be7e9757e ("dev_container: Only pass /dev/kvm if present")
Change-Id: I150009beb9b0b438013c2dd86fae7f99c959be75
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5021441
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Pierre-Clément Tosi <ptosi@google.com>
2023-11-13 17:03:08 +00:00
recipe-roller
ac5ec84d82 Roll recipe dependencies (trivial).
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/8764542375567420945

depot_tools:
7f22330c69
  7f22330 (liviurau@chromium.org)
      Make rdb status calculation reusable

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: I3711888575ac05b3f7a2cdf592c7ebc88f5ed60f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5024433
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-11-13 12:40:33 +00:00
Joe Hattori
05d2d4f347 devices: virtio: Fix a simple doc comment
This commit fixes a simple doc comment on the method
`get_remaining_with_count`.

BUG=NONE
TEST=./tools/presubmit

Change-Id: I1b110274ab63d3797ca884907d200d916b62860f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5020114
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
Commit-Queue: Joe Hattori <hattorij@google.com>
2023-11-13 04:32:40 +00:00
Jakob Vukalovic
d31b856040 crosvm: Apply device tree overlays
This change propagates the overlay files to the `fdt::create_fdt`
function, load the file contents, and applies a series of device tree
overlays to the base device tree after it has been constructed.

Test: tools/run_tests
Bug: b/296796644
Change-Id: I01f4db604fba5b8ecd756f93d092432145357977
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4855968
Commit-Queue: Jakob Vukalović <jakobvukalovic@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-11 18:54:42 +00:00
Alyssa Ross
d9bc6e99ff Fix tests with non-4K pages
Change-Id: Ifc242d81fbaa7022554b96a9bb181ae390f231d7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5017868
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-10 23:26:00 +00:00
Daniel Verkamp
b2dc9003a2 base: unix: implement set_errno() for macos
The libc::__error() function seems to be the macOS equivalent of
errno_location().

<https://docs.rs/libc/latest/x86_64-apple-darwin/libc/fn.__error.html>

BUG=b:309020556
TEST=cargo test --target=aarch64-apple-darwin -p base

Change-Id: I4cd80cfbfd600d0a7ce9bd62511a91296c4dc994
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5014790
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
2023-11-10 22:59:04 +00:00
Daniel Verkamp
1eeb071622 crosvm: move plugin config into the plugin mod
This cleans up some extra #[cfg(feature = "plugin")] checks and slightly
reduces the size of the gigantic main config.rs file.

No functional change.

TEST=cargo test --features=plugin

Change-Id: Iaa5a8850adfafbbb6439183fb4e4af2dcd7939d4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5017969
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-10 22:50:39 +00:00
Daniel Verkamp
5c43797eb7 base: change Protection representation to bools
This makes the generic Protection code more portable and allows removal
of the unix-specific PROT_READ and PROT_WRITE constants from the base
public API.

Users of base should not need to change anything if they were already
using the Protection pub APIs (read(), write(), etc.)

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: I4100e333e1a2133d54942780ddd79f722194f487
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5013638
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-10 20:37:59 +00:00
Daniel Verkamp
de987e927c fuse: use base::Protection instead of u32
Convert from the libc PROT_READ and PROT_WRITE flags into the portable
base::Protection type one layer earlier than before. This makes the
`fuse` crate API not depend on the numeric constants for PROT_READ and
PROT_WRITE, which aren't necessarily the same on all platforms.
Currently it still will only work on Linux, but this is a step toward
making it generic.

BUG=None
TEST=tools/dev_container tools/presubmit

Change-Id: I8f036ca9a5d7066aeae5a8578a8cb45c41fa4883
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5014789
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-10 20:19:07 +00:00
Daniel Verkamp
be33277580 base: remove read_from/write_to_memory
These duplicate existing VolatileSlice and FileReadWriteAtVolatile
functionality. Removing them means that they don't need to be
reimplemented separately for each platform's MemoryMapping.

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

Change-Id: Ia4332159461efc001b4e980fdb2a9984e852c931
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5019440
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-10 18:41:10 +00:00
Daniel Verkamp
8bd5681104 base: deduplicate MmapError
The Windows and Linux versions were effectively identical, and the same
one should also work for macos.

BUG=b:309020556
TEST=tools/dev_container tools/presubmit
TEST=cargo build --target=aarch64-apple-darwin -p base

Change-Id: Ieaedc256acb80d2b1655cc51ad23899fcc667762
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5018780
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-10 18:24:12 +00:00
Jakob Vukalovic
9ab89c2832 cmdline: Add DT overlay command line options
This change adds a '--device-tree-overlay' command line option to pass
device tree overlay files which will be applied to the VM device tree.
The overlay files are opened and propagated to `Arch::build_vm`
function.

Bug: b/296796644
Test: cargo test
Change-Id: I6a1571b2b14cb36cdb9f02e099ef56ee263d6efc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4855959
Commit-Queue: Jakob Vukalović <jakobvukalovic@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-10 09:38:27 +00:00
Jakob Vukalovic
12dead57f2 cros_fdt: Implement overlay filtering
For large overlay files, sometimes it is not neccessary to apply the
entire overlay, and only a few nodes must be applied instead. For
example, a large overlay file may contain nodes for all devices that can
be assigned to a VM via VFIO. However, in most cases only a small subset
of devices will actually be assigned, so only a small subset of the FDT
overlay must be applied.

This change implements device tree overlay filtering. Ie, it allows the
API user to choose which overlay nodes will be applied to the base.
It is possible to pass a set of symbols (node labels) to `apply_overlay`
function, which act as a filter for the device tree nodes.

This requires defining node labels (symbols) in DT source and compiling
DT overlays (`-@` option in dtc), so that the node symbols are exported
in `__symbols__` node.

Bug: b/296796644
Test: cd cros_fdt && cargo test
Change-Id: I2238cf08b85e1825f668f83d8edadd2446a28869
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4855967
Commit-Queue: Jakob Vukalović <jakobvukalovic@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-10 09:38:05 +00:00
recipe-roller
0515360dee 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/8764833040143611425

recipe_engine:
2e756c9e02
  2e756c9 (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from b9d18397d77b to bd7ce256f73f

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: Ie3668d7de292d3fb009197534ede7ffec4901c75
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5018791
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-11-10 07:39:26 +00:00
recipe-roller
df118b399b 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/8764856946871801601

recipe_engine:
1453bfeae7
  1453bfe (bryner@google.com)
      Add the 'packaging' wheel for recipes.

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: Ic9ffe8267a86dba47ccebd3a2ce76d6064349839
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5019444
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-11-10 01:17:48 +00:00
Daniel Verkamp
668ad1f774 base: linux: delete more unused signal-related code
Change-Id: I65199a02318deac633fcd5ab80d2a94fa541a474
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5018779
Reviewed-by: Frederick Mayle <fmayle@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-11-09 21:40:08 +00:00
Daniel Verkamp
b597e2bd27 base: linux: remove unused scoped_signal_handler
This is dead code and can be removed.

Change-Id: Ic6bee7b3a6fe59af117f7667ce4ff2a893cf9228
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5018778
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-09 21:04:40 +00:00
recipe-roller
a2bd9441f4 Roll recipe dependencies (trivial).
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/8764878339234083057

depot_tools:
88cc0b8ca8
  88cc0b8 (sokcevic@chromium.org)
      Remove old Cog detection

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: Idf0287388944ae13fd6906eeeb3369392166c7a6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5018696
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-11-09 19:36:11 +00:00
Daniel Verkamp
e453124f0f base: windows: remove Uid, Gid, and Mode types
These are not used anywhere in platform-independent code, so we can
clean them up.

BUG=b:309848917
TEST=tools/dev_container tools/presubmit crosvm_unit_tests_mingw64

Change-Id: Ic5a9ceeee2a41a5a9ff401e0bd59d0921897a0d6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5015650
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-09 17:59:14 +00:00
recipe-roller
9d542e6daf Roll recipe dependencies (trivial).
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/8764909793399966625

depot_tools:
5828285134
  5828285 (philwo@google.com)
      Deprecate autosiso.bat and autosiso.

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: Ie89d7e4e7ee4eb0be652fda44a3a4602b34a468b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5016797
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-11-09 11:15:09 +00:00
recipe-roller
568a8174c8 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/8764943139952176689

recipe_engine:
5aabe73071
  5aabe73 (mohrr@google.com)
      [lint] Remove --whitelist compatibility option

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: I2e03b82a99d8f261961c1a19feddacd79a2df5c9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5014855
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-11-09 02:29:29 +00:00
Frederick Mayle
e13058bb4a devices: virtio: console: preserve input file on sleep
Tested by using a VM with the following option and verified the TTY
works after a susend-resume sequence.

    --serial=type=stdout,stdin,hardware=legacy-virtio-console,console

Bug: 309816267
Change-Id: I16e3fdd5bfb2dc6dc8ceffb5e71c8aa4c9ffa7f7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5013636
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-11-09 02:03:54 +00:00
Frederick Mayle
848a8c4290 devices: virtio: console: preserve output file on sleep
BUG=b:309816267

Change-Id: I1baf006b76d71f0359cd1256ff51c459de99feb6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5013635
Reviewed-by: Elie Kheirallah <khei@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-09 02:03:54 +00:00
Frederick Mayle
d0f649884a devices: simplify sleep/wake for buses
There was some redudant logging and inconsistent error formatting.

Change-Id: I398467957d656316e46c19287d03a1b9484437a9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5013634
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Elie Kheirallah <khei@google.com>
2023-11-09 02:03:54 +00:00
Federico 'Morg' Pareschi
e2c86810a5 devices: usb: Add dispatch macro to backend enum
We introduce a new macro to dispatch function calls across different
enum fields to simplify the code. This way we don't have to
re-write multiple match statements for each backend type and
implementation, as most code will be shared (but some may differ).

BUG=b:297957754
TEST=presubmit and tested USB behavior on a DUT

Change-Id: Ib4bc53a9baf3398b66b3e4a4678d3ad4d817ee28
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4943431
Auto-Submit: Morg <morg@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2023-11-09 01:53:10 +00:00
Daniel Verkamp
ad11022bbf base: clean up Pid type definition
Move the Linux Pid type to unix (it should work for any unix-like
environment) and redefine the Windows Pid as DWORD to match
GetProcessId() and similar APIs (rather than declaring a pid_t type on
Windows).

BUG=b:309848917
BUG=b:309020556
TEST=tools/dev_container tools/presubmit
TEST=cargo build --target=aarch64-apple-darwin -p base

Change-Id: Iaa1cddb84eb16b94fe35c02f2f4988b8d955318a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5014787
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-09 01:26:20 +00:00
Daniel Verkamp
b1aa58ba8b base: move sysconf wrappers to unix
These should work for both Linux and macOS.

BUG=b:309848917
BUG=b:309020556
TEST=tools/dev_container tools/presubmit
TEST=cargo build --target=aarch64-apple-darwin -p base

Change-Id: If0353304bf12b1596adb64e412ee8d39c825db38
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5014786
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Cody Schuffelen <schuffelen@google.com>
2023-11-09 01:26:20 +00:00
Norman Bintang
8e86372078 e2e_tests: Add tests for vhost user snd
BUG=b:309032358
TEST=./tools/run_tests --dut=host

Change-Id: I599c235effd7edcec4fa4341bb7e8db04ab91321
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5004931
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Norman Bintang <normanbt@chromium.org>
2023-11-09 00:46:21 +00:00
Pujun Lun
8bb5b07a9d gpu_display: turn window messages into enums.
The WindowMessage enum covers general window messages that multiple
modules may want to process, such as window manager, input manager,
etc.

After this change, it isn't necessary to have the HandleWindowMessage
trait anymore. It will be nuked in the follow-up CL.

BUG=b:244492422

Change-Id: Ib4d8dfd29ff7d7f55aa2d1f759b091aee32c2cdf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5002765
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2023-11-08 20:53:35 +00:00
Vikram Auradkar
fd83ee4f2e tools: start podman machine on windows if it not already running
BUG=b:308883445
TEST=on windows ran `py .\tools\dev_contain` with/out machine running

Change-Id: Ib6fe00e4f5b6630a9595b57aedd3dcc00efe8860
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5010883
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
2023-11-08 20:42:13 +00:00
Daniel Verkamp
488633a762 plugin: append to String instead of format! + collect
Change-Id: Ie80b6a98847d6f8ffd78014e89737ad4beb88c51
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5009191
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-08 19:42:16 +00:00
Daniel Verkamp
4241704e84 General clippy fixes for Rust 1.73
- Replace unwrap_or_else(Vec::new) with unwrap_or_default()
- When implementing PartialOrd for a type that has Cmp, use .cmp()
- Create zero-initialized Vec with vec![] macro
- Fix extra slash in doc comment (//// -> ///)

Change-Id: I92a37cdffbe5a297b9f5d08a9264040f7fdac721
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5007730
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-08 19:21:49 +00:00
recipe-roller
cb768bdac3 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/8764970194304955585

recipe_engine:
d084b4e8e9
  d084b4e (chromium-autoroll@skia-public.iam.gserviceaccount.com)
      Roll CAS Client from 2baa055d4de9 to 38b65dfa7a0d

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: I1c58ee9b609fabba9e0d2509102fb5a53c54d72b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5013630
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-11-08 19:18:00 +00:00
Daniel Verkamp
64d1c50ab3 cros_fdt: embed test data with include_bytes!()
This allows the test binary to run without opening any files from the
source directory, fixing the ChromeOS crosvm ebuild tests.

TEST=`FEATURES=test emerge-hatch crosvm`

Change-Id: I3ced2d69f2ffb43305e8e13fc9f8b6a548120b44
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5013626
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-11-08 18:44:54 +00:00
Dennis Kempin
594c3a07a0 infra: Disable RISCV builder
Unfortunately, riscv for debian has not been stable enough for us
to reliably build containers for cross-compilation.
Hence the builder is disabled for now.

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

Change-Id: Icee9802f8bcb6a9586ff857105b76591e9de1099
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5014784
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-08 18:44:31 +00:00
Dennis Kempin
50c265f856 install-deps: Upgrade binstall and fix source builds of dependencies
Running cargo binstall on some packages will install them from source
if no binary release is available.
In that case, the rust-toolchain file of the CWD is used for building,
which may not be the right version required by the binary package
we are trying to install.

The new version of binstall is now also able to pull binaries from
github releases without hitting API quotas.

BUG=b:309563518
TEST=./install-deps

Change-Id: I869002cf766f806f66ba58d5b712b81c0bd30f4f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5014783
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2023-11-08 18:03:37 +00:00
Pierre-Clément Tosi
eb06aab7fa vfio: Call VFIO_CHECK_EXTENSION(Type1ChromeOS)
Align with the uAPI documentation, which states that

  /**
   * VFIO_SET_IOMMU - _IOW(VFIO_TYPE, VFIO_BASE + 2, __s32)
   *
   * Set the iommu to the given type.  The type must be supported by an
   * iommu driver as verified by calling CHECK_EXTENSION using the same
   * type. [...]
   */

Note that if a kernel supports Type1ChromeOS but doesn't properly
implement CHECK_EXTENSION for it, crosvm will now fall back to TYPE1v2.

TEST=tools/run_tests
BUG=b:306110430

Change-Id: I4480f07a64edd945b83d2b3674334f46ff674066
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5010355
Commit-Queue: Pierre-Clément Tosi <ptosi@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-08 13:24:03 +00:00
Pierre-Clément Tosi
e7cc2ffa62 vfio: Harden VfioContainer IOMMU calls
As VFIO containers are assigned one (and only one) IOMMU type, keep
track of it in VfioContainer and detect IOMMU functions being wrongly
called before the IOMMU has been configured.

Note: no functional change intended.

TEST=tools/run_tests
BUG=b:306110430

Change-Id: Ie91d171de385d673041988b06cbc1ae2c875b8ed
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5009545
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pierre-Clément Tosi <ptosi@google.com>
2023-11-08 12:55:44 +00:00
Pierre-Clément Tosi
7c66e3ebe2 vfio: Pass IommuDevType to VfioContainer
Instead of relying on abstractions that aren't fully encaspulated (such
as assuming that !iommu_enabled means vIOMMU or CoIOMMU or the way
IommuTypes are being selected), make the VfioContainer constructor aware
of the IommuDevType in use.

Note: no functional change intended.

TEST=tools/run_tests
BUG=b:306110430

Change-Id: I4d2f6afbc0bc9b8b4fe595550b9e8b5af2d06bda
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5009544
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-08 12:55:44 +00:00
Pierre-Clément Tosi
8e3cbaf4c4 vfio: Flatten VfioContainer::get_group*()
Remove 2 levels of unnecessary indentation before any actual change.

Note: no functional change intended.

TEST=tools/run_tests
BUG=b:306110430

Change-Id: Ib34405733d0c5734ffbd606b55bc43ada82648d0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5009543
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-08 12:55:44 +00:00
recipe-roller
227ed4cf5b Roll recipe dependencies (trivial).
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/8765026816476227649

depot_tools:
a83e690662
  a83e690 (aredulla@google.com)
      [ssci] Add condition on license field separator warning

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: I7425ec34d0ae21d09e8d976d5eb1679f4a9dd6d8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5011328
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-11-08 04:18:12 +00:00
Shintaro Kawamura
cfe4220507 swap: shutdown the monitor process on dropping SwapController
Even main process shutdown by an error, the vmm-swap monitor process
should be terminated by Command::Exit via the command tube. Dropping
SwapController without explicit SwapController::exit() has caused panic
by tube disconnection in the monitor process when the main process shuts
down by an error.

SwapController will never be dropped in child processes because
ProxyDevice and fork_process() exit with libc::exit() and not drop
objects in the upper stack.

BUG=b:309463106
TEST=manual test

Change-Id: I35386dd1aefe15dafd3e9981a9432c00f8faa3fa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5009772
Reviewed-by: David Stevens <stevensd@chromium.org>
Commit-Queue: Shin Kawamura <kawasin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-08 02:43:43 +00:00
A. Cody Schuffelen
1d50332ec5 Restore handle_eintr from linux to unix
Bug: b/309020556
Change-Id: Ib593b1105c3c70b857f66b3e72008ab410b1c84b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5005753
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-08 02:15:54 +00:00
A. Cody Schuffelen
3f44e7d860 Extract unix parts from base/src/sys/linux/file_traits.rs
`fallocate` is Linux-specific. On Linux, `pread*64` and `pwrite*64` are
renamed to `pread*` and `pwrite*` to match the posix definitions.

Bug: b/309020556
Change-Id: Iadeaa843af9380b09a3fa7a7d3ef4ad57c9641dd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5001582
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2023-11-07 21:53:30 +00:00
A. Cody Schuffelen
12922a52ad Remove descriptor_reflection exports from platform-specific code
Every platform was re-exporting the non-platform-specific symbols
defined in descriptor_reflection.rs.

Change-Id: I95d0acdaaf8c157206ca788e4cdf64f15ebd2f84
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5001574
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
2023-11-07 21:35:42 +00:00
recipe-roller
e35530c8df Roll recipe dependencies (trivial).
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/8765052611764390721

depot_tools:
197399a8ac
  197399a (tperrotta@chromium.org)
      depot_tools: add a `--dry-run` alias to `--cq-dry-run`

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: I6a2fb2c85a541bf681ced88c1d26bcbedc03e259
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5009602
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-11-07 21:30:29 +00:00