Commit graph

4839 commits

Author SHA1 Message Date
Dennis Kempin
891455563b system_api: Add copy of ChromeOS's system_api
Adds a script that copies the bindings we need upstream. We cannot
use the original repository, as it's part of the large platform2 git
repository, and the original build.rs depends on ChromeOS tooling to
generate these bindings.

So instead, this change adds a script that can be called from a
chromiumos checkout of crosvm to update the upstream bindings.

This allows us to enable certain features that talk to ChromeOS
dbus services. They won't be functional upstream, but at least we
can compile and test the code.

To make things more consistent, we no longer replace the crate
with the ChromeOS version when building for ChromeOS.

BUG=b:244618505
TEST=presubmit

Change-Id: I504cbf6d12b0cb50d9935f5e49b7fa72b692d45c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3919814
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-28 18:13:00 +00:00
Jason Macnak
9ce7255fa0 devices: gpu: Don't hardcode display 0 for EDID
BUG=b:163864461
TEST=launch Cuttlefish with multiple displays

Change-Id: Idc61e86cb03b7b2afca6a416cbf6770b8b217cf2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3911101
Commit-Queue: Jason Macnak <natsu@google.com>
Reviewed-by: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-28 16:18:01 +00:00
Vikram Auradkar
21d2a616f0 crosvm: enable building with crash-report and slirp on linux
BUG: b:244619302
BUG: b:244618109
TEST: presubmit
Change-Id: Iaa7d5ac866e76da0a53ac86f65320a00694b00e7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3916695
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2022-09-28 14:47:24 +00:00
Vikram Auradkar
e493edd79e crash-report: Build with feature crash-report
BUG: b:244618109
TEST: Presubmit and built with the feature on windows and linux.

Change-Id: Idf9ae87243eb0a7c7b9a6ff525406f1430b49c20
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3916339
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-09-28 14:45:00 +00:00
Pierre-Clément Tosi
7245e26c57 aarch64: Add support for GDB SingleRegisterAccess
Add the infrastructre for GDB 'p'/'P' packets, used by the client to get
or set individual registers.

Implement a back-end using KVM_{G,S}ET_ONE_REG on AArch64, enabling the
client to access the architecture's numerous system registers.

Add stubs for x86 to please the compiler; leave them unimplemented as,
although the ioctl is available, the architecture doesn't seem to make
use of it.

BUG=b:222222882
BUG=b:240711627
BUG=chromium:1141812
TEST=tools/dev_container ./tools/run_tests

Change-Id: I01968275e88e9d0098de40b3f78e2cd3a61b75da
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3785468
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-09-28 11:26:00 +00:00
Pierre-Clément Tosi
7737c533db gdb: Add basic support for AArch64
Enable the "gdb" feature on AArch64 (KVM) builds and add support for:

 - reading & writing guest memory (only guest IPAs, for now)
 - getting & setting core registers
 - getting & setting the few system registers from kvm_regs
 - setting hardware breakpoints (no software breakpoints, for now)
 - enabling single-step mode

BUG=b:222222882
BUG=b:240711627
BUG=chromium:1141812
TEST=tools/dev_container ./tools/run_tests

Change-Id: I0ae38c1065002d55a569b1575b1637110694e6db
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3785467
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Takaya Saeki <takayas@chromium.org>
2022-09-28 11:25:50 +00:00
Tatsuyuki Ishi
18b779fef0 virtio: video: Add conversion helper for virtio Format to AvPixelFormat.
Generalize and move it out of the decoder for potential future use in
the encoder module.

A ffmpeg.rs module is introduced to accommodate any video-related code
that requires the ffmpeg feature flag, similar to what we have for
libvda.

BUG=b:239897269
TEST=cargo test --features "video-decoder,ffmpeg" -p ffmpeg -p devices

Change-Id: I341d6d238b5593d16cbdc8dd8c96eb2fa4e143fe
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3911109
Commit-Queue: Tatsuyuki Ishi <ishitatsuyuki@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-09-28 02:54:50 +00:00
Tatsuyuki Ishi
0d94089855 media: ffmpeg: Add helper to create AvPixelFormat from raw enum values.
Since re-enumerating all the formats supported by FFmpeg in our bindings
would be a rather large effort, it looks like a good compromise here is
to allow the user to create an AvPixelFormat from the raw enum values
exposed by bindgen.

