From c86e465e3506f0776a52b345d34f996d0356c61b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Fri, 12 Jan 2024 11:58:16 +0100 Subject: [PATCH] drop qemu-rutabaga patches --- checks/wayland-proxy-virtwl/default.nix | 8 +- flake.lock | 30 +-- pkgs/aemu/default.nix | 28 --- pkgs/flake-module.nix | 10 - pkgs/gfxstream/default.nix | 60 ----- pkgs/qemu-wayland/default.nix | 9 - ...-t-clone-wayland-memfd-file-descript.patch | 68 ------ ...er-ugly-workaround-to-get-private-ke.patch | 75 ------ ...-stale-cross-domain-keymap-resources.patch | 204 ---------------- pkgs/rutabaga-gfx-ffi/Cargo.lock | 222 ------------------ pkgs/rutabaga-gfx-ffi/default.nix | 49 ---- 11 files changed, 17 insertions(+), 746 deletions(-) delete mode 100644 pkgs/aemu/default.nix delete mode 100644 pkgs/gfxstream/default.nix delete mode 100644 pkgs/qemu-wayland/default.nix delete mode 100644 pkgs/rutabaga-gfx-ffi/0001-rutabaga_gfx-don-t-clone-wayland-memfd-file-descript.patch delete mode 100644 pkgs/rutabaga-gfx-ffi/0002-rutabaga_gfx-super-ugly-workaround-to-get-private-ke.patch delete mode 100644 pkgs/rutabaga-gfx-ffi/0003-rutabaga_gfx-fix-stale-cross-domain-keymap-resources.patch delete mode 100644 pkgs/rutabaga-gfx-ffi/Cargo.lock delete mode 100644 pkgs/rutabaga-gfx-ffi/default.nix diff --git a/checks/wayland-proxy-virtwl/default.nix b/checks/wayland-proxy-virtwl/default.nix index 1b0c6cd03..d678bcb81 100644 --- a/checks/wayland-proxy-virtwl/default.nix +++ b/checks/wayland-proxy-virtwl/default.nix @@ -14,13 +14,9 @@ import ../lib/test-base.nix ({ config, pkgs, lib, ... }: { virtualisation.qemu.options = [ "-vga none -device virtio-gpu-rutabaga,cross-domain=on,hostmem=4G,wsi=headless" ]; - virtualisation.qemu.package = lib.mkForce self.packages.${pkgs.hostPlatform.system}.qemu-wayland; + + virtualisation.qemu.package = lib.mkForce pkgs.qemu_kvm; }; - # FIXME: currently we still see this error in the build sandbox, - # but it gives us some smoke test - # vm-test-run-wayland-proxy-virtwl> machine # qemu-kvm: The errno is ENOENT: No such file or directory - # vm-test-run-wayland-proxy-virtwl> machine # qemu-kvm: CHECK failed in rutabaga_cmd_submit_3d() ../hw/display/virtio-gpu-rutabaga.c:341 - # vm-test-run-wayland-proxy-virtwl> machine # qemu-kvm: virtio_gpu_rutabaga_process_cmd: ctrl 0x207, error 0x1200 testScript = '' start_all() # use machinectl diff --git a/flake.lock b/flake.lock index a12f5399b..b33872764 100644 --- a/flake.lock +++ b/flake.lock @@ -7,11 +7,11 @@ ] }, "locked": { - "lastModified": 1703726296, - "narHash": "sha256-l/fQEjR3wAEEu1jcZWLq60BSo0r6cXspGLar+pkKZ2M=", + "lastModified": 1705017253, + "narHash": "sha256-/ysUOnF/dYJXDTxi/fi4MNN7uYKRji5CKp3EIamXB+0=", "owner": "nix-community", "repo": "disko", - "rev": "0ce1b15b99ac7c280384f136eae00b968f5b3f72", + "rev": "fa5db12d76f9e8ee11e572cdbe021230e48b6afa", "type": "github" }, "original": { @@ -27,11 +27,11 @@ ] }, "locked": { - "lastModified": 1701473968, - "narHash": "sha256-YcVE5emp1qQ8ieHUnxt1wCZCC3ZfAS+SRRWZ2TMda7E=", + "lastModified": 1704982712, + "narHash": "sha256-2Ptt+9h8dczgle2Oo6z5ni5rt/uLMG47UFTR1ry/wgg=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "34fed993f1674c8d06d58b37ce1e0fe5eebcb9f5", + "rev": "07f6395285469419cf9d078f59b5b49993198c00", "type": "github" }, "original": { @@ -78,11 +78,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1704015712, - "narHash": "sha256-GrsuUCEH5T629Py4jt6tsIzu9nEL/fD2Qt986ib13WI=", + "lastModified": 1704916437, + "narHash": "sha256-aE35YzfCrPPiBoCOKt0/GLd/Qar0Qq2VtUuC5XrY2Qk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "eae82ed71467a19374437376fbb7f5e3ad486aeb", + "rev": "5fcfdd4990ab907895fe9bcb1e2e4083d92ca670", "type": "github" }, "original": { @@ -110,11 +110,11 @@ "nixpkgs-stable": [] }, "locked": { - "lastModified": 1703991717, - "narHash": "sha256-XfBg2dmDJXPQEB8EdNBnzybvnhswaiAkUeeDj7fa/hQ=", + "lastModified": 1704908274, + "narHash": "sha256-74W9Yyomv3COGRmKi8zvyA5tL2KLiVkBeaYmYLjXyOw=", "owner": "Mic92", "repo": "sops-nix", - "rev": "cfdbaf68d00bc2f9e071f17ae77be4b27ff72fa6", + "rev": "c0b3a5af90fae3ba95645bbf85d2b64880addd76", "type": "github" }, "original": { @@ -130,11 +130,11 @@ ] }, "locked": { - "lastModified": 1702979157, - "narHash": "sha256-RnFBbLbpqtn4AoJGXKevQMCGhra4h6G2MPcuTSZZQ+g=", + "lastModified": 1704649711, + "narHash": "sha256-+qxqJrZwvZGilGiLQj3QbYssPdYCwl7ejwMImgH7VBQ=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "2961375283668d867e64129c22af532de8e77734", + "rev": "04f25d7bec9fb29d2c3bacaa48a3304840000d36", "type": "github" }, "original": { diff --git a/pkgs/aemu/default.nix b/pkgs/aemu/default.nix deleted file mode 100644 index eba4eab17..000000000 --- a/pkgs/aemu/default.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ clangStdenv -, fetchgit -, cmake -, lib -}: - -clangStdenv.mkDerivation { - pname = "aemu"; - version = "unstable-2023-08-31"; - src = fetchgit { - url = "https://android.googlesource.com/platform/hardware/google/aemu"; - rev = "caf5a079f321b6c60ab7b4bf6e5516378c6a7b37"; - hash = "sha256-JE0w9/1cSXDIfyISxE/CHv35gv1xyNwbrW24rAKAZVs="; - }; - cmakeFlags = [ - "-DAEMU_COMMON_GEN_PKGCONFIG=ON" - "-DAEMU_COMMON_BUILD_CONFIG=gfxstream" - ]; - nativeBuildInputs = [ cmake ]; - - meta = with lib; { - description = "Utility library for common functions used in the Android Emulator"; - homepage = "https://android.googlesource.com/platform/hardware/google/aemu"; - license = licenses.asl20; - platforms = platforms.linux; - maintainers = [ maintainers.mic92 ]; - }; -} diff --git a/pkgs/flake-module.nix b/pkgs/flake-module.nix index 010f20ed1..d3844a504 100644 --- a/pkgs/flake-module.nix +++ b/pkgs/flake-module.nix @@ -15,16 +15,6 @@ pending-reviews = pkgs.callPackage ./pending-reviews { }; meshname = pkgs.callPackage ./meshname { }; } // lib.optionalAttrs pkgs.stdenv.isLinux { - aemu = pkgs.callPackage ./aemu { }; - gfxstream = pkgs.callPackage ./gfxstream { - inherit (config.packages) aemu; - }; - rutabaga-gfx-ffi = pkgs.callPackage ./rutabaga-gfx-ffi { - inherit (config.packages) gfxstream aemu; - }; - qemu-wayland = pkgs.callPackage ./qemu-wayland { - inherit (config.packages) rutabaga-gfx-ffi; - }; wayland-proxy-virtwl = pkgs.callPackage ./wayland-proxy-virtwl { }; }; }; diff --git a/pkgs/gfxstream/default.nix b/pkgs/gfxstream/default.nix deleted file mode 100644 index e50cbf21b..000000000 --- a/pkgs/gfxstream/default.nix +++ /dev/null @@ -1,60 +0,0 @@ -{ clangStdenv -, fetchgit -, aemu -, meson -, pkg-config -, ninja -, python3 -, vulkan-headers -, vulkan-utility-libraries -, glm -, libglvnd -, xorg -, lib -, vulkan-loader -}: - -clangStdenv.mkDerivation { - pname = "gfxstream"; - version = "unstable-2023-12-19"; - src = fetchgit { - url = "https://android.googlesource.com/platform/hardware/google/gfxstream"; - rev = "5ef37b16f4777f6052903ffcdf96ad0bb87e1572"; - hash = "sha256-xUKDGTwF05oojuFhs1ruDPmRdOnkGuYo4IK7KdTYZ0k="; - }; - postPatch = '' - ln -s common/etc/etc.cpp host/compressedTextureFormats/etc.cpp - ln -s common/etc/etc.cpp host/gl/glestranslator/GLcommon/etc.cpp - ''; - preConfigure = '' - export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$(pwd)/common/etc/include" - ''; - buildInputs = [ - aemu - glm - libglvnd - vulkan-headers - vulkan-utility-libraries - xorg.libX11 - ]; - mesonFlags = [ - "-Ddecoders=gles,vulkan,composer" - ]; - postFixup = '' - patchelf --set-rpath "$(patchelf --print-rpath "$f"):${vulkan-loader}/lib" "$out/lib/libgfxstream_backend.so" - ''; - nativeBuildInputs = [ - meson - pkg-config - ninja - python3 - ]; - - meta = with lib; { - description = "Graphics Streaming Kit is a code generator that makes it easier to serialize and forward graphics API calls i.e. for remote rendering."; - homepage = "https://android.googlesource.com/platform/hardware/google/gfxstream"; - license = licenses.asl20; - platforms = platforms.linux; - maintainers = with maintainers; [ mic92 ]; - }; -} diff --git a/pkgs/qemu-wayland/default.nix b/pkgs/qemu-wayland/default.nix deleted file mode 100644 index d5210105b..000000000 --- a/pkgs/qemu-wayland/default.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ qemu_kvm, rutabaga-gfx-ffi, fetchurl }: -qemu_kvm.overrideAttrs (old: { - src = fetchurl { - url = "https://download.qemu.org/qemu-8.2.0.tar.xz"; - hash = "sha256-vwDS+hIBDfiwrekzcd71jmMssypr/cX1oP+Oah+xvzI="; - }; - - buildInputs = old.buildInputs ++ [ rutabaga-gfx-ffi ]; -}) diff --git a/pkgs/rutabaga-gfx-ffi/0001-rutabaga_gfx-don-t-clone-wayland-memfd-file-descript.patch b/pkgs/rutabaga-gfx-ffi/0001-rutabaga_gfx-don-t-clone-wayland-memfd-file-descript.patch deleted file mode 100644 index 764cc0415..000000000 --- a/pkgs/rutabaga-gfx-ffi/0001-rutabaga_gfx-don-t-clone-wayland-memfd-file-descript.patch +++ /dev/null @@ -1,68 +0,0 @@ -From 4cbcc9a9dab2a88d864e19000fdffd7623540002 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= -Date: Thu, 7 Dec 2023 17:09:28 +0100 -Subject: [PATCH 1/3] rutabaga_gfx: don't clone wayland memfd file descriptor -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -After cloning these file descriptor mmap will fail on the new file descriptor. -This results in mmap errors. - -Signed-off-by: Jörg Thalheim ---- - rutabaga_gfx/src/rutabaga_core.rs | 3 +-- - rutabaga_gfx/src/rutabaga_os/memory_mapping.rs | 2 +- - rutabaga_gfx/src/rutabaga_os/sys/linux/memory_mapping.rs | 2 +- - 3 files changed, 3 insertions(+), 4 deletions(-) - -diff --git a/rutabaga_gfx/src/rutabaga_core.rs b/rutabaga_gfx/src/rutabaga_core.rs -index 740f840fd..8361ec067 100644 ---- a/rutabaga_gfx/src/rutabaga_core.rs -+++ b/rutabaga_gfx/src/rutabaga_core.rs -@@ -757,7 +757,6 @@ pub fn map(&mut self, resource_id: u32) -> RutabagaResult { - )); - } - -- let clone = handle.try_clone()?; - let resource_size: usize = resource.size.try_into()?; - let map_info = resource - .map_info -@@ -765,7 +764,7 @@ pub fn map(&mut self, resource_id: u32) -> RutabagaResult { - - // Creating the mapping closes the cloned descriptor. - let mapping = MemoryMapping::from_safe_descriptor( -- clone.os_handle, -+ &handle.os_handle, - resource_size, - map_info, - )?; -diff --git a/rutabaga_gfx/src/rutabaga_os/memory_mapping.rs b/rutabaga_gfx/src/rutabaga_os/memory_mapping.rs -index d15fe81bd..885c6c9d8 100644 ---- a/rutabaga_gfx/src/rutabaga_os/memory_mapping.rs -+++ b/rutabaga_gfx/src/rutabaga_os/memory_mapping.rs -@@ -13,7 +13,7 @@ pub struct MemoryMapping { - - impl MemoryMapping { - pub fn from_safe_descriptor( -- descriptor: SafeDescriptor, -+ descriptor: &SafeDescriptor, - size: usize, - map_info: u32, - ) -> RutabagaResult { -diff --git a/rutabaga_gfx/src/rutabaga_os/sys/linux/memory_mapping.rs b/rutabaga_gfx/src/rutabaga_os/sys/linux/memory_mapping.rs -index 7eeb33f40..6d9f19124 100644 ---- a/rutabaga_gfx/src/rutabaga_os/sys/linux/memory_mapping.rs -+++ b/rutabaga_gfx/src/rutabaga_os/sys/linux/memory_mapping.rs -@@ -39,7 +39,7 @@ fn drop(&mut self) { - - impl MemoryMapping { - pub fn from_safe_descriptor( -- descriptor: SafeDescriptor, -+ descriptor: &SafeDescriptor, - size: usize, - map_info: u32, - ) -> RutabagaResult { --- -2.42.0 - diff --git a/pkgs/rutabaga-gfx-ffi/0002-rutabaga_gfx-super-ugly-workaround-to-get-private-ke.patch b/pkgs/rutabaga-gfx-ffi/0002-rutabaga_gfx-super-ugly-workaround-to-get-private-ke.patch deleted file mode 100644 index 408127a69..000000000 --- a/pkgs/rutabaga-gfx-ffi/0002-rutabaga_gfx-super-ugly-workaround-to-get-private-ke.patch +++ /dev/null @@ -1,75 +0,0 @@ -From cfeedccee6c6e7c309369b5dc37b6525aac859b6 Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= -Date: Thu, 7 Dec 2023 18:45:37 +0100 -Subject: [PATCH 2/3] rutabaga_gfx: super ugly workaround to get private - keyboard resources forwarded -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -Signed-off-by: Jörg Thalheim ---- - .../rutabaga_os/sys/linux/memory_mapping.rs | 34 +++++++++++++++++-- - 1 file changed, 32 insertions(+), 2 deletions(-) - -diff --git a/rutabaga_gfx/src/rutabaga_os/sys/linux/memory_mapping.rs b/rutabaga_gfx/src/rutabaga_os/sys/linux/memory_mapping.rs -index 6d9f19124..afd8771c8 100644 ---- a/rutabaga_gfx/src/rutabaga_os/sys/linux/memory_mapping.rs -+++ b/rutabaga_gfx/src/rutabaga_os/sys/linux/memory_mapping.rs -@@ -9,6 +9,7 @@ - use nix::sys::mman::munmap; - use nix::sys::mman::MapFlags; - use nix::sys::mman::ProtFlags; -+use nix::errno::Errno; - - use crate::rutabaga_os::descriptor::SafeDescriptor; - use crate::rutabaga_utils::RutabagaError; -@@ -55,14 +56,43 @@ pub fn from_safe_descriptor( - // TODO(b/315870313): Add safety comment - #[allow(clippy::undocumented_unsafe_blocks)] - let addr = unsafe { -- mmap( -+ let mut res = mmap( - None, - non_zero_size, - prot, - MapFlags::MAP_SHARED, - Some(descriptor), - 0, -- )? -+ ); -+ if let Err(Errno::EPERM) = res { -+ if prot == ProtFlags::PROT_READ { -+ let tmp = mmap( -+ None, -+ non_zero_size, -+ ProtFlags::PROT_READ, -+ MapFlags::MAP_PRIVATE, -+ Some(descriptor), -+ 0)?; -+ -+ let addr = libc::mmap( -+ std::ptr::null_mut(), -+ non_zero_size.into(), -+ libc::PROT_READ|libc::PROT_WRITE, -+ libc::MAP_SHARED | libc::MAP_ANONYMOUS, -+ -1, -+ 0); -+ -+ if addr == libc::MAP_FAILED { -+ munmap(tmp, non_zero_size.into()).unwrap(); -+ return Err(RutabagaError::SpecViolation("failed to mmap")); -+ } else { -+ std::ptr::copy_nonoverlapping(tmp, addr, non_zero_size.into()); -+ munmap(tmp, non_zero_size.into()).unwrap(); -+ res = Ok(addr); -+ } -+ } -+ } -+ res? - }; - Ok(MemoryMapping { addr, size }) - } else { --- -2.42.0 - diff --git a/pkgs/rutabaga-gfx-ffi/0003-rutabaga_gfx-fix-stale-cross-domain-keymap-resources.patch b/pkgs/rutabaga-gfx-ffi/0003-rutabaga_gfx-fix-stale-cross-domain-keymap-resources.patch deleted file mode 100644 index b7a124647..000000000 --- a/pkgs/rutabaga-gfx-ffi/0003-rutabaga_gfx-fix-stale-cross-domain-keymap-resources.patch +++ /dev/null @@ -1,204 +0,0 @@ -From 83d8aa249fb4cd221aa7dbb75403553d5c96e04b Mon Sep 17 00:00:00 2001 -From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= -Date: Thu, 14 Dec 2023 14:54:51 +0100 -Subject: [PATCH 3/3] rutabaga_gfx: fix stale cross-domain keymap resources -MIME-Version: 1.0 -Content-Type: text/plain; charset=UTF-8 -Content-Transfer-Encoding: 8bit - -when running vulkaninfo and other apps it seems that this resource -is requested multiple times and it fails after the first time. -After this patch vulkaninfo no longer produces any qemu errors. - -Signed-off-by: Jörg Thalheim ---- - rutabaga_gfx/src/cross_domain/mod.rs | 155 ++++++++++++--------------- - 1 file changed, 68 insertions(+), 87 deletions(-) - -diff --git a/rutabaga_gfx/src/cross_domain/mod.rs b/rutabaga_gfx/src/cross_domain/mod.rs -index 260c1b6b7..2a1fb00e3 100644 ---- a/rutabaga_gfx/src/cross_domain/mod.rs -+++ b/rutabaga_gfx/src/cross_domain/mod.rs -@@ -69,7 +69,7 @@ pub enum CrossDomainToken { - - pub(crate) enum CrossDomainItem { - ImageRequirements(ImageMemoryRequirements), -- WaylandKeymap(SafeDescriptor), -+ WaylandKeymap(Arc), - #[allow(dead_code)] // `WaylandReadPipe` is never constructed on Windows. - WaylandReadPipe(File), - WaylandWritePipe(File), -@@ -340,7 +340,10 @@ fn handle_fence( - *identifier = match *identifier_type { - CROSS_DOMAIN_ID_TYPE_VIRTGPU_BLOB => add_item( - &self.item_state, -- CrossDomainItem::WaylandKeymap(file.into()), -+ CrossDomainItem::WaylandKeymap(Arc::new(RutabagaHandle { -+ os_handle: file.into(), -+ handle_type: RUTABAGA_MEM_HANDLE_TYPE_SHM, -+ })), - ), - CROSS_DOMAIN_ID_TYPE_WRITE_PIPE => add_item( - &self.item_state, -@@ -670,95 +673,73 @@ fn context_create_blob( - ) -> RutabagaResult { - let item_id = resource_create_blob.blob_id as u32; - -- // We don't want to remove requirements blobs, since they can be used for subsequent -- // allocations. We do want to remove Wayland keymaps, since they are mapped the guest -- // and then never used again. The current protocol encodes this as divisiblity by 2. -- if item_id % 2 == 0 { -- let items = self.item_state.lock().unwrap(); -- let item = items -- .table -- .get(&item_id) -- .ok_or(RutabagaError::InvalidCrossDomainItemId)?; -- -- match item { -- CrossDomainItem::ImageRequirements(reqs) => { -- if reqs.size != resource_create_blob.size { -- return Err(RutabagaError::SpecViolation("blob size mismatch")); -- } -- -- // Strictly speaking, it's against the virtio-gpu spec to allocate memory in the context -- // create blob function, which says "the actual allocation is done via -- // VIRTIO_GPU_CMD_SUBMIT_3D." However, atomic resource creation is easiest for the -- // cross-domain use case, so whatever. -- let hnd = match handle_opt { -- Some(handle) => handle, -- None => self.gralloc.lock().unwrap().allocate_memory(*reqs)?, -- }; -- -- let info_3d = Resource3DInfo { -- width: reqs.info.width, -- height: reqs.info.height, -- drm_fourcc: reqs.info.drm_format.into(), -- strides: reqs.strides, -- offsets: reqs.offsets, -- modifier: reqs.modifier, -- guest_cpu_mappable: (resource_create_blob.blob_flags -- & RUTABAGA_BLOB_FLAG_USE_MAPPABLE) -- != 0, -- }; -+ let items = self.item_state.lock().unwrap(); -+ let item = items -+ .table -+ .get(&item_id) -+ .ok_or(RutabagaError::InvalidCrossDomainItemId)?; - -- Ok(RutabagaResource { -- resource_id, -- handle: Some(Arc::new(hnd)), -- blob: true, -- blob_mem: resource_create_blob.blob_mem, -- blob_flags: resource_create_blob.blob_flags, -- map_info: Some(reqs.map_info | RUTABAGA_MAP_ACCESS_RW), -- info_2d: None, -- info_3d: Some(info_3d), -- vulkan_info: reqs.vulkan_info, -- backing_iovecs: None, -- component_mask: 1 << (RutabagaComponentType::CrossDomain as u8), -- size: resource_create_blob.size, -- mapping: None, -- }) -- } -- _ => Err(RutabagaError::InvalidCrossDomainItemType), -+ match item { -+ CrossDomainItem::WaylandKeymap(handle) => { -+ Ok(RutabagaResource { -+ resource_id, -+ handle: Some(Arc::clone(handle)), -+ blob: true, -+ blob_mem: resource_create_blob.blob_mem, -+ blob_flags: resource_create_blob.blob_flags, -+ map_info: Some(RUTABAGA_MAP_CACHE_CACHED | RUTABAGA_MAP_ACCESS_READ), -+ info_2d: None, -+ info_3d: None, -+ vulkan_info: None, -+ backing_iovecs: None, -+ component_mask: 1 << (RutabagaComponentType::CrossDomain as u8), -+ size: resource_create_blob.size, -+ mapping: None, -+ }) - } -- } else { -- let item = self -- .item_state -- .lock() -- .unwrap() -- .table -- .remove(&item_id) -- .ok_or(RutabagaError::InvalidCrossDomainItemId)?; -- -- match item { -- CrossDomainItem::WaylandKeymap(descriptor) => { -- let hnd = RutabagaHandle { -- os_handle: descriptor, -- handle_type: RUTABAGA_MEM_HANDLE_TYPE_SHM, -- }; -- -- Ok(RutabagaResource { -- resource_id, -- handle: Some(Arc::new(hnd)), -- blob: true, -- blob_mem: resource_create_blob.blob_mem, -- blob_flags: resource_create_blob.blob_flags, -- map_info: Some(RUTABAGA_MAP_CACHE_CACHED | RUTABAGA_MAP_ACCESS_READ), -- info_2d: None, -- info_3d: None, -- vulkan_info: None, -- backing_iovecs: None, -- component_mask: 1 << (RutabagaComponentType::CrossDomain as u8), -- size: resource_create_blob.size, -- mapping: None, -- }) -+ CrossDomainItem::ImageRequirements(reqs) => { -+ if reqs.size != resource_create_blob.size { -+ return Err(RutabagaError::SpecViolation("blob size mismatch")); - } -- _ => Err(RutabagaError::InvalidCrossDomainItemType), -+ -+ // Strictly speaking, it's against the virtio-gpu spec to allocate memory in the context -+ // create blob function, which says "the actual allocation is done via -+ // VIRTIO_GPU_CMD_SUBMIT_3D." However, atomic resource creation is easiest for the -+ // cross-domain use case, so whatever. -+ let hnd = match handle_opt { -+ Some(handle) => handle, -+ None => self.gralloc.lock().unwrap().allocate_memory(*reqs)?, -+ }; -+ -+ let info_3d = Resource3DInfo { -+ width: reqs.info.width, -+ height: reqs.info.height, -+ drm_fourcc: reqs.info.drm_format.into(), -+ strides: reqs.strides, -+ offsets: reqs.offsets, -+ modifier: reqs.modifier, -+ guest_cpu_mappable: (resource_create_blob.blob_flags -+ & RUTABAGA_BLOB_FLAG_USE_MAPPABLE) -+ != 0, -+ }; -+ -+ Ok(RutabagaResource { -+ resource_id, -+ handle: Some(Arc::new(hnd)), -+ blob: true, -+ blob_mem: resource_create_blob.blob_mem, -+ blob_flags: resource_create_blob.blob_flags, -+ map_info: Some(reqs.map_info | RUTABAGA_MAP_ACCESS_RW), -+ info_2d: None, -+ info_3d: Some(info_3d), -+ vulkan_info: reqs.vulkan_info, -+ backing_iovecs: None, -+ component_mask: 1 << (RutabagaComponentType::CrossDomain as u8), -+ size: resource_create_blob.size, -+ mapping: None, -+ }) - } -+ id => Err(RutabagaError::InvalidCrossDomainItemType), - } - } - --- -2.42.0 - diff --git a/pkgs/rutabaga-gfx-ffi/Cargo.lock b/pkgs/rutabaga-gfx-ffi/Cargo.lock deleted file mode 100644 index 2ffebbd35..000000000 --- a/pkgs/rutabaga-gfx-ffi/Cargo.lock +++ /dev/null @@ -1,222 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "anyhow" -version = "1.0.75" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4668cab20f66d8d020e1fbc0ebe47217433c1b6c8f2040faf858554e394ace6" - -[[package]] -name = "autocfg" -version = "1.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" - -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - -[[package]] -name = "byteorder" -version = "1.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" - -[[package]] -name = "cfg-if" -version = "1.0.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" - -[[package]] -name = "libc" -version = "0.2.150" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "89d92a4743f9a61002fae18374ed11e7973f530cb3a3255fb354818118b2203c" - -[[package]] -name = "log" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e6163cb8c49088c2c36f57875e58ccd8c87c7427f7fbd50ea6710b2f3f2e8f" - -[[package]] -name = "memoffset" -version = "0.7.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5de893c32cde5f383baa4c04c5d6dbdd735cfd4a794b0debdb2bb1b421da5ff4" -dependencies = [ - "autocfg", -] - -[[package]] -name = "nix" -version = "0.26.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "598beaf3cc6fdd9a5dfb1630c2800c7acd31df7aaf0f565796fba2b53ca1af1b" -dependencies = [ - "bitflags", - "cfg-if", - "libc", - "memoffset", - "pin-utils", -] - -[[package]] -name = "once_cell" -version = "1.18.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dd8b5dd2ae5ed71462c540258bedcb51965123ad7e7ccf4b9a8cafaa4a63576d" - -[[package]] -name = "pin-utils" -version = "0.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" - -[[package]] -name = "pkg-config" -version = "0.3.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" - -[[package]] -name = "proc-macro2" -version = "1.0.70" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" -dependencies = [ - "unicode-ident", -] - -[[package]] -name = "quote" -version = "1.0.33" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" -dependencies = [ - "proc-macro2", -] - -[[package]] -name = "remain" -version = "0.2.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bce3a7139d2ee67d07538ee5dba997364fbc243e7e7143e96eb830c74bfaa082" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "rutabaga_gfx" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "450c21b372f2bc0adafa01a5293a5b8ed2f1b691b373a97a9c60367e75c07b6d" -dependencies = [ - "anyhow", - "cfg-if", - "libc", - "log", - "nix", - "pkg-config", - "remain", - "thiserror", - "winapi", - "zerocopy", -] - -[[package]] -name = "rutabaga_gfx_ffi" -version = "0.1.2" -dependencies = [ - "libc", - "log", - "once_cell", - "rutabaga_gfx", -] - -[[package]] -name = "syn" -version = "2.0.39" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "thiserror" -version = "1.0.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" -dependencies = [ - "thiserror-impl", -] - -[[package]] -name = "thiserror-impl" -version = "1.0.50" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - -[[package]] -name = "unicode-ident" -version = "1.0.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" - -[[package]] -name = "winapi" -version = "0.3.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" -dependencies = [ - "winapi-i686-pc-windows-gnu", - "winapi-x86_64-pc-windows-gnu", -] - -[[package]] -name = "winapi-i686-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" - -[[package]] -name = "winapi-x86_64-pc-windows-gnu" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" - -[[package]] -name = "zerocopy" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "96f8f25c15a0edc9b07eb66e7e6e97d124c0505435c382fde1ab7ceb188aa956" -dependencies = [ - "byteorder", - "zerocopy-derive", -] - -[[package]] -name = "zerocopy-derive" -version = "0.6.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "855e0f6af9cd72b87d8a6c586f3cb583f5cdcc62c2c80869d8cd7e96fdf7ee20" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] diff --git a/pkgs/rutabaga-gfx-ffi/default.nix b/pkgs/rutabaga-gfx-ffi/default.nix deleted file mode 100644 index 1555047bc..000000000 --- a/pkgs/rutabaga-gfx-ffi/default.nix +++ /dev/null @@ -1,49 +0,0 @@ -{ aemu -, rustPlatform -, fetchFromGitHub -, pkg-config -, gfxstream -, libdrm -, lib -}: - -rustPlatform.buildRustPackage { - pname = "rutabaga_gfx_ffi"; - version = "unstable-2023-12-20"; - - src = fetchFromGitHub { - owner = "google"; - repo = "crosvm"; - rev = "46279a0c03f8892f22ebd8c0dc19e4a6dc8aac41"; - hash = "sha256-xHT3uWPGVqXFr5G08jliti5RXSsZLb6fH8eiy8cyzNY="; - fetchSubmodules = true; - }; - - patches = [ - ./0001-rutabaga_gfx-don-t-clone-wayland-memfd-file-descript.patch - ./0002-rutabaga_gfx-super-ugly-workaround-to-get-private-ke.patch - ./0003-rutabaga_gfx-fix-stale-cross-domain-keymap-resources.patch - ]; - - buildPhase = '' - cd rutabaga_gfx/ffi - make build - ''; - - installPhase = '' - make install prefix=$out - ''; - - cargoHash = "sha256-lOC0bK/nePSQCkxKHjD6xAVyvx0xGRFm/5+2jEKfwQs="; - - nativeBuildInputs = [ pkg-config ]; - buildInputs = [ gfxstream aemu libdrm ]; - - meta = with lib; { - description = "FFI bindings for rutabaga_gfx"; - homepage = "https://crosvm.dev/book/appendix/rutabaga_gfx.html"; - license = licenses.bsd3; - platforms = platforms.linux; - maintainers = with maintainers; [ mic92 ]; - }; -}