From patchwork Thu Mar 9 08:51:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 13167028 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CA007C6FD1F for ; Thu, 9 Mar 2023 08:51:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.508184.782562 (Exim 4.92) (envelope-from ) id 1paBzZ-00076G-1y; Thu, 09 Mar 2023 08:51:17 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 508184.782562; Thu, 09 Mar 2023 08:51:17 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1paBzY-00075F-Ux; Thu, 09 Mar 2023 08:51:16 +0000 Received: by outflank-mailman (input) for mailman id 508184; Thu, 09 Mar 2023 08:51:16 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1paBzY-0006zN-Gz for xen-devel@lists.xen.org; Thu, 09 Mar 2023 08:51:16 +0000 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [2607:f8b0:4864:20::102a]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 8a139105-be57-11ed-956e-85ef70e17bfa; Thu, 09 Mar 2023 09:51:12 +0100 (CET) Received: by mail-pj1-x102a.google.com with SMTP id bo22so1450936pjb.4 for ; Thu, 09 Mar 2023 00:51:11 -0800 (PST) Received: from localhost ([122.172.83.155]) by smtp.gmail.com with ESMTPSA id v18-20020aa78092000000b00597caf6236esm10571382pff.150.2023.03.09.00.51.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 00:51:09 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8a139105-be57-11ed-956e-85ef70e17bfa DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678351870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=+i0w9WqIL9ZPbYW/Yv5TskuJR8MxXHPruOqgSTtE0fY=; b=iItvA+MzNT8mtvCs1pj16AOETtyxbqTr+dOV2gyWwiGrlDOUIbmxTiVtMssA8AGSe0 ssXoV06reFUqYX2L4ZPPv+dz1lqMKrTx/PmWKAVmXdGbnIPKewkh+WMrQqAfgB2QnUmE 6pce2D05X0M5Rm2lNGjZv2+sO2UvA6ycCKlOZAoJ7oKmBRYWtg8+kWW4FNwwe9mg6PdC LrPJ7WaEqhbB1p9bzfp1xqEVNvIMjvFwn0LyF53RZDubZ8foPyhpJUEygKc8wzSNPnj6 pJJ4ZeIPwh9sx//Y+qpgWODeO8siuMaVzploDGKCpQBmmMn0zcZb5j2UYyaA7qG3sx61 VU5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678351870; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=+i0w9WqIL9ZPbYW/Yv5TskuJR8MxXHPruOqgSTtE0fY=; b=PlwDVkniaDhtkY5cAsRakc9LlX3XzHPwLjGEt7uSt3SMJuzwTRI1C63jVxRQDKJAoR 1bRYyFgpMBZKozsOIvcqfJ0DmfDlFlrVccBqlofBMu/KSrmIASX2BiSE6a1E6+WtvT4a H2Q7jZQ0Dv5C06gRF/m8SoeVfUJFvNX2JUnYDYryd7Qw3HgvJSRf/YMDgcVwEZlgIv+J DoPUUgjtUeNz1KInA+LOmUJm+WTRql5UcLWSNYL0JSI2vbMI/ohxNmQkBWz8/KiSyOWq 3AgQsXHXUJzu7sboWISkLv1PERtSmcvAwybV2DBSfatHrShaPW4uPpUqlyjlQbIFiMuG EOzQ== X-Gm-Message-State: AO0yUKXg8m2hftUWbacbiJwOeXPWOnEUZH3pbtWnBgbk0lmOrXJLdRz3 RBaMWmUskd4/h1SSG4VeLSmWCQ== X-Google-Smtp-Source: AK7set8ftWQHv1D5/0RoFpnuh7BmT9reUnqkwdpkJf4bmvLnd2t//tccurlO9OTQd3vpqPWi5PediQ== X-Received: by 2002:a05:6a20:6a9e:b0:cc:f047:afaf with SMTP id bi30-20020a056a206a9e00b000ccf047afafmr18297962pzb.11.1678351869994; Thu, 09 Mar 2023 00:51:09 -0800 (PST) From: Viresh Kumar To: qemu-devel@nongnu.org, virtio-dev@lists.oasis-open.org, Stefan Hajnoczi , "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: [PATCH V3 1/2] docs: vhost-user: Define memory region separately Date: Thu, 9 Mar 2023 14:21:00 +0530 Message-Id: <7c3718e5eb99178b22696682ae73aca6df1899c7.1678351495.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 The same layout is defined twice, once in "single memory region description" and then in "memory regions description". Separate out details of memory region from these two and reuse the same definition later on. While at it, also rename "memory regions description" to "multiple memory regions description", to avoid potential confusion around similar names. And define single region before multiple ones. This is just a documentation optimization, the protocol remains the same. Signed-off-by: Viresh Kumar Reviewed-by: Stefan Hajnoczi Reviewed-by: Alex Bennée --- docs/interop/vhost-user.rst | 39 +++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 8a5924ea75ab..1720d681264d 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -130,18 +130,8 @@ A vring address description Note that a ring address is an IOVA if ``VIRTIO_F_IOMMU_PLATFORM`` has been negotiated. Otherwise it is a user address. -Memory regions description -^^^^^^^^^^^^^^^^^^^^^^^^^^ - -+-------------+---------+---------+-----+---------+ -| num regions | padding | region0 | ... | region7 | -+-------------+---------+---------+-----+---------+ - -:num regions: a 32-bit number of regions - -:padding: 32-bit - -A region is: +Memory region description +^^^^^^^^^^^^^^^^^^^^^^^^^ +---------------+------+--------------+-------------+ | guest address | size | user address | mmap offset | @@ -158,19 +148,26 @@ Memory regions description Single memory region description ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -+---------+---------------+------+--------------+-------------+ -| padding | guest address | size | user address | mmap offset | -+---------+---------------+------+--------------+-------------+ ++---------+--------+ +| padding | region | ++---------+--------+ :padding: 64-bit -:guest address: a 64-bit guest address of the region +A region is represented by Memory region description. -:size: a 64-bit size +Multiple Memory regions description +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -:user address: a 64-bit user address ++-------------+---------+---------+-----+---------+ +| num regions | padding | region0 | ... | region7 | ++-------------+---------+---------+-----+---------+ -:mmap offset: 64-bit offset where region starts in the mapped memory +:num regions: a 32-bit number of regions + +:padding: 32-bit + +A region is represented by Memory region description. Log description ^^^^^^^^^^^^^^^ @@ -952,8 +949,8 @@ Front-end message types ``VHOST_USER_SET_MEM_TABLE`` :id: 5 :equivalent ioctl: ``VHOST_SET_MEM_TABLE`` - :request payload: memory regions description - :reply payload: (postcopy only) memory regions description + :request payload: multiple memory regions description + :reply payload: (postcopy only) multiple memory regions description Sets the memory map regions on the back-end so it can translate the vring addresses. In the ancillary data there is an array of file From patchwork Thu Mar 9 08:51:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 13167030 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id DC012C74A5B for ; Thu, 9 Mar 2023 08:51:29 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.508183.782558 (Exim 4.92) (envelope-from ) id 1paBzY-00072t-Qa; Thu, 09 Mar 2023 08:51:16 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 508183.782558; Thu, 09 Mar 2023 08:51:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1paBzY-00072m-Nc; Thu, 09 Mar 2023 08:51:16 +0000 Received: by outflank-mailman (input) for mailman id 508183; Thu, 09 Mar 2023 08:51:15 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1paBzX-0006nh-49 for xen-devel@lists.xen.org; Thu, 09 Mar 2023 08:51:15 +0000 Received: from mail-pl1-x62b.google.com (mail-pl1-x62b.google.com [2607:f8b0:4864:20::62b]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 8bb1fc1b-be57-11ed-87f5-c1b5be75604c; Thu, 09 Mar 2023 09:51:14 +0100 (CET) Received: by mail-pl1-x62b.google.com with SMTP id h8so1235545plf.10 for ; Thu, 09 Mar 2023 00:51:14 -0800 (PST) Received: from localhost ([122.172.83.155]) by smtp.gmail.com with ESMTPSA id kt16-20020a170903089000b0019a7385079esm11058153plb.123.2023.03.09.00.51.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Mar 2023 00:51:12 -0800 (PST) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 8bb1fc1b-be57-11ed-87f5-c1b5be75604c DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1678351873; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ETLRpO4UaRJv+Jq2cQ1jDXzLWWERHBPOjdPoPBs2HQY=; b=kaY7yb4BgtrBRVTJaGL5YIn9l8IoTa4lyVgMiGE+LSI7rvLuSg3awOMLMnJLOKt+lH W6d6qR1BZdYIAWI86ipKF6SAvHJt12FDfZXzQex6uuHUqOU7GSMF4kJO+V+fxbDxpS9X 1dJ3CqLWQIk1MgmIX8taEexVVxGkBm/1PAv3hF+VF4Dlx80Hf3qHflMdy/POb2dqLAQn i69WPePj9IV5csX+pp+JjQj9I7BQIWVsygdYSUfiVRefrtYWhnYRgXKGdJIOd+6SyfKz C27SGThUJCnUOCTvUfZydDQw+hvdAW4FM7Ke9ONCK8itnaWY98VCIDjqH3mAa3AaK+0A 026g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678351873; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ETLRpO4UaRJv+Jq2cQ1jDXzLWWERHBPOjdPoPBs2HQY=; b=bb3Ui6ubpIkJokpN6QE8HXIdtxxjChW9KclDwjhshlHb7LdXwIgPMpi6s2/EXozJIk ESwX86wVecZTO9bbZ9bra9MXMuSPHh19IpI730w0ZB4gxhBMM0JVcz3gx+CEiJ4U2kYn wdSv6Kmb7O6SOw2gVlqibJWLisZFobkM+/ptdtAE95qhSrAOOG//kpp6dENGSJq1g+Yg UEcP+4n4umfm/XZ5t3VoRLnfd9DouPbhFtghqo2geAlkoFNc2HbhA8vMFz4eApKpOXfH 4esuYwY3xTeU85CabOQ7RZbO6wA4yFVM7pO/EWnNn7Vu7ll+SI7MoGID7ASNSQr0rqlS 4aXA== X-Gm-Message-State: AO0yUKXkf/dFMCCcOZeuqINOm5b700xOPyJDPoWK1Vs5jxouKwtfxVsj YBFEZKTKEX4VYmt5qB+92VMA1g== X-Google-Smtp-Source: AK7set/6Djb1zMP9YhPTkWppkZDJ0L3CO0duyd+NyeHjm4Zil4YeTAqUaIBzL/6AzT6fjqaHkZW0kA== X-Received: by 2002:a17:902:c14c:b0:19d:74c:78e4 with SMTP id 12-20020a170902c14c00b0019d074c78e4mr18866811plj.55.1678351872801; Thu, 09 Mar 2023 00:51:12 -0800 (PST) From: Viresh Kumar To: qemu-devel@nongnu.org, virtio-dev@lists.oasis-open.org, Stefan Hajnoczi , "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: [PATCH V3 2/2] docs: vhost-user: Add Xen specific memory mapping support Date: Thu, 9 Mar 2023 14:21:01 +0530 Message-Id: <6d0bd7f0e1aeec3ddb603ae4ff334c75c7d0d7b3.1678351495.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 2.31.1.272.g89b43f80a514 In-Reply-To: References: MIME-Version: 1.0 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(), with extra information 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 will send the additional information within the memory regions themselves. Signed-off-by: Viresh Kumar Reviewed-by: Stefan Hajnoczi Reviewed-by: Alex Bennée --- docs/interop/vhost-user.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/interop/vhost-user.rst b/docs/interop/vhost-user.rst index 1720d681264d..5a070adbc1aa 100644 --- a/docs/interop/vhost-user.rst +++ b/docs/interop/vhost-user.rst @@ -145,6 +145,26 @@ Memory region description :mmap offset: 64-bit offset where region starts in the mapped memory +When the ``VHOST_USER_PROTOCOL_F_XEN_MMAP`` protocol feature has been +successfully negotiated, the memory region description contains two extra +fields at the end. + ++---------------+------+--------------+-------------+----------------+-------+ +| guest address | size | user address | mmap offset | xen mmap flags | domid | ++---------------+------+--------------+-------------+----------------+-------+ + +:xen mmap flags: 32-bit bit field + +- Bit 0 is set for Xen foreign memory mapping. +- Bit 1 is set for Xen grant memory mapping. +- Bit 8 is set if the memory region can not be mapped in advance, and memory + areas within this region must be mapped / unmapped only when required by the + back-end. The back-end shouldn't try to map the entire region at once, as the + front-end may not allow it. The back-end should rather map only the required + amount of memory at once and unmap it after it is used. + +:domid: a 32-bit Xen hypervisor specific domain id. + Single memory region description ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -864,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_XEN_MMAP 17 Front-end message types -----------------------