Commit graph

3335 commits

Author SHA1 Message Date
Dennis Kempin
cbe2e12759 Kokoro: Use unique identifiers for gerrit API
Change-Ids can refer to multiple CLs when they are cherry-picked.
Use the 'id' field instead wich contains repo and branch info and
is unique across gerrit.

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

Change-Id: I7074e310ec7f795527610010c849acceaeb0eb06
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3556231
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-03-28 19:25:44 +00:00
Zhao Liu
6c3eadd1bf x86: Fix HT flag is incorrectly masked for no_smt
This is the revert of 77aa069b67.

At present, when set no_smt, if there are more than 1 logical processor
in a package for Guest, the HTT is set as 0 in CPUID. This does not
comply with the intel SDM specification.

From SDM, HTT indicates:
A value of 0 for HTT indicates there is only a single logical processor
in the package and software should assume only a single APIC ID is
reserved.

In fact, Intel has 2 differnet muti-threading capabilities:
Hyper-Threading Technology and Multi-Core Technology. But with
definition of lastest SDM, HTT flag in CPUID is not equivalent to
Hyper-Threading Technology.

no_smt means disable Hyper-Threading Technology feature so that each
core has 1 logical processor. But with Multi-Core Technology, there
still can be more than 1 logical processors in a package. In this case,
the HTT flag should be set as 1.

BUG=chromium:1304418
TEST=cargo build
TEST=set no_smt and check if there's HT flag in /proc/cpuinfo

Change-Id: Id53320407e247ba61a1ad7cedea8301e1c3469fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3545896
Reviewed-by: Vineeth Pillai <vineethrp@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-25 20:13:25 +00:00
David Stevens
afa8cccbf6 x86_64: acpi: create goldfish battery earlier
Create the goldfish batter device before ACPIPMResource. This order is
necessary because ACPIPMResource creates a thread, which causes forking
the sandboxed device process to fail.

BUG=none
TEST=boot ARCVM

Change-Id: Iedc84c408eb0e124912dfa411d19b773c1ccc860
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3552477
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-25 17:45:08 +00:00
Haiwei Li
e4a9e82670 devices: virtio: iommu: narrow the pci range of viot
Now we can use option `--pcie-root-port` to create a virtual pcie root
port with some attributes same as host. So a vfio device may be
connected to it statically.

And only hot-pluggable devices and vfio devices with option
`iommu=viommu` are needed to be attached to virtio-iommu. So we just
append the sub pci range of a leaf node root port to viot.

BUG=b:185084350
TEST=Boot a guest with option '--virtio-iommu' and '--pcie-root-port',
check the PCI range node in guest viot.

Change-Id: Iff59b5210fb85511370ede19bf1ca2095b4d603b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3541469
Reviewed-by: David Stevens <stevensd@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-03-25 02:44:05 +00:00
David Stevens
a7a04e6095 ci/kokoro: improve error checking
Check whether or not the rebase succeeds and fix a check that the script
is being run by kokoro.

BUG=None
TEST=tools/presubmit

Change-Id: I59ae6604c3535238f40a7df20c43b9db9e357fe3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3546578
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-03-25 00:33:06 +00:00
Vikram Auradkar
3a29174a7b Upstream windows serial device
Bug: b:213149155
Test: cargo test and presubmit
Upstream-Crate: devices
Change-Id: I1420fee814271dae9502878963872449dae8218e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3527444
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-24 23:45:10 +00:00
Xiong Zhang
626f014a48 crosvm: Add host hp gpe paratemer for pcie root port
For vitual pcie root port which link to host pcie root port need to
know host hotplug GPE number, so that acpi modal could notify pcie
root port that hw hotplug event happens, virtual pcie root port
could use this notification to do power managerment and inject
virtual pcie hotplug event into CrOS.

BUG=b:185084350
TEST=pass --pcie-root-port sysfs_path,hp_gpe=NUN into crosvm,
then verify TBT pcie in CrOS

