Commit graph

4224 commits

Author SHA1 Message Date
Dennis Kempin
163494513c infra: Add cros_workon flow to chromeos builder
We want to ensure that ChromeOS workflows to not break over time.
This is the primary supported workflow for building and testing
crosvm.

BUG=b:239255196
TEST=led get-builder luci.crosvm.ci:chromeos_amd64-generic | led
edit-recipe-bundle | led launch
https://ci.chromium.org/swarming/task/5c3a9bd9490cad10

Change-Id: I3afed9ebeff3ac2829fc7990ff520c24017ac812
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780866
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-07-21 18:35:51 +00:00
Dennis Kempin
b97b89fc0f Update ChromeOS Docs
Reflecting the new repository, supported workflows
and code submission process.

BUG=b:239255196
TEST=None

Change-Id: I52d7130ec3d72ea5ef8748875cae029f0b1f701b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780864
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-21 18:35:51 +00:00
Dennis Kempin
353efef6d9 infra: Add project-crosvm-committers group
The group will allow us to give service accounts CQ access.
Notably it'll allow us to add the recipe autoroller.

BUG=None
TEST=lucicfg validate

Change-Id: I3127dc2127a93ea8b76bfd31941095eb243556c2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764437
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-21 18:34:41 +00:00
Keiichi Watanabe
c6245341ec devices: vmwdt: Fix rustdoc::bare_urls warnings
BUG=none
TEST=tools/cargo-doc

Change-Id: Ibec2c3f289f57cbabc1533a97fbfb20dbe3385ed
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780082
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-07-21 17:22:00 +00:00
Daniel Verkamp
967e30e0fc windows: adjust import paths and Cargo.toml deps
Fill in some of the missing imports and adjust the ones with paths that
differ in upstream crosvm.

This change was tested by removing crosvm from WIN64_DISABLED_CRATES in
tools/impl/test_config.py. Some dependencies are still missing, so the
crosvm bin crate does not fully compile yet.

BUG=b:213146388
TEST=run_tests --build-target=mingw64

Change-Id: I112e1db8bf34eed9fba7e539ce8ec84318acd291
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3777070
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-07-21 17:19:50 +00:00
Daniel Verkamp
000cee6a9e metrics: add is_initialized() stub
This is used in src/sys/windows/main.rs.

BUG=b:213152497
TEST=Attempt to build crosvm bin crate for Windows

Change-Id: Ia49b9925a85ed738bcc6a229efd79840e9fd6c72
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3777069
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-21 17:11:00 +00:00
Keiichi Watanabe
3c82cee8c0 tools: cargo-doc: Exclude crash-report feature
Exclude crash-report feature when generating cargo-doc because the
feature only works on Windows. This should fix GitHub action's failure
started by crrev.com/c/3765346 [1].

[1] https://github.com/google/crosvm/runs/7417889096?check_suite_focus=true

BUG=none
TEST=run ./tools/cargo-doc locally

Change-Id: I1481bf8221fc7a583b9147992d116278b4df9e05
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780081
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-07-21 16:57:14 +00:00
Doug Horn
8d79dbb21c Fix build with no crash-report.
Bug: NONE
Test: Compile

Change-Id: Idb905038e1982babcd2ff936674986d9ff24ac8c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3777068
Tested-by: Doug Horn <doughorn@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Doug Horn <doughorn@google.com>
2022-07-21 15:43:10 +00:00
Vikram Auradkar
33974789a7 devices: add bus statistics
Collect stats for read and write functions.

BUG=b:213149155
TEST=presubmit

Change-Id: Ia9d6a5fe006d2377dadde7215a9bf6ecd7966b13
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3773173
Tested-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-07-21 15:14:50 +00:00
Sebastian Ene
acb1f6683c vmwdt: Add memory mapped watchdog backend driver
This adds a new dt node identified by "qemu,vm-watchdog". The watchdog
is instantiated per-cpu and each instance has the following layout
described in this document:
https://docs.google.com/document/d/1DYmk2roxlwHZsOfcJi8xDMdWOHAmomvs2SDh7KPud3Y/edit?resourcekey=0-oSNabc-t040a1q0K4cyI8Q#heading=h.4hbqud2zl941

The watchdog uses an internal clock which is driven by the
timerfd at regular intervals. When the internal clock expires, a counter
value is decremented. When the counter register reaches value "0",
the watchdog expires. To prevent 'watchdog expiration', regular pet
events should be sent from the guest kernel driver.

