Commit graph

151 commits

Author SHA1 Message Date
Yiwei Zhang
a2853028f1 rutabaga_gfx: set render_server_fd to None without virgl_renderer_next
BUG=b:257124165
TEST=build with virgl_renderer but without virgl_renderer_next

Change-Id: I8dda5ad35619920fa0414e6aa6f7d217de8e7a09
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3999177
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2022-11-03 22:22:42 +00:00
Dennis Kempin
6d0d597b5f gfxstream: Enable the feature upstream via stub backend
This won't be functional at runtime, but does allow us to at
least compile with gfxstream enabled.

BUG=b:244618506
TEST=presubmit

Change-Id: I72a63976310e635964645a1265a22518fc6cb694
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3967431
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-20 20:22:23 +00:00
Frederick Mayle
3d4b4809ba base: cross platform Event API
Trying to reconcile the difference between the linux and windows
implementations.

Code relying on the eventfd count must now use the linux specific
`EventExt` interface.

BUG=b:231344063
TEST=presubmits

Change-Id: I14eb50f7a02d766a00f27aca388823309633e193
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864030
Commit-Queue: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-10-19 20:17:42 +00:00
Gurchetan Singh
9142190652 rutabaga_gfx: allow running context types without 3D component
It's not necessary to build 3D rendering support to run the
cross-domain context type.

Default implementations are added for some hypercalls, since
the guest kernel may still think it's running a KMS display.
That adds log-spam if errors are present.

BUG=b:173630595
TEST=Run weston terminal in the guest

Change-Id: I8155cf9d9867a329927b7dd4bb22c385510966a2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3961536
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2022-10-18 01:54:59 +00:00
Idan Raiter
91741705a5 rutabaga: Use method instead of property
In an earlier refactor, mistakenly called .properties instead of
properties()

BUG=b:244622199
TEST=downstream

Change-Id: Ia34e6167ad04e9b42580193b9fcd6b4f8acaf1fd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3939622
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-14 18:21:28 +00:00
Idan Raiter
3e19680831 rutabaga: Don't enable all features for Vulkano device
Some devices support so many features, that they collide. In Vulkano's
autogenerated out\features.rs, some are tagged as:

crate::device::FeatureRestriction::ConflictsFeature

Meaning both cannot be on at the same time. An example failure is
on Nvidia for:

shading_rate_image
attachment_fragment_shading_rate

My GPU supports both and thus cannot be created since we attempt to
enable all supported features.

This is VUID 04480
https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#VUID-VkDeviceCreateInfo-shadingRateImage-04480

This change just removes features from being requested. Instead we
should choose the specific features we want as they come up. Currently
for GPU mapping we don't need features.

BUG=b:244622199
TEST=downstream

Change-Id: Ic511d04cf2987bfc7189182a1dc002a367b5d9f7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3936679
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-10-14 18:17:02 +00:00
Idan Raiter
466deb7a78 rutabaga: Introduce device id, remove physical index
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>
2022-10-06 20:18:48 +00:00
Idan Raiter
7f4854237b rutabaga: Fix & cross-platform Vulkano memory import
A rebase appears to have caused memory imports to allocate external
memory instead of import it. For example, the input handle is not used.

- Fix the issue and make the import cross-platform. Linux / Windows use
  different extensions.

BUG=b:244622199
TEST=presubmit & downstream

Change-Id: Iaeefa37526d42e23be521a97c9ca038659fefb11
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3926104
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Idan Raiter <idanr@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-09-30 17:18:14 +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
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
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
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
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
Daniel Verkamp
c56f161f93 rutabaga_gfx: add virglrenderer deps later
If the -ldrm option is added before the virglrenderer library in the
linker command line, the libdrm symbols will not be available, since
they aren't used and will be dropped by the linker. Move the
virglrenderer deps into a helper function to avoid duplication and call
it after the virglrenderer build to get the linker options in the right
order.

BUG=b:244618790
TEST=tools/dev_container tools/presubmit --all # with wl-dmabuf feature

Change-Id: I55cc96a28a1f02e7b6081d3cfa08bc3446b8e6a1
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3905092
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-09-20 20:30:39 +00:00
Yiwei Zhang
b896f0a153 Revert "rutabaga_gfx: Support for cached mappings on msm"
This reverts commit 84e4fbc2be.

Reason for revert: cts regression in b/247131923