Change-Id: Id4bb71f18a9715f2cb84205f5139b9ed1475452c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539567
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-24 23:41:06 +00:00
Xiong Zhang
1b6e011dab ACPI: Add register gpe notify event interface
Device want to get notification when a specific gpe happens, this commit
add register_gpe_notify_dev(gpe_num, dev) interface into PmResource trait,
so that others could register (gpe_num, dev) into acpi, then they
could get notification at specific gpe trigger.

BUG=b:185084350
TEST=Verify TBT pcie hotplug function in ManaTEE, virtual pcie root port
must get gpe notification during this process

Change-Id: I56eb90361a6b96be364d35c4b6a5ec598a50757e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539566
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-24 23:41:05 +00:00
Junichi Uekawa
c26cf3d62c crosvm: Reflect KVM_EXIT_HYPERV return value.
to_ne_bytes creates a copy and copy_from_slice wasn't updating the
actual field.

BUG=None
TEST=try

Change-Id: Ifab4fc98e5b0f6a74edf5436a7b557f4afd44788
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539330
Auto-Submit: Junichi Uekawa <uekawa@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-24 18:32:27 +00:00
David Stevens
6ae817ed7a Add release-test profile
Add a release-test profile that is the release profile with
panic=unwind. This profile is needed because crosvm has a cdylib
dependency (crosvm_plugin). If we try to run cargo test with
panic=abort, cargo builds a second version of the cdylib artifact
without panic=abort. However, cargo doesn't actually support duplicate
artifacts [1]. This can lead to flaky build failures if cargo ends up
trying to build both artifacts at the same time.

[1] https://github.com/rust-lang/cargo/issues/6313

BUG=None
TEST=CQ

Change-Id: Ie5881878efdee654e9a665fa58d21aa2280a1876
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3545739
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-24 17:44:39 +00:00
Victor Ding
3f7495983a vfio: Support user-set address for VFIO PCI devices
Currently, VfioPciDevice always use the same BDF as the device's BDF in
the host OS. However, in certain applications (e.g. Borealis), it is
desired to map the device to a different BDF.
This patch introduces a new parameter to `vfio` so that user could set
the device's BDF to a desired address.

BUG=b:208545409
TEST=Boot Borealis with `--vfio=/path/to/dGPU,guest-address=00:11.0` and
     confirmed that the dGPU is at 00:11.0 in the guest OS.

Change-Id: I7ee9e9a7f74e3541e74f89d452f9aad45302eeb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3535461
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Victor Ding <victording@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Victor Ding <victording@chromium.org>
2022-03-24 07:24:53 +00:00
Keiichi Watanabe
52a0f3b1e8 devices: vhost-user: Add a test case for ClientExit
The vhost-user VMM process is supposed to stop before the device
process, and the device process is supposed to get
`vmm_vhost::Error::ClientExit` when the VMM stops. Add the check in the
existing unit test.

BUG=b:219674197
BUG=b:220639724
TEST=cargo test in /devices/

Change-Id: I1768b9b43855e3b80f1e6e175877317338309e8a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3543005
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
2022-03-24 05:09:02 +00:00
David Stevens
6cda440730 vfio_pci: improve mmaped mmio bar tracking
Add dedicated tracking for mmio bar mmaps. This allows us to remove the
special case handing that ignores writes of 0 and 0xffffffff to the bar
configuration registers. That handling was actually broken because it
used || instead of &&, which resulted in bars being redundantly
remapped.

BUG=none
TEST=Add logs to set_user_memory_region, boot manatee, and check that
the same regions are mapped.

Change-Id: Ic9905330874a4c05f79dbdaee3b40b4d21a488ff
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3535468
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-03-24 01:47:51 +00:00
Alexandre Courbot
2c29fa8a0f devices: block: parse options using serde_keyvalue crate
Use our new serde_keyvalue crate to annotate the DiskOption structure
and allow us to deserialize it from a key-values string. Add tests to
help ensure parsing won't break in the future.

The existing `root`, `rwroot`, `disk` and `rwdisk` arguments can be
parsed in a compatible manner. In the future it would probably make
sense to merge them all into a single `disk` option since all variants
can now be specified as key-values.

BUG=b:218223240
TEST=crosvm run ... --rwroot /path/to/disk.raw
TEST=cargo test -p devices virtio::block::block::tests::params_from_key_values