BUG=b:213422094
Signed-off-by: Sebastian Ene <sebastianene@google.com>
Change-Id: Ic8c0488ffdfed1a43b6deb34b72d37f46e5e18a2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3768290
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-21 14:07:11 +00:00
Gurchetan Singh
51c07a15b3 crosvm: nuke gfxstream syncfd
Nobody ever toggles this flag, implying this flag can be removed.

By default, the gfxstream assumes ANDROID_EMU_virtio_gpu_native_sync
is present, which is the desired behavior.

BUG=b:239639751
TEST=compile gfxstream

Change-Id: I64d19c5fc2c0ac59a87ee25fbd1e7b6ed9522410
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3778078
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-07-21 00:16:41 +00:00
Gurchetan Singh
0ae68e5076 rutabaga_gfx: gfxstream: stream_renderer_context_create
Newer version with context init variable.

BUG=b:235485545
TEST=compile

Change-Id: Ia9ce7a17c59db9839bdb0caf42a97708a3fdb46f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3778077
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-07-20 23:51:30 +00:00
Daniel Verkamp
e6eeb715f3 main: clarify config parsing control flow
It was a bit difficult to see that the config parsing errors would be
printed out before init_log(); split it into a separate block to make it
more understandable.

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

Change-Id: Id7fb76c706c2e9f5e0161dac28099bff95fd5f78
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3774317
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-20 21:19:00 +00:00
Daniel Verkamp
f0d2ddddf5 main: print config errors with eprintln
If run_vm fails to convert the RunCommand into a Config (e.g. due to
failures in validate_config), no error message would get printed, since
the error!() logging macro was used before logging was initialized.

Instead of error!(), use eprintln!() to print the error to stderr so we
actually get useful output for configuration validation errors.

BUG=b:239622092
TEST=crosvm run --kvm-device /does/not/exist vm_kernel

Change-Id: Ia63f5b10f6ac7087aca10aa71df7d45a6fd5b70e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3774316
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-07-20 21:19:00 +00:00
Dennis Kempin
f4e4f35d4a infra: Fix git repack cwd
BUG=None
TEST=./infra/recipes.py test run
led get-builder luci.crosvm.ci:health_check | led edit-recipe-bundle | led launch

Change-Id: Idd6b0b70271bbc0b489bd4a25470ca53e1e2a4ac
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3777063
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-20 20:43:15 +00:00
Dennis Kempin
7be83ca79a infra: Repair submodules if sync fails
The submodules on our builders were getting into a bad state.
This change should be able to repair those cases.

BUG=None
TEST=./infra/recipes.py test run

Change-Id: I87198c30478f25d505f9a9ad5211af6fe7bbd547
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3777061
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-07-20 20:05:50 +00:00
Daniel Verkamp
8b62989327 crosvm: plumb --hypervisor option to cmdline
This allows the selection of the hypervisor kind from the command line;
it was previously added to Config, but there was no way to set it from
the CLI.

Linux builds only have one hypervisor available (kvm), but the config
support is stubbed out to match the Windows platform code so it can
potentially be hoisted into a common implementation later.

BUG=None
TEST=tools/presubmit --all
TEST=crosvm run --hypervisor kvm ...

Change-Id: I6eedb6f8179233bfd51f56efd6713cfe9453dc25
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3774503
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-20 20:03:29 +00:00
Daniel Verkamp
52675ca555 crosvm: clean up kvm device creation checks
Remove the redundant file existence checks and replace them with a
better error message from the call where we open /dev/kvm or the path
specified by the user with --kvm-device.

Example error message:

  crosvm has exited with error: failed to open kvm device
  /does/not/exist: No such file or directory (os error 2)

BUG=None
TEST=crosvm run --kvm-device /does/not/exist vm_kernel

Change-Id: I8ba7ce5d77441f193174ec891709a47165787a9f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3774502
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-20 05:15:40 +00:00
Dmitry Torokhov
e3554d516d devices: vvu: remove knowledge of PCI from open_vfio_device
Now that we no longer switch drivers for VVU PCI devices when accessing
them via VFIO, open_vfio_device() need not be aware that it is dealing
with a PCI device and can instead handle any device given its sysfs
path.

BUG=b:196186396
TEST=Boot redrix-manatee, start crostini.

Change-Id: Ieda8f2b846a96b9c054dfdd0602101a4b3c11424
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3766820
Auto-Submit: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Tested-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-07-20 00:49:09 +00:00
Vikram Auradkar
7110ddc62b x86_64: build and test on windows
BUG=b:213149155
TEST=presubmit

Change-Id: I15d217ffd355563b839bf4d7b0d0a19e01666060
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3774497
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-07-19 23:55:49 +00:00
Vikram Auradkar
1a29d849a4 devices: refactor acpi
Enable acpi on windows.

