Commit graph

3853 commits

Author SHA1 Message Date
Noah Gold
eac74eb836 broker_ipc: add crate
Adds the broker_ipc crate, which is used for communication & setup tasks
shared between the broker (Windows orchestrator for crosvm & vhost-user
devices) and all other crosvm processes.

BUG=b:232318124
TEST=builds

Change-Id: I17d529305dd348a50574e6c3c082808e97ffff45
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3648474
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-06-03 22:00:11 +00:00
Noah Gold
b803f10fa2 base: add unix no op impl of enable_high_res_timers.
This is needed by broker_ipc (next crate in the chain).

BUG=232318124
TEST=builds

Change-Id: I7d71b9208123dd055b7150fd3ae6703cdc21bf6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3685809
Commit-Queue: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2022-06-03 22:00:10 +00:00
Dennis Kempin
59cfdaaff0 tools: Add tools/cl script as a helper for uploading to gerrit
See USAGE for documentation.

This tool will be needed to upload to the upstream repository, as
we will no longer be able to use repo.

Currently, for testing it still points to the chromiumos repository.

BUG=b:221088786
TEST=Follow USAGE

Change-Id: I4a8d88a8354942f0ddfb7f9420ef1cf7f5885867
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687419
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-03 21:35:31 +00:00
Dennis Kempin
9cf56a869e infra: Add merge_into_chromeos builder
This builder re-creates ci/build_merge_into_chromeos and just calls
the merge_bot script.

Eventually this could be better integrated with Luci UI. For now,
this is feature parity with Kokoro.

BUG=b:233913643
TEST=recipe.py run merge_into_chromeos

Change-Id: Ia5de775cad943687be654c3a054f1150ba9adbb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3673786
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-03 19:18:06 +00:00
Dennis Kempin
47e25297d5 merge_bot: Handle merge conflicts
The bot cannot resolve those automatically. To ease the process, we
will upload the merge anyway, so the oncall can download and resolve
the conflict.

Dry runs are not created when there are conflicts, they are bound
to fail and there is nothing the oncall can do about conflicts
until the actual merge is generated.

BUG=b:234847583
TEST=MERGE_BOT_TEST=1 ./tools/chromeos/merge_bot update-merges / update-dry-runs

Change-Id: I409e6b99284ff8a98b504b390c35329875d6a8b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3689544
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-03 19:12:04 +00:00
Dennis Kempin
ca66addad0 Update merge_bot to support merging across repos
We will be merging from the upstream repo into the cros repo. The
script can be run from both an upstream and a cros checkout, it
will setup the required remotes.

The CLI changes a little. We now require a revision to merge from
needs to be specified, since the script is not setting up the
upstream remote.

CI jobs will simply use HEAD, as the version to merge is already
checked out by the CI system.

BUG=b:233913643
TEST=
./merge_bot update-merges HEAD
./merge_bot update-merges origin/main
./merge_bot update-dry-runs HEAD

Change-Id: I247e1edc3ad951becf5d59b63efd74914bb2205f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687222
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-03 19:12:04 +00:00
Dennis Kempin
bebb69843a infra: Add a little documentation about testing recipes
Recipes can be tested with unit tests, run locally or run on a build
bot. The documentation shows how to do this.

BUG=None
TEST=None

Change-Id: Iec139de5c38d45765c9da0d95e8ac076c5df1dfd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3682200
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-03 18:36:40 +00:00
Kaiyi Li
26e0aeb03b crosvm: move gpu display parameter parser into one struct
BUG=b:233676779
TEST=presubmit

Change-Id: Ib30bab79fbe1e593a10e8807f4217d19b1ac24d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668928
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
2022-06-03 17:12:54 +00:00
Keiichi Watanabe
5fffb39355 devices: vvu-proxy: Introduce an enum to manage device lifecycle
Introduce `State` enum to handle vvu-proxy's lifecycle.
This state will be used to support recovery from sibling disconnection in the follow-up CL.

BUG=b:216407443
TEST=run VVU