Original change's description:
> rutabaga_gfx: Support for cached mappings on msm
>
> This is a stop gap solution until we have some way for the kernel to
> report mapping info to crosvm.  But since on arm devices without FWB,
> the mapping attributes are the more restrictive of the S1 and S2
> mappings, for now we can just map them as cached in the S2 pgtables.
>
> BUG=b:239718180
> TEST=cts-tradefed run cts -m CtsVideoTestCases -t android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Perf0320x0240
>
> Change-Id: Ib3f085fd8da768b58e7a6d8deadf3a16c7cbcc4c
> Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3832355
> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
> Auto-Submit: Rob Clark <robdclark@chromium.org>
> Commit-Queue: Rob Clark <robdclark@chromium.org>
> Tested-by: Rob Clark <robdclark@chromium.org>

BUG=b:247131923
TEST=BasicVulkanGpuTest

Change-Id: I6566ab033840a5f9bd99dca7cbecfc1f42a5c363
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3903099
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-19 16:55:50 +00:00
Ryan Neph
bf6e7d9060 rutabaga_gfx: unmap from gpu thread for virglrenderer
Virglrenderer must not unmap from any thread other than the virtio-gpu
thread because virglrenderer is not thread-safe and EGL requires that
only one thread own a context concurrently.

For the VirglRenderer RutabagaComponent, we can unmap directly from the
virtio-gpu thread. In fact, we can greatly simplify the use of
ExternalMapping if we eliminate the associated map/unmap callbacks for
all RutabagaComponents.

Now VirtioGpu is responsible for ensuring that the map/unmap occurs and
is registered/unregistered. Also, the shared `map_request:
Arc<Mutex<ExternalMapping>>` spanning the KVM and virtio-gpu threads is
no longer necessary.

BUG=b:244626679
TEST=OpenGL and Vulkan gameplay with sandboxing disabled
TEST=OpenGL and Vulkan gameplay on ChromeOS with sandboxing

Change-Id: I4acaf4aabff3891536ca0439221cfbd021dba123
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3888602
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-09-16 17:29:37 +00:00
Alexandre Courbot
33f90e6eb0 devices: gpu: remove deserialize_wsi deserialization function
When converting the GpuParameters to serde_keyvalue, we moved the custom
parsing code into custom deserializations functions. However, in the
case of the 'wsi' member, it looks like the same result can be obtained
by using kebab-case and aliasing "vk" to the "Vulkan" variant.

BUG=b:218223240
TEST=cargo test --features "gpu" parse_gpu

Change-Id: Ie7b892a9aebd0b0915c089473e1a114ab992202e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3889323
Reviewed-by: Pujun Lun <lunpujun@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-14 18:13:56 +00:00
Alexandre Courbot
a11457c245 devices: gpu: make 'wsi' gpu option recognize the 'vulkan' parameter
'GpuParameters' are used for parsing the command-line, but are also
passed through a tube. When that happens, the default serializer turns
the 'wsi' member to "Vulkan", but the custom deserializer function
expects 'vk' in order to build it properly.

Fix this by making RutabagaWsi use the kebab-case for
serializing/deserializing so it gets serialized into 'vulkan', and
making the 'deserialize_wsi' function accept 'vulkan' as a valid option.

BUG=b:218223240
TEST=cargo test --features "gpu" parse_gpu

Change-Id: I831ddc623ff6b5ddd74dbfe82cf7ccc0f7647272
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3889322
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Reviewed-by: Pujun Lun <lunpujun@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-09-14 18:09:56 +00:00
Gurchetan Singh
8ab7d9b715 rutabaga_gfx: nuke fake capset
All Android guests have been updated.

BUG=b:239639751
TEST=compile

Change-Id: Ic1d6e7bc338335d3afd36d8d70f6f291a24cc63f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3892130
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-09-13 22:31:55 +00:00
Daniel Verkamp
7c6d8bec3f health-check: enforce blank line after copyright
While we are tweaking all of the copyright headers, let's take the
opportunity to ensure there is always a blank line after the copyright
header for consistency. (Almost all files already follow this style.)

This includes a slightly ugly regex to allow the end of a C-style
comment block after the end of the copyright:

/*
 * Example comment block
 */   <-- this line

Change-Id: Idfd0855861e5ecb3d33afae942fdba908af0dcff
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3892521
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-09-13 22:24:35 +00:00
Dennis Kempin
1dab58a2cf Update all copyright headers to match new style
This search/replace updates all copyright notices to drop the
"All rights reserved", Use "ChromiumOS" instead of "Chromium OS"
and drops the trailing dots.

This fulfills the request from legal and unifies our notices.

./tools/health-check has been updated to only accept this style.

BUG=b:246579983
TEST=./tools/health-check

