Commit graph

4097 commits

Author SHA1 Message Date
Dennis Kempin
382acd20d3 tools/cl: Support worktree checkouts
CrOS checkouts are experimenting with using git worktree, where
the path to the hook directory is not .git/hooks. So ask git
where the hooks are stored instead.

BUG=b:236645893
TEST=./tools/cl upload in a worktree checkout

Change-Id: Ib353da0aea5d27ce29d1c082268a326adb429d23
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739373
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-06 18:02:43 +00:00
Daniel Verkamp
2689c838af base: simplify Clock/FakeClock API
Clock now has a single now() function that returns a std::time::Instant
rather than wrapping an Instant itself.

FakeClock provides the same now() API, except the Instant it reports is
only advanced when test code calls add_ns(). FakeClock continues to
provide the add_event() and add_ns() APIs used by tests.

The only functional difference is that the epoch used by FakeClock is
now whatever moment in (real) time it is created, rather than a fixed
timestamp, but this should not change the results of the tests. The only
way to observe the contents of an Instant is by comparing it to other
Instants, which should all be derived from the Clock/FakeClock now()
API.

BUG=None
TEST=cargo test -p base -- --test-threads=1
TEST=cargo test -p devices

Change-Id: I9a0ed8d252f213d85dba3dfbbcd1182e2db981f0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3736922
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-06 17:44:05 +00:00
Kazuhiro Inaba
8f6f1407cb crosvm: Fix --per-vm-core-scheduling option handling.
Apparently the flag handling was forgotten to be
migrated in the switch to Argh crrev.com/c/3684144.

BUG=b:237216718
TEST=cheets_CTS_R.internal.arm.CtsVideo on Fizz.Kench

Change-Id: Ia967883cd5c4e2efcc1ca2cf97fd6adfc0bf163a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3746902
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Kazuhiro Inaba <kinaba@chromium.org>
2022-07-06 17:23:49 +00:00
David Stevens
b60cbbf0f6 devices: vvu: use mmap instead of vfio write
Access notification configuration area via mmap instead of via vfio-pci
driver. With this, all accesses to vvu bar 2 are done via mmap.

BUG=b:237647217
TEST=boot sibling VM, observe /sys/kernel/debug/x86/pat_memtype_list

Change-Id: Id73530accad97af2e6cbb3480f2c9859e9d0688a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739562
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-07-06 00:46:27 +00:00
Alexandre Courbot
d84f8b5f14 virtio: vhost-user: cras: fix build
Another one in the long tradition of forgetting to update cras...

BUG=None
TEST=emerge crosvm passes for Hatch.

Change-Id: Id2a2675ffbc7bcd2908f4682055b7848321bbe0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3744915
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-07-05 11:36:28 +00:00
Alexandre Courbot
a99ad34826 crosvm: cmdline: remove JailConfig from run arguments
This member is never used since jail configuration is set up using other
flags to remain compatible with the way `run` was working pre-argh.
Furthermore, having it here makes a `jail-config` command-line option
appears in the help text that is a no-op.

BUG=None
TEST=cargo build

Change-Id: I715ac80270e7b775926c7ca8759e22e5f7c15014
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3744909
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-07-05 11:36:18 +00:00
Keiichi Watanabe
06e6f41576 OWNERS: Add comments
BUG=none
TEST=none

Change-Id: I18ec0fc387eaab7717cc6e94eb3a865f6b6d5f94
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739573
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-05 10:34:14 +00:00
Alexandre Courbot
8249907797 docs: book: fix instructions for VVU
Fix a few typos in the instructions to start a VVU device.

BUG=b:196186396
TEST=Copy/paste the new instructions and make sure the device starts and
works.

Change-Id: I0726185fc9d7026a7d7d81a5678fb81350cac113
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3744908
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-07-05 10:33:54 +00:00
Alexandre Courbot
78709b185c virtio: vhost-user: console: add type to reset stdin to canon mode
Add a type that, when dropped, resets the standard input to canon mode
if needed. We were doing it manually so far, which is error-prone if we
exit early due to an error.

