Commit graph

3725 commits

Author SHA1 Message Date
Yuanjun Huang
e98d378d34 [luci] turn off builders in Luci temporarily
Turn off crosvm builders in Luci temporarily since the cloud storage
bucket in crosvm-infra doesn't grant proper access for logdog.

Bug:1300370
Change-Id: Ie91b33d10c1a9e6e155961be4cfb8c7a406fcef5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636269
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Yuanjun Huang <yuanjunh@google.com>
Reviewed-by: Robbie Iannucci <iannucci@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-09 22:17:41 +00:00
Daniel Verkamp
3fab3baecc virtio-sys: add virtio_config and clean up imports
Restrict the bindgen patterns so that only the declarations from the
appropriate header are included in each binding, and add the
virtio_config binding to get the source of the VIRTIO_F_ and
VIRTIO_CONFIG_ #defines.

BUG=None
TEST=tools/presubmit --all

Change-Id: I216bd8d3540d918ad9bba162db0ae86b76d73f31
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582522
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-09 21:20:27 +00:00
Lepton Wu
97a8f891a8 devices: vhost-user: fs: support VVU
Device can be started with

    crosvm device fs --vfio <PCI ID> --tag <TAG> --shared-dir <DIR>

BUG=b:213533074
TEST=manual - fs is usable from a sibling guest when using VVU.

Change-Id: I199113b1837686d78140936adcd8741a8c2b066e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631019
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Lepton Wu <lepton@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Lepton Wu <lepton@chromium.org>
2022-05-09 18:06:31 +00:00
Vikram Auradkar
c57fcc8ef2 base: add clear() to WaitContext as a platform specific extension
BUG=b:213153157
TEST=presubmit

Change-Id: I9f7c958834e9727acaba860600aecfbdc98fcdc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631414
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-09 17:06:19 +00:00
Junichi Uekawa
78a12954cf crosvm: Keep one MsrFileType per vcpu.
Each vcpu has a vcpu->MsrDev file mapping. Instead of trying to create
an instance at first use, just keep an empty map in the beginning.

BUG=b:215297064
TEST=boot volteer-manatee

Change-Id: Ic5a63b0427a6441f190da3917b5f272bbb8ec778
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3611369
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-09 08:11:40 +00:00
Zhao Liu
1608127c37 x86_64: Fix compatibility of HWP CPUID
Originally, crosvm expose some HWP related CPUID under
'host-cpu-topology', now this is moved under 'itmt' flag.

Before the 'itmt' option is set in initramfs, this may break some freq
related sysfs check. So fix this compatibility issue.

BUG=b:225375705
TEST=boot brya and check cpuinfo_max_freq under sysfs

Change-Id: Iaf7f1590717c12b166d41a0e410a8fd6f605f318
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3609238
Reviewed-by: Lepton Wu <lepton@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2022-05-08 23:56:19 +00:00
Vikram Auradkar
fd277205e2 base: enable wait_context on windows
BUG=b:213153157
TEST=presubmit

Change-Id: I34707cab4d7a4c6a5b0fa349258eb271cb2e0255
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631413
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 23:13:11 +00:00
Vikram Auradkar
ffc0fb84fa base: move platform specific WatchingEvents under unix/
The struct is not used on windows - windows has something equivalent.

BUG=b:213153157
TEST=presubmit

