From patchwork Tue Feb 21 09:50:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 655372 Delivered-To: patch@linaro.org Received: by 2002:adf:9bcd:0:0:0:0:0 with SMTP id e13csp1870480wrc; Tue, 21 Feb 2023 01:52:12 -0800 (PST) X-Google-Smtp-Source: AK7set+A1/6dkzqbvAgJF0Wi/uvTMeSu5ALO8Ex6aaVYHu8CtAwa5E8GGALjklGw4cK3y13zQTFI X-Received: by 2002:a05:6214:f2e:b0:53a:6e21:5f6c with SMTP id iw14-20020a0562140f2e00b0053a6e215f6cmr7647941qvb.32.1676973132304; Tue, 21 Feb 2023 01:52:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676973132; cv=none; d=google.com; s=arc-20160816; b=pseoXJqtIZIqbkSe8SxDgal0zTA5ARYoQiCCGqV8NNE/DN6OAk1lubtnvnDbyAW7/W e18QN2HcD9kMKiKmnUcOVrlkfAP1Jd8ZYvPqBm1MU665I21xxwN1TqhnqvjzxRGhtRrA Ab6fRGQpWaLiuEZRcIxc99MJwrl85H7XnRvORYWLhr7+fKcipAJfD6gBPZc7lnB9KOEY XYbEBaSu0mvfq+xFS2mCVx6j2Sv15Mq87XZRBRnCX5KtXLj5acx//qXjYB3DYCd2sAlx MeRrzntme9kVuJyY7SjhfR3iHZMQ5dhsILJPy+m3IuRrRCJY2RNNpj7IPl2eLz+cjimD RRUw== 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=wNQkeraNsuw6hFISAboGasHi5jkq9Qw1lk2C7Y7QJNM=; b=h9F4qZrGF/Mf0529cu+RVZ+mPCBSMsu5Md6CyPMoKUdxn5AYlLHLPJf3AtR4NKP14e Cz0z2qqL8uLcCYzWDqKkEoyJmbtv+Q5gb78SX/VuDHPPVhNWOsnzIKc8rBEa9HElT1X1 +lRTf2QsiIg65/xPJrxZlAqgsb/CEepVadYNLXVJQk2JjUtlWZLAbc92oXbop6jtPWgl XQsQEPLA62S6DTyq9fM7UFiAHn+Z4bTcfVXv4sRfvgq1Ba1LlYTGg1bB2zFtmbGvWgVb X2T5M5BWYL9cIi6jR1GxPMzAfsiZRcbwp2Hsowq7qniUJYvgQ6C+2MLNf091AaalOCtO +gmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Sp7J+0CT; 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 c28-20020a0ca9dc000000b0056c0d156c35si2265458qvb.474.2023.02.21.01.52.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 21 Feb 2023 01:52:12 -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=Sp7J+0CT; 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 1pUPIy-0007SU-M2; Tue, 21 Feb 2023 04:51:24 -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 1pUPIp-0007El-LS for qemu-devel@nongnu.org; Tue, 21 Feb 2023 04:51:16 -0500 Received: from mail-pj1-x102c.google.com ([2607:f8b0:4864:20::102c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pUPIi-0006uu-94 for qemu-devel@nongnu.org; Tue, 21 Feb 2023 04:51:09 -0500 Received: by mail-pj1-x102c.google.com with SMTP id na9-20020a17090b4c0900b0023058bbd7b2so4114920pjb.0 for ; Tue, 21 Feb 2023 01:51:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=wNQkeraNsuw6hFISAboGasHi5jkq9Qw1lk2C7Y7QJNM=; b=Sp7J+0CTBva8aEj2O9RPa7/fe/vPPgO/x/0R35WMCIEt+K5/CuaIDpJV5pICjBM3i/ 7+YqI+uYKU28wB0J6rXEsxFspuixkueTtJC1QuHP618WlV+JcjMm7ok4BlQCOStrfpNM 2yQVECM/gqB9R4OI372Uh0Ob8q/K1DnWn1311m8zKpRNAwuAVkwMdZXA366q40fR2nt8 +kg02BiIzImPF1W3uJpLDlBacsl39TblpS4TdxtPbW5oVShvfF9GEySZukT2XuIVm+KG ppaGdIC0ARz6+iYjOoPQ3rYf6JzbmxSu+M/7nVry3YTqF5A1nug85vTy/hUml6ZvFuwm u/5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=wNQkeraNsuw6hFISAboGasHi5jkq9Qw1lk2C7Y7QJNM=; b=lu2nT0It7Y/adwmYrm2lFugry/beotgAuWhsICbAi/qwbJECgOTxoRmUeu4RmvhJPz HT0CtOu5Bb4QFo5sxx2+GTs9dVeJT8zpCkss4+7RIcx2pF3zoZsEHPml0Axt7EHz+IJV XOPVYtdkoYp6CBoLCZyrvkH///CiU+nLSFPf/zAHd8WP8mAsJNKpLJZMCGEF9VzWbXrR F0jDU0PcfK/2umvJTaLJ54OZ0krBwJ1F034mD0+n7ECDD/Q/yQg7OCq1enmSlM3WDY9h ZmR4oY2R17b1lBERl5sIcljqnHTeVM6xu2rjPMZtgOq5ZMAnSwFIxhxx50P8rcxrt6eM I8ug== X-Gm-Message-State: AO0yUKUv9C6+gNDd89sCTgK/L8O/LUWi2LsX0G0OX/YSKzq+vAp3Fhib nj043hldlPjmyrx0Hymmx5lhqfjRL/BiBI8m X-Received: by 2002:a17:902:ee91:b0:19a:b302:5158 with SMTP id a17-20020a170902ee9100b0019ab3025158mr4053751pld.29.1676973062371; Tue, 21 Feb 2023 01:51:02 -0800 (PST) Received: from localhost ([122.172.83.155]) by smtp.gmail.com with ESMTPSA id 17-20020a170902c21100b00199190b00efsm9493493pll.97.2023.02.21.01.51.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Feb 2023 01:51:01 -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 Subject: [RFC QEMU] docs: vhost-user: Add custom memory mapping support Date: Tue, 21 Feb 2023 15:20:41 +0530 Message-Id: X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::102c; envelope-from=viresh.kumar@linaro.org; helo=mail-pj1-x102c.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 with Qemu, where a standard call to mmap() for the respective file descriptor, passed from front-end, is generally all we need to do before the front-end can start accessing the guest memory. There are other complex cases though, where we need more information at the backend and need to do more than just an mmap() call. 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() followed by an ioctl() (or vice-versa), 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_CUSTOM_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_CUSTOM_MMAP' message type to provide the additional information to the back-end. Signed-off-by: Viresh Kumar Reviewed-by: Alex Bennée --- docs/interop/vhost-user.rst | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 3f18ab424eb0..f2b1d705593a 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -258,6 +258,23 @@ Inflight description :queue size: a 16-bit size of virtqueues +Custom mmap description +^^^^^^^^^^^^^^^^^^^^^^^ + ++-------+-------+ +| flags | value | ++-------+-------+ + +:flags: 64-bit bit field + +- Bit 0 is Xen foreign memory access flag - needs Xen foreign memory mapping. +- Bit 1 is Xen grant memory access flag - needs Xen grant memory mapping. + +:value: a 64-bit hypervisor specific value. + +- For Xen foreign or grant memory access, this is set with guest's xen domain + id. + C structure ----------- @@ -867,6 +884,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_CUSTOM_MMAP 17 Front-end message types ----------------------- @@ -1422,6 +1440,20 @@ Front-end message types query the back-end for its device status as defined in the Virtio specification. +``VHOST_USER_CUSTOM_MMAP`` + :id: 41 + :equivalent ioctl: N/A + :request payload: Custom mmap description + :reply payload: N/A + + When the ``VHOST_USER_PROTOCOL_F_CUSTOM_MMAP`` protocol feature has been + successfully negotiated, this message is submitted by the front-end to + notify the back-end of the special memory mapping requirements, that the + back-end needs to take care of, while mapping any memory regions sent + over by the front-end. 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. + Back-end message types ----------------------