BUG=b:213149155
TEST=presubmit

Change-Id: I697f118ca59b73679debeed7a4b7c168b8c61b1b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3774496
Tested-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-07-19 23:55:29 +00:00
Vikram Auradkar
ce5172c899 crosvm: upstream windows src
- Upstreams all windows specific files in src/
- Adds windows specific args to Config/Command parsing.
- Adds noop anti tamper crate.

There are still some deltas between upstream and downstream src because
of moving HEAD in upstream and some code refactors downstream. But this
is most of the code.

BUG=b:213146388
TEST=built on windows downstream. upstream crosvm does not build on
     windows yet because of to-be-upstreamed dependency crates.
     presubmit.

Change-Id: I3445975749f8108ae51d5fb6e1c2f1447439e1fb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765346
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-19 20:58:59 +00:00
Noah Gold
46b9f75a36 arch: split platform serial code into sys mod.
As part of the split, we're re-enabling the Windows code (it was
commented out as part of earlier refactoring).

BUG=b:237597358
TEST=builds

Change-Id: I04554b109033b4616c0a6521757c4aeb70d2ea5d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3767462
Tested-by: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-07-19 18:20:59 +00:00
Zihan Chen
e2f7c0c24b crosvm: Fix cross-compile in dev container
- Fix devcontainer.json to be used by vscode correctly
- Fix wayland-protocols path finding
- Add missing SYSROOT env for pkg_config
- Add missing linker settings

TEST=native/armv7/aarch64 targets compile in dev container

Change-Id: Id6fc43b2fd63d09bc46169d996387d5417ada93e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3766822
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-07-19 17:07:49 +00:00
Daniel Verkamp
6385eee278 devices: remove ioevents() overrides that can use the defaults
A few PciDevice implementations were providing an ioevents function that
did the same thing as the default trait implementation. Remove them to
clarify which devices actually need ioevent support.

BUG=None
TEST=cargo build

Change-Id: I40a6ca14028ea1d739f169c81079ffac648e7035
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3770820
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-07-19 16:41:59 +00:00
Norman Bintang
022fb73b67 audio: Reconfigure usage of audio_cras cfg
Reconfigure usage of audio_cras cfg to allow virtio-snd device
to be compiled with null audio device. audio cfg is still needed
to compile audio device. Also fix clippy errors in virtio-snd.

BUG=b:233542268
TEST=emerge and aplay with enabled and disabled audio_cras cfg

Change-Id: I2e0a4114314891794dbf3c060f47247f876db80a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765005
Commit-Queue: Norman Bintang <normanbt@chromium.org>
Tested-by: Norman Bintang <normanbt@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2022-07-19 06:31:39 +00:00
Dennis Kempin
a919bcb7a5 tools/dev_container: Support cros checkouts
Mount the cros root instead so the git worktree or symlink can be
resolved.

BUG=b:234322274
TEST=./tools/dev_container

Change-Id: I52d0cbe5e9a38cb6febcf1f328970e13209bcf9f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3768048
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
2022-07-18 23:32:48 +00:00
Daniel Verkamp
4ca8a5fe3a config: parse VvuOption with serde_keyvalue
This removes a bunch of boilerplate parsing code.

BUG=None
TEST=cargo test

Change-Id: I8c557feb9f483552f3ba7f905eb49b53f48d8177
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3767095
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-18 20:07:18 +00:00
Daniel Verkamp
67eb9cfb33 devices: pci: serialize PciAddress as a string
Implement custom serde Serialize/Deserialize versions that just format
the PciAddress as a plain string rather than a struct so it can be used
for parsing command-line options.

BUG=None
TEST=cargo test -p devices

Change-Id: Ia6e5891c614be1fc7e1d136e40835e1622f5a2c0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3767094
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-18 20:02:28 +00:00
Vikram Auradkar
f1d8ff7d19 devices: refactor bat.rs
Windows does not use monitor. Move unix specific monitor feature
under sys/unix.

Enable bat module for windows.

BUG=b:213149155
TEST=presubmit

Change-Id: Ic48562f4d7e78a332e5387e5274131d35a59a7b5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764428
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-07-18 16:34:39 +00:00
Daniel Verkamp
db94670f7f main: restore --syslog-tag functionality
The crosvm run --syslog-tag argument was accepted, but it did not do
anything after the argh refactor. Tweak the LogConfig setup so the
default tag is "crosvm" and can be overriden by the --syslog-tag option.

BUG=None
TEST=crosvm run --syslog-tag="TESTVM" ... # observe tag in syslog