Change-Id: Ied2d76c33a179d801f2cf185b2224b32c7367254
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631412
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 23:13:10 +00:00
Daniel Verkamp
e78f169547 third_party/minijail: update to latest
Pull in commit 77c59db8ff9a ("rust: add minijail_run_env to
minijail-sys") so the minijail-sys build script does not keep making the
submodule dirty on every build.

BUG=None
TEST=cargo build && git status

Change-Id: I662a4a9801eb27245691f69644508026a69e8a11
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631409
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 23:09:20 +00:00
Kaiyi Li
ffa8743f2c rutabaga_gfx: add gfxstream search path by using env
TEST=build
BUG=b:199167472
BUG=b:231635891

Change-Id: I8c69e9dad97007305097e9068a57d74163337648
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3602045
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-06 22:50:21 +00:00
Douglas Anderson
e742c70edc seccomp: Add io_uring_setup / io_uring_enter to gpu_common.policy
The top part of gpu_common.policy is supposed to match
common_device.policy. In https://crrev.com/c/1993163 we added
io_uring_setup and io_uring_enter to common_device.policy. Even though
there's nothing known to be broken, add these to the gpu_common.policy
to keep things matching.

BUG=None
TEST=kokoro

Change-Id: Ifd4c53c50ec12eb7e1e14f7eb80d2c9b8f0fbe46
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631411
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Douglas Anderson <dianders@chromium.org>
2022-05-06 22:09:01 +00:00
Douglas Anderson
0508572d3c seccomp: Move prctl in gpu_common to gpu-specific section
The top part of gpu_common.policy is supposed to match
common_device.policy, but "prctl" is in this top part and isn't in
common_device.policy. A bit of history:
* prctl used to be in the common_device.policy but was removed in
  <https://crrev.com/c/2837307>.
* Even when prctl was in common_device.policy, it had different
  arguments than what we allow in gpu_common.policy.

This is a no-op cleanup change.

BUG=None
TEST=None

Change-Id: Ic71c9da3ef9eb24665711d2000416ff9c87d49a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631410
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Douglas Anderson <dianders@chromium.org>
2022-05-06 22:09:00 +00:00
Daniel Verkamp
b744af775c tools/cargo-doc: exclude crosvm-fuzz
crosvm-fuzz only contains fuzzer binaries, which don't have any
documentable items and clutter up the list of crates.

BUG=None
TEST=tools/cargo-doc

Change-Id: I0a8a5a61977643920d66a0f2662a1050a66192a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630425
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-06 20:47:00 +00:00
Daniel Verkamp
4fb38ced74 base: improve the WaitContext doc test
Use the PollToken derive and the build_with() function to make the
example more representative of actual uses.

BUG=None
TEST=cargo doc
TEST=cargo test -p base --doc wait_context

Change-Id: I1f154dfd6247786024dc94035ea63db11968e85a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630424
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 20:46:59 +00:00
Daniel Verkamp
c7e45226be devices: pci: fill out the PciAddress docs
More or less fully document this file to make it a good documentation
example.

BUG=None
TEST=cargo doc
TEST=cargo test -p devices --doc pci_address

Change-Id: I9a02c057135bc684ccc7897a07cb8cfce77dd388
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630423
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 20:46:58 +00:00
Daniel Verkamp
45b0920767 doc: add a top-level comment to all crates
This provides at least a minimal one-line description to show what each
crate is about.

BUG=None
TEST=tools/cargo-doc

Change-Id: I26732e8c29062e622d5be09bdc120a49d564b9fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630422
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 20:46:57 +00:00
Daniel Verkamp
132957468f devices: pci: fix markdown quoting in doc comments
Escape the square brackets in doc comments to resolve the rustdoc
warning.

BUG=None
TEST=tools/cargo-doc

Change-Id: I78f60ef65f57b213da2f0e687ee295b7e046db9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630421
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-06 20:46:56 +00:00
Daniel Verkamp
5e43f03d80 Fix rustdoc bare URL warnings
BUG=None
TEST=cargo doc

Change-Id: Ib9d14d8aa38eef97c02c60fca3928b70a833b6bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630420
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 20:46:55 +00:00
Xiong Zhang
314dbc3afe pcie: Hotplug out interrupt for multi devices
When multi pcie endpoint devices are connected to one virtual pcie
root port as pcie multi function device, virtual pcie root port couldn't
inject hotplug out interrupt for each removed pcie device. Only one
hotplug out interrupt is needed for all the removed pcie devices.

When the first vfio-pci device send hotplug out vfio command, virtual
pcie root port will inject hotplug out interrrupt. Other vfio-pci device's
hotplug out vfio command just clean virtual pcie root port's structure,
and let virtual pcie root port prepare for the next hotplug in.

BUG=b:185084350
TEST=Check TBT dock's hotplug out function, TBT dock has multi pcie
devices.

Change-Id: I15c2807097c0065d2a78ef269720e57d15eeaf9e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3604291
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 20:33:16 +00:00
Xiong Zhang
7245ebd353 pcie: hotplug in interrupt for mutli devices
When multi pcie endpoint devices are connected to one virtual pcie
root port as pcie multi function device, virtual pcie root port couldn't
inject hotplug in interrupt for each added pcie device. Only one hotplug
in interrupt is needed for all the added pcie devices.

So this commit adds a hp_interupt field into VfioCommandRequest, only
the last added pcie device sets hp_interrupt to true and requests virtual
pcie root port to inject hotplug in interrupt. Ohter added pcie devices
just create and configure vfio-pci device.

BUG=b:185084350
TEST=Check TBT dock's hotplug in function, TBT dock has multi pcie
devices.

Change-Id: I5a68ec38af9a32de9d4233b48e0aa3681e5a3ba3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3604290
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 20:33:15 +00:00
Kazuhiro Inaba
6b8153e9c1 seccomp: add sched_yield for arm64
We already allow the system call in arm32.
Testing revealed that the call is actually in use.

BUG=b:231660764, b:230609113
TEST=cheets_CTS_R.internal.arm.CtsSkQP

Change-Id: Ia04089d1454312ac637e5c76d0aceafd2ab55134
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3632320
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
Commit-Queue: Douglas Anderson <dianders@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 20:19:04 +00:00
Daniel Verkamp
418c33e605 base: unify WriteZeroes and PunchHole traits
Move the trait definitions and tests into a single cross-platform file.
The File impl is also defined in the top-level crate so it can be
exported, and that impl calls new platform-specific functions that
provide the actual implementations.

BUG=None
TEST=cargo test -p base write_zeroes
TEST=tools/dev_container tools/run_tests --target=host --arch=win64

Change-Id: I15267c27bd43385545bc406a0143e943e06b16e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631027
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 18:14:25 +00:00
Noah Gold
f1bd7230be devices: vhost-user net device => multi-platform
Splits out the unix specific code in the vhost-user net device into the
sys module, and adds Windows support.

BUG=b:226233737
TEST=builds

Change-Id: I62690d007700f4ea1f55e1079b18115d6f7e0876
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3621416
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-06 18:03:53 +00:00
Vaibhav Nagarnaik
609872d779 hypervisor: Trait changes for VmX86_64
There are 3 new methods added to the trait:
- `handle_cpuid`
- `get_tsc_offset`
- `set_tsc_offset`

These methods allow handling of cpu exit for reading CPUID which is
required for Hyper-V support. The other 2 methods related to TSC are
required for special Hyper-V handling.

BUG=b:213150327
TEST=Compiled crosvm

Change-Id: Ibc95163d9625883521a56ec9a1573725d0f41711
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630709
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-05-06 15:55:25 +00:00
Andrew Walbran
0465b61b1e Move PVTIME down below MMIO_BASE.
This leaves the region between 0x4000_0000 and the start of RAM free of
MMIO, which simplifies the stage 1 page table mappings needed by the
guest, and makes room for the pVM firmware allocation to be expanded.

TEST=tools/dev_container tools/run_tests --target=vm:aarch64

Change-Id: Ibae73a946cadd16e6f03559d23cc256f4b9d3f3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3627454
Commit-Queue: Andrew Walbran <qwandor@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 13:01:31 +00:00
Andrew Walbran
d4bfea4bb9 Document memory layout.
Change-Id: I3ddd6b355a77527063886065ab2c576364709fc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3627453
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Andrew Walbran <qwandor@google.com>
2022-05-06 12:09:40 +00:00
Rob Clark
5807bd9d80 rutabaga_gfx: enable debug callback on aarch64
BUG=b:231459413
TEST:croslog --follow | grep virgl_renderer.rs:152

Change-Id: I597990dbb1f9e715627db544fa2f84caa6bdfdf1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628235
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 00:45:00 +00:00
Daniel Verkamp
13e2950632 vcpu: restore behavior of reading unpopulated Bus regions
When handling a MMIO or IO read vcpu exit, we don't want to report an
error if there is nothing on the Bus at that location. Instead, we
should just return all zeroes. This matches the previous behavior before
https://crrev.com/c/3606975 and removes an error message during
integration_tests:boot.

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

Fixes: 06c00d580d ("hypervisor: Trait changes for windows hypervisors support")
Change-Id: I6c955ece9184f253b1173e46465cd9a6dafe25bf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631029
Reviewed-by: Vaibhav Nagarnaik <vnagarnaik@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-06 00:33:11 +00:00
Anton Romanov
f94281434b crosvm:cros_async:uring: Implement async operation cancellation
BUG=None
TEST=presubmit

Change-Id: I8d0bd6109e8230f953ee736a805677609f5c434d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628241
Auto-Submit: Anton Romanov <romanton@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-06 00:13:38 +00:00
Xiong Zhang
98f0e3d29f pcie_host: Use pci multi function to attach multi devices under pcei root port
Usually a TBT dock has one pcie switch and one or more pcie endpoint device
which connect to pcie switch's downstream port, when such TBT dock is hotplug in,
crosvm will find the first pcie endpoint device, passthrough it into guest and
put it under virtual pcie root port in guest, as one pcie root port could
connect one device only, This means only one pcie endpoint device could work
in guest now.

In order to let all the TBT dock's pcie endpoint devices work in guest, virtual
pcie switch is needed. But virtual pcie switch need more development work, as a
short solution, this commit mark all the pcie endpoint devices as multi pci
function device, then all of them could connect to one virtual pcie root port.

This commit do the following three things:
1. Search all the pcie endpoint devices under host pcie root port.
2. Record all the pcie endpoint devices attached to virtual pcie root port,
so that they could be removed in hotplug out.
3. Allocate pci function number to all the pcie endpoint devices.

BUG=b:185084350
TEST=Check TBT dock's function in guest, the TBT dock has multi pcie
endpoint device.

Change-Id: I07df3b556ba1ac8f7a7a3e49f221f0bf6c7ce97b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3604289
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-05 22:35:39 +00:00
Xiong Zhang
1756efb801 Pcie: Bind hotplug vfio pci device into vfio-pci-pm driver first
This commit use the same logic as in initramfs, let hotplug vfio
pci device bind to vfio-pci-pm driver first, if it fails, then
bind to vfio-pci driver.

Without this, there are error message about hotplug vfio pci device's
pm_ops.

BUG=None
TEST=Check hotplug vfio pci device's driver in hypervisor

Change-Id: I8330c7859dff2b8b2db1baa67c16181e2de66ae1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3595227
Reviewed-by: Micah Morton <mortonm@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-05 22:35:38 +00:00
Vaibhav Nagarnaik
06c00d580d hypervisor: Trait changes for windows hypervisors support
No functional changes.

Add trait changes to allow upstreaming hypervisor implementations. This
change differentiates between the hypervisor related data structures
from the VM specific actions to take. The format chosen is using a FnMut
that gets passed to hypervisor handler which contains the VM specific
actions.

BUG=b:213150327
TEST=Compiled crosvm.

Change-Id: I05fde5ff3d6b5f42684c7bfe8a135b6805c9dc06
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3606975
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-05-05 22:22:54 +00:00
Vaibhav Nagarnaik
235d76e9d2 tools/clippy: Allow json formatted output
This helps with integration of `tools/clippy` in `rust-analyzer` and
potentially other IDEs which can parse the json output better than the
text output.

TEST=Ran it with `rust-analyzer` in VSCode.

Change-Id: Iceb2748994cbbacf48dc473a9ad06eec567beb0a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630700
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-05 22:22:53 +00:00
Vikram Auradkar
71902a2af5 flatten windows/ directory tree a bit
Moves most of the files out of windows/win into windows/. There are a
few files still in windows/win which will be moved in later cls.

BUG=b:213153157
TEST=presubmit

Change-Id: I1fe1bf0cfdcf6ddfdbe35611c0592bac9cc1e6ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630710
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-05 21:35:50 +00:00
Vikram Auradkar
1018275948 base: Prefer descriptor over raw fd in shm
BUG=b:213153157
TEST=presubmit

Change-Id: I308ca7a554bffa0887705a294e0f53c9d2bd1299
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630705
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-05 21:35:49 +00:00
Vikram Auradkar
eee515bb56 base: windows shm support
BUG=b:213153157
TEST=presubmit

Change-Id: I1a6b17821ff274ac8c0b010c44c3927881975aaa
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3630704
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-05-05 21:35:48 +00:00
Daniel Verkamp
d47ca53c26 third_party/minijail: update to latest
Pull in ff062d54f9a4 ("rust: remove redundant format in unreachable") to
fix warnings in Rust 1.60.

BUG=None
TEST=cargo build # no warnings with Rust 1.60.0

Change-Id: Ib2bf2445bc064fe3f81589e426de104565805bbf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3624801
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-05 21:12:48 +00:00
Daniel Verkamp
b12dcb5405 base: enable WriteZeroes tests on wine
Replace the File::set_len() call with a normal write to set the initial
file size. Wine does not support the SetFileInformationByHandle features
that set_len() needs:

  0009:fixme:file:SetFileInformationByHandle 0000000000000078, 6,
  00000000002ED970, 8

BUG=None
TEST=tools/dev_container tools/run_tests --target=host --arch=win64

Change-Id: Ib63cef7fd909d8f8a2163f6fe8a27ad8a2e27e76
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3626024
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-05 21:12:01 +00:00
Daniel Verkamp
eaac8ba442 base: remove WriteZeroes trait
Only WriteZeroesAt is required now, so remove the unused trait.

BUG=None
TEST=cargo test -p base write_zeroes

Change-Id: I138529c4242d8307fab423fb1f1092b00cb3e950
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3626023
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-05 21:12:00 +00:00
Daniel Verkamp
97c11d70bf disk: qcow: switch to WriteZeroesAt
This removes the last usage of the non-At WriteZeroes trait.

BUG=None
TEST=cargo test -p disk

Change-Id: I54e9990140afdebccfd1b97dd2b6e75b17f3135a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3626022
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-05 21:11:59 +00:00
Daniel Verkamp
404c8261e9 cros_async: ignore punch_hole tests on wine
Wine does not support the FSCTL_SET_ZERO_DATA request:

  fixme:ntdll:server_ioctl_file Unsupported ioctl 980c8 (device=9 access=2
  func=32 method=0)

So ignore the tests that require it when using the mingw toolchain,
which we assume means testing in wine for now.

BUG=None
TEST=tools/dev_container ./tools/run_tests --target=host --arch=win64

Change-Id: I351758fac3b3e1eb44545bb1d2340ddec4461120
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3626021
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Anton Romanov <romanton@google.com>
2022-05-05 21:11:58 +00:00
Dennis Kempin
1f43c67a12 infra: Also support gitlies input to support use as post-submit
BUG=1300370
TEST=./recipes.py test run

Change-Id: I5db70526f728aebd9dd253da0d85056a340c7c22
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3627054
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Yuanjun Huang <yuanjunh@google.com>
2022-05-05 20:18:39 +00:00
Daniel Verkamp
9ab4f29e7a devices: vhost-user: fs: keep executor fd inside jail
A previous commit moved the creation of the executor for the vhost-user
device processes before the minijail jail_and_fork() call, and the file
descriptor of the executor was not marked for preservation when entering
the jail, so running the vhost-user-fs device would result in errors
like this:

  [WARNING:cros_async/src/sys/unix/uring_executor.rs:343] Failed to
  submit NOP for waking up executor: Failed to enter io uring: 9

This is because the io_uring context file descriptor was no longer
valid, so uring system calls would return 9 (EBADF).

Add AsRawDescriptors implementations to UringExecutor and FdExecutor so
we can preserve the fd across the minijail fork.

Other vhost-user devices were not affected because they don't enter a
jail; the fs device requires this so it can do uid/gid remapping.

BUG=b:231396155
TEST=crosvm device fs --socket /tmp/vhost.sock --tag test --shared-dir /

Fixes: d368c1520a ("devices: vhost-user: fs: remove global executor variable")
Change-Id: I38cf02034bbc28de2582e2ea92bdc13b1d6055d2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628292
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Lepton Wu <lepton@chromium.org>
2022-05-05 20:03:03 +00:00
Daniel Verkamp
91c757e648 docs: rewrite PollContext architecture section to WaitContext
Describe the cross-platform abstraction from base rather than the
Linux-specific PollContext/EpollContext.

BUG=None
TEST=read mdbook output

Change-Id: I5733913d389b222fdbdcee39c3554435524c46ad
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3625928
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-05 18:18:40 +00:00
Vikram Auradkar
95707cfa9c io_uring: use WaitContext
BUG=b:213153157
TEST=presubmit

Change-Id: I5875151109f391fbd217269c864abe7d32b7b92e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3626209
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-05 16:59:04 +00:00
Dennis Kempin
d724d41e19 infra: Add CQ status host
This will allow us to view Change Verifier task information
at https://luci-change-verifier.appspot.com/ui/recents/crosvm

BUG=1300370
TEST=lucicfg validate main.star

Change-Id: Ia9db97888a2d18241b56a0efbbebd406ae4980a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628240
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Yuanjun Huang <yuanjunh@google.com>
2022-05-05 00:25:59 +00:00
Dennis Kempin
1b2000227f infra: Add CI and TRY builders to luci configuration
BUG=1300370
TEST=lucicfg validate main.star

Change-Id: I67eca30a694a69875eb585ad155fbf0419fed353
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3626224
Reviewed-by: Yuanjun Huang <yuanjunh@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-04 21:40:49 +00:00
Dennis Kempin
6b2b2184fd infra: Add example verify_cl recipe
The recipe follows luci onboarding instructions to verify configuration.

It currently just checks out the gerrit change provided as input.

BUG=1300370
TEST=Basic test included

Change-Id: I249ce2124f4b161465d7603155cbe25a85d2551a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3626223
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Yuanjun Huang <yuanjunh@google.com>
2022-05-04 21:40:49 +00:00
Andrew Walbran
ecbf9dcfa1 Derive Debug for SharedMemory.
This is useful when adding temporary logs to dump it for debugging.

TEST=tools/dev_container tools/run_tests --target=vm:aarch64

Change-Id: Ia982104943b214b67472f7bdd03c9511191c35cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3627452
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
2022-05-04 18:01:58 +00:00
Andrew Walbran
9ef18e4760 Use ? rather than Result::map.
It's simpler and cleaner.

TEST=tools/dev_container tools/run_tests --target=vm:aarch64

Change-Id: I6289722c2415e5afd51c337a8628ba7f5dcc0702
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3627451
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Auto-Submit: Andrew Walbran <qwandor@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-04 17:01:41 +00:00