Commit graph

3706 commits

Author SHA1 Message Date
Zhao Liu
34d958f581 crosvm: Add MSR handler after setting CPU affinity
For MSR handlers with "from running CPU" configuration, they will open
and store the MSR file descriptior immediately while their creation.

So move their creation after crosvm sets CPU affinity for each vCPU
thread can avoid storing redundant MSR file fds.

BUG=b:225375705
TEST=Set `--userspace-msr=0x1a2,type=r,action=pass,from=cpu0`

Change-Id: Iaa7bf804595ef45eec150e826be87c86ffeeef24
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3641478
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-05-12 04:54:11 +00:00
Xiong Zhang
f6173ca7bb x86_64: Change guest memroy layout from constant to variables
When pcie cfg mmio and pci low mmio address could be specified by user,
guest memory layout will be changed to avoid conflict between guest ram,
and pci mmio below 4G. So this commit changes them from constant to
variables, the default value is prefined constand value, but it could
be changed later.

BUG=b:197877871
TEST=tools/presubmit

Change-Id: I5ad1f9d6a050d83ea16a53b926d1fadfac1ed75d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3305947
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2022-05-12 01:17:36 +00:00
Xiong Zhang
efb69c3c0a x86_64: Move PCIE config mmio into pci low mmio
By default PCIE config mmio is above pci low mmio, and they are adjacent.
When user could specify pcie config mmio address and size, the specified
address range will be highly overlap with pci low mmio or guest memory,
then it will split pci low mmio or guest memory. Finally three memory
regions exist in the below 4G space: guest ram, pci low mmio and
pcie config mmio.

In order to simplify memory space management, this commit move pcie
config mmio into pci low mmio, and pcie config mmio is reserved from
pci low mmio at the beginning. In this way, only guest ram and pci
low mmio exist in below 4G space.

BUG=None
TEST=boot a vm and check memory layout below 4G.

Change-Id: I0b253b7bf7fb0287a27a88b34ee28b0a0bd2d172
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3578016
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-12 01:17:35 +00:00
Xiong Zhang
3be45af929 linux: Reserve direct mmio in mmio allocator
Direct mmio range couldn't be assigned to any device, so this commit
exclude them from mmio allocator before build_vm().

BUG=None
TEST=tools/presubimt and boot manatee

Change-Id: I71414de1d44545e2c490ce75f5ced5545752858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3605163
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-12 01:17:34 +00:00
Xiong Zhang
496bcbe8bf resource: Add reserve_mmio() function
Some mmio should be reserved from mmio allocator such as direct mmio and pcie config mmio,
and the space of mmio allocator is determined by arch and mmio-address-range parameter
which are in different model, it is hard to exclude the reserved mmio at mmio allocator
creation.

So this commit add a reserve_mmio() function, so that different model could call it.
If any part of the reserved mmio has been allocated, it returns Error, the caller
should handler it.

BUG=b:197877871
TEST=tools/presubmit

Change-Id: If64542ee0cef7b8949e4bd01d27f6119aea4eea0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3605162
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-12 01:17:33 +00:00
Junichi Uekawa
350e0520c9 crosvm: Sort struct Config
The order doesn't matter and every time I add something it conflicts.

BUG=None
TEST=build

Change-Id: Iebf3bc2636160e05ad120f5f8d2a16de60e54034
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636539
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-12 00:49:49 +00:00
Vikram Auradkar
151a573acc base: catch-up with downstream windows changes
- Updates changes to named-pipe.
- Adds high resolution timer support.

BUG=b:213153157
TEST=presubmit

Change-Id: I08615d343aaa0f6576f3e8df884310adf3ade087
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3639144
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-12 00:21:59 +00:00
Keiichi Watanabe
2d93d4473c devices: vvu: Make driver exit when a sibling closes connection
When a sibling shuts down, the VVU device process in the guest will exit

BUG=b:216407443
TEST=run vvu on workstation

Change-Id: I0c067b3fbea705dab362f9a3fd05e3770f1dc519
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591104
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
2022-05-11 22:40:49 +00:00
Long Cheng
1d32cd6312 Only ingore first set_config to active config
When a usb device is attached to guest kernel, guest kernel will
Try to set the usb configuration to value returned by
usb_choose_configuration. Unless the device has multiple configurations
and host side set it before attach to guest os, it will be same value
as what host kernel would set it during initialization. This would casue
a device reset and for Android devices in adb mode it will cause a
disconnect and reconnect.

