Commit graph

3868 commits

Author SHA1 Message Date
Junichi Uekawa
c1b467f17a Revert "Add rseq to the seccomp policy file on aarch64."
This reverts commit 637402a827.

Reason for revert: break CrOS build

Original change's description:
> Add rseq to the seccomp policy file on aarch64.
>
> Some newer versions of glibc use this syscall.
>
> Change-Id: I553db954b019fa5fc738074b28dbba78392c3ede
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3690467
> Tested-by: kokoro <noreply+kokoro@google.com>
> Auto-Submit: Peter Collingbourne <pcc@chromium.org>
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>

Change-Id: If2ff928964bb2184e473a4b15cacb92367d594b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3688025
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
2022-06-07 04:30:15 +00:00
Noah Gold
157bd6f04d x86_64: reset msrs when using bios
Our BIOS doesn't set the TSC MSR to 0 on boot, but our hypervisors need
this to be set so they can correctly sync their TSC offsets. This
introduces a generic "reset_msrs" function where we currently reset the
TSC msr, but where we could also reset if we need to in the future.

Cherrypick from downstream branch.
Actual author: Colin Downs-Razouk <colindr@google.com>.

BUG=191981229
TEST=tested downstream

Change-Id: I17b5709411394ae48fb5d7310636636295ebfaad
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3690370
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-06-07 02:19:06 +00:00
Federico 'Morg' Pareschi
8839e1c368 devices: virtio: Use mmap for vvu doorbell
This change enables memory mapping of the vfio device doorbell regions so
we can access the vfio bar more efficiently by limiting the scope of the vvu
device interactions with the guest kernel.

BUG=b:231938067
TEST=built and run, verified vvu communication happens as expected

Change-Id: I16925d99a467d44ce7f74316770f1c665de75433
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3670459
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Morg <morg@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Morg <morg@chromium.org>
2022-06-07 01:41:49 +00:00
Daniel Verkamp
8579daefae devices: virtio: fs: fix warning about extra parens
The outer set of parentheses is redundant.

BUG=None
TEST=emerge-kevin crosvm

Change-Id: I482e04601b0f7a3ef22221a77c00ef746bbd288a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3691969
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-06 23:52:21 +00:00
Peter Collingbourne
e44dbaa6ad Fix running the tests natively on aarch64.
Change-Id: Icdeacc8247fbd44cd62445e610306ce0c67d70e0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3689858
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Peter Collingbourne <pcc@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-06 19:49:03 +00:00
Dennis Kempin
301da40bc5 Kokoro: Fix dry-run merge target
Using HEAD for both calls will cause update-dry-runs to use the
merge branch as a target to do the merge, creating the dry run on top
of the merge.

BUG=None
TEST=./ci/kokoro/simulate.py ./ci/kokoro/build-merge-into-chromeos.sh
Change-Id: Ib466272d3acce30888e1e3c5db853be9ded46106

Change-Id: Ifc40ffb81a61a75326b296419a4337c49a8fd7db
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3688803
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-06 19:42:57 +00:00
Richard
e7a35d8f9c devices: descriptor_utils: split out tests that don't run correctly on
Windows

BUG=b:213149162
TEST=built and presubmits

Change-Id: I3b88ea3032458c39b78f6059ecf06e830887a424
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3669691
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-06 18:38:29 +00:00
Daniel Verkamp
62636c5b2f data_model: use fully qualified name in flexible_array_impl! macro
The flexible_array_impl! macro should not rely on the caller to import
FlexibleArray; use $crate::FlexibleArray to refer to it instead.

BUG=None
TEST=tools/presubmit

Change-Id: I9743a4cbc01deb6cdfadd98e63f4803a5572421c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687064
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-06-06 18:17:03 +00:00
Peter Collingbourne
637402a827 Add rseq to the seccomp policy file on aarch64.
Some newer versions of glibc use this syscall.

Change-Id: I553db954b019fa5fc738074b28dbba78392c3ede
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3690467
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Peter Collingbourne <pcc@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-06 18:08:15 +00:00
Vikram Auradkar
76188090d9 Adding Vikram to crosvm OWNERS
BUG=None
TEST=None

Change-Id: I96027017e37740108d95acfae62b0fdd917fa0c6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3641319
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-06-06 17:20:10 +00:00
Daniel Verkamp
4c0de58cbf base: unix: rename PollContext to EventContext
We already exported PollContext as EventContext for use in the portable
WaitContext wrapper, so this makes no difference to callers.

A few remaining references to PollContext in documentation and errors
are fixed up as well to avoid confusion.

BUG=None
TEST=cargo build

Change-Id: I89943d4d9e135a0da7dd0fbff470b6a14efd669a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687059
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-06-06 17:07:35 +00:00
Daniel Verkamp
25f08902ff base: unix: remove unused IntoRawDescriptor for PollContext
PollContext is wrapped by the platform-agnostic WaitContext, which does
not support IntoRawDescriptor, so nobody should be using this.

BUG=None
TEST=cargo build

Change-Id: I5d931d20cb3d0a8f42cc1e625d35df4047e45c7d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687058
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-06-06 17:07:34 +00:00
Daniel Verkamp
f0f10c4209 base: remove WatchingEvents in favor of EventType
Migrate the last few users of WatchingEvents to the equivalent EventType
values so we can remove the unix-specific WatchingEvents type.

BUG=b:213153157
TEST=cargo build

Change-Id: I215127309591125c4c64ff2963e7d2b8e1914cf3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687057
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-06-06 17:07:33 +00:00
Daniel Verkamp
e3d9206dc9 io_uring: expand poll_events to 32 bits
The original poll_events field in io_uring_sqe was 16 bits wide, but it
was later extended to 32 bits to allow the use of all epoll flags.

Technically, we should check for the IORING_FEAT_POLL_32BITS feature,
but the new poll32_events union member was added in Linux commit
5769a351b89c ("io_uring: change the poll type to be 32-bits"), which was
included in Linux 5.9, so we can assume this is available for all
io_uring-enabled kernels due to our baseline version of 5.10.

BUG=None
TEST=cargo test -p io_uring

Change-Id: I5a6266f24ba53a1826b40c91c281527481e99c8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687056
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-06 17:07:32 +00:00
Peter Collingbourne
4f7d84e5b9 Fix some clippy warnings on aarch64.
Change-Id: Iac9a9540c585a08374c966a1014c6746fbba0554
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3687061
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Peter Collingbourne <pcc@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-06-06 16:58:32 +00:00
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