Add a helper that checks that the value is in range of valid formats and
convert it into our enum wrapper.

BUG=b:239897269
TEST=cargo test --features ffmpeg -p ffmpeg

Change-Id: I3c1433e9d76d645b7615bde81433e1df2cfa3910
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3911108
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-09-28 02:54:50 +00:00
Alexandre Courbot
a6396869a4 serde_keyvalue: fix cargo doc warning
TEST=cargo doc

Change-Id: I7ef54dc973aa279222214b5dc08579f2a9973ee0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3918032
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
2022-09-28 02:16:40 +00:00
recipe-roller
62f09aa8f5 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8801831834323119761

depot_tools:
fcf9fc4c36
  fcf9fc4 (sokcevic@google.com)
      Remove freeze as suggestion on git cl upload

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: Id145d7e761dd7ad2e637e54005bbf753215eb86f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3923875
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-09-27 22:18:00 +00:00
Pujun Lun
26d9803ccb gpu_display: sync with downstream code.
Notable changes:

1. Use "W" methods during window creation and message dispatching
   to ensure unicode characters are sent to the window.
2. In DisplayEventDispatcher::dispatch(), filter() and map() will
   be ignored if we don't call collect(). We replace map() with a
   for loop to make this clearer.

Other changes are due to linter/formatter warnings, etc.

Bug=b:213150276
TEST=cargo b -p gpu_display --features win64 --no-default-features

Change-Id: I767aec208d8afd7d7cb86039d08ba8ec8369da81
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3913991
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-09-27 20:12:29 +00:00
Idan Raiter
51f9faf3a4 rutabaga: Update Vulkano to 0.31.0
- We now have ::empty() for flags instead of ::none().

- PhysicalDeviceType was changed to vulkan_enum which is not Ord, so we
  have to change BTreeMap to HashMap.

- The abstract holders for MemoryType or QueueFamily are gone, so more
  index tracking is required. Some constructors take indices now.

- Physical devices are proper objects now, and are enumerated via the
  instance. To keep things simple, this CL only replaces with equivalent
  logic, but the next one should replace device indices entirely with
  device UUIDs.

- Device memory errors were condensed into a single DeviceMemoryError
  type. We also need to handle the VulkanError type from
  enumerate_physical_devices.

BUG=b:244622199
TEST=presubmit

Change-Id: I1bba7e652ca67ecc5d9c10ddba3e1da35185078b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3913993
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-09-27 19:53:50 +00:00
Mike Gerow
bb9603b19f Revert "x86: cpuid: clear FSRM bit"
This reverts commit fa1e6e3249.

Reason for revert: This turns out to have been a bug in the kernel that can be addressed with the following patch:

```
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 2d7ea5480ec3..71b412f820c7 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -328,6 +328,7 @@ static void early_init_intel(struct cpuinfo_x86 *c)
                         pr_info("Disabled fast string operations\n");
                         setup_clear_cpu_cap(X86_FEATURE_REP_GOOD);
                         setup_clear_cpu_cap(X86_FEATURE_ERMS);
+                        setup_clear_cpu_cap(X86_FEATURE_FSRM);
                 }
         }
```

Original change's description:
> x86: cpuid: clear FSRM bit
>
> This seems to cause an unexpected fault under Bruschetta, and possibly
> any other software using Ice Lake's Fast Short REP MOVs.
>
> This is a port of a patch from AOSP[1].
>
> [1]: https://android-review.googlesource.com/c/platform/external/crosvm/+/2138413
>
> BUG=b:228795137
> TEST=deployed to brya board, bruschetta bootup no longer hangs after
> entering smpboot
>
> Change-Id: Ifb4e8af104ee8e2945598ea4c06001cbd98c40e9
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3913990
> Auto-Submit: Mike Gerow <gerow@google.com>
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>

Bug: b:228795137
Change-Id: I7bd8be1b33315dddb5b73df62303bd967ac0573e
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3916337
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Mike Gerow <gerow@google.com>
2022-09-27 19:14:59 +00:00
Daniel Verkamp
31a517d5e2 x86_64: set fast REP MOVS bit in IA32_MISC_ENABLE for BIOS too
This MSR seems to be the responsibility of the hypervisor to set up even
when booting with BIOS/firmware in the guest. When it is missing, the
configuration of IA32_MISC_ENABLE will be inconsistent with CPUID bits
like ERMS and FSRM, which report fast REP MOVSB behavior as well.