Change-Id: I47f9c69abb9d08520ec90a4a9a87fc4d230c96a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591105
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-03 15:28:42 +00:00
Kevin Hamacher
75f7988c9b devices: virtio: user-net: allow MAC feature
vhost-user implementations of the net device can currently not
specify a MAC for the guest, even though they would support this.
This adds the corresponding feature to the allowlist and increases
the queue size to 1k to avoid situations where the device runs out
of available descriptors.

BUG=None
TEST=./tools/run_tests

Change-Id: Iefe8ce21215b36c65ee2516428249c41bf13f285
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3683380
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Kevin Hamacher <hamacher@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-03 08:53:09 +00:00
Keiichi Watanabe
ab9576ece6 docs: Add a page for vhost-user usage
BUG=b:233174191
TEST=mdbook build

Change-Id: I3fae676885a41ff6cd21b77f864a1379afe2a2ce
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3659818
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-03 03:11:23 +00:00
Keiichi Watanabe
c101f207da docs: Add a page about block device
BUG=b:233174191
TEST=mdbook build

Change-Id: I5a52dff7caa7cd151d1ad382be1bd81cb13e1369
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3659817
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-06-03 03:11:22 +00:00
Keiichi Watanabe
3f7932c6b1 docs: Split net/wayland sections into individual pages
BUG=none
TEST=mdbook build

Change-Id: I6941b8e8a67562110af4255f94e8660a8fa7bd6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3607793
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-06-03 03:11:21 +00:00
Keiichi Watanabe
1f8455fc61 docs: Add "Devices" chapter
To explain use of various devices, let's have a separate chapter.

BUG=none
TEST=mdbook build

Change-Id: I0fe9926f9e6b97731a3a19d7b5f59b0eb2d1cf73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3607792
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-03 03:11:20 +00:00
Junichi Uekawa
af9d617e2d crosvm: Simplify Msr set up loop and MsrFilter.
Name the enums instead of bool so that it's easier to reason, and factor
out the MSR loop.

BUG=b:229770963
TEST=build

Change-Id: I7d2306472bdf7482479b40b0ef00f378754a811f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3685671
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-06-03 00:00:04 +00:00
Richard
d2ca9e04c7 devices: Split Unix and Windows code in virtio balloon that was missed
in previous upstream CL

previous CL: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3655755

The balloon implentation did not match on B* vs mainline. This CL should
reduce future automerger conflicts.

BUG=b:213149162
TEST=built and presubmits

Change-Id: Ibf78421256f2b43fe84e2fc7825897c7623b6265
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3674537
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-06-02 23:24:10 +00:00
Daniel Verkamp
d4505a7f1c base: replace PollToken with EventToken tree-wide
Pull the declaration of the `EventToken` enum up to the top level of the
base crate, replacing the identical implementations inside sys/windows
and sys/unix.

Use the `EventToken` name consistently throughout the tree to remove the
unix-flavored "poll" nomenclature.

BUG=b:213153157
TEST=tools/dev_container tools/presubmit --all

Change-Id: I0ba42037b533b796797a7a3f6d8d7e71a5592aba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3642673
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-06-02 22:30:38 +00:00
Mike Gerow
b53a156fbc serde_keyvalue: parse hex, octal, and binary nums
This adds support for parsing hex `m=0x1234abcd` octal `0o755` and
binary `m=0o1100` values according the their prefix. Negative numbers
can also be specified by adding a `-` after the prefix.

Note that negative values like `m=-0x1234` don't work, largely as an
artifact of the way the Num trait works. This could probably be fixed,
but given hex, octal, and binary numbers tend to be used in unsigned
situations most of the time this shouldn't be an issue.

The main motivation for this is the debugcon serial device, which
accepts an argument which is an x86 IO port. These are much more
naturally described in hex.

BUG=b:233610263

Change-Id: Ic68bacd772de6aebfaad0de7b8aa6faf5d4c1555
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671595
Commit-Queue: Mike Gerow <gerow@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-02 22:03:20 +00:00
Daniel Verkamp
3e8054ee7c base: unix: merge EpollContext into PollContext
The main distinction between PollContext and EpollContext was that the
latter was safe to use from multiple threads. This was not true of the
more widely-used PollContext for two reasons:

