Commit graph

4235 commits

Author SHA1 Message Date
Junichi Uekawa
6e7a617abb crosvm: Make commands work.
Previewing docs, from CONTRIBUTING.md or from the dev_container, it's
`cd docs/book`.

BUG=None
TEST=copy-paste

Change-Id: If56a9f83c6722764b0979b6738f96a0800031da6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3779081
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-07-22 02:05:48 +00:00
Dennis Kempin
89f754b0be docs: Fix link to building_crosvm.md
BUG=None
TEST=mdbook build docs/book

Change-Id: I5331cb9fed056c8b57171ba3db4d5b2521e6995c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782185
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-07-22 01:52:58 +00:00
David Stevens
6d7143990a balloon: Improve optional queue handling
Make status queue properly optional. As part of this, refactor how the
optional event queue is handled, to prevent exponential growth in the
number of select statements needed to handle optional queues.

BUG=None
TEST=ARCVM boots and balloon works

Change-Id: I55d59875b7e0223a57f1c8c5d0e0d8a4a6b9a26c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3779083
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-07-22 01:27:23 +00:00
Richard
a5df8a52c0 devices: Upstream virtio vsock
Currently this only builds and runs for Windows

BUG=b:213149155
TEST=built and presubmits

Change-Id: Icc874da61c987fc36c4c9ccea56bd136d660f453
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764469
Tested-by: Richard Zhang <rizhang@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-07-22 00:29:48 +00:00
Mike Gerow
0c49f872a1 devices: add pflash to provide NVRAM for OVMF
This change adds a pflash implementation similar to the the one QEMU
has[1] for the purpose of giving OVMF a place to store BIOS settings and
UEFI variables. Unlike the QEMU version, though, this one only
implements the parts that OVMF relies on[2], and is therefore much simpler.

[1]: https://github.com/qemu/qemu/blob/HEAD/hw/block/pflash_cfi01.c
[2]: https://github.com/tianocore/edk2/tree/master/OvmfPkg/QemuFlashFvbServicesRuntimeDxe/QemuFlash.c

TEST=tools/presubmit --all; boot VM under OVMF and confirmed UEFI
variables can be set and are persistent
BUG=b:238344840

Change-Id: I83bebb57006f39c6f0eb7ee4986c6af0e64de0bc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3764374
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Mike Gerow <gerow@google.com>
Commit-Queue: Mike Gerow <gerow@google.com>
2022-07-21 23:17:32 +00:00
Vikram Auradkar
2314c4701b crosvm: Fix drift
BUG=b:213146388
TEST=presubmit

Change-Id: I59e6b7ad7aff8d4659c62e310a7955146a10d743
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3777405
Tested-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-07-21 23:13:18 +00:00
Daniel Verkamp
5a4ed32368 tools/cl: add prompt to set upstream branch if missing
When running tools/cl on a branch without an upstream set, ask if the
user would like the script to fix it automatically.

BUG=None
TEST=tools/cl upload # on a new branch with no upstream

Change-Id: Id5f4ee30058a209ac352013159d09278cd92a23b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780873
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-21 21:51:48 +00:00
Daniel Verkamp
32ba2688bb tools/cl: add prune to usage text
BUG=None
TEST=tools/cl --help

Change-Id: If4e632b00b04c9ab4644c37c039372969abf8c3a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780872
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-21 21:44:18 +00:00
Junichi Uekawa
15c09e6d7f crosvm: Spell fix.
BUG=None
TEST=None

Change-Id: I88830bdf8023f8e812e33bf6326f0dd39e970c61
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3779078
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Tested-by: Junichi Uekawa <uekawa@chromium.org>
2022-07-21 21:34:18 +00:00
Dennis Kempin
290622c389 tools/cl: Always run prerequisites
It was missing in some commands. Also runs them when no command
is specified. This will ensure the git hook is installed and
print documentation when calling: "./tools/cl"

BUG=b:239823229
TEST=./tools/cl

Change-Id: Id2248310011f4692cf477ac51d52b578d2f00a8d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780868
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-07-21 18:50:48 +00:00
Dennis Kempin
12d4f71cb2 Update CONTRIBUTING.md
The doc was long outdated.

BUG=b:239823229
TEST=None

Change-Id: If324c7b3fe22f03df4307a5eed1002465b5cce4d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3780867
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-21 18:35:51 +00:00
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