Specificially, this avoids a problem with newer Linux kernels when
booted in crosvm with a BIOS where the ERMS feature is masked out due to
the IA32_MISC_ENABLE bit being unset but the FSRM feature is not masked
out, leading to a normally impossible combination of CPUID features that
the memmove code did not expect.

BUG=b:228795137
TEST=Boot Linux with OVMF on brya

Change-Id: I9e9e8301d8cb3d1f0f0d0c7d2137ff3286f35c1d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3919374
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Mike Gerow <gerow@google.com>
2022-09-27 19:11:29 +00:00
Idan Raiter
6af40edd41 rutabaga: Fix typo rutabagE -> rutabagA
Some types have a typo on them. For the FFI case we don't currently use
the definition so it should be safe to rename.

BUG=b:244622199
TEST=presubmit

Change-Id: I9e3c29755f0c4479b54bef206f9173ab22030ab9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3913992
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Idan Raiter <idanr@google.com>
2022-09-27 18:44:09 +00:00
Alexandre Courbot
980fb8896c devices: video: fix build
http://crrev.com/c/3911103 renamed a member of BufferInfo, but did not
update the video code that uses it.

BUG=b:3911103
TEST=cargo build --features "video-decoder,video-encoder,ffmpeg,vaapi,libvda"

Change-Id: Icc8c5c2f564ea2fdaeee12abe57cfd29c8373a72
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3920255
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: Keiichi Watanabe <keiichiw@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
2022-09-27 03:15:28 +00:00
Pujun Lun
db5bb70726 devices: make resource_bridge::ResourceInfo use SafeDescriptor.
It used to use File instead. In VirtioGpu::export_fence() and
VirtioGpu::export_resource(), we had to turn SafeDescriptor into
File, which is not supported on Windows (to avoid converting a
SafeDescriptor that is not a file handle to a File). To make them
more platform-agnostic, we replace them with SafeDescriptor.

BUG=b:213149288
TEST=presubmit

Change-Id: I259bbc4d3461bc68b5a7a1e24d50bf77bdc6a5b0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3911103
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-09-26 23:08:48 +00:00
Dennis Kempin
15b67b7385 Fix compilation with "gpu" and "plugin" enabled.
This fixes ChromeOS compilation of crosvm.

BUG=None
TEST=presubmit / cargo build --features=gpu,plugin

Change-Id: I1e2b3f95a5d4afab82798b01e8fb42a131f4a819
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3919817
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-09-26 22:38:38 +00:00
Alexandre Courbot
e1c1719b84 serde_keyvalue: remove enum wrapper
This wrapper type is useless as we can just implement the access traits
on KeyValueDeserializer directly.

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

Change-Id: I5013b3fea2f0a2febf182a2fd42037d1cbdbe737
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3915037
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
2022-09-26 22:25:28 +00:00
recipe-roller
0e0f125777 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (recipe_engine) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8801932498190801617

recipe_engine:
13052ddf4b
  13052dd (amellen@google.com)
      [test] Fix large output file diff

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: I3a4a8bb11efc1a5b6224aae955076487a3b29b79
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3919911
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-09-26 19:34:58 +00:00
recipe-roller
94889474bd Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (recipe_engine) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8801937531488998929

recipe_engine:
ff74f3e865
  ff74f3e (kuanhuang@chromium.org)
      Export ResultDB API: QueryUniqueTestVariants and QueryTestResults

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: I5c44020b6447effa2e4668beaa0fcf6958eb68d2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3919371
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-09-26 18:13:47 +00:00
Daniel Verkamp
5c3815747a devices: vhost-user: clean up config functions
The generic type used in read_config() and write_config() was only used
to check the offset against the size of that type; the backend device is
capable of checking this itself, so we can drop the type from the
function signatures.

Additionally, fix the config functions to use the offset rather than
reading/writing the whole config and copying out the relevant parts.

This makes the config function implementation identical for all
vhost/user/vmm/ code.

BUG=None
TEST=mount vhost-user-fs filesystem in guest

