Commit graph

42 commits

Author SHA1 Message Date
Jason Macnak
9148e0136f rutabaga_gfx: use serde for snapshots
... to avoid re-inventing the wheel when supporting snapshotting
more of rutabaga in upcoming changes.

Bug: b/369615058
Test: cvd start --enable_virtiofs=false
Test: cvd snapshot_take --snapshot_path=/tmp/snapshot1
Test: cvd create --snapshot_path=/tmp/snapshot1
Change-Id: Ibf73ac103e4796f2e70a01991f4a06046c01d08e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5917179
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
2024-10-31 18:18:50 +00:00
Gurchetan Singh
9c105ec4f6 rutabaga_gfx: introduce Tube and Listener abstractions
This is mostly to use SockType::SeqPacket in nix,
since std::os::unix::net for some reason does not
support SeqPacket yet.

As predicted in crrev.com/c/5645904, not using
SeqPacket does lead to test failures for
multi-threaded tests, so we actually need it for
kumquat.

Note RutabagaStream takes it's naming inspiration from
gfxstream, not UnixStream.

Also, since RutabagaStream is more cross-platform friendly
now, remove the "ipc" feature.  It's now always compiled.

BUG=b:354706346
TEST=tfw-pkg/bin/testfw_app --gfx egl --gl_api=gles \
     -w 1280 -h 720 -t gl_driver2_off

Change-Id: I0aebbe4239ba78c70f9049ff8b3fcd0e5fc27d28
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5747101
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-07-31 21:12:36 +00:00
Gurchetan Singh
7d20d126c3 rutabaga_gfx: introduce virtgpu_kumquat + Kumquat server
This introduces a client-side library with FFI bindings
(libvirtgpu_kumquat_ffi.so) + server (Kumquat).  The main goal
is to develop features and test applications, without
a VM.

gfxstream and other virtio-gpu contexts may easily connect to the
virtio-gpu part of the multi-media server via replacing
traditional virtgpu DRM ioctls with FFI functions (they are ABI
compatible).

gfxstream has had similiar features for a long time, with the main
goal of testing deqp-{gles, vk} without a VM.  It was known the
"Android host build" for the longest time, and it was recently
improved to GfxstreamEnd2EndTests.  The downside of this approach is
if you want to test complex apps (think gfxbench) and multiple apps
at the same time, it breaks down.

This is good enough to run vulkaninfo and all headless apps
probably.  Apps with windowing fail, but due to gfxsteam-specific
bugs so far.  Getting windowing working + Kumquat is a goal.

A side goal would be to test cross-domain and that requires the
ability for multi-context interop using external memory.  The current
GfxstreamEnd2EndTests only support one GPU context at a time.

It addition, camera/video support is important too, hence the name
Kumquat (since ideally it won't just be rutabaga, it'll be something
different).  If we added emulated virtio-media support, we in theory
can test GPU <--> media interop without a VM too.

Probably the allocator <--> renderer flow should work first, and
generically it really doesn't (everyone has their own workarounds). We
might want to connect the virtgpu_rutabaga APIs in minigbm..

Dependencies: Clap 4.1.8, same version as in AOSP

KNOWN ISSUES:

  1) Use of UnixStream as the socket type.  This is a stream socket, so
     there are no message boundaries (the bytes sent by a particular
     send() won't necessarily be received by a single corresponding recv()).
     This could also lead to partial commands.  The proper solution
     would be to leverage SEQPACKET socket, but std::os::unix::net does
     not have support yet.  One could leverage nix and do a DIY
     RutabagaSocket.

     However, this is not observed in practice yet, since the client
     side library as a mutex around every access.  Many commands also
     wait for a response ensuring ordering.  It should be fixed though.

   2) Mmap instead of Vulkano Mapping.  Unlikely to work on Nvidia.

   3) Emulated import/export not complete.

BUG=b:300140266
TEST = cargo build --features=gfxstream + target/debug/kumquat
      vulkaninfo via gfxstream (works)
      tfw-pkg/bin/testfw_app --gfx egl --gl_api=gles -w 1280 -h 720 -t gl_manhattan_off
      (loads but hangs due X11/virtio-gpu spec/gfxstream bugs).