This new type is also required for properly implementing the new
`devices` command.

BUG=b:217480043
TEST=vhost-user console device works on Linux.

Change-Id: I36d55f248198dc6383ae8e5557ac394baaab6e70
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3725736
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-07-05 08:17:03 +00:00
Alexandre Courbot
c6a73deee8 crosvm: linux: device_helper: add VirtioDeviceBuilder trait
As we are going to jail vhost-user devices, we will need a way to obtain
a Minijail that we can use in that case. This CL introduces a
VirtioDeviceBuilder trait that can be implemented for any device
configuration type and allows to spawn a configured device as well as
its jail, which is created from the correct policy file depending on the
virtio transport desired. In effect, it splits the creation of the
device and jail into two separate methods so the same jail creation code
can be reused with both regular virtio and vhost-user.

In order to illustrate, the console device is converted to this new
scheme. Other devices will follow when relevant.

BUG=b:217480043
TEST=serial device works with `crosvm run`.

Change-Id: I6b59d3794580bbdabce6df290c9ab8262d8e178c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3706491
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-07-05 08:17:01 +00:00
Alexandre Courbot
b5cc1dcc62 devices: vhost-user: handler: unroll guest memory creation functions
These functions are now called from only one point, and can be unrolled
without any harm to readability.

BUG=None
TEST=cargo build

Change-Id: I97c110d80f8f81c2c66eed48ae042e160535cec6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3599231
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-07-05 08:17:00 +00:00
Alexandre Courbot
1379a39567 devices: vhost-user: handler: define trait for platform-dependent ops
The DeviceRequestHandler used to differenciate between regular
vhost-user and VVU using an internal enum. This doesn't scale and makes
platform-dependent code visible in the handler code.

Improve this by introducing a VhostUserPlatformOps trait that is
implemented by vhost-user and VVU supporting structs. This will allow us
to move these structs into a sys directory in the future, and to add
support for new platforms without it being intrusive.

As a nice side-effect, the trait can also be used for free in the vsock
device, removing some technical debt there.

The Doorbell also happens to be platform specific, so put it behind the
platform module too.

BUG=b:229554679
BUG=b:230665747
TEST=vhost-user console device works.
TEST=VVU console device works.
TEST=vhost-user vsock device works (tested with socat on both ends).
TEST=VVU vsock device works (tested with socat on both ends).

Change-Id: I8d9faece7e5631921e0b622efaafba5b7fa2df8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3599230
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-07-05 08:16:58 +00:00
Alexandre Courbot
c771a1dc1a virtio: vhost: user: introduce VhostUserListener platform type
Vhost-user transport can be implemented differently depending on the
system ; on Unix it can work through a socket or a VFIO device, whereas
Windows will use a Tube. This CL introduces a platform-specific
VhostUserListener type that we will use to abstract this part and
increase the part of shared code between Unix and Windows. It is also
useful to abstract the difference between the different kinds of
listeners on a same system, as it is able to create the right type from
an input string.

This type will also be important to implement jailed vhost-user devices.

The Windows implementation is still a TODO ; this is ok for now as only
the Unix code makes use of it.

BUG=b:217480043
TEST=vhost-user console device works on Linux.

Change-Id: If2f308ce7f71420012ebd2d49361454706f8a6ae
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3706489
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-07-05 08:16:57 +00:00
Junichi Uekawa
9fff598b26 arch: update add_serial_devices comment.
BUG=None
TEST=build

Change-Id: I67b3b9c70cb3599109014e66eb072ead040a5927
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3744904
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-05 06:27:29 +00:00
David Stevens
92fabe33c7 crosvm: remove stray comma in copyright statement
BUG=None
TEST=repo upload