Change-Id: I22493f4e87bff68ef9d68f1d1a0feeb29ec059da
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3867543
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Auto-Submit: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-09-26 08:46:28 +00:00
Takaya Saeki
ae9280a20a devices: virtio: video: add run_async method to Worker
Implement `run_async` method in `Worker` for the video device.
`run_async` is necessary for implementing vhost-user video device, which
prefers async wait loop.

For now, the async runner depends on the wrapper of WaitContext, which
the implementation of decoder device depends on, rather than making the
decoder device async.  In addition, this commit does not unify the block
`run` and `run_async` yet.

BUG=b:179756087
TEST=cargo build succeeds.

Change-Id: Iec14a342bade14bf1f68ec0211da3dd2b52c85da
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3783295
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-09-26 06:54:07 +00:00
Takaya Saeki
9369814695 cros_async: make run_one utilize Executor::new
Currently, the utility function `run_one` has its own logic to create
`FdExecutor` and `UringExecutor`. However, this logic duplicates that of
`Executor::new`. So when you update the logic of `Executor::new`, you
must also update `run_one`, which is easy to forget and error-prone.

This commit updates `run_one` to delegate the executor building logic to
`Executor::new`. Also, the error type of `run_one` has been updated to
match `Executor::new`.

BUG=None
TEST=`cargo build` and `cargo test -p cros_async` succeeds.
TEST=windows build succeeds

Change-Id: Ic90a064c4c9017ed14e2897bccf68f9e275e1fef
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3829220
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-09-26 03:32:27 +00:00
Takaya Saeki
a150978ca0 devices: virtio: video: make Worker async friendly
Update `Worker` of the video device to make it easier to add async run
method; separate the interrupt into two `SignalableInterrupt`s for the
command/event queues, and move `Event`s to outside `Worker`. These are
changes preparing for introducing `run_async` method to `Worker`.
`run_async` will need separate Interrupts for the command queue and the
event queue, and will not need `Event`s inside `Worker`.

BUG=b:179756087
TEST=simple_decoder test script (see the crosvm book) worked with and
without -p "pci=nomsi" guest kernel parameter, which triggers interrupt
resample by disabling MSI-X interrupt.

Change-Id: Ia169e11bb5ecf992f768ab65cfb19a7a9f8fc9f0
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3850019
Commit-Queue: Takaya Saeki <takayas@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
2022-09-26 03:26:37 +00:00
Yiwei Zhang
2d1d44b6df handle new CV run ended message
As announced in http://g/luci-announce/d5-USDV4YXQ, the run pass
and failure message will be changed as part of CQ -> CV migration.
This CL allows the tool to handle both old style and new style
messages.

Change-Id: Ia06c05eeff321b26af92dc67bd41747e60d9b071
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3914865
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Yiwei Zhang <yiwzhang@google.com>
2022-09-23 16:58:44 +00:00
Ryan Neph
2a8339f85d rutabaga_gfx: make non-sandboxed opaque fd mapping explicit
When sandboxing is disabled, rutabaga.external_blob is unset and blob
resources with RUTABAGA_MEM_HANDLE_TYPE_OPAQUE_FD can be mapped via
rutabaga.map() as VmMemorySource::ExternalMapping. This is already
implicitly allowed for the Virglrenderer component, which doesn't
recognize the OPAQUE_FD handle type upon export_blob() and automatically
falls back on the ExternalMapping path. Mesa CI currently relies on this
for testing Venus in Crosvm with the host lavapipe driver.

When sandboxing is enabled, rutabaga.external_blob is set and opaque
fds MUST be mapped from the hypervisor process via Vulkano as
`VmMemorySource::Vulkan` instead.

This CL makes non-sandboxed OPAQUE_FD mapping explicit, documents the
two mapping paths, and prepares for virglrenderer to support sandboxed
OPAQUE_FD mapping.

For the non-sandboxed configuration, Crosvm exports a RutabagaHandle
with handle of type RUTABAGA_MEM_HANDLE_TYPE_OPAQUE_FD upon blob
creation with virglrenderer. When mapped, the RutabagaHandle is dropped,
closing the cloned opaque_fd, and virgl_renderer_resource_map()
completes the mapping internally by looking up the resource_id and
dispatching to the context type from which it was created.

BUG=b:244591751
TEST=`deqp-vk -n dEQP-VK.memory.mapping.*` using venus with lavapipe host driver
TEST=CQ