Change-Id: I4c16a2fc7b41691585cf4ba7ee8f36602cb6036d
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5645904
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-07-01 21:41:01 +00:00
Gurchetan Singh
b516e66963 rutabaga_gfx: update Vulkano to v0.33
This the version of vulkano in AOSP.

BUG=b:336291294
TEST=compile

Change-Id: Ie6a46e94cb649e7b218d78c60e3252d4408c1f78
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5472146
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2024-04-24 01:59:11 +00:00
Daniel Verkamp
5ae8dd2816 rutabaga_gfx: upgrade to nix 0.28
BUG=b:330231913

Change-Id: Ifcea0f2755482b563f3f28a9adae4abc8d0ea789
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5379406
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2024-04-03 18:39:18 +00:00
Gurchetan Singh
ae733ceb2b rutabaga_gfx: release commit 0.1.3
This revbumps rutabaga_gfx and rutabaga_gfx_ffi to
version 0.1.3

BUG=b:322802940
TEST=compile

Change-Id: Ib8026be6a7e64969fd502c4b3dde75b9af5485c4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5270777
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-02-09 20:41:50 +00:00
Ryan Neph
b3c42bb9d7 Cargo.toml: add vulkano as top-level feature
Hook rutabaga_gfx/vulkano into a new top-level feature of the same name,
so that it can be detected for conditional compilation of gpu device
creation details.

Also moves the `vulkano` dependency out of windows-specific list and
into generic list for all platforms.

(Note: the existing rutabaga_gfx/Cargo.toml hacks must still be locally
applied and rust-toolchain channel must be manually set to 1.70 or
greater to successfully build with --feature=vulkano)

BUG=b:246334944
BUG=b:244591751
Test=tools/dev_container tools/presubmit

Change-Id: Ic1938f3d8599de1414539abf5a4b57a9fe1764dd
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5264226
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2024-02-08 00:17:33 +00:00
Gurchetan Singh
f29fff8331 rutabaga_gfx: fix cross-compile on Windows
When cross-compiling Windows on Linux, multiple features are
reported missing.  Also, winapi::ctypes::c_void and
libc::c_void differ.

winbase isn't used yet, but there's a few futre patches that
benefit from it.

BUG=322802940
TEST=cargo build --target x86_64-pc-windows-gnu

Change-Id: I7aee961b1758050e5f93c3619db27d59bf918fe2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5245137
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2024-01-29 17:44:33 +00:00
Dmitry Osipenko
dbda320eb8 rutabaga_gfx: Remove virgl_renderer_next feature flag
Crosvm enables unstable virglrenderer features based on the pkgconfig
flags. The virgl_renderer_next build flag isn't used anymore, remove it.

BUG=none
TEST=none
Suggested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Change-Id: I96ba36a9a8c1af9a252e8dcbe664cbf1597543a6
Signed-off-by: Dmitry Osipenko <dmitry.osipenko@collabora.com>
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5077248
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Ryan Neph <ryanneph@google.com>
2023-12-15 00:59:44 +00:00
Yiwei Zhang
521ee98d41 rutabaga_gfx: adding missing nix ioctl feature for rutabaga_gralloc
Fix regression in f3dbf20eed

BUG=b:314785753
TEST=rutabaga_gralloc builds

Change-Id: Id2715076ab239b49fb00d230b4a76f4c4493e55e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5081852
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Andrew Walbran <qwandor@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-12-04 17:58:53 +00:00
Andrew Walbran
f3dbf20eed rutabaga_gfx: Uprev nix to 0.27.1
The new version of nix uses OwnedFd in various places, which allows us
to have less unsafe code.

TEST=CQ
BUG=b:293289578