Change-Id: I7cd83b0623ac725c59a1dc1fcc4f8952e749e00a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764041
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
2022-07-16 03:17:26 +00:00
Alexandre Courbot
96c3a79138 virtio: vhost: user: use volatile access to memory-mapped registers
We recently started to map VVU device registers into the process address
space, but accessed them like regular memory. This is dangerous as the
compiler can reorder and optimize these accesses.

Add new `write_obj_volatile` and `read_obj_volatile` ops to
`MemoryMapping` that are designed to perform such I/O accesses and use
them where appropriate.

BUG=b:238282334
BUG=b:237647217
TEST=VVU console device can be created from Linux.

Change-Id: I40f30acfd358248d4f9d0c00d5cd708eabae047d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762971
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-07-16 01:25:47 +00:00
Alexandre Courbot
95a00b9a99 base: mmap: merge identical methods on Windows and Unix
Move MemoryMapping's implementations of write/read_slice, write/read_obj
and get_slice as well as the definition of the MappedRegion from the
platform module into the base mmap module, since these definitions were
strictly identical between Windows and Linux. This removes quite a bit
of duplicated code.

In the process, some tests need to be adapted in order to work with the
common MemoryMapping type instead of the platform one, as the above
mentioned methods become unavailable on the platform type.

BUG=b:213153157
TEST=./tools/dev_container ./tools/run_tests --target=host
TEST=./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64
TEST=cargo test -p base --doc

Change-Id: I20e6f47c3c4763b63eae707a527a084b229cd951
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762970
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-07-16 01:16:36 +00:00
Alexandre Courbot
35bb8c6efd base: mmap: merge Unix and Windows implementations of Protection
Windows and Unix now use identical code for their Protection
implementation, the only difference being the value of their PROT_*
constants. Make the contants part of the platform and use these from the
common mmap module to avoid duplicated code.

BUG=None
TEST=./tools/dev_container ./tools/run_tests --target=host
TEST=./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64

Change-Id: I95f2769e868f32ae70de8159ac4fbb481c4ef467
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762969
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2022-07-16 01:08:46 +00:00
Alexandre Courbot
395c486ce9 base: remove Protection::none() constructor
This state is invalid for Windows, and we can easily avoid using it
altogether.

BUG=None
TEST=./tools/dev_container ./tools/run_tests
TEST=./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64

Change-Id: Id5aba0498f9c19df0d95e86aea04fbe8a4023707
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762968
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2022-07-16 00:49:56 +00:00
Alexandre Courbot
1f04bbc602 base: windows: convert protection to use c_int internally
The Windows and Unix Protection struct are extremely close, with the
only difference being how they internally represent their state. Make
the Windows implementation adopt the same storage type as the Unix one
so we can merge them.

BUG=None
TEST=./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64

Change-Id: Idb47243e7d2003d7eb499e683993dba2419e8841
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3762967
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-16 00:49:46 +00:00
Daniel Verkamp
57470a47d0 tools/cl: don't try to prune branches with no upstream
This cleans up the output a bit when there are many local branches that
don't have an upstream configured.

BUG=None
TEST=tools/cl prune

Change-Id: Ic5892dcbca315613682326c5615fce28d49b421d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764046
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
2022-07-15 22:58:46 +00:00
Richard
d12728e6d3 devices: Enable virtio snd and console build/test for Windows
BUG=b:237011316
TEST=ran "./tools/run_tests --target=host --build-target=mingw64 --verbose"

Change-Id: I0660bd123f6a4a9ad9f256710ca62191dc749d86
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764372
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
Tested-by: Richard Zhang <rizhang@google.com>
2022-07-15 22:46:06 +00:00
Colin Downs-Razouk
98b42fd75f devices: tsc: calibrate handle offline cores
If a core is offline, we will not be able to set the cpu affinity to
that core. The TSC calibration code attempts to determine the TSC offset
of all cores. Determining which cores are online requires parsing the
contents of /sys/devices/system/cpu/online on linux, and it's not clear
how to do it on Windows. Instead, the calibration code will treat errors
when calling set_cpu_affinity as legitimate reasons for a core to be
offline, and will exclude that core from the offset information in the
TscState. This will prevent the TSC sync mitigation logic from setting
any vpu's affinity to that core.

This also changes how number_of_logical_cores is implemented on linux,
to count the number of configured cores instead of the number of online
cores, which seems more correct.

BUG=b:230372694
TEST=added a new unittest, also ran unittests with an offline core