Change-Id: I2ff32cf8868d6c9c1eb16480456cde98d376cc65
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3900320
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-09-22 21:43:19 +00:00
Mike Gerow
fa1e6e3249 x86: cpuid: clear FSRM bit
This seems to cause an unexpected fault under Bruschetta, and possibly
any other software using Ice Lake's Fast Short REP MOVs.

This is a port of a patch from AOSP[1].

[1]: https://android-review.googlesource.com/c/platform/external/crosvm/+/2138413

BUG=b:228795137
TEST=deployed to brya board, bruschetta bootup no longer hangs after
entering smpboot

Change-Id: Ifb4e8af104ee8e2945598ea4c06001cbd98c40e9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3913990
Auto-Submit: Mike Gerow <gerow@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-09-22 21:42:39 +00:00
Pujun Lun
698d2dcc3a devices: add feature flags to render_server_fd.
We want to hide this variable from platforms that don't use it.

BUG=b:213149288
TEST=presubmit

Change-Id: I0d44d2bc50843b86d82b4084f95c8d1a1f750aa6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3895401
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
2022-09-22 20:21:59 +00:00
Pujun Lun
05e0443fe5 gpu: add a serializer for context mask.
Apart from being used for arg parsing, GpuParameters is also sent
through a Tube on Windows. Since we've added a deserializer for
the context_mask field, we also need a serializer for it.

BUG=b:233676779
TEST=cargo test -p devices --features=all-linux
virtio::gpu::parameters::tests::context_mask_serialize_deserialize

Change-Id: Ic0a01acc07ac39b5962e3cfad970dae1ae8c8b27
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3906468
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-09-22 16:34:19 +00:00
Pujun Lun
9a415a2559 gpu: don't use raw descriptors of resource bridges on Windows.
Resource bridges are not supported on Windows, so we shouldn't try
to add their raw descriptors in Gpu::keep_rds().

Struct Gpu is updated to hold the ResourceBridges struct rather
than the Vec<Tube>.

BUG=b:213149288
TEST=presubmit

Change-Id: I6b71076d17057728b927d93462e3aee29f3ac8af
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3911100
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-09-22 16:33:59 +00:00
Grzegorz Jaszczyk
572519253d audio: fix VirtioSnd re-activation
Hitherto the activation could succeed only once since take() function on
Option "Takes the value out of the option, leaving a None in its place."
Above resulted with crosvm crash in guest suspend/resume scenario when
the activate was called more than once (for the second time snd_data
and stream_source_generators was None).

To overcome above issue use clone for snd_data. For
stream_source_generator the clone can't be
easily used due to missing Clone support for stream_source_generators
embed data types (e.g.
369 | struct AudioBuffer<'a> {
370 |     buffer: &'a mut [u8],
    |     ^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for
    `&mut [u8]`

and some other). Therefore for stream_source_generator move
create_stream_source_generators from new() to activate.

BUG=b:246728970
TEST=Perform multiple suspend/resume s2idle cycle for borealis VM and
make sure that 1) crosvm doesn't crash anymore 2) audio from borealis VM
is still working after VM suspend/resume cycles.

Change-Id: I8b27042e4cc0e5efb1d92756ac3b71a5a744f705
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3904649
Commit-Queue: Norman Bintang <normanbt@chromium.org>
Reviewed-by: Norman Bintang <normanbt@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
2022-09-22 09:14:19 +00:00
Vineeth Pillai
aea39132e8 libcras_stub: Stub implementation
Stub the required parts of libcras so that upstream builds with
audio_cras feature

BUG=b:244618503
TEST=cargo build --features audio_cras

Change-Id: I21eb3bcb9a61990740b1419f124401878619481e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3911099
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vineeth Pillai <vineethrp@google.com>
2022-09-21 23:36:06 +00:00
Frederick Mayle
1c3ba38583 base: don't export platform specific Event types
TEST=cargo build && ./tools/dev_container ./tools/run_tests --target=host --build-target=mingw64 --build-only
BUG=b:231344063

Change-Id: I125f4b200abdc6758bae93d98c590c2139fe915b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864025
Auto-Submit: Frederick Mayle <fmayle@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-09-21 21:35:48 +00:00
Vineeth Pillai
ea67d8ba10 audio: Fix the unreachable pattern warning with audio_cras
Builds with audio_cras feature gets the following warning