1. The `events` array was stored inside the `PollContext` structure,
   whereas `EpollContext` required the caller to pass their own storage
   for events.
2. `PollContext` had a hangup detection feature used to debug busy
   looping cases that result from a failure to remove hungup file
   descriptors from the context.

Point 1 is resolved by returning a `SmallVec` of events that avoids
allocation for the normal case (and in fact it should avoid allocation
in all cases on Linux, where the maximum number of events returned from
a single `epoll_wait()` call is limited to the same size as the
preallocated `SmallVec`). This simplifies the API and also means that
there is no need for per-context storage.

Point 2 can't easily be resolved, since it would require the `wait` call
to mutate shared state (this could be done by adding a mutex around the
shared data, but that seems like too much overhead for the value of the
feature). Instead, this patch just removes the hangup detection code.

BUG=b:213153157
TEST=tools/dev_container tools/presubmit --all

Change-Id: Ia48c46de96976da27cb5387e3e5e8fcf92d0e85b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3633111
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-02 21:44:39 +00:00
Anton Romanov
33adade230 crosvm: arghify top-level cmdline options
Change-Id: I8e31f8fb56ed0a4bc83f9eec7fdffd2bdf072c89
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671861
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-02 21:34:01 +00:00
Anton Romanov
01a9386cde crosvm: argh-ify device command
Example help output (note that in main crosvm device help is broken)
```
Usage: crosvm device <command> [<args>]

Devices

Options:
  --help            display usage information

Commands:
  block             Block device
  net               Net device
  console           Console device
  fs                FS Device
  gpu               GPU device
  vsock             Vsock device
  wl                Wayland device
```
crosvm device wl help:
```
Usage: crosvm device wl --socket <PATH> --vm-socket <PATH> [--wayland-sock <PATH[,name=NAME]...>] [--resource-bridge <PATH>]

Wayland device

Options:
  --socket          path to bind a listening vhost-user socket
  --vm-socket       path to a socket for wayland-specific messages
  --wayland-sock    path to one or more Wayland sockets. The unnamed socket is
                    used for displaying virtual screens while the named ones are
                    used for IPC
  --resource-bridge path to the GPU resource bridge
  --help            display usage information
```

Change-Id: Ie976b5545644c10b24cb3cdfcb17b213641064f9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668920
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-06-02 19:21:36 +00:00
Anton Romanov
8bf7292d1a Make crosvm.rs a mod instead of a separate lib crate
Change-Id: Iedb8c632853bb5b0484ab6e6522d41580a413dae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668921
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-02 18:56:24 +00:00
Daniel Verkamp
d682784257 Revert "devices: pci: PciBarIndex API cleanup"
This reverts commit e84d9c1d7c.

Reason for revert: vfio-pci fails on ManaTEE with an out-of-range BAR index (8), so further investigation is required

Original change's description:
> devices: pci: PciBarIndex API cleanup
>
> Everything that takes a PCI BAR index should use the appropriate
> PciBarIndex type rather than u8 (or usize) for better type safety and
> descriptiveness.
>
> BUG=b:232838930
> TEST=tools/presubmit
>
> Change-Id: I0a918a6da6327c963fb297ba765563774a7e5e49
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3664282
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Anton Romanov <romanton@google.com>

Bug: b:232838930
Change-Id: Id5d19e779289e47045af67fa51c301ba2b79ee7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687516
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-06-02 17:08:47 +00:00
Alexandre Courbot
d29e48f823 virtio: video: fix broken test
http://crrev.com/c/3676695 removed the `anon` constructor from
SharedMemory. Update the test that uses it.

BUG=None
TEST=cargo test --features "video-decoder,ffmpeg" -p devices virtio::video

Change-Id: Ic4d8a48d2466dc35c47422cd89f9d99d031e2d1a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3685673
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-02 12:01:16 +00:00
Alexandre Courbot
fb1aff7f4f devices: vfio: factorize code in new()
Once we have opened /dev/vfio/vfio we can leverage new_from_container().

