patches and low-level development discussion
 help / color / mirror / code / Atom feed
blob 2a846bfdec05d20ba68d6ca8ed175aa06321158d 3679 bytes (raw)
name: pkgs/cloud-hypervisor/vhost/0003-vhost_user-add-crosvm-shmem-map-compat.patch 	 # note: path name is non-authoritative(*)

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
 
From 4f0849043c9ef8d683f257f34e590a6842d7355c Mon Sep 17 00:00:00 2001
From: Colby Townsend <colby@colbyt.com>
Date: Fri, 26 Jun 2026 04:01:00 -0700
Subject: [PATCH] vhost_user: add crosvm SHMEM_MAP compatibility
SPDX-License-Identifier: Apache-2.0

crosvm's vhost-user GPU backend advertises the shared-memory mapping
protocol bit as SHMEM_MAP at 0x0010_0000.  rust-vmm/vhost 0.16 uses
SHMEM at 0x0020_0000 for the same GET_SHMEM_CONFIG and SHMEM_MAP/
SHMEM_UNMAP flow.

Accept either bit when checking local state, and expose the crosvm bit
name so frontends can negotiate with crosvm without sending an
unsupported protocol feature.

Signed-off-by: Colby Townsend <colby@colbyt.com>
---
 vhost-user-backend/src/handler.rs           | 4 +++-
 vhost/src/vhost_user/backend_req_handler.rs | 4 +++-
 vhost/src/vhost_user/frontend.rs            | 4 +++-
 vhost/src/vhost_user/message.rs             | 2 ++
 4 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/vhost-user-backend/src/handler.rs b/vhost-user-backend/src/handler.rs
index ea1fd6942..465dc2757 100644
--- a/vhost-user-backend/src/handler.rs
+++ b/vhost-user-backend/src/handler.rs
@@ -571,7 +571,9 @@ where
         if self.acked_protocol_features & VhostUserProtocolFeatures::SHARED_OBJECT.bits() != 0 {
             backend.set_shared_object_flag(true);
         }
-        if self.acked_protocol_features & VhostUserProtocolFeatures::SHMEM.bits() != 0 {
+        let shmem_features = VhostUserProtocolFeatures::SHMEM
+            | VhostUserProtocolFeatures::SHMEM_MAP;
+        if self.acked_protocol_features & shmem_features.bits() != 0 {
             backend.set_shmem_flag(true);
         }
         self.backend.set_backend_req_fd(backend);
diff --git a/vhost/src/vhost_user/backend_req_handler.rs b/vhost/src/vhost_user/backend_req_handler.rs
index d74b04558..fbe750c15 100644
--- a/vhost/src/vhost_user/backend_req_handler.rs
+++ b/vhost/src/vhost_user/backend_req_handler.rs
@@ -686,7 +686,9 @@ impl<S: VhostUserBackendReqHandler> BackendReqHandler<S> {
                 self.send_reply_message(&hdr, &msg)?;
             }
             Ok(FrontendReq::GET_SHMEM_CONFIG) => {
-                self.check_proto_feature(VhostUserProtocolFeatures::SHMEM)?;
+                self.check_proto_feature(
+                    VhostUserProtocolFeatures::SHMEM | VhostUserProtocolFeatures::SHMEM_MAP,
+                )?;
                 let msg = self.backend.get_shmem_config()?;
                 self.send_reply_message(&hdr, &msg)?;
             }
diff --git a/vhost/src/vhost_user/frontend.rs b/vhost/src/vhost_user/frontend.rs
index 195a6af1e..037f1b7f3 100644
--- a/vhost/src/vhost_user/frontend.rs
+++ b/vhost/src/vhost_user/frontend.rs
@@ -590,3 +590,5 @@ impl VhostUserFrontend for Frontend {
         let mut node = self.node();
-        node.check_proto_feature(VhostUserProtocolFeatures::SHMEM)?;
+        node.check_proto_feature(
+            VhostUserProtocolFeatures::SHMEM | VhostUserProtocolFeatures::SHMEM_MAP,
+        )?;
 
diff --git a/vhost/src/vhost_user/message.rs b/vhost/src/vhost_user/message.rs
index 5826d19a6..006f2e0fe 100644
--- a/vhost/src/vhost_user/message.rs
+++ b/vhost/src/vhost_user/message.rs
@@ -441,6 +441,8 @@ bitflags! {
         const DEVICE_STATE = 0x0008_0000;
         /// Support suspend in-flight I/O requests and record them
         const GET_VRING_BASE_INFLIGHT = 0x0010_0000;
+        /// crosvm name for the shared-memory mapping protocol bit.
+        const SHMEM_MAP = 0x0010_0000;
         /// Allow the backend to request file descriptors be mapped into virtio shared memory
         /// regions.
         const SHMEM = 0x0020_0000;
--
2.50.0

debug log:

solving 2a846bf ...
found 2a846bf in https://inbox.spectrum-os.org/spectrum-devel/20260626185509.3715326-7-colby@colbyt.com/

applying [1/1] https://inbox.spectrum-os.org/spectrum-devel/20260626185509.3715326-7-colby@colbyt.com/
diff --git a/pkgs/cloud-hypervisor/vhost/0003-vhost_user-add-crosvm-shmem-map-compat.patch b/pkgs/cloud-hypervisor/vhost/0003-vhost_user-add-crosvm-shmem-map-compat.patch
new file mode 100644
index 0000000..2a846bf

1:70: trailing whitespace.
 
Checking patch pkgs/cloud-hypervisor/vhost/0003-vhost_user-add-crosvm-shmem-map-compat.patch...
Applied patch pkgs/cloud-hypervisor/vhost/0003-vhost_user-add-crosvm-shmem-map-compat.patch cleanly.
warning: 1 line adds whitespace errors.

index at:
100644 2a846bfdec05d20ba68d6ca8ed175aa06321158d	pkgs/cloud-hypervisor/vhost/0003-vhost_user-add-crosvm-shmem-map-compat.patch

(*) Git path names are given by the tree(s) the blob belongs to.
    Blobs themselves have no identifier aside from the hash of its contents.^

Code repositories for project(s) associated with this public inbox

	https://spectrum-os.org/git/crosvm
	https://spectrum-os.org/git/doc
	https://spectrum-os.org/git/mktuntap
	https://spectrum-os.org/git/nixpkgs
	https://spectrum-os.org/git/spectrum
	https://spectrum-os.org/git/ucspi-vsock
	https://spectrum-os.org/git/www

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).