Also we should allow user space trying to reset the device by setting
device configuration to active configuration.

BUG=b:123374026
BUG=b:232272092
TEST=Able to attach Pixel2 and Pixel4 to vm
TEST=Run CTS usb device verifer test on both phones
TEST=adb from crostini to test phones

Change-Id: I0e30aaa1b42a18741a2981e256d2268c1a70c46f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3631026
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Long Cheng <lgcheng@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-11 20:02:03 +00:00
Ryan Neph
4b23ee78bc gfxstream: enable async_fence_cb
Flip the switch for Gfxstream to stop using timer-based fence
polling and start using async fence handling callback.

BUG=b:175527587
BUG=b:192614792
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Change-Id: I5f00f44d29bd584ad554d8892e9f13448c29c712
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628303
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-05-11 19:44:16 +00:00
Ryan Neph
d255742197 gfxstream: add support for per-context fencing
This adds the asynchronous interrupts in crosvm-gpu for gfxstream.
This will allow gfxstream to alternate between the main signalling
method (ASG [1]) and the more traditional interrupts when it
makes sense performance-wise.

gfxstream also requires new write fence callbacks that take into
account the ring_idx and ctx_id where the fence is on.

[1] goto.google.com/address-space-graphics

BUG=b:175527587
BUG=b:192614792
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Change-Id: I52b8eb0e70671e8b43bae6e9e5264268bfb076df
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628301
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
2022-05-11 19:44:15 +00:00
Ryan Neph
d5fa537753 rutabaga_gfx: avoid fence_poll() if all components use async_fence_cb
An optional performance optimization that almost completely avoids the
wakeup cost of timer-based fence polling when all RutabagaComponents use
async_fence_cb. There is still a small overhead from the per-loop
virtio_gpu.needs_fence_poll() tests. This overhead will be removed in
later CLs, when timer-based fencing support is removed.

BUG=b:175527587
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Change-Id: Id9f14bcbdaa4dcdc42b24be12d85cad2ea0efed5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628300
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-11 19:44:15 +00:00
Ryan Neph
e246fff20c rutabaga_gfx: support fence handling via async callback
Adds another method for fencing where a rutabaga component may provide
an asynchronous callback for fence completion. When this method is
enabled, fences no longer need to be polled on the main thread.

When async_fence_cb is enabled, optional polling still occurs for
Rutabaga Components that still rely on it for other purposes (e.g.
virglrenderer for GL query checking).

Both the old and new methods of fence handling are supported with this
CL; e.g. timer-based polling and async callback, but timer-based polling
is the only one active. Follow-up CL(s) will switch to using the async
callback for each RutabagaComponent. Support for the old timer-based
polling will be removed after the async callback method stabilizes in
production.

Also, use a BTreeMap rather a HashMap since we only expect a dozen or so
entries at most. In such cases, a BTreeMap is faster.

* v1 (lfrb@collabora.com): remove all polling + add async_cb
* v2 (ryanneph@google.com): re-introduce optional polling to fix
  virglrenderer that relies on it for GL query checking.
* v3 (ryanneph@google.com): replace timer-based polling with
  eventfd-based poll() signaling for components that want to use it.
* v4 (ryanneph@google.com): add async fence handling beside timer-based
  polling to support both for a short time.

This is a pseudo-reland of commit
a999284da2, but modifications have been
made to support both fencing methods simultaneously.

BUG=b:175527587
TEST=cargo build --features=virgl_renderer,virgl_renderer_next,gfxstream
TEST=Run glxgears and vkcube in a crosvm guest VM with virglrenderer

Change-Id: I28f754aeef01972a01dab7990267415814a36c77
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628299
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-11 19:44:13 +00:00
Daniel Verkamp
b5f8224312 base: windows: use sync::Mutex to avoid unwrap()
Switch the uses of std::sync::Mutex to our custom sync::Mutex, which
panics internally if lock() fails. This helps to reduce the instances of
unwrap(), making it easier to review and understand the code.

BUG=b:213153157
TEST=tools/dev_container tools/run_tests --target=host --arch=win64

Change-Id: I99bfc85967152f50045e64293104de788a5d3829
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3633108
Reviewed-by: Vikram Auradkar <auradkar@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-11 17:56:27 +00:00
Vikram Auradkar
8212e88f83 base: add generate_uuid function
This function will be used by crash reporter to associate a unique id
to a session.

BUG=b:213153157
TEST=presubmit