warning: unreachable pattern
   --> src/crosvm/sys/unix/device_helpers.rs:443:9
    |
443 |         _ => unreachable!(),
    |         ^
    |
    = note: `#[warn(unreachable_patterns)]` on by default

This is because the enum is fully matched when audio_cras is enabled.
Make the unreachable conditional based on the audio_cras feature.

TEST=None
BUG=None

Change-Id: I68f9d7e4571e043ba81ceef62ced075415398802
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3911098
Commit-Queue: Vineeth Pillai <vineethrp@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-09-21 21:27:14 +00:00
Pujun Lun
ea55d0fecd rutabaga_gfx: add an interface to enable GLES 3.1 for gfxstream.
GLES 3.1 is not yet well tested with gfxstream backend on Windows
and we don't enable it by default. We control this via command
line arg for now.

BUG=b:213151426
TEST=presubmit

Change-Id: Ic3f8ac0e10ab988cc7bb4a5ab741ee6542617943
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3911097
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-09-21 21:21:14 +00:00
Dennis Kempin
7cd928d985 Remove ChromeOS only PR_SET_CORE_SCHED
This feature is only available on ChromeOS and should live in
the downstream ChromeOS repository.

Note: This change should be reverted with the next ChromeOS merge.

BUG=b:244618505
TEST=None

Change-Id: I33d4e6c5feb4178ebf7cd946ea654dbd20291653
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3907532
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-21 20:51:16 +00:00
Pujun Lun
dd2c0a932a crosvm: move enum ProcessType to win_util.
This is to keep consistency with Windows downstream code.
The conversion from ProcessType to EmulatorProcessType is moved to
the metrics crate as it is only used for generating metrics.

BUG=b:213146388
TEST=presubmit

Change-Id: Ia62f76835a1f162dd8bbc9e53fd671968c368473
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3908370
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Pujun Lun <lunpujun@google.com>
2022-09-21 19:28:49 +00:00
Daniel Verkamp
02214710df devices: vhost-user: remove incorrect get_config offset check
The offset field of the VHOST_USER_GET_CONFIG message indicates the
offset within the whole device configuration, not within the buffer in
the message, so offset does not need to be less than size.

BUG=None
TEST=connect fs device with modified read_config() impl

Change-Id: Ifabac14ec087da200a09f41aa3a0041e96cf56f3
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3867542
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Abhishek Bhardwaj <abhishekbh@chromium.org>
2022-09-21 18:44:38 +00:00
Daniel Verkamp
c1c37179e1 crosvm: replace VhostUserWlOption with VhostUserOption
The wl device specific version of this was identical to VhostUserOption,
which is used for all other vhost-user device types, so just use that
instead.

BUG=None
TEST=tools/presubmit --all

Change-Id: I0d5868b78bc8b84d24e901601a1a9a1037853ee2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3867539
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-09-21 18:36:29 +00:00
recipe-roller
cb4d39b688 Roll recipe dependencies (trivial).
This is an automated CL created by the recipe roller. This CL rolls
recipe changes from upstream projects (depot_tools) into this repository.

The build that created this CL was
https://ci.chromium.org/b/8802391772360396401

depot_tools:
08bb5c487f
  08bb5c4 (gbeaty@chromium.org)
      Use the gerrit host when setting gitiles commit.

Please check the following references for more information:
- autoroller, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#autoroller
- rollback, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/workflow.md#rollback
- cross-repo dependencies, https://chromium.googlesource.com/infra/luci/recipes-py/+/main/doc/cross_repo.md

Use https://goo.gl/noib3a to file a bug.

R=denniskempin@google.com

Recipe-Tryjob-Bypass-Reason: Autoroller
Ignore-Freeze: Autoroller
Bugdroid-Send-Email: False
Change-Id: Ibb199c0f2eadaed563701b7f4b78a05e6218d8b7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3911096
Bot-Commit: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
Commit-Queue: Recipe Roller <recipe-mega-autoroller@chops-service-accounts.iam.gserviceaccount.com>
2022-09-21 17:59:58 +00:00
Dennis Kempin
e749002260 DIR_METADATA: Add public buganizer component
Change-Id: If33e86b18834a4a6df0af4b9be2df59bc0b551c9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3911095
Reviewed-by: Dmitry Torokhov <dtor@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-09-21 17:43:59 +00:00
Alexandre Courbot
86210e591e serde_keyvalue: fix error reporting offset
After deserializing a value, do not consume the next character until we
confirm it is the expected delimiter, otherwise the "expected comma"
error will be reported with an extra offset of 1.