Change-Id: I009cd11f3e0f8463fcd43170ec6f7fc052a2c009
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3744903
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2022-07-05 05:38:34 +00:00
Junichi Uekawa
0b89290a27 arch: Clone jail object for serial.
80690665b8 removed the clone but that
caused sig11 in minijail.

BUG=b:238026909
TEST=tast run rammus-arc-r arc.Boot.vm

Change-Id: Icf887ae62df682d72f2ea469a1d1a15cc303dc1c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3744902
Reviewed-by: David Riley <davidriley@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-07-05 05:06:28 +00:00
David Stevens
c6dfb309d2 devices: vvu: set interrupt vector before enable
According to the virtio spec, drivers must configure other virtqueue
fields before enabling the virtqueue.

BUG=None
TEST=boot manatee sibling

Change-Id: I7431682a351269a3c45a508848ae6e9992ab0c10
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3737408
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-07-05 04:32:03 +00:00
David Stevens
7a64a8ecf3 devices: pci: fix typo in pci bridge window allocation
Fix an error where window_base was updated instead of pref_window_base.
Since the calculations for the two windows are the same, refactor it out
into a separate function. Also, return an error on allocation failure,
instead of just printing an error.

BUG=b:237576651
TEST=boot brya-manatee on primus

Change-Id: I82ffdea00156a95886a0a5913552f3fd6e77a2fe
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739712
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-04 10:22:41 +00:00
David Stevens
4a62a8ee3f irqchip: disable flaky unit tests
Disable tests which rely on sleep for correctness.

BUG=b:237977699
TEST=kokoro

Change-Id: I37f467f5385de4e70c31f5ce7c815d3ba4dd83d6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3740226
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-04 09:42:25 +00:00
Dmitry Torokhov
264c805f04 devices: vvu: do not try to change driver for VVU devices
It is not the task of crosvm, which is usually unprivileged process, to
mess up with the system configuration, so it should simply expect that
VVU devices are already bound to vfio-pci driver and stop trying to do
it itself.

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

Change-Id: Icb777cf66fd54bd74d656821fb76587c7ee70ca3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3712552
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
2022-07-02 19:33:21 +00:00
Noah Gold
80690665b8 arch: add Windows bits to serial.
BUG=b:237597358
TEST=builds + tested on Windows downstream.

Change-Id: I9a38ddae0e66fdbd491e2c9a0145fdf2407ac812
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3736760
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Richard Zhang <rizhang@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-02 00:00:32 +00:00
Richard
1b0f01be24 devices: Enable mods that already build or had a trivial fix
BUG=b:213149155
TEST=built and presubmits

Change-Id: I42065bb583aed2ed3ad85b2c4189cb5d86aacfd5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3736924
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-07-02 00:00:29 +00:00
Richard
5d77466913 virtio-vhost: Enable block tests
Commented out code reference sandbox crate, which still needs to be
upstreamed

Still need to enable:
 * balloon (try_clone not implemented)
 * console (Need to enable Serial)
 * snd (Unix code not conditionally compiled out)
 * gpu (Waiting for graphics team to upstream)

BUG=b:237011316
TEST=ran "./tools/run_tests --target=host --arch=win64 --verbose"

Change-Id: I1b5f7ae575365351184042bc65cffcfd7efe999a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3721870
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-07-01 23:44:09 +00:00
Vikram Auradkar
b6b4081b76 crosvm: refactor cmdline
Prepares cmdline for upstreaming.

- Removes wildcard import
- Adds empty platform specific command

BUG=b:213146388
TEST=built on downstream windows and presubmit

Change-Id: I835101f486e07248d452937589c2268f23f8d0e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739584
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-01 23:12:40 +00:00
Vikram Auradkar
f52e15f2e2 crosvm: move files under src/crosvm from linux/ to unix/
The contents of the mod.rs were moved to unix.rs

BUG=b:213146388
TEST=presubmit