Change-Id: I61aa80c4105eaf1182c5c325109b5aba11cf60de
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/5072293
Auto-Submit: Andrew Walbran <qwandor@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Commit-Queue: Frederick Mayle <fmayle@google.com>
2023-11-29 18:36:53 +00:00
A. Cody Schuffelen
97dff044f8 Replace #[cfg(unix)] with #[cfg(any(target_os = "android", target_os = "linux"))]
Updates are made to source and documentation.

This more accurately represents the currently supported platforms of
Android/Linux and Windows, without unexpectedly including other
unix-like operating systems.

Command to reproduce:
$ find . -type f -not -path '*/\.git/*' | xargs -I {} sed -i 's/cfg(unix)/cfg(any(target_os = "android", target_os = "linux"))/g' {}
$ cargo fmt

md files manually updated to fix line lengths.

Renaming `unix` modules to `linux` will be done in a later CL.

Test: ./tools/dev_container ./tools/presubmit
Bug: b/298269162
Change-Id: I42c1bf0abf80b9a0df25551613910293217c7295
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4909059
Commit-Queue: Cody Schuffelen <schuffelen@google.com>
Reviewed-by: Frederick Mayle <fmayle@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Noah Gold <nkgold@google.com>
2023-10-11 00:43:29 +00:00
Zihan Chen
cbba480ebe crosvm: Uprev zerocopy to 0.7.x
zerocopy 0.7.x has finally released as a stable version, uprev it
to allow some remaining structs to be derivable.

TEST=CQ

BUG=b:300969352
FIXED=b:300969352

Change-Id: I90f0dfb09494f875fef1cd11bfcbd48030846092
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4878761
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Zihan Chen <zihanchen@google.com>
2023-10-10 17:34:32 +00:00
Gurchetan Singh
fd0a3fbd6b rutabaga_gfx: release commit 0.1.2
This revbumps rutabaga_gfx and rutabaga_gfx_ffi to
version 0.1.2

BUG=b:296070975
TEST=compile

Change-Id: I45d2930b0bee39a569def85354418d0b391e1d23
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4778941
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-08-23 01:02:33 +00:00
Daniel Verkamp
695d254bcd rutabaga_gfx: replace VolatileSlice with IoSliceMut
This removes the rutabaga_gfx dependency on data_model.

BUG=b:273555494
TEST=tools/dev_container tools/presubmit

Change-Id: I03be8c8f9f722d368d90e6d9b0d7aeac475f2b06
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4785448
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Frederick Mayle <fmayle@google.com>
2023-08-22 23:54:17 +00:00
Gurchetan Singh
f24ecac01c rutabaga_gfx: remove serde dependency
Serde is supported widely, but we can likely remove for
rutabaga_gfx.

BUG=b:273555494
TEST=compile

Change-Id: I60f1f08a072c3c0ebd5d4d6695f7b9e28259854e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4615987
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-06-14 21:23:02 +00:00
Gurchetan Singh
61ee6744f2 rutabaga_gfx: nuke base dependency
The base crate has some nifty abstractions but also
pulls in things like minijail, audio_streams and
various random items.

This prevents true cross-platform interoperatibility,
which requires the ability to upload to crates.io
with relative ease.

This change removes the base crate.  The replacement
strategy is two fold:

- For things like SafeDescriptor which don't have
  adequate solutions on crates.io, just copy it
  internally.  I think SafeDescriptor in particular --
  since it works on bot Windows/Linux should probably
  be made into a separate crate long-term since it is
  generically valuable.  Similarly for the Event and
  WaitContext APIs.  For now, live with the duplication.

- Otherwise, the nix crate does most of the Linux
  specific items.

The cross-domain context type has a lot of dependencies
on Linux sockets / epoll.  This is refactored to look more
like the Fuchsia solution, which uses std::sync::mspc
channels to connect to an utility Wayland FIDL library.

The rest of Rutabaga mostly relies just on SafeDescriptor
and the ability to clone it.  rutabaga_gralloc allows
provides shared memory used via virtwl.

Another thing to call out is zerocopy is now strongly
versioned to the latest stable release on crates.io

I also got rid of #[cfg(feature = "virgl_renderer_next")]
on the renderer server fd, since it was complicating the
refactoring.  SafeDescriptor works everywhere and adding
the #ifdef should be reserved for the lowest-levels of
platform specific code when possible.