Change-Id: I5f17e023f8895a75062d80773d1aac6315ce4dcf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3639685
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-11 15:43:25 +00:00
Li-Yu Yu
18f0830489 README: Update link to contributor guide
https://crrev.com/c/3557813 moved
/doc/book/src/contributing.md to /doc/book/scr/contributing/index.md

The link needs to be updated as well.

BUG=b:227345067
TEST=curl -I https://google.github.io/crosvm/contributing/
     shows HTTP/2 200

Change-Id: I6f659fde2d03da573f63cc656d95d24a253138b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3640903
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
Commit-Queue: Chih-Yang Hsia <paulhsia@chromium.org>
2022-05-11 13:21:04 +00:00
Zyta Szpak
467430613a virtio: video: Increase command queue size
The queue size defines the number of available descriptors, that can be
used for exchanging messages between guest and hypervisor. Each
virtio-video command uses at least 1 descriptor (eg. CMD_QUEUE uses 2).
The amount of descriptors in use depends on the number of sessions and
buffers in input and output video queue.
In the worst case scenario the peak number can reach over 672 for 8
simultaneous streams, with 26 + 16 buffers each just for CMD_QUEUE
commands alone.

If the entire queue is overfilled with CMD_QUEUE for OUTPUT queue only,
the driver has no free descriptors for INPUT queue buffers. This leads
to encoder/decoder starvation, hence no OUTPUT buffer can be produced
and no CMD_QUEUE will finish, which leads to dead locking the device.

This patch increases the queue size with consideration of above details
with some headroom to avoid driver's deadlock.

BUG=b:204055006
TEST=App from https://github.com/chromeos/video-decode-encode-demo.git
with 8 simultaneous stream runs without blocking the device.

Change-Id: If51e340dd501b5b261518fba23fc541e3b55af8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3606869
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Reviewed-by: Emilie Roberts <hadrosaur@google.com>
Reviewed-by: Chih-Yu Huang <akahuang@chromium.org>
Commit-Queue: Marcin Wojtas <mwojtas@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-11 08:05:32 +00:00
Anton Romanov
a4cb63d7ce crosvm: add example rust baremetal app that can be booted with crosvm
BUG=none
TEST=`cargo run`

Change-Id: I97eb56eec0d08c67e62755ef21b5ac0cd3e9a461
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3638965
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-10 23:36:47 +00:00
Vikram Auradkar
878a53ea57 base: remove wildcard exports
Also exports few more windows symbols.

The current exports are not well grouped/organized yet. We will get to
that in another patch.

BUG=b:213153157
TEST=presubmit

Change-Id: I902ec0f9f572ac7889bd7703365dad472fc8d930
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636274
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-05-10 21:04:22 +00:00
Daniel Verkamp
5297fadcc9 devices: virtio: clean up unsupported flags
Several devices were accepting virtio ring flags that they don't
actually support; remove these, as well as the common base_features
flags that are provided by the generic virtio device infrastructure.

The features removed from device implementations are:
- VIRTIO_F_VERSION_1: set by base_features()
- VIRTIO_RING_F_EVENT_IDX: set by base_features()
- VIRTIO_RING_F_INDIRECT_DESC: unsupported
- VIRTIO_F_NOTIFY_ON_EMPTY: unsupported
- VHOST_F_LOG_ALL: unsupported
- VIRTIO_F_ANY_LAYOUT: unsupported; transitional devices only

BUG=None
TEST=tools/presubmit --all

Change-Id: I9619d9bb784cb47ec85ffa4e25b7a743284d6da6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582525
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-05-10 21:00:11 +00:00
Daniel Verkamp
3b98d5476a devices: virtio: mask bits in driver ready check
Previously, the check would only accept exactly the combination of bits
we specify in ready_bits due to the == comparison; the second check for
the failed bit would never be reached. Instead, mask off only the bits
we are interested in checking before comparing them.

BUG=None
TEST=tools/presubmit --all

Change-Id: Ib6cccdb249adeb267282ec0e5b51c0ac6b572490
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582524
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-10 21:00:09 +00:00
Daniel Verkamp
78c474d423 virtio: create a DeviceType wrapper enum
This makes the VirtioDevice::device_type() function return type more
descriptive, and it lets us implement fmt::Display for the type instead
of a custom type_to_str() function.

BUG=None
TEST=tools/presubmit --all