Change-Id: Ib7188dba3bb7b5e7c78b72b39a84f99be67c53ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739365
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-01 22:47:57 +00:00
Daniel Verkamp
eb4bfb26e0 main: accept -h as an alias for --help
This is a widely-used convention, and it's not very helpful to just
print "Unrecognized argument: -h". We won't be able to use -h as a short
argument name for anything else, but that seems like a reasonable
tradeoff.

BUG=b:3739371
TEST=crosvm -h
TEST=crosvm run -h

Change-Id: I6eef06bfd3cf526e54a6904e5085789566dcc958
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739372
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-07-01 21:34:39 +00:00
Daniel Verkamp
3ccb636365 main: accept --arg=options without a warning
The workaround for argh's lack of --arg=option is not a big deal to keep
around permanently; just drop the warning message.

BUG=b:235882579
TEST=crosvm run --root=test.img vm_kernel # runs without warnings

Change-Id: I3ef5e237f80c2df775d684775e67a08f1fd89bf0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739371
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-07-01 21:34:38 +00:00
Dennis Kempin
070cc87986 infra: Nest preparation steps and mark them as infra steps
This will clean up the luci log page and failures in any of these
steps will be marked as infra failures.

BUG=None
TEST=None

Change-Id: I7bce6ba3eb34c1a68d7ca8d21d6b5f4e332de17c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739375
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-07-01 21:34:07 +00:00
Dennis Kempin
323d267a8c infra: Add build_windows recipe
Refactors the crosvm recipe API a little to provide 3 different
environments for builds: Just the source, building with containers
and building on the host.

For building on the host, we will install rustup-init via CIPD and
then use rustup to install the required rust version.

BUG=b:233914170
TEST=./recipes.py run build_windows

Change-Id: I12ef22f286af584edeb02beed4d231565b698099
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3718900
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-01 20:11:59 +00:00
Dennis Kempin
767e094fb8 tools/run_tests: Use triples for arch
Updates run_tests to use cargo style target triples for specifying
build targets. A simple 'aarch64' or 'armhf' was nice while we just
had linux builds. We now are looking at windows and possibly
different toolchain options (e.g. msvc vs gnu), so our old system
was getting confusing and inconsistent.

We used to have some special handling for adding wrappers to test
runs for emulation (e.g. wine, qemu). That logic has been moved
into TestTarget which now contains not just where to run the test
but also how.

Supported are armhf/aarch64 qemu as well as wine64.

The CLI has been updated to match and now uses the build-target
argument instead of arch.

The following combinations have been tested (though not all
combinations actually pass all tests, which is a separate issue).

./tools/run_tests
./tools/run_tests --target=host --build-target=x86_64-unknown-linux-gnu
./tools/run_tests --target=host --build-target=armhf
./tools/run_tests --target=host --build-target=aarch64
./tools/run_tests --target=host --build-target=mingw64
./tools/run_tests --target=vm:aarch64
./tools/run_tests --target=vm:aarch64 --build-target=armhf

BUG=b:233914170
TEST=See above

Change-Id: Ic6dbb5b39788e2573714606d3bb0e7c712032d91
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739240
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-01 19:16:59 +00:00
Vikram Auradkar
1a9caa2f53 crosvm: move panic_hook
Windows has a different implementation of set_panic_hook.

BUG=b:213146388
TEST=presubmit

Change-Id: Idecf70645c2869e3790ed692260a1cf2b32f8cbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739364
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-07-01 18:25:21 +00:00
David Stevens
31f04e9270 vmm_vhost: fix receiving reply payloads
The existing code confuses the length of the request with the length of
the reply in recv_reply_with_payload. This makes it impossible to use
for any requests where the reply differs in size. Fix this by
determining payload size after reading the reply header.

BUG=b:201745804
TEST=compiles

Change-Id: Iec21918e45b81d299f3178e7893e146cbd4c7db7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716343
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-07-01 08:13:52 +00:00
Keiichi Watanabe
2e2e4910d5 Add stevensd@ to OWNERS
BUG=none
TEST=none