Overall, this makes compiling on Fuchsia hosts much
simpler.

BUG=b:273555494
TEST= - run cross_domain context type, see Wayland apps
      - note there is a previous bug in cross domain
        when resizing windows, it occurs before this CL.
        The reason seems to be raciness and can likely be fixed
        gfxstream-like seqno.
      - run gfxstream + virgl on Linux, verify everything works.

Change-Id: I7519f2b8ed0cd57c47980d4e76403057498cf064
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4353700
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-03-27 18:46:22 +00:00
Gurchetan Singh
ce5ff3e75e rutabaga_gfx: add log package
This tracks librust-log-dev, which is at version 0.4.17-3 in the
Debian package tracker.

It may be possible to use another version too.

BUG=b:273555494
TEST=rutabaga_test

Change-Id: Ib0aaca5800f22960dad89b4e138a0dd5fefcb9c2
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4353699
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-03-27 18:46:07 +00:00
Gurchetan Singh
f63214bda1 rutabaga_gfx/ffi: Makefile for rutabaga_gfx/ffi
This creates a makefile for rutabaga_gfx.  Most package managers
seem to still use Cargo to compile, but not packagement.  We need
to install headers and the library.

I looked into to cargo-c, but it was just easier to open code it.

BUG=b:173630595
TEST=sudo make install
     export LD_LIBRARY_PATH=/usr/local/lib
     make and run rutabaga_test

Change-Id: Ibd68ecd0c6215cc36bc104d843847ee47d02123e
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4335238
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-03-14 20:21:47 +00:00
Zihan Chen
30f58a81aa crosvm: Partially convert DataInit to zerocopy (6/n)
This CL removed many uses of DataInit in devices. Some paddings
are manually added/fixed to allow AsBytes to derive without ABI
changes.

TESTED=CQ

BUG=b:204409584

Change-Id: I1f8c2d5304fc8e685cc3e5166c73481f6a3f78f7
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4235224
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Auto-Submit: Zihan Chen <zihanchen@google.com>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-02-10 01:52:24 +00:00
Gurchetan Singh
22a2dce38a crosvm: revbump for rutabaga_gfx
- Revbum to 0.1.1, 0.1.0-{anything} causes data_model
  0.1.0 to be downloaded since it's a higher release number.

- Also, add include LICENSE in the package includes for
  data_model.

- Also, use the correct version when not using path in rutabaga_gfx.

BUG=b:173630595
TEST=compile

Change-Id: I68af3eb1fa4ab89a77968f784e388b10c94d8b97
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4209693
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-02-01 23:22:03 +00:00
Gurchetan Singh
a52694d88e crosvm: add licensing/description to alpha crates
crates.io requires:
    - descriptions
    - license or license-file.

in the manifest.  It doesn't seem the SPDX license
list includes the Chromium license, though it could
be added in the future.

https://github.com/spdx/license-list-XML/blob/main/DOCS/license-inclusion-principles.md

Though for now just copy the license to the specific crates.