BUG=None
TEST=cargo build

Change-Id: Ib309ab708cf561ec5dde8a606164a7df9a1bc4aa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3675886
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-06-02 11:25:30 +00:00
Hikaru Nishida
4f5ba4bd28 Revert "crosvm: remove balloon stats request timeout"
This reverts commit 56c0d02760.

Reason for revert: Break ARCVM after suspend/resume

BUG=b:234067421
TEST=Checked that ARCVM kept working after suspend/resume

Original change's description:
> crosvm: remove balloon stats request timeout
>
> It was done to avoid deadlock when stats are requested before guest is
> up. Implement a stub BalloonStats::NotReady replier until host is up so
> that timeout is no longer necessary.
>
> BUG=b:232289535
> TEST=few tast crostini/arc tests
>
> Change-Id: I6731b4ee9eaecdd65aebdd3f530f0932b0660c85
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3652887
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Anton Romanov <romanton@google.com>
> Auto-Submit: Anton Romanov <romanton@google.com>

Bug: b:232289535
Change-Id: Iffafaef1e1136ebc050d69d001d384eedd0a2319
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3686789
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Hikaru Nishida <hikalium@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Hikaru Nishida <hikalium@chromium.org>
2022-06-02 11:09:31 +00:00
Alexandre Courbot
d160cd22cf devices: virtio: console: move process_transmit_request around
Move this function to a place closer from its call site - this will make
the following CL less cluttered.

BUG=None
TEST=cargo build

Change-Id: I2837af9bb1f721967d7b7676140a8bd11973a34b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600171
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-02 06:09:55 +00:00
Alexandre Courbot
2009824d86 devices: vhost-user: console: use async queue structs
Use the newly introduced async queue structs to manage the vhost-user
console device queues. This allows the device to restart its queues
after they are stopped or reset. The previous implementation was losing
the input and output streams as the queue was stopped.

BUG=b:228385297
BUG=b:228912920
TEST=vhost-user console device is working (with input) on Linux.

Change-Id: Ie968af7cfa77734c86c088da3a52f4d6937c3d0d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600170
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-06-02 06:09:54 +00:00
Alexandre Courbot
aa54ea18ca devices: virtio: add asynchronous queue helper struct
Add a structure that facilitates managing the state and resources of a
queue running on an async executor. This is to be first used by the
console device, but the goal is also to extend these helpers and use
them on as many devices as possible.

BUG=b:228385297
BUG=b:228912920
TEST=cargo build

Change-Id: I72a3df7d9bf900cff38b189380d3c8ec4f098a0b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3600169
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-02 06:09:53 +00:00
Alexandre Courbot
1adf131537 tools: dev_container: add missing script to Dockerfile
This file also needs to be copied otherwise the container generation will fail.

BUG=None
TEST=make -C tools/impl/dev_container crosvm_dev

Change-Id: I571213a0078e5cf8bd6c7e5f157b6e7dda5fff47
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3685677
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-02 05:56:53 +00:00
Noah Gold
a89e65beb1 third_party: libslirp-rs: remove unused files.
These files are not used, and libslirp-rs is not a functional crate.
Only context.rs is used in heavily forked form as a part of crosvm's `net_util`.

BUG=b:213151463
TEST=n/a

Change-Id: I6536cde7ff2beed655e83c3d920c6940ed4969a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3650467
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-06-02 03:00:37 +00:00
Noah Gold
1977979fbb net_util: upstream Windows support
Adds the libslirp interface code, as well as the Windows pseudo-tap
device.

BUG=b:213151463

TEST=bots (unix + windows)

Change-Id: I975b27a76c82e25037d4061587fec0c31222a159
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3598234
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-06-02 03:00:36 +00:00
Noah Gold
465479699b third_party: clone libslirp-rs
libslirp-rs cloned from 19553209436ae7b9e036641f4013246111192d5c.

BUG=b:213151463
TEST=n/a

