From patchwork Mon Mar 6 11:10:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 659236 Delivered-To: patch@linaro.org Received: by 2002:adf:a3c6:0:0:0:0:0 with SMTP id m6csp1756070wrb; Mon, 6 Mar 2023 03:10:50 -0800 (PST) X-Google-Smtp-Source: AK7set/ZNMQCXh0hWWREm5qOAiXm7RJmy0vZkf/OWfXDIx34Zmt+ip7e7+QpCdlsMOA6eXjiwodH X-Received: by 2002:ad4:5c43:0:b0:56e:b21c:61e5 with SMTP id a3-20020ad45c43000000b0056eb21c61e5mr20069286qva.47.1678101050768; Mon, 06 Mar 2023 03:10:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678101050; cv=none; d=google.com; s=arc-20160816; b=ThyXVkZGcdQggUDrb9x+sir/wNLpPnPVG5iH0yAb1UGyy+90Y0xtR4nXpymNz7bgyy IlDWadZnKHftRR405S/FLH8Kb/In7Hy6y+Dqro79s21UiwHHVbRzXYEwq6zAwfCV/Nk1 YLSQs0MBzqwOnrvL3eUYQmx0xyAq15WpJS855OnsQ53A1utaGbEmtfwJFzNwOfW3dUIS k4R6qgP6rOg/Yy0f2HClWWIInmj3u2YGdC6qbpnhI4iVx8HO451mw8Vqdgrt1cwp2arO Jl+oOxj0mbgmYiwzTCqkHi+ew8ZixZDrMmlXRjreeG3JcnOY6tROEwM7KQDOmt/vTS1m O+iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=lzt81DQlpQsWvSvVQpEytEsQpJe9zI8mvbr2m91fVZY=; b=shD65haezt+8U1KXCWXbeSJUaqkDfYexjFGXNzZCAXgLmeL6iyrjIkmu5cxa8MdcVK Zr6wOGeg7gzA50mrwTeXIgO/9AUxt/+OF6JSLNtXVJ1+UlSsPGjP/e93ZK3KZqY4golb BzYP+LKEv1bHK9+WTbcyfZyMEQJlGju1tXfDMXytpXrkgt7XAKzf9IeNiKqtKRdYxrkv DRJvhkimOokH7p11OEIv3LUT6tg1lyKFcYgYTEdP/4Loi6ZOtd9BaF5zeVvsTqHOwDBG m2zySrtWUuZbM7AfA0GgexsHijcZvcvu3zAI7qiOlUuk7yhhkAiHkomdfsWR+X43AN6i zRlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KkADiyum; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q14-20020a0c8cce000000b0056ec2d9f293si6856997qvb.344.2023.03.06.03.10.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Mar 2023 03:10:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=KkADiyum; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pZ8jn-0002z0-Un; Mon, 06 Mar 2023 06:10:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pZ8jl-0002x3-Uy for qemu-devel@nongnu.org; Mon, 06 Mar 2023 06:10:37 -0500 Received: from mail-pl1-x630.google.com ([2607:f8b0:4864:20::630]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pZ8jj-0004LY-PL for qemu-devel@nongnu.org; Mon, 06 Mar 2023 06:10:37 -0500 Received: by mail-pl1-x630.google.com with SMTP id p20so9821899plw.13 for ; Mon, 06 Mar 2023 03:10:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678101034; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lzt81DQlpQsWvSvVQpEytEsQpJe9zI8mvbr2m91fVZY=; b=KkADiyumUMwnMwSZagTAmvDoqMmGCkviqQ5W3Ewa+3JcciWXtrok3LZkOQpgRqaWN8 iIraLBPdCrkwyfvvxTfFWrMD07MuMxJtjKz1BdtSHYJjAASZUi+LNNR8UHlYM772k1Xl RTyo+wE8i4TbHbQVvuW9wwSRWTQWvdQMKB9oMvQVba+RPf18ATxFLtn/K0H5L8izMZsH solmldOc/veuoYtEIY84nID8jNwgdBcj7JlCmIRn5YFhnyLHrCIGn6zU+UaMDrgOBhYW xkluFP3sUtX1hyDtiqhgUKPV7wQ+Quody+t3OAoNMG6vOR8/9RjgiU9E/Jm1Wcrwgk04 52VA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678101034; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lzt81DQlpQsWvSvVQpEytEsQpJe9zI8mvbr2m91fVZY=; b=V8Cn+EyrYBB5t0mN++s4lKmexnWHLys/dyg/H1rEiCy1OqcEBN6NerT2Z7BXGGaOXM gnmJC91doiLFu0430y76TuZdWgCeXUgCVYMXZd135NROsn9epZ9tTwUeDRCt/DuKfOWY B4oIFVqX3nhxXhOdpIh5kaCdwrSSz7bQSykKgpO65CGfBu2dbo6Z0DQu7YptSm1bokLm 3YkcCeLqfP0Qa6OJUBm9I0cdFNSN2huBuPv2oAluTF9gFNCasnPvugcJlZRV06rreew4 42fSfhhvbiZgv0R+Q51uftmUCBfD1sUGiNhT/IAGZzW9wqb6DL5Yy3IoO6cKC+3YZpV7 uW2Q== X-Gm-Message-State: AO0yUKUZGqWThcGF2OPzmCcVTXMJutLVEHxHjESgpg/EWGE38HNzy7NG UZAjPrElXSdkDthiD9wj2efnR6RCoxkiKbnKdK4= X-Received: by 2002:a17:903:18e:b0:19a:75b8:f4ff with SMTP id z14-20020a170903018e00b0019a75b8f4ffmr13424289plg.35.1678101033802; Mon, 06 Mar 2023 03:10:33 -0800 (PST) Received: from localhost ([122.172.83.155]) by smtp.gmail.com with ESMTPSA id ke13-20020a170903340d00b0019ea9e5815bsm4457935plb.45.2023.03.06.03.10.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Mar 2023 03:10:33 -0800 (PST) From: Viresh Kumar To: qemu-devel@nongnu.org, virtio-dev@lists.oasis-open.org, "Michael S. Tsirkin" Cc: Viresh Kumar , Vincent Guittot , =?utf-8?q?Alex_Benn=C3=A9e?= , stratos-dev@op-lists.linaro.org, Oleksandr Tyshchenko , xen-devel@lists.xen.org, Andrew Cooper , Juergen Gross , Sebastien Boeuf , Liu Jiang , Mathieu Poirier , Stefan Hajnoczi Subject: [PATCH V2] docs: vhost-user: Add Xen specific memory mapping support Date: Mon, 6 Mar 2023 16:40:24 +0530 Message-Id: <7c3c120bcf2cf023e873800fd3f55239dd302e38.1678100850.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::630; envelope-from=viresh.kumar@linaro.org; helo=mail-pl1-x630.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The current model of memory mapping at the back-end works fine where a standard call to mmap() (for the respective file descriptor) is enough before the front-end can start accessing the guest memory. There are other complex cases though where the back-end needs more information and simple mmap() isn't enough. For example Xen, a type-1 hypervisor, currently supports memory mapping via two different methods, foreign-mapping (via /dev/privcmd) and grant-dev (via /dev/gntdev). In both these cases, the back-end needs to call mmap() and ioctl(), and need to pass extra information via the ioctl(), like the Xen domain-id of the guest whose memory we are trying to map. Add a new protocol feature, 'VHOST_USER_PROTOCOL_F_XEN_MMAP', which lets the back-end know about the additional memory mapping requirements. When this feature is negotiated, the front-end can send the 'VHOST_USER_SET_XEN_MMAP' message type to provide the additional information to the back-end. Signed-off-by: Viresh Kumar --- V1->V2: - Make the custom mmap feature Xen specific, instead of being generic. - Clearly define which memory regions are impacted by this change. - Allow VHOST_USER_SET_XEN_MMAP to be called multiple times. - Additional Bit(2) property in flags. docs/interop/vhost-user.rst | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 3f18ab424eb0..8be5f5eae941 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -258,6 +258,24 @@ Inflight description :queue size: a 16-bit size of virtqueues +Xen mmap description +^^^^^^^^^^^^^^^^^^^^ + ++-------+-------+ +| flags | domid | ++-------+-------+ + +:flags: 64-bit bit field + +- Bit 0 is set for Xen foreign memory memory mapping. +- Bit 1 is set for Xen grant memory memory mapping. +- Bit 2 is set if the back-end can directly map additional memory (like + descriptor buffers or indirect descriptors, which aren't part of already + shared memory regions) without the need of front-end sending an additional + memory region first. + +:domid: a 64-bit Xen hypervisor specific domain id. + C structure ----------- @@ -867,6 +885,7 @@ Protocol features #define VHOST_USER_PROTOCOL_F_INBAND_NOTIFICATIONS 14 #define VHOST_USER_PROTOCOL_F_CONFIGURE_MEM_SLOTS 15 #define VHOST_USER_PROTOCOL_F_STATUS 16 + #define VHOST_USER_PROTOCOL_F_XEN_MMAP 17 Front-end message types ----------------------- @@ -1422,6 +1441,23 @@ Front-end message types query the back-end for its device status as defined in the Virtio specification. +``VHOST_USER_SET_XEN_MMAP`` + :id: 41 + :equivalent ioctl: N/A + :request payload: Xen mmap description + :reply payload: N/A + + When the ``VHOST_USER_PROTOCOL_F_XEN_MMAP`` protocol feature has been + successfully negotiated, this message is submitted by the front-end to set the + Xen hypervisor specific memory mapping configurations at the back-end. These + configurations should be used to mmap memory regions, virtqueues, descriptors + and descriptor buffers. The front-end must send this message before any + memory-regions are sent to the back-end via ``VHOST_USER_SET_MEM_TABLE`` or + ``VHOST_USER_ADD_MEM_REG`` message types. The front-end can send this message + multiple times, if different mmap configurations are required for different + memory regions, where the most recent ``VHOST_USER_SET_XEN_MMAP`` must be used + by the back-end to map any newly shared memory regions. + Back-end message types ----------------------