It's not ergonomic for the calling code to pass in an array of
references.
Just take ownership of that array, as it's not going to be used again
when the calling code succeeds in creating the wrapper.
BUG=b:214478588
TEST="cargo build --features=video-decoder,vaapi" successfully builds
the libva crate
Change-Id: I97d91f9f996c298450e65c21c126a9739ec4615f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3900314
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Implement access to vaQuerySurfaceStatus for Picture<PictureEnd>. This
means that a decoder can initiate a decode operation and query its
status at a convenient time instead of blocking on it for completion.
Also expose libva::VASurfaceStatus to calling code while at it, since it
is needed to interface with this API.
BUG=b:214478588
TEST="cargo build --features=video-decoder,vaapi" successfully builds
the libva crate
Change-Id: I8a20455ef9937a4a54943325d359fa361190d8a4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3875042
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Previously, only PictureSync would allow us to retrieve a borrow to the
underlying surface, but this is too restrictive. If we can take the
Surface back by calling take_surface() in PictureReclaimableSurface,
there is no reason not to be able to get a borrow to a Surface as well.
This makes the calling code more ergonomic.
BUG=b:214478588
TEST="cargo build --features=video-decoder,vaapi" successfully builds
the libva crate
Change-Id: I71f9f46e6bac6188c4c3862332c445c68028dbef
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3783006
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
In preparation for interlaced support, allow for picture creation using
another picture's Surface. This is so one can decode both fields to the
same underlying surface.
BUG=b:214478588
TEST="cargo build --features=video-decoder,vaapi" successfully builds
the libva crate
Change-Id: If3ffcc2592b7213644ed92f7202502fc92bac4b3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3783005
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
While the current design works well for progressive content, in
interlaced content a common strategy is to decode both fields to the
same Surface.
Thus, add support for sharing the underlying Surface. This means that we
can only retrieve the Surface if we are the last Picture with a
reference to it.
While we are at it: only retrieve Surfaces if we are the last users
In preparation for interlaced decoding support, only retrieve Surfaces
back into the surface pool if we are the last users. This means that the
surface will not be dropped until both of its fields have been dropped.
BUG=b:214478588
TEST="cargo build --features=video-decoder,vaapi" successfully
builds the libva crate
Change-Id: I80412a86f51ab639fab6af229572fb7bc800a928
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3946300
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
When we detect a VCPU stall we propagate the watchdog reboot error code
to the event tube. The newly added error code WATCHDOG_REBOOT = 36 is
returned from the crovm process.
Bug: 245900797
Test: manual testing, build and Virtualization apk on a device
Signed-off-by: Sebastian Ene <sebastianene@google.com>
Change-Id: Ib1ce97de911784b33d130d40536be26813edc3d7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3936647
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
The current crosvm implementation is using
`GuestMemory::checked_offset()` for the following two cases:
(1) To get a valid `GuestAddress` representing `addr + offset`.
(2) Guarantee that the memory range `[addr, addr+offset]` is valid.
However, using `checked_offset()` for the case (2) is wrong because the
method only checks if the end address `addr+offset` is valid and doesn't
check if an invalid region exists between `addr` and `addr+offset`.
So, this CL adds `GuestMemory::is_valid_range()` to replace the (2)
cases.
BUG=b:251753217
TEST=cargo test in vm_memory
TEST=start a vm with virtio devices
Change-Id: I21bce5d1c60acdff79284cdad963849a6e19e19c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3945520
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
This is a followup of crrev.com/c/3931568.
Since `derive(serde_keyvalue::FromKeyValues)` used for `ExecutorKind` is
guarded by the serde_keyvalue's `argh_derive` feature, we need to
specify the feature in cros_async's Cargo.toml.
The original CL didn't break the crosvm build because our builder always
enable the `argh_derive` feature.
BUG=b:239154263
TEST=cargo test in /cros_async
Change-Id: I10c77373241271e3002fe574c69e0118059a7f1a
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3945519
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Adds `crosvm gpu <>` commands which allows for interactively
adding/listing/removing virtio-gpu displays/scanouts.
Also updates the virtio gpu device to use a Map<u32, Scanout>
instead of a Vec<Scanout> and always report the maximum number
of displays (16) with enabled/disabled. This helps handle the
case of removing a display that is not the last display number.
BUG=b:163864461
TEST=cargo build
TEST=cargo build (with gpu feature disabled)
TEST=Android build
TEST=launch Cuttlefish
TEST=crosvm gpu list-displays <socket>
TEST=crosvm gpu add-displays
--gpu-display=width=900,height=600
--gpu-display=width=600,height=480
<socket>
TEST=crosvm gpu list-displays <socket>
TEST=crosvm gpu remove-displays
--display-id=1
<socket>
Change-Id: I7530498897eb4e84199eaeb3d66df006df62817f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3911102
Commit-Queue: Jason Macnak <natsu@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Without _PRx method, device couldn't put into D3cold. In order to
put vfio-pci device into D3cold in VM, this commit add _PRx method
for vfio-pci device. When guest call _PRx method, crosvm will trap
it and forward the _ON/_OFF request to host vfio-pci kernel driver
which manage physical device PM.
BUG=b:194390621
TEST=dump ssdt table in a guest with vfio-pci device
Change-Id: I5ec6ebc84f5328574b62b2d6e091ffe9605d1dd4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3822009
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Victor Ding <victording@chromium.org>
vfio-pci device will have ACPI PowerResource/_DSM method later, this commit
add more AML objects which are needed to construct _PRx and _DSM method for
vfio-pci device
BUG=b:194390621
TEST=dump ssdt table in a guest with vfio-pci device
Change-Id: Ieb5728210b6ad557ba400b48154d615c16d46f53
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3892625
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Victor Ding <victording@chromium.org>
The path does not belong to crosvm and should not, for example, be
revealed to UnlinkUnixSeqpacketListener which would try to remove it.
TEST=cargo test, added a new unit test
BUG=b:251742702
Change-Id: I6e81623b76d62961c774010e1dafcf73ffca6471
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3941684
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Keir Fraser <keirf@google.com>
I got stuck on the "/var/empty doesn't exist" error when setting up on a
new machine. This makes it much easier to diagnose.
Change-Id: I08f7e025fc3ddec92f58a0ce10c6a8ca6bdc84d7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3939625
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
BUG=b:237011316
TEST=presubmit and ran the script to ensure that it installs and builds
the binaries.
Change-Id: I5109eda6795ad2710df495afb99846c052afbf15
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3936734
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
We don't want mprotect or mmap being called with write and execute at
the same time. This policy is for a test, but still filter the arguments
incase this policy is used as a starting point elsewhere.
BUG=b:172212144
TEST=Kokoro passes
Change-Id: I8be82a9af7e404a4eb17f5b2fbb1e6269447de11
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3942708
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Allen Webb <allenwebb@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
We want to move towards enabling all features upstream. To
verify we are not disabling any, nor adding any disabled
features, this check will verify that all features are
included in one of our composite features for each platform
we are building upstream.
BUG=None
TEST=health-check
Change-Id: I076c7b79143b40e59d8806ad2286ac7e357b1fc1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3938628
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Zihan Chen <zihanchen@google.com>
The Suspendable trait's restore() function allows returning a Result, so
we can use the `?` operator to return errors in case the serde_json
deserialization process fails, rather than using `unwrap()` on the
Result, which would panic if the call failed. This doesn't make much
difference for this particular case, since it is in test code, but we
should provide a good example in case this code gets copied for other
implementations of the Suspendable trait.
BUG=None
TEST=cargo test -p devices
Change-Id: I8252fef5ee8f19c73f08971352984cd91766aa0c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3942512
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Elie Kheirallah <khei@google.com>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
The nightly rustfmt command had an extra .with_color_flag() call,
duplicating the one below. Drop it to fix the error message when using
tools/fmt --nightly:
Option 'color' given more than once
BUG=None
TEST=tools/fmt --nightly
Change-Id: I7158e4394167fa89d78f9eb38beb0b827471e3a9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3942707
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Use fchmodat(), fchownat(), and utimensat() to implement the SET_ATTR
request rather than using the non-'at' variants of these functions.
These can operate on a file descriptor path using the /proc file handle
and "self/fd/N" filename to modify the attributes of a file without
actually opening it, which means we can avoid problems like not being
able to open a read-only file with O_RDWR, which happened previously
with chmod requests.
This means we don't need to open the file at all, except in the case of
a request that needs to set the size, since there is no equivalent
truncateat() function.
BUG=chromium:1369647
TEST=touch /mnt/chromeos/MyFiles/Downloads/hello.txt
TEST=chmod -w /mnt/chromeos/MyFiles/Downloads/hello.txt
TEST=chmod +w /mnt/chromeos/MyFiles/Downloads/hello.txt
TEST=chmod a-r /mnt/chromeos/MyFiles/Downloads/hello.txt
TEST=chmod a+r /mnt/chromeos/MyFiles/Downloads/hello.txt
TEST=chown $USER /mnt/chromeos/MyFiles/Downloads/hello.txt
TEST=truncate -s1 /mnt/chromeos/MyFiles/Downloads/hello.txt
Change-Id: I0461ed231cc78b26bcc37ede1a364af984c87f8b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3935537
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Allow devices to perform runtime power management via
VFIO_DEVICE_FEATURE IOCTL.
BUG=b:194390621
TEST=host's VFIO_DEVICE_FEATURE can be triggered from guest
Change-Id: Id649a1e5fe317dfb315f841a152ec8b81fab8e7c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3822004
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Victor Ding <victording@chromium.org>
Remove unused method.
BUG=none
TEST=cargo test --all-features in vmm_vhost for both Linux and Windows
Change-Id: I7fb7fb343f1742c2bea80b4031d43821f7437db6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863048
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Some structs in vmm_vhost have `error` field and expose `set_failed` to
allow callers to invalidate an instance. However, `set_failed` is not
used in crosvm at all. In addition, the `error` field cannot be modified
any private methods in vmm_vhost. This means that the callers can manage
the error states entirely.
So this CL removes the `error` fields and `set_failed` methods to make
it clearer that the callers have responsibilities of error handling.
BUG=none
TEST=cargo test --all-features in vmm_vhost
TEST=cargo test --all-features --target=x86_64-pc-windows-gnu in vmm_vhost
Change-Id: Idf478790a0a75282a4c504456d93604f7369c015
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3863046
Reviewed-by: Noah Gold <nkgold@google.com>
Auto-Submit: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Use the enum to document the exit code and refer from the rustdoc.
BUG=b:251305451
TEST=mdbook build and observe
Change-Id: Ie75fc40a8301151266af112f275e331f1a49c769
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3935671
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
If you specify a wrong parameter on concierge there's no message and
just an exit code of 35.
BUG=b:251305451
TEST=boot with concierge.
Change-Id: I1524363f3a76345b4f09a646ae89e2f363d3200c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3935670
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Junichi Uekawa <uekawa@chromium.org>
Use the new ability of serde_keyvalue to parse tuple enums to directly
parse display arguments into their target struct. This requires an
incompatible update on the syntax, but it doesn't seem to be used on
Unix anyway.
Windows code still uses its own parser so it is not affected by this
change.
TEST=cargo test --features "gpu" parse_gpu
Change-Id: I2b718600015a57f5dd6675e9d60de3b8c149a80f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3920254
Reviewed-by: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Fix a few stray references to "CrosVM" and "CrosVm" so that we refer to
the crosvm project with consistent capitalization.
BUG=None
TEST=None
Change-Id: If5c3c131774d6e5da1d27466810642aec3cb42ac
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3938640
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Instead detect if we have embedded policies.
This removes the last remainging uses of the chromeos flag.
BUG=b:244618505
TEST=presubmit
Change-Id: I5cdb5302199ed33a7e56a4e95466b07a5b024def
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3933977
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Mesa DB cache is a single-file shader cache with less wasted space and
support for shader cache file size limitation.
We want this DB cache so that we can take advantage of more efficient
shader cache that respects shader cache file size limit.
BUG=b:245831076
TEST=`vmc launch borealis` then see mesa_cache_db directory under
/run/daemon-store/crosvm
Change-Id: Ib8576bcd8ccebaf4834948c8a140b0b3a7a61124
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3931567
Commit-Queue: Max Lee <endlesspring@google.com>
Reviewed-by: Renato Pereyra <renatopereyra@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Adds a new message that can be used to map GPU memory via Vulkano.
BUG=b:244622199
TEST=presubmit & downstream
Change-Id: I4018cfda7573d4df2d89225060d5d61c8ac5d3d9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3924935
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: David Stevens <stevensd@chromium.org>
Add a new identifier for a device, the "device id". This is a
combination of the device UUID + driver UUID. Reason for not only using
device UUID is that the spec calls out both must match:
https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#external-memory-handle-types-compatibility
We have also seen some less-ideal implementations of device UUID on
Windows that return mostly zero with a few bits set, so adding the
driver UUID should increase confidence.
physical_device_idx is removed.
BUG=b:244622199
TEST=presubmit & downstream
Change-Id: I8174227e3d4bcadf778b7a73c9f84bb475169326
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3926105
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Each vhost-user device frontend (devices/src/vhost/user/vmm/*) has its
own VirtioDevice implementation; however, most of the code is common
between all devices. This patch adds a VhostUserVirtioDevice struct that
is used for all vhost-user frontends. It accepts some options at time of
creation to customize the supported features and queue count per device
type.
This patch attempts to maintain the previous behaivor of all device
types, so there should be no functional change. Additional cleanup and
refactoring should be possible, but it will be done in follow-up
patches.
BUG=b:249361790
TEST=Connect crosvm vhost-user frontends to all supported backends
Change-Id: I7054fbeaba39b94a1da05792204bc48573ce7caa
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864878
Reviewed-by: Noah Gold <nkgold@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>