Change-Id: I87a80701dc651f1baf4820e5cc42469d7c5f5bf7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3894243
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-09-13 18:41:29 +00:00
Ryan Neph
9f97f53c8b gpu: remove timer-based fence polling
Remove the deprecated timer-based fence polling strategy, leaving the
async callback-based strategy that is now in use by all Rutabaga
components.

BUG=b:175527587
TEST=glxgears & vkcube in ChromeOS VM
TEST=Vulkan & OpenGL games in ChromeOS VM
TEST=GfxBench in ARCVM
TEST=Asphalt 9 in ARCVM

Change-Id: I75714f82e36f1d6291a875fe3dd47d850ff2eb82
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3880586
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
Tested-by: Ryan Neph <ryanneph@google.com>
2022-09-08 00:10:15 +00:00
Ryan Neph
cc7c43183a rutabaga_gfx: silence some compiler warnings
BUG=None
TEST=cargo build

Change-Id: Ife9616a258a685535483432991b3a06207d955b2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3880623
Tested-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Ryan Neph <ryanneph@google.com>
2022-09-07 21:21:45 +00:00
Pujun Lun
1c4620794b gpu: add resource_flush() interface.
On Windows, we don't use import_resource_to_display() + flip_to(),
but the newly added resource_flush(). This applies to both Vulkan
and D3D backend. We would need some refactoring for the GpuDisplay
interface to create a better abstraction.

BUG=b:213149288
TEST=presubmit

Change-Id: If1d3dc543a17aa7fabf591aa2c1b87b226e8a4a6
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3869171
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Pujun Lun <lunpujun@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Pujun Lun <lunpujun@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-09-01 21:11:50 +00:00
Gurchetan Singh
710b3c9082 rutabaga_gfx: add stream_renderer_vulkan_info
The exact internals of the API may change though.  For example,
using a device UUID is a less error-prone than using physical
device index.

However, this is sufficient to get gfxstream external memory on
atleast some platforms.

BUG=b:235485545
TEST=compile and run ./deqp-vk with kFeature_ExternalBlob enabled

Change-Id: I10d2aaecfbcd61f383dd326184e60942755db196
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3864029
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Idan Raiter <idanr@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-08-31 18:03:28 +00:00
Gurchetan Singh
7f5c54392a rutabaga_gfx: update Vulkano to match ToT
- Instance creation requires VulkanLibrary type
- UnsafeImage --> Arc<UnsafeImage>

BUG=b:173630595
TEST=cargo test --features=vulkano

Change-Id: Ie64d06fe0f20d63a19c94ae9fe6c904e83508178
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3858687
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-08-26 20:57:17 +00:00
Rob Clark
84e4fbc2be rutabaga_gfx: Support for cached mappings on msm
This is a stop gap solution until we have some way for the kernel to
report mapping info to crosvm.  But since on arm devices without FWB,
the mapping attributes are the more restrictive of the S1 and S2
mappings, for now we can just map them as cached in the S2 pgtables.

BUG=b:239718180
TEST=cts-tradefed run cts -m CtsVideoTestCases -t android.video.cts.VideoEncoderDecoderTest#testAvcGoog0Perf0320x0240

Change-Id: Ib3f085fd8da768b58e7a6d8deadf3a16c7cbcc4c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3832355
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Tested-by: Rob Clark <robdclark@chromium.org>
2022-08-18 20:33:55 +00:00
Daniel Verkamp
9c12c41185 rutabaga_gfx: remove use of VolatileRef
Replace the command parsing code that used VolatileRef with the new
DataInit::read_from_prefix() function. The code is parsing a normal Rust
&[u8] slice, so it does not need to use volatile loads at all.

BUG=None
TEST=tools/presubmit --all

Change-Id: I1ee57404ae39da3400f455959e7d396f20a0d22b
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3823999
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2022-08-16 18:43:03 +00:00
Dennis Kempin
4fea399df9 Reformat imports
crosvm is switching the import style to use one import per line.
While more verbose, this will greatly reduce the occurence of merge
conflicts going forward.

Note: This is using a nightly feature of rustfmt. So it's a one-off
re-format only. We are considering adding a nightly toolchain to
enable the feature permanently.

BUG=b:239937122
TEST=CQ

Change-Id: Id2dd4dbdc0adfc4f8f3dd1d09da1daafa2a39992
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3784345
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
2022-07-28 00:15:50 +00:00
David Stevens
01e2724335 devices: wl: initialize gralloc after sandboxing
Initializing gralloc may spawn threads, so it needs to be done after
sandboxing the wl device. Initializing gralloc requires expanding the
wl device's sandbox. Rather than trying to maintain a new dedicated
minijail configuration for wl, reuse the gpu's configuration. This
should be sufficient, since virglrenderer has to open minigbm within the
sandboxed gpu process.