(context: https://fxbug.dev/114169)

BUG=b:173630595
TEST=compile

Change-Id: I84676d2fe0200b18a23c85dec75c2a934353f507
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4082335
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-01-14 02:05:06 +00:00
Gurchetan Singh
780c2727f7 rutabaga_gfx: build for Fuchsia
- Don't build cross-domain -- uses too many Unix like features.
  Once we have a good idea on which abstractions display integration
  should use, we can start incrementingly re-enabling it.

- Stub out common base things for now.  First we probably want to
  fill out the stub before we determining a long-term soluton.

BUG=b:173630595
TEST=build rutabaga using Fuchsia SDK

(context: https://fxbug.dev/114169)

Change-Id: I21db796f59ba7dbf1101a50ae0be482a32e69cc8
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4081627
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2023-01-14 02:04:57 +00:00
Gurchetan Singh
641ac8a26a rutabaga_gfx: match Fuchsia releases of various crates
BUG=b:173630595
TEST=compile

Change-Id: Ia8c34e30059a8308260a8a2682a96504487c32a4
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4151813
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2023-01-13 17:13:39 +00:00
Daniel Verkamp
ac0fc378a3 Fix remaining Chrome/Chromium OS instances
These should be written as ChromeOS and ChromiumOS (without the space)
to match the updated branding. The copyright headers were already
migrated to the new style (https://crrev.com/c/3894243), but there were
some more instances left over.

BUG=None
TEST=tools/cargo-doc

Change-Id: I8c76aea2eb33b2e370ab71ee9b5cc0a4cfd00585
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4129934
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
2023-01-03 22:14:30 +00:00
Gurchetan Singh
6f6875b9c5 rutabaga_gfx: use std::sync instead of sync
This allows the elimination of the sync crate for
rutabaga, at the cost of extra unwrap()'s.

BUG=b:173630595
TEST=compile

Change-Id: I7b28df4f069510b85e9c922743211307b13bd366
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4089123
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Dennis Kempin <denniskempin@google.com>
2022-12-09 17:00:08 +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
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
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
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
Alexandre Courbot
eea1729c39 rutabaga_gfx: do not support GLX if x feature is not enabled
At the moment compiling with the "virgl_renderer" feature enabled but
"x" disabled results in a link error because the virgl_renderer enables
all its platforms without checking. Fix this by enabling the glx
platform only if the x feature has also been enabled.

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

Change-Id: I85041fc2a3db7e49415add69389bee3160ba4a5b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3539327
Reviewed-by: Keiichi Watanabe <keiichiw@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Alexandre Courbot <acourbot@chromium.org>
2022-03-23 02:12:23 +00:00
Dennis Kempin
ef516189db Refactoring: Move common/base into base
Executes the script in https://crrev.com/c/3530502

BUG=b:223206469
TEST=presubmit

Change-Id: Ibeffdc8de0b2270f070e60bb2de8d9fdc78a2a6d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3530503
Reviewed-by: Vikram Auradkar <auradkar@google.com>
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2022-03-17 00:01:27 +00:00
Anton Romanov
bed40ad547 crosvm: migrate to Rust 2021 edition
BUG=none
TEST=cq

Change-Id: I0059c970879b78bfd40b6ce58b10debcf154b50f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3508322
Tested-by: kokoro <noreply+kokoro@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Anton Romanov <romanton@google.com>
2022-03-09 01:16:03 +00:00
Dennis Kempin
8a1c50d5cd Refactoring: Move various general purpose crates to common/
This change contains the results of running

./tools/contib/cargo_refactor.py

This will break the next uprev, and needs to be synchronizized
with the corresponding ebuild changes in https://crrev.com/c/3248925

BUG=b:195126527
TEST=./tools/run_tests

Change-Id: Ied15a1841887bb8f59fba65b912b81acf69beb73
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3248129
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
2021-10-29 22:31:43 +00:00
Daniel Verkamp
2e7dbd4fa4 rutabaga_gfx: convert to ThisError and sort
BUG=b:197143586
TEST=cargo check

Change-Id: I78d3d70c0a9a328ac04857bb78a9d633b93db6c5
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3105426
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Daniel Verkamp <dverkamp@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-09-24 22:52:30 +00:00
Dennis Kempin
ab0ad4caa0 Move virglrenderer/minigbm build into build.rs
Both libraries have previously been built as part of
ci/build_environment/Makefile. This CL moves that behavior into the
build.rs file of rutabaga_gfx.

This is the last third party dependency that we need to build from
source, and allows us to build/test on the host machine instead of
requiring the builder container.

It also allows us to greatly simplify the builder containers, which
I will do in a follow-up CL as we also need to upgrade them to bullseye.

This CL uprevs virglrenderer to include:
https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/609

and minigbm to include: https://crrev.com/c/3141018

BUG=b:196059146
TEST=./test_all && ./run_tests --run-privileged

Change-Id: I4442ccc991d13a3fcfa224de50e916b3926f0cb4
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3141771
Commit-Queue: Dennis Kempin <denniskempin@google.com>
Tested-by: Dennis Kempin <denniskempin@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-09-09 23:13:24 +00:00
Gurchetan Singh
781d975d0b Revert "Revert "rutabaga_gfx: cross-domain: a new year's miracle in February""
This is the original CL with one minor exception: we don't bind
mount the camera socket with the GPU device.  That was the prior
behavior, and for some reason it really doesn't work with Mali +
SECCOMP[1].  It's not really important for the Wayland prototype,
so we'll let the camera team figure it out if and when they are
so inclined.

Bug: b:146066070
Bug: b:173630595
Bug: b:150239451
Bug: b:180126126

TEST=arc.Boot.vm

[1] audit(1613339319.226:43): auid=4294967295 uid=603 gid=603
   ses=4294967295 subj=u:r:cros_camera_algo:s0 pid=17107
   comm="cros_camera_alg" exe="/usr/bin/cros_camera_algo" sig=31
   arch=40000028 syscall=54 compat=1 ip=0xe86a70b8 code=0x0

This reverts commit 51e1c4ad3e3a71a263501d2566d3b1ea59ba2070.

Change-Id: I74f49ece55656d7a9096900e3f19a528234b4224
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2695550
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Robert Tarasov <tutankhamen@chromium.org>
2021-02-16 18:02:47 +00:00
Hiroki Sato
942b8fc00a Revert "rutabaga_gfx: cross-domain: a new year's miracle in February"
This reverts commit a9c4b3a749.

Reason for revert: This made ARCVM fail to boot on kukui-arc-r. See http://b/180126126.

Original change's description:
> rutabaga_gfx: cross-domain: a new year's miracle in February
>
> The cross-domain context is specialized for cross domain
> allocation/resource sharing. It takes direct inspiration from
> the pioneering virtio_wl device and tries to incorporate
> similiar functionality into virtio_gpu.
>
> The goal here is just to introduce the building blocks so we
> can continue experimenting.  In particular, this change:
>
> * hooked up the RutabagaChannels.  This is typically a socket to
>   Wayland or Mojo for the camera use case.
>
> * added CROSS_DOMAIN_CMD_INIT and CROSS_DOMAIN_CMD_GET_IMAGE_REQS
>   to the cross-domain protocol.  Further commands (such as
>   CROSS_DOMAIN_SEND) will be needed, but that requires more
>   Sommelier refactorings.
>
> * added a path to RutabagaGralloc to allocate via minigbm or shared
>   memory.
>
> * Recieves responses via a shared ring buffer of type BLOB_MEM_GUEST.
>   The synchronization protocol looks positively primitive compared to
>   the revolutionary Address Space Graphics (ASG) algorithm [1], but
>   it may be sufficient for the Wayland use case.
>
> [1] https://goto.google.com/address-space-graphics
>
> BUG=b:146066070, b:173630595, b:150239451
> TEST=launch virtual machine with 2D mode
> TEST=launch virtual machine with 3D mode
> TEST=run sommelier with "wl-dmabuf" and "wl-shm"
>
> Change-Id: I46784f17040494ce3a646bdbde516800aa64bd5d
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2626488
> Tested-by: kokoro <noreply+kokoro@google.com>
> Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
> Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
> Reviewed-by: Zach Reizner <zachr@chromium.org>

Bug: b:146066070
Bug: b:173630595
Bug: b:150239451
Bug: b:180126126
Change-Id: Ie33442fdcedcf43b6a24d25198fa2d88b5b96919
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2695056
Reviewed-by: Ryo Hashimoto <hashimoto@chromium.org>
Reviewed-by: Hiroki Sato <hirokisato@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Hiroki Sato <hirokisato@chromium.org>
Commit-Queue: Hiroki Sato <hirokisato@chromium.org>
2021-02-16 00:15:38 +00:00
Gurchetan Singh
a9c4b3a749 rutabaga_gfx: cross-domain: a new year's miracle in February
The cross-domain context is specialized for cross domain
allocation/resource sharing. It takes direct inspiration from
the pioneering virtio_wl device and tries to incorporate
similiar functionality into virtio_gpu.

The goal here is just to introduce the building blocks so we
can continue experimenting.  In particular, this change:

* hooked up the RutabagaChannels.  This is typically a socket to
  Wayland or Mojo for the camera use case.

* added CROSS_DOMAIN_CMD_INIT and CROSS_DOMAIN_CMD_GET_IMAGE_REQS
  to the cross-domain protocol.  Further commands (such as
  CROSS_DOMAIN_SEND) will be needed, but that requires more
  Sommelier refactorings.

* added a path to RutabagaGralloc to allocate via minigbm or shared
  memory.

* Recieves responses via a shared ring buffer of type BLOB_MEM_GUEST.
  The synchronization protocol looks positively primitive compared to
  the revolutionary Address Space Graphics (ASG) algorithm [1], but
  it may be sufficient for the Wayland use case.

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

BUG=b:146066070, b:173630595, b:150239451
TEST=launch virtual machine with 2D mode
TEST=launch virtual machine with 3D mode
TEST=run sommelier with "wl-dmabuf" and "wl-shm"

Change-Id: I46784f17040494ce3a646bdbde516800aa64bd5d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2626488
Tested-by: kokoro <noreply+kokoro@google.com>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2021-02-11 22:58:33 +00:00
Gurchetan Singh
293913c01a rutabaga_gfx: rutabaga_gralloc: a shimmering beacon of hope
rutabaga_gralloc is a cross-platform, Rust-based buffer
manager.

The rationale for this change is:

1) For the {cross-domain, wayland} context type, we need to
have a good story for the crucial "wl-dmabuf" feature.  As
minigbm has been thoroughly tested on ChromeOS and currently
powers the "wl-dmabuf" feature, it only makes sense for us to
have a path to minigbm for the cross-domain prototype.  This
will be used by Sommelier.

2) While minigbm allocation works well on Chromebooks, it is
not sufficient for cross-platform purposes.  For their Virtual
Graphics Interface (VGI) initiative, Android graphics
virtualization experts have expressed their desire for a Vulkan
based allocator.  This will to go alongside cros_gralloc in
minigbm, which is considered by many to be the ""world's
premiere gralloc implementation".

3) Android graphics virtualization experts have expressed their
desire for vkMapMemory(..) to be used when crosvm is in
multi-process mode.  Currently, only dma-buf mmap() is supported
for zero-copy blobs in multi-process mode.  dma-buf mmap() is not
guaranteed to work on Nvidia (a "must have" for Cuttlefish) or
any other driver for that matter (we *make* it work for ChromeOS).
Possibly only solution: vkMapMemory ;-)

