Commit graph

3306 commits

Author SHA1 Message Date
Daniel Verkamp
cb3749e632 devices: xhci: allow statx syscall on x86_64
Recent builds (starting R100.14501.0.0) crash when attaching a USB
device to the Linux VM due to calling the statx syscall, which was
missing from the seccomp policy. stat was already allowed, so add statx
as well to prevent the crash.

The change is likely due to the upgrade of the Rust toolchain in the
Chrome OS SDK (https://crrev.com/c/3439725), which landed in this build.

This was already allowed on arm/aarch64, so no other changes are
required.

BUG=b:218565401
TEST=Attach USB device to crosvm on hatch

Change-Id: Ia3a383429a839c68b44040f4b99c990a1f1f8e9d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3448188
Reviewed-by: Long Cheng <lgcheng@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-11 19:40:28 +00:00
Dennis Kempin
5f46e21c02 Remove rutabaga_gfx_ffi from workspace
The crate requires special compilation flags that conflict with the
workspace flags.

We may want to consider moving it to common/ so the test runner can
compile it in a separate workspace.

This brings us one step closer to be able to run
`cargo build --workspace` with no excludes.

BUG=b:206689789
TEST=./tools/presubmit

Change-Id: Ice747ced00f81db0a8e05ff2bc43d4d0e323e456
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3453050
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-11 15:58:56 +00:00
Lepton Wu
6ac3f7332d gpu: Allow F_GET_SEALS arg in fcntl
This is used in upcoming virglrenderer change:
https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/688

BUG=None
TEST=manual - push updated policy to device and no crash.

Change-Id: Ic95d2cedcc13542b6ee3864b5a39ed2bce794c3a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3453118
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
2022-02-11 06:08:38 +00:00
Alexandre Courbot
4da0e52ba5 Cargo.toml: add "chromeos" and "lto" build profiles
Add a "chromeos" profile that mimics the flags used when compiling for
Chrome OS. This is useful to determine how much the crosvm binary will
inflate due to a given CL.

Also add an "lto" profile enabling LTO on top of the "chromeos" profile,
so we can easily see how much space we save by enabling LTO.

BUG=b:218473401
BUG=b:218566754
TEST=cargo build --profile chromeos
TEST=cargo build --profile lto

Change-Id: I2fd743b6c980b847af1f3db593a55b683cbb8d57
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450026
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-11 05:34:19 +00:00
Dennis Kempin
12ae5e8bc8 Update ./tools/presubmit defaults and add --all mode
The new default should be quick, aarch64 tests barely take longer
than clippy/fmt and gives good enough coverage for most things.

The --all mode will add all other builds run by kokoro, including
armhf and a --no-default-features build.

BUG=b:203152778
TEST=./tools/presubmit (--quick, --all)

Change-Id: Ie778f397e9d65d9ca79bcb55acf0e74394bb04af
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3447293
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-10 22:04:18 +00:00
Dennis Kempin
4d0436e74e Add DO_NOT_RUN_ON_FOREIGN_KERNEL option
While we can run armhf binaries on aarch64 or use user-space emulation
to run aarch64 tests on the x86 host, some tests will fail in that
scenario as they will interact with kernel APIs directly (e.g. kvm).

This will make it easier to distinguish 'do not run on armhf because
we haven't fixed the tests' from 'this test is not supported on
a foreign arch kernel and that is expected'.

It also enables a quicker method of running aarch64 tests with
user-space emulation.

BUG=b:218374759
TEST=./tools/dev_container ./tools/run_tests --target=host
--arch=aarch64

Change-Id: I81871e11d3b02ee1ed3bac88bada28fbba8a3f31
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3447292
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-10 22:04:18 +00:00
Keiichi Watanabe
ee58ebff65 devices: vvu: Disable time-consuming tests on non-native environment
BUG=none
TEST=kokoro

Change-Id: Id1de70e3037c03d0d204793b0015992a8ff15cb9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3451760
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-10 16:30:50 +00:00
Kaiyi Li
74abb9de04 rutabaga_gfx: use as to perform type conversion
On Windows os_handle is of type void*, can't use Into::into to cast to
i64. Use as i64 instead.

Test: launch_cvd
Change-Id: I7fe44dbadf5214ff9bfd81482f5b598091a8f692
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3448217
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
2022-02-10 16:30:04 +00:00
Keiichi Watanabe
c8d819dda8 devices: vhost-user: block: Support VVU
crosvm device block --vfio 0000:00:07.0 --file disk.img

BUG=b:213532031
TEST=Run vvu on QEMU

Change-Id: Idf288c0d6ec9e6784772f3147e4a25607bd434f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3245356
Reviewed-by: Chirantan Ekbote
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-10 11:22:14 +00:00
Keiichi Watanabe
6f9c40feee devices: vhost-user: Extend DeviceHandler to support VVU
BUG=b:194137301
TEST=cargo test in devices

Change-Id: I1b5a53eec0114f35421512f374f7cec693520fd7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3149876
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-10 11:22:13 +00:00
Andrew Walbran
a24a752708 Disable RNG device for protected VMs.
They can't trust the host to provide entropy, so there's no point
providing it.

BUG=b:217506382
TEST=tools/dev_container tools/run_tests
TEST=tools/dev_container tools/run_tests --target=vm:aarch64

Change-Id: I5355e846191d34e10c0c5c3cf0b2afaa3c779313
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450875
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2022-02-10 10:04:55 +00:00
Junichi Uekawa
67d4219489 system_allocator: use config object pattern for constructing
In preparation to allow multiple low memory regions to be passed on, I wanted to
make initialization simpler.

Introduce `MemRegion` struct instead of tuple to help me understand it is a base
and size.

BUG=b:188011323
TEST=build

Change-Id: Ie8b54354a25c478d5ad0a0185b7e07d28840dd87
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439666
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-02-10 08:46:07 +00:00
Keiichi Watanabe
52e0085daa devices: vhost-user: Introduce Doorbell enum
crrev.com/c/3205229 introduced an associated type
`VhostUserBackend::Doorbell` to allow support different types for
vhost-user and vvu.

However, we finally concluded having it as an enum would be better
because it allows us to decide which vhost-user or vvu is used at
run-time so that we can share more code between vhost-user and vvu.

So this CL replaces the associated type with an enum value.

BUG=b:194137301
TEST=build

Change-Id: I60d7080e5d3bcd397ab70c8f9b83c7d6cd08bb92
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3353057
Reviewed-by: Chirantan Ekbote
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-09 17:08:34 +00:00
Keiichi Watanabe
7bae9eeda5 devices: vvu: Add VFIO PCI driver for vvu
BUG=b:194137301
TEST=build

Change-Id: Ib4c6a8c5cca3e270a4236be9bf37df2b170e8eb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3295304
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-09 17:08:33 +00:00
Keiichi Watanabe
70e41c106b devices: Drop vvu feature
Enable VVU feature unconditionally.
Since kokoro will start checking VVU code from this CL, clippy errors
are fixed.

In addition, the time limit of kokoro unit testing needed to be
increased because some time-consuming unit tests will start running on
aarch64 QEMU, which is really slow.

BUG=none
TEST=kokoro

Change-Id: I67437c060ff5ba9f690dcfc6e5c3dd155b95a785
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3450014
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-09 17:08:32 +00:00
Woody Chow
3c2a4616a8 iommu: Add generic MemoryMapper interface
and BasicMemoryMapper impl. This will be used for
VIRTIO_F_IOMMU_PLATFORM support in virtio-iommu.

BUG=b:215307964
TEST=cargo test/block device with VIRTIO_F_ACCESS_PLATFORM
     with crrev.com/c/3347309 (to be submitted)

Change-Id: Iadd964556edf5b95aa00b542b4bde5a997756090
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3334331
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
2022-02-09 07:31:01 +00:00
Keiichi Watanabe
6aeb0d0b5d devices: vfio: Add helper to check VFIO device information
Add a safe helper function to call `VBFIO_DEVICE_GET_INFO` ioctl, which
will be used from VVU later

BUG=b:194136484
TEST=build

Change-Id: Ia3b797fba7cd77fc7698230e88a94e619485eaca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3446522
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-09 01:24:31 +00:00
Keiichi Watanabe
9ba5f665fc devices: pci: Use bit_field for MSI-X message control register
This will allow reusing `MsixCap` for virtio-vhost-user in the later
CLs.

BUG=b:194136484
TEST=cargo test

Change-Id: I38bced958d42ce7e3192a54564628c9b559c4269
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3446521
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-02-09 01:24:30 +00:00
Dennis Kempin
bb27416ccb TestRunner: Clean up test options
This will still run the same tests as before, the options are just
more consistent now.

BUG=b:218374759
TEST=./tools/presubmit

Change-Id: I41a8730f6cfaf65a62aaa26c45e2c284f0356d33
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3447541
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-09 00:20:38 +00:00
Kaiyi Li
3ff6bbd1ac rutabaga_gfx: change os_handle type
Windows HANDLE is defined as void* which is incompatible with current
os_handle type i32. Change that to i64.

TEST=launch_cvd --gpu_mode=gfxstream
BUG=b:217977329

Change-Id: I78c6c4c0d7573773ed530d8987b932438222144f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3445529
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
2022-02-08 21:31:45 +00:00
Vikram Auradkar
7aa543ca35 Introduce code hygiene checks
The patch disallows any platform specific code in sys_util_core and
doesn't let sys_util compile on windows platform.

This ensure to some extent that we keep sys_util and it's dependency
sys_util_core independent of windows code.

check_code_hygiene is not foolproof.

Test: Ran the script against a modified file in sys_util_core containing
      string "target_os = "
      Tried to compile sys_util on windows.
Bug: b:215610772
Upstream-Crate: common/win_sys_util

Cq-Depend: chromium:3433709
Change-Id: Ideb45092a959dd347d966633c3bd4e82f842b1a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3438709
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-02-08 20:59:24 +00:00
Vikram Auradkar
323006cf82 Move os independent files under a new crate sys_util_core
sys_util_core won't have OS specific features so that sys_util and
win_sys_util can depend on it.

Test: Presubmit
Bug: b:213149154
Upstream-Crate: common/win_sys_util

Cq-Depend: chromium:3433709
Change-Id: I863f7a6bc7549944b4d114cca6d7be04c3093fc3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3426380
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-02-08 20:59:24 +00:00
Dennis Kempin
9503e86ff4 Enable bit_field_derive tests
proc-macro tests run on the host, adding logic into the test runner
to accomodate for that.

BUG=b:218374759
TEST=./tools/presubmit

Change-Id: I83c853b9e28dae725d299509f7e3a07f56bd6ad8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3445531
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-08 17:08:52 +00:00
Dennis Kempin
e225a10959 Enable cros_async tests
Adds use_uring checks to a few more test cases that are using the
URingExecutor.

BUG=b:218374759
TEST=./tools/run_tests

Change-Id: Ie5822dea4f22c2e8cffab13549c07873e89129d8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3443634
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-08 17:08:51 +00:00
Sebastian Ene
0440d35c31 Add option to disable USB devices for protected VMs.
It is not compatible with protected VMs and leads to crashes due to host
trying to access the guest ring buffers.

BUG=b:215516857
Signed-off-by: Sebastian Ene <sebastianene@google.com>
Change-Id: I110c8844903de20d9d3833d5dfdc25c3d41d2afb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439895
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Andrew Walbran <qwandor@google.com>
2022-02-08 10:06:18 +00:00
Dennis Kempin
5eb7743abd clippy: Fix cros_async
This is the last one. Just a few nits and we can now run clippy on all
crates.

BUG=b:192373803
TEST=./tools/presubmit

Change-Id: I93ad9ce3b1cf0718bda8588279d7e1a891a0a6f3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439052
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-07 22:22:44 +00:00
Dennis Kempin
04ccba5143 clippy: Fix net_sys / virtio_sys / x86_64
The bindings need to be regenerated. Just disable warnings for now.

BUG=b:192373803
TEST=./tools/presubmit

Change-Id: Ia34638cbc20c4705631ea3693d4476137ebf8d55
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439051
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-07 22:22:43 +00:00
Dennis Kempin
f23f62c521 clippy: Fix libvda
Mostly issuses in bindings, which have just been suppressed.
The bindings will need to be regenerated in a separate CL.

BUG=b:192373803
TEST=./tools/presubmit

Change-Id: I653e4903778087943456fb82fc2643fed0f86314
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439050
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-07 22:22:42 +00:00
Dennis Kempin
53fccea4e7 clippy: Fix kvm(_sys)
This adds a blanket allow to the top of the bindings file. The bindings
will need to be regenerated in a separate CL.

BUG=b:192373803
TEST=./tools/presubmit

Change-Id: I6554d17fffde2089e29bf2e7c184b8cac937db6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439049
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-07 22:22:41 +00:00
Dennis Kempin
f881af3c1f clippy: fix devices crate
Fixes clippy failures and enables clippy checks on the crate.

BUG=b:192373803
TEST=./tools/presubmit

Change-Id: I9022d40e997f94c03d3f936734116e3ea0505022
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3441348
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-07 22:22:39 +00:00
Dennis Kempin
7a543caa2e clippy: fix disk crate
Just a few nit fixes and we can now enable clippy for this crate.

BUG=b:192373803
TEST=./tools/clippy

Change-Id: Ia6ab90fa33e979066d9eeae2372630d93cf4026a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3441343
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-07 22:22:38 +00:00
Xiong Zhang
4a356f670a pcie: Add PME support
When virtual pcie root port RTD3 is enabled, it will enter into suspend if child device
isn't exist. Pcie hp driver disable hotplug interrupt once it enters into suspend state,
so hotplug interrupt couldn't be injected into guest if pcie RP is in suspend state. In
such case a PME will be injected into CrOS to wakeup itself first, another hotplug event
will be injected after this PME.

BUG=b:185084350
TEST=Hotplug a vfio-pci device into CrOS with virtual RP RTD3 enabled

Change-Id: I96f8ac6ba27072f6cfbc01df00c0a48f2d92a7e5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3423463
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-07 21:30:01 +00:00
Xiong Zhang
5823da01d5 pcie: Add pci power control capability
In order to link virtual pcie root port's power status with physical
pcie root port, power control capability should be added to let guest
enable RTD3 for virtual pcie root port.

BUG=b:185084350
TEST=check virtual pcie root port's RTD3 status in CrOS

Change-Id: I25e36b845b7ec198f995e82dda7850e4a1af0d9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3423462
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-07 21:30:00 +00:00
Xiong Zhang
4f6d228629 Pcie: Reserve the same bridge window size as host RP
When pcie-root-port parameter is used to link virtual pcie RP with
physical RP, they should have the same bridge window size.

BUG=b:185084350
TEST=Boot CrOS with pcie-root-port parameter in ManaTEE and check
bridge window size in CrOS

Change-Id: I7864b37ecd61af52b470701803e746080f3a9025
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3423461
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-07 21:29:59 +00:00
Xiong Zhang
f787471913 Linux: Add parameter to pass host pcie root port into guest
Add pcie-root-port parameter, it specify host pcie root port's sysfs, then
it will have a virtual pcie root port in guest, as guest and host have
the same pci address, so virtual pcie root port creation should be prior
to build_vm().

BUG=b:185084350
TEST=boot CrOS with --pcie-root-port=sysfs_path in ManaTEE and check virtual
RP's function in CrOS

Change-Id: Id357e0de057d5387f135213e89702f27163faaee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3423460
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-07 21:29:58 +00:00
Xiong Zhang
cf093620a8 pcie: Link virtual pcie root port to physical pcie root port
On ManaTEE, each physical pcie root port has a virtual pcie root port in
CrOS, this commit links virtual RP to physical RP. The following virtual
RP's config registers are from physical:
--devie ID
--device type
--bridge bus range

BUG=b:185084350
TEST=Check virtual pcie RP config registers in ManaTEE CrOS

Change-Id: Ia38a0f2417331d562dbb305433c68a3bee678bde
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3423459
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-07 21:29:57 +00:00
Xiong Zhang
10e4637525 Pcie: let PcieRootPort determine bridge's PciAddress
Currently bridge's PciAddress is allocated from system bus allocator,
but when virtual pcie root port is linked to physical pcie root port,
its PciAddress should be same as physical pcie RP, so thid commit let
bridge get its PciAddress from the backend pcie RP device, this is
convenient for later pcie root port.

This commit doesn't change function.

BUG=b:185084350
TEST=tools/presubmit

Change-Id: I2b81f6447898bd76758569095aa48f3daa2b0dcc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3423458
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-07 21:29:56 +00:00
Xiong Zhang
d1f6ca1dc1 Pcie: let PcieRootPort determine bridge bus range
Currently pci bridge's bus range is managed in pci bridge structure, but
when virtual pcie root port is linked to physical pcie root port, the bus
range of virtual pcie RP should be same as physical pcie RP, so this commit
let bridge get its bus range from the backend pcie root port device, this
is convenient for later physcial pcie root port.

This commit doesn't change function.

BUG=b:185084350
TEST=tools/presubmit

Change-Id: I80c54365d6def455e32e7934e7216c677902450d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3423457
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-07 21:29:56 +00:00
Xiong Zhang
760f8ba70a pcie: split pcie.rs into pcie directory
As more function are adding into pcie.rs, one file wil be larger. This commit
split pcie.rs into three files:
pci_bridge.rs: handle pci bridge device and implement PciDevice trait
pcie_device:rs: define PcieDevice trait and PcieCap
pcie_rp.rs: virtual pcie root port emulation, implement PcieDevice trait and
            HotPlugBus trait

This commit doesn't change function.

BUG=b:185084350
TEST=tools/presubmit

Change-Id: I4ab16f35e78a9d084a7a47d91a7fcf37e9f3e91d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3423456
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-07 21:29:55 +00:00
Woody Chow
100d7a85c1 iommu: Switch to async
An async IPC translation request handler will be added for
b/215307964. This CL is preliminary.

BUG=b:215307964
TEST=cargo test/block device with VIRTIO_F_ACCESS_PLATFORM
     with crrev.com/c/3347309 (to be submitted)

Change-Id: I1ce7b1c53e8efb3ae8652caba02693fee77646b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3382499
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Woody Chow <woodychow@google.com>
2022-02-07 06:23:47 +00:00
Alexandre Courbot
1ee6783a57 devices: vhost-user: properly return device failures
The `run_until` method of the executor returns a Result<Result<..>>,
where the outer result signals errors within the async executor, and the
inner result is the actual result of the passed future.

The current error handling completely ignores this inner error, making
"crosvm device" exit silently if we e.g. specify a socket that already
exists.

Fix this by explicitly returning outer errors if they exist, and
returning the inner anyhow::Result as-is so both levels of errors are
properly reported.

BUG=None
TEST=cargo build
TEST=console device properly reports and error if its socket file
already exists.

Change-Id: I7d091bd7b0d66a07c6f340ebf9e395d0dab2c212
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439668
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Anton Romanov <romanton@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-07 02:28:50 +00:00
Bartłomiej Grzesik
73072d6d16 virtio: video: encoder: set frame rate only if successfully changed
Encoders Stream's frame rate was updated before a request was made.
This could cause hypervisor to report incorrect frame rate to guest and other
invalid behaviour if the request failed.

This CL changes the order in which frame rate is updated. First a
request is made, and then if successful, the frame rate is updated in
the stream structure.

BUG=b:160440787
BUG=b:161774071
TEST=v4l2-compliance -d /dev/video1
TEST=v4l2-ctl -d 1 --set-fmt-video-out
width=1280,height=1280,pixelformat=NV12 \
        --set-output-parm 10 --get-output-parm
        TEST=tast run eve arc.Video*

Change-Id: I11a93d6d6338829ee0622f40f9b544a4ef2a69dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3425362
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Marcin Wojtas <mwojtas@google.com>
2022-02-04 21:52:46 +00:00
Bartłomiej Grzesik
2bbbe1184a virtio: video: encoder: store frame rate in input and output params
Prior to this change, frame rate wasn't modified in video encoder input
and output params. This resulted in hypervisor reporting to guest a frame
rate equal to zero at all time. This is inconsistent with actual frame rate.
Futhermore frame rate equal to zero causes v4l2-compliance to fail.

This CL ensures that frame rate is stored in input and output stream
params and that its value is reported correctly to the guest. With this
change we remove field_rate from Stream struct to avoid storing the same
value in 3 saperate places instead 2.

BUG=b:160440787
BUG=b:161774071
TEST=v4l2-compliance -d /dev/video1
TEST=v4l2-ctl -d 1 --set-fmt-video-out width=1280,height=1280,pixelformat=NV12 \
        --set-output-parm 10 --get-output-parm
TEST=tast run eve arc.Video*

Change-Id: Iff76a923d5f337db86fe67bfc77b13cd6bf58edf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3417310
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Marcin Wojtas <mwojtas@google.com>
2022-02-04 21:52:45 +00:00
Bartłomiej Grzesik
b021c0b7c2 virtio: video: store frame size in both input and output params
Till this point, frame size was stored in either input params or output
params depending on the device. This caused to virtio-video to report
zerod width and height on one buffer end, which caused v4l2-compliance
to fail.

This CL makes encoder and decoder store frame sizes in both params.

BUG=b:160440787
BUG=b:161774071
TEST=v4l2-compliance -d /dev/video0
TEST=v4l2-compliance -d /dev/video1
TEST=tast run eve arc.Video*

Change-Id: I77d8ab4c0ed1d0a877ed090b169a922606dcee70
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3412775
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Marcin Wojtas <mwojtas@google.com>
2022-02-04 21:52:44 +00:00
Bartłomiej Grzesik
ca52033219 virtio: video: decoder: set default stream parameters
Previously most decoder initial parameters were set to zero due to use
of Default::default(). This caused decoder to start with incorrect values,
and led to v4l2-compliance failing.

This CL sets initial decoder parameters to artificially chosen values in
order to comply with v4l2-compliance.

BUG=b:160440787
TEST=v4l2-compliance -d /dev/video0
TEST=tast run eve arc.Video*

Change-Id: I283473d856e94087f039bc8f60c978c384f7f22c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3402215
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Marcin Wojtas <mwojtas@google.com>
2022-02-04 21:52:43 +00:00
Bartłomiej Grzesik
12e0d6417f virtio: video: introduce PlaneFormat::get_plane_layout function
Before this CL, both encoder and decoder had separate code which
computed plane formats for given format.

This CL removes code duplication, by introducing PlaneFormat::get_plane_layout,
which returns vector of plane formats if given format is supported. At
this point only NV12 is supported.

BUG=b:160440787
BUG=b:161774071
TEST=v4l2-compliance -d /dev/video0
TEST=v4l2-compliance -d /dev/video1
TEST=tast run eve arc.Video*

Change-Id: I427346d7e286a2e52aa4cbdc6e042a996812f3b1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3425360
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Marcin Wojtas <mwojtas@google.com>
2022-02-04 21:52:42 +00:00
Daniel Verkamp
995c91af7d ci/kokoro: add a no-default-features build
To help find missing feature cfg checks, add a build with all features
disabled to the CI scripts.

BUG=None
TEST=tools/presubmit

Change-Id: I98f38ecc3bf90cbeb081a1fafe4f2f540e4fc348
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3437362
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-02-04 21:19:33 +00:00
Dennis Kempin
d9af9d6a58 clippy: Fix aarch64 and crosvm-fuzz
Add proper conditional compilation flags. This will largely still skip
most of those crates, but at least the syntax will be checked.

BUG=b:192373803
TEST=./tools/clippy

Change-Id: I66d29ccdfec01f3a83b682a9cc135188fdc830cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3438705
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-02-04 19:16:05 +00:00
Richard Fung
08289b1a83 Move GPU initialization earlier
Moving the GPU initialization earlier makes it so that the addition of
block devices does alter PCI slot of the GPU. This makes it so that
SELinux rules won't need to be changed any time we add a new device.
Without this patch, adding another disk breaks ARCVM for this reason.

BUG=b:199685490
TEST=local_test_runner arc.Boot.vm

Change-Id: I55e2a4c95cd5783108b0458e6cb2fc5f554e1847
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3433227
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Richard Fung <richardfung@google.com>
2022-02-04 17:27:27 +00:00
Alexandre Courbot
5d12163091 devices: vhost-user: console: always restore terminal capabilities
We used to bail early if an error happened while we run the console
device, leaving the terminal in raw mode.

BUG=None
TEST=cargo build

Change-Id: I3dc4a681f736246548d1cc7b7eab0bfd429587be
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439667
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-02-04 12:12:20 +00:00