Change-Id: I2c8b853b9817aefce0c5f0f5c4d5a1da1f9a45d9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3473708
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-24 01:33:23 +00:00
Alexandre Courbot
da20cf1d78 devices: serial: parse options using serde_keyvalue crate
Use our new serde_keyvalue crate to annotate the SerialParameters
structure and allow us to create it from a key-values string. Add tests
to help ensure parsing doesn't break in the future.

The existing arguments can be parsed identically by this new code, so
replace the old serial options.

BUG=b:218223240
TEST=cargo test -p devices serial_device::tests::params_from_key_values
TEST=cargo test parse_serial

Change-Id: I4898a45399b69b87a44f80d3a214daf081b06173
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439670
Reviewed-by: Anton Romanov <romanton@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-24 01:33:22 +00:00
Alexandre Courbot
aa043e8c00 add serde_keyvalue crate
Add a crate for deserializing command-line options given as key-values.

This crate leverages serde to deserialize key-value argument strings (a
commonly used pattern in crosvm) into configuration structures. This
will allow us to remove a big part of the manual parsing currently done
in `main.rs`, will provide consistent arguments to the `crosvm run` and
`crosvm device` commands, and results in more precise error reporting.

The use of serde will also allow us to similarly deserialize
configuration structures from configuration files with very little extra
code involved.

As explained in the crate's documentation, its main entry point is a
`from_key_values` function that allows a build a struct implementing
serde's `Deserialize` trait from a key/values string.

In order to integrate transparently with `argh`, there is also a
`FromKeyValue` derive macro that automatically implements `FromArgValue`
for structs deriving from it.

BUG=b:218223240
BUG=b:217480043
TEST=cargo build
TEST=cargo test -p serde_keyvalue

Change-Id: Id6316e40150d5f08a05e6f04e39ecbc73d72dfa0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3439669
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-24 01:33:21 +00:00
Keiichi Watanabe
2558b26297 vmm_vhost: Allow vmm to turn down before device
This is follow-up of CL:3468235.
For vhost-user, a device (i.e. slave) works like a server while a
vmm (i.e., master) does like a client. So the devices should allow the
vmm to close the connection. An error handling code added by CL:3468235
was opposite. It should have been added to `slave_req_handler.rs`
instead of `master_req_handler.rs`.

BUG=b:219674197
BUG=b:220639724
TEST=run tast.vm.Audio*.vhost_user_cras and tast.vm.VhostUserNet

Change-Id: Ie661c02bed8287d9d770c6c6c0c658ef6681db10
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3533239
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-03-23 23:23:39 +00:00
Daniel Verkamp
e89629770f devices: virtio: vvu: allow non-zero guest mem descriptor offset
Fill the fd offset into the VmMemoryRequest::RegisterMemory source field
now that it is supported.

BUG=b:194136484
TEST=tools/presubmit

Change-Id: I9f8ae069d73cf0974bb739a768b731d6b0c289ca
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3508321
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-23 22:41:24 +00:00
Daniel Verkamp
6ba4551b43 devices: vfio: remove unnecessary MemSlot casts
The values that were cast in these expressions were already MemSlot, so
there is no need to cast back and forth between MemSlot and u32.

BUG=None
TEST=tools/presubmit

Change-Id: I8a215bc50d10a93b21f6d2fe7e4ed7267242a50b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3508320
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-23 22:41:23 +00:00
Daniel Verkamp
4440db2370 vm_control: refactor VmMemoryRequest
Many of the subtypes of VmMemoryRequest share similar or exactly
identical code, but it is difficult to tell how they differ and what
each variant does. Reorganize the various memory registration requests
into a single RegisterMemory variant with orthogonal source and
destination structures to unify the shared functionality into a single
implementation.

BUG=None
TEST=tools/presubmit
TEST=Boot Crostini on trogdor
TEST=Boot Crostini on hatch

Change-Id: I059ce40b90812067e5ec882320ea7c8b6a3cc0fd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3470539
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-23 22:41:22 +00:00
Vikram Auradkar
4023f0602a move add_bind_mount
add_bind_mount is a unix specific function that uses only public
fields of SerialParameters. So moved the function closer to call site.