With these goals in mind, here's a summary of the revelant changes:

* Renamed the {gpu_allocator.rs, GpuMemoryAllocator trait} to be
  {gralloc.rs, Gralloc trait}.

* Moved all GPU allocation out of the resources crate and into
  the rutabaga_gfx crate.  This will allow the resources crate to
  be focused on managing resources for virtual machines.

* Moved the gpu_buffer crate into the gralloc module in the
  rutabaga_gfx crate.  The same functionality is now under
  "minigbm.rs", "minigbm_bindings.rs" and "rendernode.rs"

* Added an optional dependency on vulkano.rs.  vulkano.rs is a safe
  Rust wrapper around the Vulkan api [a].  It's emphasis on type
  safety makes a good fit for crosvm, though there are other high
  quality crates out there (gfx-rs, ash.rs).  Though development
  has slowed down, it should satisfy goals (2) and (3) quite easily.

* Added a system_gralloc implementation based on memfd.  This can be
  used when minigbm or Vulkano features are not used, to replicate the
  highly useful "wl-shm" feature in Sommelier.  Astute observers will
  note this can also enable seamless Wayland windowing without GPU
  features for Android too.  Some minor changes to the base crate were
  needed.

* Cut down on the amount of DrmFormats to the subset needed by
  Sommelier and cros_gralloc.