BUG=None
TEST=ARCVM and crostini GUI on volteer, zorc-arc-r, grunt-arc-r

Change-Id: I291fb59c665a8ba65058a6f55dee959c839bb43c
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3787936
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: David Stevens <stevensd@chromium.org>
2022-07-27 01:54:48 +00:00
David Stevens
e9673a428a wl: allocate dma-bufs in process
Directly allocate dma-bufs within the virtio-wl process and remove the
VmMemoryRequest::AllocateAndRegisterGpuMemory type. This is preparation
for migrating to the SharedMemoryMapper interface.

BUG=b:201745804
TEST=Launch arcvm, launch gedit w/crostini, launch gedit w/vhost-user-wl

Change-Id: I232f1fd3dfdb8d7ed068c6b3c2ea23f35d0ddabc
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3765012
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Alexandre Courbot <acourbot@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2022-07-22 02:28:09 +00:00
Gurchetan Singh
51c07a15b3 crosvm: nuke gfxstream syncfd
Nobody ever toggles this flag, implying this flag can be removed.

By default, the gfxstream assumes ANDROID_EMU_virtio_gpu_native_sync
is present, which is the desired behavior.

BUG=b:239639751
TEST=compile gfxstream

Change-Id: I64d19c5fc2c0ac59a87ee25fbd1e7b6ed9522410
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3778078
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-07-21 00:16:41 +00:00
Gurchetan Singh
0ae68e5076 rutabaga_gfx: gfxstream: stream_renderer_context_create
Newer version with context init variable.

BUG=b:235485545
TEST=compile

Change-Id: Ia9ce7a17c59db9839bdb0caf42a97708a3fdb46f
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/3778077
Reviewed-by: Kaiyi Li <kaiyili@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-07-20 23:51:30 +00:00
Vikram Auradkar
69f3931ee6 rutabaga_gfx: Upstream cross_domain.rs
BUG=b:213151426
TEST=presubmit. enables windows tests

Change-Id: I1ec80b88c8e66454d7eb911a8d366747528ff4fc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3698048
Commit-Queue: Vikram Auradkar <auradkar@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-13 17:34:42 +00:00
Daniel Verkamp
d4505a7f1c base: replace PollToken with EventToken tree-wide
Pull the declaration of the `EventToken` enum up to the top level of the
base crate, replacing the identical implementations inside sys/windows
and sys/unix.

Use the `EventToken` name consistently throughout the tree to remove the
unix-flavored "poll" nomenclature.

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

Change-Id: I0ba42037b533b796797a7a3f6d8d7e71a5592aba
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3642673
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2022-06-02 22:30:38 +00:00
Kaiyi Li
bf7a2f37b2 gpu: add new gfxstream initialization flags
BUG=b:233676779
TEST=presubmit

Change-Id: I02103077006c2ac4bc8b3b21bf186de9743530e7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3668930
Auto-Submit: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Kaiyi Li <kaiyili@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-01 18:47:41 +00:00
David Stevens
569a58490e base: clarify SharedMemory API
When creating shared memory, 'name' can have one of two meanings. It
could either be a debugging tag with no semantic meaning, or it could
uniquely identify a shared memory object within some namespace. Linux
memfd uses name in the first meaning, whereas Windows (and Linux shm)
uses it in the second meaning.

Currently, crosvm has no use cases for the named shared memory of the
second type, so it is not supported. Make it clear that the SharedMemory
APIs treats name as a debugging-only name. Remove the "anon" and "named"
constructors, since they had no semantic meaning. Also require a name
when constructing a SharedMemory, since there's no reason not to provide
one to make debugging easier.

The only semantic change is setting the name of GuestMemory's underlying
shmem to "crosvm_guest", which it was until recently. This fixes some
ManaTEE tests which use the name to determine CrOS guest memory usage.

BUG=None
TEST=compiles

Change-Id: I78d5046df04d6f19640abbbc67af6bd433a177b0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3676695
Commit-Queue: David Stevens <stevensd@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-06-01 03:55:47 +00:00
Ryan Neph
3b24bd0a53 rutabaga_gfx: virglrenderer: enable async_fence_cb
Flip the switch for Virglrenderer's virgl/vrend contexts to stop using
timer-based fence polling and start using async fence handling callback.

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