TEST=cargo test -p serde_keyvalues

Change-Id: Id3b80a256bfee51eb1125091dcb0114c2e4af226
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3905070
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-21 16:50:09 +00:00
Takaya Saeki
f6d446d209 main: prefer .context to map_err(|e| anyhow!(...))
`anyhow::context` is more idiomatic way to handle errors than mapping an
error by `map_err(|e| anyhow!(...))`. However, main.rs uses the latter
right now.

This commit rewrites such error handling to the `.context` manner.

Note that this commit does not rewrite all `map_err` because some of
them requires refactoring various functions which return the unit type
as their error like `Result<..., ()>`. Because the unit type does not
implement `std::Error`, we cannot wrap it with `.context`.

BUG=None
TEST=build succeeds

Change-Id: I5829db1ed98bafd3d61a165172a009ab8db29d53
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3831834
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Takaya Saeki <takayas@chromium.org>
2022-09-21 05:31:48 +00:00
Daniel Almeida
53523c943c video: decoder: vaapi: retry flush() if new buffers are available
The previous implementation would silently not flush all buffers if not
enough output buffers were available. It would also unconditionally emit
the FlushCompleted event.

Fix this by retrying the flush whenever new output buffers are
available, and only exiting the flush state when there is nothing left
to flush.

BUG=b:214478588
TEST="cargo test --features=video-decoder,vaapi
virtio::video::decoder::backend::vaapi::tests::test_get_capabilities"

Change-Id: I47402d3e561ca98ba93462f448eb4eb76acd3eee
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3783001
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-09-21 03:24:28 +00:00
Daniel Almeida
e64a119bed video: decoder: vaapi: change flush() signature
Some codecs might need to return frames on flush. This is notably the
case on h264, as it has to output the frames in the DPB on flush, but
the current design makes it impossible.

Fix it by changing the signature of flush to allow for possibly
returning frames when flushing. These frames are appended to the ready
queue and outputted as soon as output buffers become available.

BUG=b:214478588 TEST="cargo test --features=video-decoder,vaapi
virtio::video::decoder::backend::vaapi::tests::test_get_capabilities"

Change-Id: Ifd982518bc09cbdd3c32da5409e348a3a2e0b91d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3783000
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-09-21 03:15:59 +00:00
Daniel Almeida
ede5a80959 media: libva: Also export VASurfaceID
BUG=b:214478588
TEST="cargo test"

Change-Id: I4ab17409afd08f23ed3addd6463f150a6c768ccf
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3782998
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-09-21 03:03:57 +00:00
Alexandre Courbot
aad77ff1e2 serde_keyvalue: add a few tests
Add tests for a unit type and an untagged enum.

TEST=cargo test -p serde_keyvalue

Change-Id: Ifb840e3270624ef0e54d69b7eba2e631ffcac4e5
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3906752
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-09-21 02:57:52 +00:00
Noah Gold
90063081cb devices: simpler disk image opens + bug fix for Windows.
* Fixes a regression where we stopped setting sparseness on Windows
  disk images when they were opened.

* Simplifies how disk images are opened. io_concurrency is not
  currently used and may be repurposed in a way that won't use the more
  complicated code in disk image opening.

BUG=b:247582339
TEST=builds

Change-Id: I25dd71985d512e5d6991a74e4e1b01fa798856a9
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3908372
Commit-Queue: Noah Gold <nkgold@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-21 01:48:26 +00:00
Tatsuyuki Ishi
3af6d25d61 virtio: video: Move decoder utils to the root video module.
We want to use this for the encoder too, so move it to a place that can
be accessed from both.

BUG=b:239897269
TEST=cargo test --features "video-decoder,ffmpeg" -p devices video

Change-Id: I5f880a9907d0750249d50a8b36f8431f180c31a4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3889332
Commit-Queue: Tatsuyuki Ishi <ishitatsuyuki@google.com>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
2022-09-21 01:44:38 +00:00