* Moved checked arithmetic into it's own file.

* Internally renamed to "wl-dmabuf" feature to be the "minigbm"
  feature.  This is because "wl-dmabuf" has a dependency on minigbm.

* Small rutabaga_gfx cleanups

[a] https://github.com/vulkano-rs/vulkano/blob/master/DESIGN.md

BUG=b:146066070, b:173630595, b:150239451
TEST=launch virtual machine with 2D mode
TEST=launch virtual machine with 3D mode
TEST=run sommelier with "wl-dmabuf" and "wl-shm"

Change-Id: I693a39cef64cd98e56d843d3c60caa7983d4d6e1
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2626487
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-02-04 02:35:52 +00:00
Gurchetan Singh
028b8044bc crosvm: clearer naming about GPU features
It's possible to compile the gpu device without virgl_renderer.
In fact, in many instances, this may be required.

This builds the gpu device default, but only with --gpu do I see
/dev/dri/renderN128, so this should be safe.

BUG=b:173630595
TEST=compile and run

Cq-Depend: chromium:2592111
Change-Id: I5fbf2de8a2f818a9ca2e5ac4a1a02c7797cff927
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2592089
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Daniel Verkamp <dverkamp@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-12-17 01:18:00 +00:00
Gurchetan Singh
b1394f719d rutabaga_gfx: an electrifying possibility
rutabaga_gfx is a cross platform, Rust-based, Wayland and
Vulkan-centric Virtual Graphics Interface (VGI).