Change-Id: I12c187a7ca1dd06e25b396eaeae542628fdf563c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764280
Tested-by: Colin Downs-Razouk <colindr@google.com>
Commit-Queue: Colin Downs-Razouk <colindr@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-07-15 22:23:06 +00:00
Dennis Kempin
53c7515c3f tools/cl: Add prune command
The prune command will delete all branches with gerrit changes
that have been submitted.

BUG=None
TEST=./tools/cl prune

Change-Id: I2f942591e6e29a16d1ed6655655ef9f8cb4fd34f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765345
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-07-15 21:29:36 +00:00
Dennis Kempin
a02065aadb tools: Move gerrit utilities into common.py
These will be useful in other scripts as well.

BUG=None
TEST=./tools/chromeos/mergebot update-dry-runs

Change-Id: Id75ed458fdd212d4564a547274209b1f39796ceb
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765344
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-07-15 21:23:16 +00:00
Daniel Verkamp
15fe29bae3 seccomp: add rseq to x86_64 common_device.policy
This was missed in the original rseq change.

BUG=b:235172163
BUG=b:235960683
TEST=emerge-hatch crosvm

Fixes: 17c782f1c1 ("seccomp: add rseq to all policy files")
Change-Id: Id78f0e0cd5c22142230abdc0cea6a7f91d492569
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765348
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-15 20:55:46 +00:00
Richard
d569281cc6 devices: Upstream Windows implementation for Serial
This adds a sync thread that will call `fsync` once a second. This is a
safety measure since Window OS handles flushing automatically, but has been
proven to be somewhat unreliable.

TEST=built and presubmits
BUG=b:233951530

Change-Id: I7f5922da09fd95999bf8a7a40abc3b6ae796eafc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764466
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-07-15 20:50:16 +00:00
Daniel Verkamp
7159299e9a Revert "seccomp: allow rseq syscall"
This duplicates rseq in all of the policy files and causes the minijail
compiler to fail due to duplicate definitions.

rseq was already added in commit 17c782f1c1 ("seccomp: add rseq to all
policy files").

This reverts commit 1a7a822858.

BUG=b:235960683
TEST=emerge-trogdor crosvm

Change-Id: I9d45897e6815b6cdd5ef376a27563ebc4af06bdd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765347
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
2022-07-15 20:45:46 +00:00
Richard
27d27a0402 audio_streams: Upstream to support Windows
BUG=b:213150293
TEST=built and presubmits

Change-Id: Ia032dd4645d5a827e4b462ebbf9d10db410f5468
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764468
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Tested-by: Richard Zhang <rizhang@google.com>
2022-07-15 20:33:15 +00:00
Daniel Verkamp
57d3db037f devices: tsc: use slice where a Vec is not needed
Fixes a Rust 1.60 clippy lint:

  error: writing `&mut Vec` instead of `&mut [_]` involves a new object
  where a slice will do

BUG=b:239075544
TEST=tools/clippy # with rust-toolchain = 1.60.0

Change-Id: Ib1a8e30bc70a7c7036c038f364ec1067169a0698
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764423
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-07-15 18:27:56 +00:00
Daniel Verkamp
c8506b8abb virtio-video: use to_vec() to copy &Vec
Fixes a Rust 1.60 clippy lint:

  error: called `iter().copied().collect()` on a slice to create a
  `Vec`. Calling `to_vec()` is both faster and more readable

BUG=b:239075544
TEST=tools/clippy # with rust-toolchain = 1.60.0

Change-Id: I37ac1b5708ed5f8a1ac5487225fe2ee8fb6486ad
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764422
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-07-15 18:27:56 +00:00
Dennis Kempin
943b7432b6 infra: Enable allow_submit_with_open_deps on CQ
BUG=None
TEST=lucicfg validate

Change-Id: Ibad9d90bad730c9bf6cc858032abe20585713dba
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765376
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-07-15 17:50:11 +00:00
Daniel Verkamp
3bd68ea223 libva: use slice rather than Vec for attributes
Fixes a Rust 1.60 clippy lint:

  error: writing `&mut Vec` instead of `&mut [_]` involves a new
  object where a slice will do

BUG=b:239075544
TEST=tools/clippy # with rust-toolchain = 1.60.0

Change-Id: I273bd647067b807982f9a9b7248ba788ad3f2032
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764421
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-07-15 17:41:15 +00:00
Daniel Verkamp
7c47dfe3f2 tests: disable plugin_hint test
This test uses kill(getppid(), SIGSTOP), which stops the cargo test
runner process instead of crosvm as intended.

Skip it until someone has time to fix it.

BUG=b:239094055
TEST=cargo test --features=plugin -- --test-threads=1

Change-Id: Ib41351154bc585cecc8471f0150f393ce9431da9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764464
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-15 17:35:52 +00:00