Change-Id: Ic5a581263497a0fd6206ded38c0649e06b2cb2ed
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739571
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2022-07-01 07:23:28 +00:00
David Stevens
9df3eb7ef2 devices: virtio: disallow modification of ready queues
Disallow modification of a queue configuration's after it has been
enabled, since the spec states drivers MUST configure the other
virtqueue fields before setting enabling the virtqueue. This allows the
queue validation to be done once and then saved, instead of requiring
validation for every peek.

Before this change, modifications of running virtqueues were not well
defined, since the Queue instance owned by the VirtioPciDevice is not
the same as the Queue instance owned by the VirtioDevice implementation.

BUG=None
TEST=boot ARCVM and crostini on ManaTEE and non-ManaTEE

Change-Id: Ibd1f2bdb0a49865cedd8a0424199a72316696b4d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3737409
Commit-Queue: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-01 06:03:56 +00:00
David Stevens
540872395e vmm_vhost: add Send trait to Endpoints
BUG=b:201745804
TEST=compiles

Change-Id: I8cca96a54bce0aa74f43dc1ff82e3af199118414
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716345
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-07-01 05:51:19 +00:00
David Stevens
3b6c7295e3 vm_memory: move udmabuf support to vm_memory
Refactor udmabuf support out from virtio_gpu into the shared vm_memory
target, so that can be used for vvu.

BUG=b:201745804
TEST=compiles
TEST=./tools/bindgen-all-the-things

Change-Id: I2944f0cb8c75e4320400bfb9f7026dc1efe0c12b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716339
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-01 05:29:23 +00:00
David Stevens
48b0b429d6 vhost_user: refactor device activation
Move worker thread creation from frontend device into handler. This
removes the need to duplicate the worker thread boilerplate in each
individual device.

BUG=b:201745804
TEST=compiles

Change-Id: Ib6567402a809b9cafe286f575751419e31469d76
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3716338
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-07-01 04:44:36 +00:00
David Stevens
908adc6403 resources: implement Debug for AddressRange
Manually implement Debug for AddressRange so that it gives the same
formatted output as Display.

BUG=None
TEST=compiles

Change-Id: I0d76c9aeea3c0eaac2b1c315017a14fd09d8bcd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3737404
Commit-Queue: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-07-01 01:11:15 +00:00
Vaibhav Nagarnaik
7b30003435 hypervisor/tests: Upstream tests common to all hypervisors
All tests pass on kvm.

`read_only_memory` test does not pass on whpx and haxm, there is a bug
tracking its resolution.

BUG=b:213151455
TEST=Ran `cargo test -p hypervisor` on linux.

Change-Id: Ieb8042c9eb964873b685437f94802fae83765a43
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3739488
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-07-01 00:52:35 +00:00
Daniel Verkamp
cdf33f9660 cros-fuzz: upgrade to rand_core 0.6
This is the version used by rand 0.8.x (and the latest available version
as of this writing), so this allows us to upgrade crosvm-fuzz to rand
0.8 as well.

BUG=b:236978141
TEST=tools/dev_container tools/run_tests --target=host
TEST=USE='asan fuzzer' emerge-amd64-generic crosvm

Change-Id: I297f6c17114b2b8e8f12d5dd9d35b071b91d6780
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3722780
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-30 23:22:39 +00:00
Daniel Verkamp
98fcb96d6b Cargo: bump all rand dependencies to 0.8
The previous configuration made us pull in three different versions of
rand, and depending on "*" is a recipe for API incompatibility.

crosvm-fuzz needs to match its rand version to the rand_core used in
common/cros_fuzz, so that will be upgraded separately.

BUG=b:236978141
TEST=cargo build
TEST=emerge-hatch crosvm

Change-Id: I655ed3f156e4ac43afa3122596f62e9caa43b4f2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3722184
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-06-30 23:22:37 +00:00
Vaibhav Nagarnaik
b36807ecec haxm: Fix compilation issues with cpuid changes
The registers for cpuid got refactored into a new `cpuid` member. Update
the haxm tests to work with the new structure.