Apologies for the mega-change, but it was hard to do this piece
by piece.

The rationale for this change is:

1) Android graphics virtualization experts have been proposing
for a VGI for many months (years?).  Their goal is to boot
Android anywhere, everywhere.

2) For the {wayland, cross-domain} context type prototype,
it's desirable to create a {wayland, camera} connection at the
appropriate time. Details can be found in the code, though the
RutabagaChannels have yet to be hooked up.

There's a high chance neither effort will work.  As such,
rutabaga is just a prototype.

However, even (1) and (2) don't end up working, this
refactor/cleanup by itself makes a ton of sense.

Here's a summary of revelant changes:

* Removed auto-generated {p_defines, p_format, virgl_protocol}.
These files were added for tests when bringing up crosvm-gpu,
and AFAICT these tests are not run.  There's actually now a
commit queue for virglrenderer changes and container boot tests
that provides excellent coverage.

* Removed command_buffer.rs.  Used only for the previously
mentioned tests.  It's quite nice, but couldn't determine the right
place to put it.  Maybe data_model?  But removed it in the interim.

* Removed {write_from_guest_memory, read_to_volatile}.  The same
basic functionality has been moved into {transfer_write,
transfer_read} in Rutabaga.

* Removed VirtioResource, Virtio3DResource, Virtio2DResource,
and VirtioGfxStreamResource in favor of VirtioGpuResource and
RutabagaResource.  This leads to less duplication and clearer
separation between external library functions and VMM functions.

* Moved display and hypervisor memory management functions to
virtio_gpu.rs.  This is because external components do not interface
with this functionality, and there was a lot of duplication (for example
map/unmap blob).

* Added context management between gfxstream and virglrenderer.

* Added separate gfxstream and virglrenderer flags.

* Clearer naming.

* Added simple implementations for context init and multiple timelines.
These changes have no effect since all Google kernels don't pass the
revelant flags, but are useful for theoretical {wayland, cross-domain}
prototype.

* Unify RESOURCE_CREATE_3D and RESOURCE_CREATE_2D handling.

* Better error handling.

BUG=b:146066070, b:173630595, b:150239451
TEST=launch virtual machine with 2D mode
TEST=launch virtual machine with 3D mode
TEST=boot ARCVM

Change-Id: I240b0c134a3b562cbc65981837a41f6db7767c92
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/2522452
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: kokoro <noreply+kokoro@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Zach Reizner <zachr@chromium.org>
2020-12-08 20:17:05 +00:00
Renamed from gpu_renderer/Cargo.toml (Browse further)