Change-Id: Icfc2be37cf31ecab5e73f4b29c2eaaaa417317ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3582523
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-05-10 21:00:07 +00:00
Vaibhav Nagarnaik
b929c1e2be kvm: Fix assert check
For handling HYPERV hypercalls, the exit reason needs to be checked
against KVM_EXIT_HYPERV.

TEST=Compiled.

Change-Id: Ib11d558e25e2c5fd037e1bc6ca88a454e957a1c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3639149
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vaibhav Nagarnaik <vnagarnaik@google.com>
2022-05-10 20:45:34 +00:00
Tinghao Zhang
7f1b94e96a devices: pci: use msi for pcie bridge
This patch split msi emulation from vfio-pci to a seperate file
msi.rs and make it usable for other devices. And we make pcie
bridge use msi instead of msi-x. The reason to use msi is that
msi-x would need extra mmio bar allocation, which does not work
when bridge is hotplugged into the system.

BUG=None
TEST=check msi functionality in both pcie root port and vfio device

Change-Id: Id262e4635d074c2a952807a625c8a0bf0afbf86a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3591961
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Xiong Y Zhang <xiong.y.zhang@intel.corp-partner.google.com>
2022-05-10 20:02:51 +00:00
Michael Hoyle
4c2017c757 metrics: Add metrics crate.
This crate is effectively a collection of stubs in this repo,
but will allow a downstream repo to implement those stubs.

BUG=b:213152497
FIXED=b:213152497
TEST=build + kokoro

Change-Id: I3c544644ec3d7917f9ebb2e8621042c35b556db8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3622799
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-10 03:52:13 +00:00
mikehoyle
b10fa49a6f base: Add CloseNotifier support to Linux
This is necessary for its cross-platform usage in metrics.

BUG=b:213152497
TEST=build

Change-Id: I6618777679349d1f6298f79e1f93fe4e9a3ecf7a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3622798
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Michael Hoyle <mikehoyle@google.com>
2022-05-10 03:52:11 +00:00
Zhao Liu
e2f8fb4fcb x86_64: Add description of intel ITMT option
ITMT option allows VM to enable ITMT scheduling, but it doesn't ensure
the success of ITMT scheduling in VM.

Whether ITMT enabling can succeed depends on HWP and ACPI CPPC support
on hardware.

This option exposes related HWP and CPPC information to VM and the
intel_pstate driver of VM will decide wheter to enable ITMT scheduling
or not.

BUG=b:225375705
TEST=Set `--itmt` and check /proc/sys/kernel/sched_itmt_enabled

Change-Id: I5d12cf3fb1a30b040945e8d1db68063e810217b9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636808
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
2022-05-10 03:13:53 +00:00
Zhao Liu
b48571dee5 x86_64: Deprecate old userspace-msr cmd format
The old format is like:
--userspace-msr=0x10,action=r0

Now this format can be deprecated. Please use the new format like:
--userspace-msr=0x10,type=r,action=pass,from=cpu0

Also ask the MSR to be handled in crosvm must be unique in order to know
which MSRs have been handled in more complex scenarios.

BUG=b:225375705
TEST=Set `--userspace-msr=0x1a2,type=r,action=pass,from=cpu0`

Change-Id: I3c31affb738c558aaf4da5cea8d17b74428708a1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3610843
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-10 03:13:52 +00:00
Zhao Liu
ad545d042d x86_64: Support intel ITMT scheduling in Guest
Now expose running pythcial CPU's max frequency to vCPU to allow intel_
pstate driver to set different CPU priority for task rebalance.

With different CPU priority, ITMT scheduling can really work in Guest.

And remove HWP and ITMT CPUID support from host-cpu-topology.

BUG=b:225375705
TEST=Set `--itmt` and check /proc/sys/kernel/sched_itmt_enabled

Change-Id: I4aa712929fe23b760d8692fed1a55992d1868fc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3610842
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-10 03:13:50 +00:00
Vikram Auradkar
209c8e774d base: add few more windows specific Event functions
BUG=b:213153157
TEST=presubmit

Change-Id: Ie0fa96e4b84199323bd03000f9be25cf6c3b7723
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636273
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-10 02:19:24 +00:00
Kameron Lutes
299c1121c3 crosvm_control: Add make_rt API
Adds a make_rt API to the crosvm_control library.

BUG=b:188858559
TEST=cq

Change-Id: I3affcd6cb003a17f125b45e78906fabe1e371c43
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3635255
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Kameron Lutes <kalutes@chromium.org>
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
2022-05-10 01:29:17 +00:00
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