Bug: b:213149155
Test: cargo test and presubmit
Upstream-Crate: devices

Change-Id: I05232c10ddc474421b6dba4ff34ecec9965c3913
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3543886
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-03-23 22:06:09 +00:00
Keiichi Watanabe
15b4769df5 devices: vvu: Add uuid argument for vvu-proxy
Add optional `uuid` argument to `--vvu-proxy` so a user can specify a
UUID that will be stored in virtio_vhost_user_config space so that the
guest can read the value by reading /sys/devices/pci*/*/resources.
We can use this value to allow the guest to know the socket path that
the VVU proxy device uses.

BUG=b:215472603
TEST=pcimem /sys/device/pci.../resource0 0x2008 b*16,
     where 0x2008 == (DEVICE_CONFIG_BAR_OFFSET + offset in vvu config)

Change-Id: I99f1d988cb793b44682ddf927837139dabd42cf8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3516669
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-03-23 08:11:12 +00:00
Alexandre Courbot
04b9ce6d8a gpu: display detailed resource bridge errors
Unfold the anyhow errors returned so we can identify their source
precisely.

BUG=None
TEST=cargo build

Change-Id: I5bdfcc893b7ca98d83561cac820bcee443013547
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3543011
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-23 08:08:49 +00:00
Alexandre Courbot
3e28ed0f5f mdbook: add instructions for enabling and running Wayland
It is now relatively easy to build and run sommelier against a regular
Linux guest, and doing so enables the powerful feature of being able to
show guest Wayland clients on a compositor running on the host. Document
the process for those interested in doing it.

BUG=None
TEST=mdbook serve
TEST=./tools/fmt --check

Change-Id: I45b99243481ee66c1e88e597669a219a4e5b9376
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3531694
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-23 04:00:26 +00:00
Alexandre Courbot
eea1729c39 rutabaga_gfx: do not support GLX if x feature is not enabled
At the moment compiling with the "virgl_renderer" feature enabled but
"x" disabled results in a link error because the virgl_renderer enables
all its platforms without checking. Fix this by enabling the glx
platform only if the x feature has also been enabled.

BUG=b:226033718
TEST=`cargo build --features "virgl_renderer"` passes.
TEST=`cargo build --features "virgl_renderer,x"` passes and enables GLX
in virgl_renderer.

Change-Id: I85041fc2a3db7e49415add69389bee3160ba4a5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539327
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-23 02:12:23 +00:00
Xiong Zhang
cdffe497e1 pcie: Use physical hotplug GPE as virutal hotplug event
This commit uses physical pcie hotplug GPE as virtual hotplug event
trigger point.

When virtual pcie root port gets such physical GPE notification, it
will prepare hotplug and inject PME to wakeup virtual pcie root port,
once virtual pcie root port is waken up, it will let host pcie root
port to rescan and probe the added new pcie device, finally request
crosvm to add the new pcie device into CrOS.

BUG=b:185084350
TEST=Verify TBT pcie hotplug function in ManaTEE

Change-Id: I5d02582d0eb9bcfd9d8998065ccc758c91169f81
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3520985
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-23 00:48:39 +00:00
Xiong Zhang
5631839e90 pcie: Implement added GpeNotify() trait
When specific GPE event happens, some devices want to get notification.
For example, virtual pcie root port wants to get notification when
acpi hotplug GPE occurs. So virtual pcie root port implements this trait.

When virtual pcie root port gets this hotplug GPE notification, it will
inject a PME into CrOS, CrOS PME handler will wakeup virtual pcie root
port and TBT DMA engine, and forbit them to enter into suspend again
during hotplug process.

Once hotplug process is finished, virtual pcie root port and TBT DMA
engine could be allowed to suspend again.

BUG=b:185084350
TEST=Verify TBT pcie hotplug function in ManaTEE

Change-Id: I6c984e4f81713ad34383f1fb4ea2a5776ac2fccf
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539565
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-23 00:48:38 +00:00
Alexandre Courbot
b0d2e4da00 rutabaga_gfx: make build fail if default component is not enabled
Rutabaga's components are all included in the component type enum, even
those that are not enabled at compile-time. This causes a problem with
crosvm, which selects the virgl renderer as its default component even
if the corresponding cargo feature is not enabled. In such a case we
would get a cryptic panic.

Prevent this from happening by checking at build time that we are not
using a disabled component and return a detailed error if that's the
case.

BUG=b:223485028
TEST=Check that message appears with gpu device is run with the
`virglrenderer` backend but the `virgl_renderer` cargo feature is not
set.

Change-Id: Ib1bea10af82f4230350d19d534023e2b5814489d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3512393
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-23 00:10:46 +00:00
Anton Romanov
3333441b8e crosvm: Fix few warnings
BUG=None
TEST=cq

Change-Id: Ie7c13f5256fd91bc65582cb189878542e811633d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3543647
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-03-22 23:35:26 +00:00
Dennis Kempin
9fbf4987f0 Refactoring: Move win_(sys_)util
This executes the script in https://crrev.com/c/3537257

BUG=b:223206469
TEST=presubmit

Change-Id: I51176d02081a7130270cf1b2ebe7c58ef9056db3
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3537258
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-22 22:23:41 +00:00
Dennis Kempin
1e80b0d6a3 Refactoring Script: Move win_(sys_)util
This script moves win_util from crosvm/common/ to crosvm/
and win_sys_util into base::windows.

The CL makes some prerequisite code changes needed to enable
building of tests after the script is applied.

BUG=b:223206469
TEST=presubmit

Change-Id: I5c1952596d3161730be3f42ce5d6cb554ab66b4a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3537257
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-22 22:23:41 +00:00
Daniel Verkamp
445fd4d3f8 vmm_vhost: use base::Event in place of EventFd
Use the cross-platform base::Event type to replace the Linux-specific
base::EventFd.

BUG=b:221882601
BUG=b:219522861
TEST=tools/presubmit

Change-Id: I0503c130306b508af9dd5044653408bd316c7ef1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3533618
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-22 20:25:00 +00:00
Noah Gold
c286772db8 base: upstream Tube cross platform support.
Upstreams support for Tubes on Windows, splitting Tube into platform
specific files. This contains several critical enhancements:

* POSIX Tubes support multi producer multi consumer configurations, but
  Windows has remained strictly SPSC for each direction. Windows cannot
  support MPMC, and that configuration is not really something we want
  either. To address that, this CL introduces directional Tubes. A
  SendTube is clonable, and a RecvTube is not, which gives us MPSC.

* This CL also fixes multiple interface conflicts that have developed
  between Linux & Windows:
    + send wasn't async on the Linux AsyncTube.
    + send data wasn't passed as owned on the Linux AsyncTube.
    + Adds the 'static constraint for AsyncTube::send on POSIX. This is an
      requirement on Windows.
    + Event::read_timeout doesn't need to take &mut self, and it wasn't
      downstream. This CL switches to &self.

* Adds the missing notifier.rs file in base.

Note that this CL does not attempt to remove balloon's usage of
Tube::try_clone. That's a somewhat involved issue that should be tackled in
its own CL.

Test: tested downstream on Windows & Linux bots, upstream on Linux bots.

Bug: b:221484449

Change-Id: I288dbc1d1e42f8ce08258cdaaf85100ca93721ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3536897
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Noah Gold <nkgold@google.com>
2022-03-22 19:00:54 +00:00
David Stevens
8e0d4a99bf sys_util: re-export scoped_path
crrev.com/c/3523746 removed scoped_path from sys_util's public API.
Although nothing in crosvm uses scoped_path, it is used by cronista and
sirenia.

BUG=None
TEST=cargo build -p sirenia

Change-Id: Ia78363355049f5a4c03491f78ef169ebfecec164
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539331
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-03-22 09:30:44 +00:00
Alexandre Courbot
104b471578 devices: gpu: fallback to 2d rendering if virgl is not enabled
The virgl renderer was unconditionally selected as the default backend
for crosvm, even if the "virgl_renderer" feature is not enabled. This
forces the user to explicitly specify the 2d backend with the --gpu
option, which can be confusing for new users.

Simplify things a bit by using the 2D renderer as default if the
"virgl_renderer" feature is not enabled - that way the GPU can be used
without having to specify a backend explicitly.

BUG=b:213532598
TEST=successfully run crosvm without the "virgl_renderer" feature and
without specifying the "backend" GPU option.

Change-Id: Ib36b7d92cef62d9dd91b0a41051362d1c57e0536
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3528233
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-22 06:07:38 +00:00
Dmitry Torokhov
0550775207 devices: acpi: ensure that both direct GPE and host SCI are supplied
Rearrange the code to make sure that if direct GPE feature is used then
it is enforced that both host SCI events and GPE list are supplied when
instantiating ACPIPMResource.

BUG=None
TEST=./tools/presubmit

Change-Id: Ib44e217b09344b1c6bed091312eb196863ca2fee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3537264
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-03-22 00:50:58 +00:00
Dmitry Torokhov
bc09a2d8aa devices: acpi: use slice instead of vectors to pass around direct GPEs
We make a copy of the data when creating instance of ACPIPMResource, so
let's use slice to pass the data around.

BUG=None
TEST=./tools/presubmit

Change-Id: Idf9627c4ef6aee86fa9de4d1c24ec45aa684432e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3537263
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dmitry Torokhov <dtor@chromium.org>
2022-03-21 23:53:34 +00:00
Daniel Verkamp
baa34b5be5 Revert "x86_64: remove special-case mappings for direct"
This reverts commit 052f7df430.

Reason for revert: breaks tast.health.DiagnosticsRun.cpu_cache on volteer-manatee

Original change's description:
> x86_64: remove special-case mappings for direct
>
> Now that we can handle file-backed mappings that overlap with guest
> memory, we can remove the workarounds for coreboot regions when
> compiling with --features=direct.
>
> BUG=b:188011323
> TEST=cargo test -p x86_64 --features=direct
> TEST=Boot volteer-manatee and brya-manatee
>
> Change-Id: I9ac2a25e1896c5ec61bd302882d4c99d8b36b0dd
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3498210
> Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
> Tested-by: kokoro <noreply+kokoro@google.com>
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>

BUG=b:188011323
TEST=tast run health.DiagnosticsRun.cpu_cache

Change-Id: I313620d99726ed185ba2ec04df4413e43a612670
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3537260
Reviewed-by: Anton Romanov <romanton@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-03-21 23:26:44 +00:00
Dennis Kempin
b65b67d1d9 Refactoring: Copy sys_util(_core) into base
This applies the script from: https://crrev.com/c/3536890

BUG=b:22320646
TEST=presubmit

Change-Id: Iec8e24c43e5ae190aeabf1174300a6be86018170
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3536891
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-03-21 19:52:56 +00:00
Dennis Kempin
4fa9b5147c Refactoring script: Copy sys_util(_core) to base
This will allow us to merge sys_util and win_sys_util.
The original source locations will remain until they
are moved into the ChromeOS source base.

See go/future-of-sys-util for details

BUG=b:22320646
TEST=run it

Change-Id: Ie1adcadba9d35f18cc7472dc78f05262114a726f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3536890
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-21 19:52:56 +00:00
Dennis Kempin
4d53d5683d Refactoring: Make io_uring use base instead of sys_util
sys_util will go away in the crosvm world, but base exports
the same symboles.

BUG=b:22320646
TEST=presubmit

Change-Id: Ibacba5821f7e9b734e58b21ffa376ee23db36d59
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3534503
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-21 19:52:56 +00:00
Dennis Kempin
0928f91f98 Refactoring: Copy common/io_uring to io_uring
This applies the script from https://crrev.com/c/3534501

BUG=b:22320646
TEST=presubmit

Change-Id: Ib0c5bdb55df2098930fb1c65e9bd59288c44f357
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3534502
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-03-21 19:52:56 +00:00
Dennis Kempin
00cbeb7d4c Refactoring script: Copy common/io_uring to io_uring
The crate is only used by cros_async, which has already been
copied to crosvm.
The old source location will eventually move to ChromeOS.

See go/future-of-sys-util for details

BUG=b:22320646
TEST=presubmit

Change-Id: Icf3522497cb4e8c04a4687403466b781f0d7a9ee
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3534501
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
2022-03-21 19:52:56 +00:00
Dennis Kempin
4193d87a97 cros_async: Depend on base, not sys_util
base was previously providing some async types which now would
cause a circular dependency. Those have been moved into cros_async.

BUG=b:22320646
TEST=presubmit

Change-Id: I1f526ccfc5882f3a64404f714b13ac92ebfddcd6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3533614
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-21 19:52:56 +00:00
Dennis Kempin
55c6a3b5cd Refactoring: Move common/cros_async to cros_async
This runs the script added in https://crrev.com/c/3533607

BUG=b:22320646
TEST=presubmit

Change-Id: I2e7efdb35508d45281f046e64c24aa43e27f2000
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3533608
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-21 19:52:56 +00:00
Dennis Kempin
dca90f49bd Refactoring script: Copy common/cros_async to cros_async
The copy is going to be used by crosvm going forward, while the
old version will eventually be moved to ChromeOS.

See go/future-of-sys-util for details

BUG=b:22320646
TEST=presubmit

Change-Id: Ic3216855fc244e366423160464dc722a04dfc56d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3533607
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-03-21 19:52:56 +00:00
Grzegorz Jaszczyk
9317c41ed7 acpi: improve check against acpi_mc_group id and improve error msgs
Make sure that the group id received from get_acpi_event_group is not 0
before proceeding it further. At the occasion improve some error
messages.

As per review comments:
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3407321/27
that I didn't make before it was merged.

BUG=None
TEST=Build and boot volteer-manatee

Change-Id: I41a77fc3de10b13905f3f94277d2284acf29e67f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539980
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Grzegorz Jaszczyk <jaszczyk@google.com>
2022-03-21 18:53:39 +00:00
Grzegorz Jaszczyk
2fc3036ba8 acpi: extend acpi event listener about power button events
Upon receiving acpi event related to ACPI button notification emulate
PM/PWRBTN_STS and trigger SCI.

BUG=None
TEST=After enabling CONFIG_ACPI_BUTTON on hypervisor kernel, check if
power button events are propagated to the guest by reading
/sys/firmware/acpi/interrupts/ff_pwr_btn counter.

Change-Id: Ie52c58d0934fb6657940bdca35dfbc68a8f4f42c
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3521728
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-03-21 09:16:44 +00:00
Dmytro Maluka
ab50403924 acpi: event listener: ignore events for direct GPEs
Ignore ACPI netlink events for GPEs which are configured as direct
GPEs. Such GPEs are forwarded to the guest directly as physical GPEs
using eventfd based forwarding of physical SCI interrupts (which
ensures that the GPE handling in the guest is synchronized with SCI
interrupt context in the host).
Forwarding via netlink should be used for emulated GPEs only.

With this change, we are still propagating all GPE events received by
the host to the guest. In the future we may need to enhance this logic,
since for some types of GPEs we may not want to inject them to the
guest at all, e.g. for Thunderbolt hotplug GPE we want to receive it
in crosvm and then inject a normal PCI hotplug interrupt instead.

BUG=b:197247746, b:205072342
TEST=Make sure that GPE marked as direct are ignored

Change-Id: Id5b05a99951455f52dcb375289cb10d040e8ff7f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3492225
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-03-21 09:16:43 +00:00
Grzegorz Jaszczyk
3323fc3530 acpi: extend acpi pm worker to listen on acpi_event
In order to listen on acpi_mc_group of acpi_event family there is need
to query kernel about it's group id, which is next used to create ACPI
event related socket. This socket is next used during ACPI PM worker's
wait context build.

Upon receiving ACPI events, dispatch them by device class and in case of
receiving "gpe" one, emulate proper vGPE and inject vSCI to the guest.

BUG=b:197247746, b:205072342
TEST=Receive, parse and use GPE generated by ACPI events. With use of
additional kernel patches make sure that GPE notifications are correctly
received, emulated and vSCI injected to the guest.

Change-Id: I18bdfe18ebb1e5bcfa7277b91ae195a61fac1a3d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3407321
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Tomasz Nowicki <tnowicki@google.com>
2022-03-21 09:16:42 +00:00