Change-Id: I560bb39ca96e68b3cf2654690bb3feb3af0325a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3650466
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-06-02 03:00:35 +00:00
Lepton Wu
39a8c88e79 devices: vhost-user: gpu: support VVU
With this and some pending hacks, dEQP works inside sibling
guest with VVU.

Device can be started with "crosvm device gpu --vfio <PCI ID>"

BUG=b:213532598
TEST=manual - run dEQP from a sibling guest when using VVU.

Change-Id: I97fa0e44c36cd5be13b6d31592878bdc19e48aed
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3682201
Auto-Submit: Lepton Wu <lepton@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-06-02 00:40:37 +00:00
Vaibhav Nagarnaik
65806f5213 base: Introduce number_of_logical_cores()
This crossplatform API returns the number of logical cores on the
system.

Remove the older `get_vcpu_count()` that was mis-named and replace its
use with `number_of_logical_cores()`.

TEST=Compiled

Change-Id: I4c46deb35e8354ad2313230d26c94c0f7558e06f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3684930
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-06-02 00:05:07 +00:00
Vaibhav Nagarnaik
478c7104f8 hypervisor: Update Cargo.toml dependencies
The `haxm` implementation depends on `win_util` and `winapi` crates
which are only required on Windows. The `tempfile` crate is used in
testing.

Move `kvm` and `kvm_sys` dependencies for non-windows builds.

BUG=b:213151459
TEST=Compiled on linux.

Change-Id: I55b8ee4ac5da953a17e8bdd063e5ed488e3f53f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3684929
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-02 00:05:06 +00:00
Dennis Kempin
9a50dfbdcf infra: Fix push to github builder
Kokoro would maintain a local main branch in the local checkout,
so pushing --all will push the latest HEAD of main.

Luci will instead put us on a detached HEAD, with the local
main branch unmaintained. So we have been pushing the same old
version of crosvm.

Update the force push to submit HEAD to the remote main.

BUG=b:233913820
TEST=./recipes.py run push_to_github (requires authentication with
github to run)

Change-Id: I8282498382968768d66d9c807b9e86d191977beb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3681989
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-01 22:05:04 +00:00
Anton Romanov
72da5dcd77 fix compilation with cras
Change-Id: Ic7f2f941b9066828f4347a6a01b599a6915b5e85
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3682448
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-06-01 20:32:02 +00:00
Dennis Kempin
fd9ad57aee infra: Really fix cros_run_unit_tests invocation
This was accidentally amended into the wrong commit. This code
has been teststed to work by launching a task in the crosvm bot
pool.

BUG=b:233913797
TEST=https://ci.chromium.org/swarming/task/5b3579040ba79210

Change-Id: Icb631d35a32bd0cc9cb44f54f4066a492b97bf64
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3684131
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-01 18:53:56 +00:00
Kaiyi Li
bf7a2f37b2 gpu: add new gfxstream initialization flags
BUG=b:233676779
TEST=presubmit

Change-Id: I02103077006c2ac4bc8b3b21bf186de9743530e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668930
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-01 18:47:41 +00:00
Anton Romanov
1575e1c2f3 devices: unix: argh-ify devices subcommand
This has only a tiny change outside of unix-specific code so shouldn't
complicate windows upstreaming

Change-Id: Iae68e761d730ed7497b4586b9b9a948524224d8e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3671093
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-06-01 18:35:11 +00:00
David Stevens
ecb376c7b2 devices: virtio: iommu: fix spurious warning
Skip logging an error when the translate request tube closes. That
happens whenever the process on the other side of the tube closes, and
isn't an error in and of itself.

BUG=None
TEST=exit crosvm and observe no virtio-iommu error message

Change-Id: I5f0460182a96d00f8c348224c838554710fc5451
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3659815
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-06-01 08:46:41 +00:00
David Stevens
6e13a86d25 devices: virtio: iommu: fix vfio device removal
Make sure the endpoint is removed from the endpoint and domain maps when
a vfio device is removed.

BUG=b:232161488
TEST=Boot a guest, hotplug in and out a vfio-pci device repeatedly