TEST=Ran `tools/run_tests --target=host --arch=win64` by temporarily
TEST=enabling `haxm` in `Cargo.toml`.

Change-Id: I6a70be72fc49015ed2301b422a18b88b374e17c1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3737458
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-06-30 21:03:40 +00:00
Noah Gold
3fd26a58b3 arch: fix file permissions for Windows pstore.
Without setting the share mode, we can't do occasionally useful things like
tail the pstore file.

BUG=b:237597358
TEST=builds + tested downstream on Windows

Change-Id: I893d0e52a671eeec5981527c1009b9d188110534
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3736759
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-30 20:34:14 +00:00
Noah Gold
b273d2f30b arch: upstream Windows support.
Fix various odds and ends that don't build / work properly on Windows.

BUG=b:237597358
TEST=builds

Change-Id: I5a6393cc15b3775f8d35b147498210ffc096cd10
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3736758
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
2022-06-30 20:34:12 +00:00
Vikram Auradkar
0ae4602c6b crosvm: refactor config
Prepares config for upstreaming.

- Adds Ser/De to Config.
- Makes some of Config's members as unix only.
- Moves platform specific gpu validation code.
- Rearranges imports.

Windows serializes/deserializes Config to send over a Tube.

BUG=b:213146388
TEST=built on downstream windows and presubmit

Change-Id: I7300ee68c7a59feacd43a7d4a82ef2758f3cca3b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3735636
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-06-30 20:20:51 +00:00
Vaibhav Nagarnaik
45fb59a2bb Enable irqchip and tsc for windows
Enable most of modules under `irqchip` as well as `tsc` to work with
windows since all their dependencies have been completed. They were
already working for unix.

The test `irqchip::userspace::tests::irq_event_tokens` fails on wine,
however, it work on windows and unix natively.

The test `tsc::calibrate::tests::test_frequency_higher_than_u32` fails
for hosts with cpu>64, since the windows implementation for setting
thread affinity does not support cpu>64.

BUG=b:237024070
TEST=Ran `tools/run_tests --target=host --arch=win64`

Change-Id: I15d8f3c3256e89f89efbe64dbe2ad809fcd90a72
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3737456
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-06-30 19:24:08 +00:00
Vaibhav Nagarnaik
fcc9e4cf9c haxm_sys: follow mod guidelines
TEST=NA

Change-Id: I54a0820e5eeb9c9193cc5e0be344e7913b577284
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3737455
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-06-30 18:36:03 +00:00
Vikram Auradkar
1295a6af47 crosvm: add serde to arg types
Windows serializes/deserializes these types to send over a Tube.

BUG=b:213146388
TEST=built on downstream windows and presubmit

Change-Id: Ib9ca4cbb2758a997788c4bab46d573a532e8e3d4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3735635
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-06-30 17:47:59 +00:00
Norman Bintang
8dd4be42e9 audio_streams: Add StreamSourceGenerator trait
Add StreamSourceGenerator trait and add its implementation
for NoopStreamSourceGenerator

BUG=b:220649000
TEST=emerge audio_streams

Change-Id: I470353e95dded61aaab3048c6b3c90bb4bb893b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3715078
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2022-06-30 13:01:29 +00:00
Richard
b9ddd723ce virtio-vhost: Enable handler to be built and tested on Windows
Still need to enable:
 * balloon (try_clone not implemented)
 * console (Need to enable Serial)
 * snd (Unix code not conditionally compiled out)
 * gpu (Waiting for graphics team to upstream)
 * vhost-user block

BUG=b:237011316
TEST=ran "./tools/run_tests --target=host --arch=win64 --verbose"

Change-Id: If2b69250477f88ded7176054196107733736786e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3721868
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Richard Zhang <rizhang@google.com>
2022-06-30 00:48:02 +00:00