Change-Id: I0b309be2086225bbbb7beb0943379a22acb62a07
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628304
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2022-05-31 22:50:14 +00:00
Rob Clark
82c5129590 rutabaga_gfx: Expose "fake" capset for minigbm
minigbm virtgpu_cross_domain backend checks for this capset.  Eventually
once this check is removed in minigbm (once everyone is using the
context-types arg to control whether cross-domain is exposed) we can
drop the dummy capset.  But we need it for now.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I7c955c365f439806c797d1d38daef2e1c9b3079f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3608703
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-24 15:27:36 +00:00
Rob Clark
d570dc761f rutabaga_gfx: Add cmdline arg to control exposed context types
Add a way to control exposed capsets from cmdline.  This will let us
enable certain context types only in certain VMs, with a single build
of crosvm.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I8d32a22c4c198566e984b06d6aa545796752c128
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636797
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-24 15:27:36 +00:00
Rob Clark
69ecfb0e39 rutabaga_gfx: Add support for drm native contexts
Expose support for the new virtgpu drm native contexts.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I068e9b14ac47782c9251d9b67156755f2888d17f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3469494
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-05-24 15:27:36 +00:00
Rob Clark
567c777f15 rutabaga_gfx: conditionally enable capsets based RutabagaBuilder input
If the context_mask is specified, only advertise those capability sets.

If not specified, for backwards compatibility, use the older behavior.
Eventually, the older beahvior may be deprecated.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I3c37f94dfb5df25831d187deff600027aac2382d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636798
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2022-05-24 15:27:36 +00:00
Gurchetan Singh
3c77043c19 rutabaga_gfx: consolidate flags into the rutabaga builder
A lot of these flags can be deprecated over time.  For example,
specifying the context type and "use_vulkan" is a bit redundant.
Things like "use_syncfd" and "use_guest_angle" can also be removed.

BUG=b:173630595
TEST=compile

Change-Id: I77bff7f02ebfd3b0e65145d144bfc15afa50f386
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3655286
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-05-24 15:27:36 +00:00
Rob Clark
6d7a90be3a rutabaga_gfx: add context type mask
A way to control exposed capsets.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I91616405b695be73d6cc872aa5ae2a9dcecd0fb1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3636799
Commit-Queue: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-05-24 15:05:16 +00:00
Alexandre Courbot
6cabd03d60 gpu: fix unused_mut warning when no gpu feature is enabled
These variables will be left untouched if no GPU feature is enabled,
triggering a compiler warning.

BUG=None
TEST=`cargo build` does not display any warning.

Change-Id: Id1c80bd8f21272dce9e3a3f37cd3350727e5bc9a
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3659824
Reviewed-by: Junichi Uekawa <uekawa@chromium.org>
Auto-Submit: Alexandre Courbot <acourbot@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-05-23 08:21:26 +00:00
Rob Clark
953670c3ea virglrenderer: Add cross-domain support
For cross-domain, virgl_renderer needs to be able to import a dmabuf fd
allocated by another component.

BUG=b:230100768
TEST=gfxbench, android games in arcvm

Change-Id: I9d6f965589ec24f06a83a6d921a9c00db1f057f6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3501130
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Auto-Submit: Rob Clark <robdclark@chromium.org>
Commit-Queue: Rob Clark <robdclark@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
2022-05-20 20:49:55 +00:00
Gurchetan Singh
c1a2fa27b4 rutabaga_gfx: stop unconditionally advertising the cross domain capset
Currently, there are two use cases for the cross domain capset:
   (1) Sommelier
   (2) minigbm

Niether is used by a production VM yet and it was unconditionally
enabled only to enable testing.  To effectively productize, it should
be conditionally enabled, which is done later in this patch series.

BUG=b:173630595
TEST=compile

Change-Id: I736f58065c692d7ee4736f28da30fa28de43f0c8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3655285
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Rob Clark <robdclark@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
2022-05-19 22:39:47 +00:00
Ryan Neph
bfe3bcf96a rutabaga_gfx: virglrenderer: add support for per-context fencing
Permits virglrenderer contexts to make use of per-context/per-ring
fencing.

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

Cq-Depend: chromium:3654708
Change-Id: I30028afa5daff2a7a1b0ade13bc9fae2cd548f8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3628302
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2022-05-19 22:39:47 +00:00
Ryan Neph
646de85eee gfxstream: fix fence_handler not stored in fencing cookie
While we support both the old and new fence handling methods of
b:175527587, we need two copies of the RutabagaFenceHandler (one for
each method).

BUG=b:228051513,b:175527587
TEST=emerge crosvm
TEST=tested by gfxstream team

Change-Id: I516cf135819aebb5128e41b8a9d585e17680c6a9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3646777
Commit-Queue: Ryan Neph <ryanneph@google.com>
Auto-Submit: Ryan Neph <ryanneph@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Kaiyi Li <kaiyili@google.com>
2022-05-13 18:37:56 +00:00