Change-Id: Ie9838b412cac22a9e14bb6e986be39303aeb01e3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3676692
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-06-01 08:46:40 +00:00
David Stevens
6374a3a370 devices: virtio: iommu: refactor shared state
Refactor shared state so that it can be shared between multiple async
callbacks. This moves all state from the Worker to a dedicated State
struct, which allows it to be passed via Rc<RefCell<>> to the various
async callbacks. The collection of endpoints can also be passed as part
of the shared state, rather than as its own dedicated argument.

There should be no behavioral changes in this CL.

BUG=b:232161488
TEST=Boot a guest, hotplug in and out a vfio-pci device repeatedly

Change-Id: I1e65ef3e4048bf0889fdee0f18fa5b58be264666
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3659554
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-06-01 08:46:39 +00:00
David Stevens
35ce872a45 devices: virtio: iommu: check for invalid attaches
Check that the same mapper isn't used for multiple domains. This ensures
that there won't be mapping collisions/leaks if the guest tries to use
the same mapper with multiple domains.

BUG=None
TEST=Boot ManaTEE with devices managed by viommu

Change-Id: I45889e6fe020c3a24b355fc05a8f74734bece78a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3641221
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-06-01 08:46:38 +00:00
David Stevens
fef85d48c8 devices: virtio: iommu: fix detaching issue
Remove incomplete support for detaching a virtio endpoint from domains
with multiple endpoints. We could technically handle this by checking
domain mappings when handling TranslateRequests, but there are no use
cases for this at the moment.

BUG=None
TEST=Boot ManaTEE with devices managed by viommu

Change-Id: I9d1cb86f246f7d8639058eaaf158f6538f1c1c57
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3676697
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-06-01 08:46:37 +00:00
David Stevens
a334b0931a linux: refactor create_vfio_device
Refactor create_vfio_device so that it returns the created viommu
related mapper, if any. This allows add_vfio_device to be written more
cleanly.

BUG=None
TEST=Boot ManaTEE with devices managed by viommu

Change-Id: Ieaa345ed5f9146fde8e305fc7bc37001ff708683
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3676698
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-01 08:46:36 +00:00
Junichi Uekawa
6d26fef1d6 crosvm: Simplify MSR filter.
Don't use box and just use an array.

BUG=b:229770963
TEST=build

Change-Id: I8121e4809e418d7f3e1aa876d567e543ee50693c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3675887
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-01 08:20:38 +00:00
David Stevens
5d6d595116 devices: vfio: use VFIO_TYPE1v3_IOMMU if available
For vfio devices which we expect to have granular, dynamic IOMMU
mappings (i.e. passthrough devices using viommu/coiommu), use the
ChromeOS specific VFIO_TYPE1v3_IOMMU if available, as it is optimized
for that use case.

BUG=b:217479627
TEST=boot ManaTEE, observe reduced hypervisor memory usage after IO

Change-Id: I7b3a04adb5049c165885917fa29cedf2ccdee1d0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3675885
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-06-01 05:47:40 +00:00
David Stevens
569a58490e base: clarify SharedMemory API
When creating shared memory, 'name' can have one of two meanings. It
could either be a debugging tag with no semantic meaning, or it could
uniquely identify a shared memory object within some namespace. Linux
memfd uses name in the first meaning, whereas Windows (and Linux shm)
uses it in the second meaning.

Currently, crosvm has no use cases for the named shared memory of the
second type, so it is not supported. Make it clear that the SharedMemory
APIs treats name as a debugging-only name. Remove the "anon" and "named"
constructors, since they had no semantic meaning. Also require a name
when constructing a SharedMemory, since there's no reason not to provide
one to make debugging easier.

The only semantic change is setting the name of GuestMemory's underlying
shmem to "crosvm_guest", which it was until recently. This fixes some
ManaTEE tests which use the name to determine CrOS guest memory usage.

BUG=None
TEST=compiles

Change-Id: I78d5046df04d6f19640abbbc67af6bd433a177b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3676695
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-01 03:55:47 +00:00