From nobody Thu May 16 01:44:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1618211218; cv=none; d=zohomail.com; s=zohoarc; b=j4jEhzj1UAVhRHV4onFwYUxwyxVLWSY0ex4W3RmAatF2EMn5VMf9OiUNyqF9aiKUgP89MuQeaRhGtGTvBT0aJ+xx0SBVbk3fgsJfEWIXxPskA6zOMfvb/J2BYEhnFJso4ltx8S44nDlQSYsdoIaW0uo9/Duu1PuHjt+wCH7jZxE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618211218; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qxcYnKFE1mz7PV+WVepuZK0eXes0j/aWj5sbhD8flgs=; b=W6BZpCm2rH+mRRD3IzUAJDo4VDTZUXIlr1+pk71MaGV+4d8jZtTpghoD0rU0Qqo4PtmwitBQlrk4XjIFKzDoA7TVL27OqjtfseKrXINU42wKNQeHNYGPXJaH8YdRB39z1yjPQk3XpPmlpvXqhl2U4vx6b+35MUHvSCgYpLLQ+bI= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161821121810161.81865299226433; Mon, 12 Apr 2021 00:06:58 -0700 (PDT) Received: from localhost ([::1]:49170 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lVqeu-00045N-Do for importer@patchew.org; Mon, 12 Apr 2021 03:06:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42044) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVqZz-0001Hx-PF; Mon, 12 Apr 2021 03:01:51 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:41303) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVqZw-0000ur-Rb; Mon, 12 Apr 2021 03:01:51 -0400 Received: from compute2.internal (compute2.nyi.internal [10.202.2.42]) by mailout.nyi.internal (Postfix) with ESMTP id 5B8F55C008B; Mon, 12 Apr 2021 03:01:46 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Mon, 12 Apr 2021 03:01:46 -0400 Received: from apples.local (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by mail.messagingengine.com (Postfix) with ESMTPA id 89DF9240054; Mon, 12 Apr 2021 03:01:44 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; s=fm2; bh= qxcYnKFE1mz7PV+WVepuZK0eXes0j/aWj5sbhD8flgs=; b=YlXZlI61QIxn1r0Y IkH8YROPRksLpKOThEotiylxtIWfbsgrVS8e5CxlrsGgBwfYEJc6JTgY9Dxgj8ve KUNmxNHzWFH8ejLxhrSWe8gQ+nv2qbTlVjkl2gXvm8zi3LqYABUCOGaGVWrO9Jr5 kE7mSZWIv87A8+HRyy9wfbD8ZoRiEXqQIKhxwr6eBPpgE1PluIP98+Iubmy2AXaO AcEfr7HcFoxUPYKO9W1lTEM89YYjbqpBmZgMigzG+xAliMrrVqMLcO4Z8X9rdEKO Z1CFf4bbMxTF2ZoFui912Ylbhsme64IV5RKNDax4zFpcZAWskQ6fwq7OeOehuiKD j110jA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; bh=qxcYnKFE1mz7PV+WVepuZK0eXes0j/aWj5sbhD8fl gs=; b=m8AOCRgHX2uuW9pvnfAZzQ1q/Gp+C1nlH/dpTUQOTYb6RXOc1jzyIn9PY J8cDjRbtydGNo7XUsGuINa2M69pgfE12kBPchQtEEXZJbkNsL56EeymZxINEY1GX jACPd3/98YolAgW9I6nCI++3SHuwZE0h0d8leOQbkD3KIR8UJ0p30rTyu80Lnl+n VfxX+LUu5P6+O4vdLzI/M79GTt1mVl/CZQ213KRqGPbjdAjEXGBaThQhvF2PRiXc Nkgo6Q95m4HfKv0I+md6t20641gs6u1Fz2mQ3zI3+iprvO1bEidZ8FOEBLTJX47J c/EHPO+7qLrJD+l7kLEnnKNeg9WSw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudekiedguddufecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhggtgfgsehtkeertdertdejnecuhfhrohhmpefmlhgr uhhsucflvghnshgvnhcuoehithhssehirhhrvghlvghvrghnthdrughkqeenucggtffrrg htthgvrhhnpeeufeeggfeludelgffghfduvddvteeiheeikefgleefjefgtdduffdtgeff vddvueenucffohhmrghinhepnhhvmhgvgihprhgvshhsrdhorhhgpdhinhhfrhgruggvrg gurdhorhhgnecukfhppeektddrudeijedrleekrdduledtnecuvehluhhsthgvrhfuihii vgeptdenucfrrghrrghmpehmrghilhhfrhhomhepihhtshesihhrrhgvlhgvvhgrnhhtrd gukh X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL for-6.0 1/4] docs: add nvme emulation documentation Date: Mon, 12 Apr 2021 09:01:38 +0200 Message-Id: <20210412070141.521593-2-its@irrelevant.dk> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412070141.521593-1-its@irrelevant.dk> References: <20210412070141.521593-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.26; envelope-from=its@irrelevant.dk; helo=out2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Klaus Jensen , Max Reitz , Keith Busch , Klaus Jensen , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" From: Klaus Jensen Remove the docs/specs/nvme.txt and replace it with proper documentation in docs/system/nvme.rst. Signed-off-by: Klaus Jensen Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/specs/nvme.txt | 23 ----- docs/system/index.rst | 1 + docs/system/nvme.rst | 225 ++++++++++++++++++++++++++++++++++++++++++ MAINTAINERS | 2 +- 4 files changed, 227 insertions(+), 24 deletions(-) delete mode 100644 docs/specs/nvme.txt create mode 100644 docs/system/nvme.rst diff --git a/docs/specs/nvme.txt b/docs/specs/nvme.txt deleted file mode 100644 index 56d393884e7a..000000000000 --- a/docs/specs/nvme.txt +++ /dev/null @@ -1,23 +0,0 @@ -NVM Express Controller -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - -The nvme device (-device nvme) emulates an NVM Express Controller. - - -Reference Specifications ------------------------- - -The device currently implements most mandatory features of NVMe v1.3d, see - - https://nvmexpress.org/resources/specifications/ - -for the specification. - - -Known issues ------------- - -* The accounting numbers in the SMART/Health are reset across power cycles - -* Interrupt Coalescing is not supported and is disabled by default in vola= tion - of the specification. diff --git a/docs/system/index.rst b/docs/system/index.rst index 02d07071810f..b05af716a973 100644 --- a/docs/system/index.rst +++ b/docs/system/index.rst @@ -23,6 +23,7 @@ Contents: net virtio-net-failover usb + nvme ivshmem linuxboot generic-loader diff --git a/docs/system/nvme.rst b/docs/system/nvme.rst new file mode 100644 index 000000000000..f7f63d6bf615 --- /dev/null +++ b/docs/system/nvme.rst @@ -0,0 +1,225 @@ +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +NVMe Emulation +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +QEMU provides NVMe emulation through the ``nvme``, ``nvme-ns`` and +``nvme-subsys`` devices. + +See the following sections for specific information on + + * `Adding NVMe Devices`_, `additional namespaces`_ and `NVM subsystems`_. + * Configuration of `Optional Features`_ such as `Controller Memory Buffe= r`_, + `Simple Copy`_, `Zoned Namespaces`_, `metadata`_ and `End-to-End Data + Protection`_, + +Adding NVMe Devices +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Controller Emulation +-------------------- + +The QEMU emulated NVMe controller implements version 1.4 of the NVM Express +specification. All mandatory features are implement with a couple of excep= tions +and limitations: + + * Accounting numbers in the SMART/Health log page are reset when the dev= ice + is power cycled. + * Interrupt Coalescing is not supported and is disabled by default. + +The simplest way to attach an NVMe controller on the QEMU PCI bus is to ad= d the +following parameters: + +.. code-block:: console + + -drive file=3Dnvm.img,if=3Dnone,id=3Dnvm + -device nvme,serial=3Ddeadbeef,drive=3Dnvm + +There are a number of optional general parameters for the ``nvme`` device.= Some +are mentioned here, but see ``-device nvme,help`` to list all possible +parameters. + +``max_ioqpairs=3DUINT32`` (default: ``64``) + Set the maximum number of allowed I/O queue pairs. This replaces the + deprecated ``num_queues`` parameter. + +``msix_qsize=3DUINT16`` (default: ``65``) + The number of MSI-X vectors that the device should support. + +``mdts=3DUINT8`` (default: ``7``) + Set the Maximum Data Transfer Size of the device. + +``use-intel-id`` (default: ``off``) + Since QEMU 5.2, the device uses a QEMU allocated "Red Hat" PCI Device and + Vendor ID. Set this to ``on`` to revert to the unallocated Intel ID + previously used. + +Additional Namespaces +--------------------- + +In the simplest possible invocation sketched above, the device only suppor= t a +single namespace with the namespace identifier ``1``. To support multiple +namespaces and additional features, the ``nvme-ns`` device must be used. + +.. code-block:: console + + -device nvme,id=3Dnvme-ctrl-0,serial=3Ddeadbeef + -drive file=3Dnvm-1.img,if=3Dnone,id=3Dnvm-1 + -device nvme-ns,drive=3Dnvm-1 + -drive file=3Dnvm-2.img,if=3Dnone,id=3Dnvm-2 + -device nvme-ns,drive=3Dnvm-2 + +The namespaces defined by the ``nvme-ns`` device will attach to the most +recently defined ``nvme-bus`` that is created by the ``nvme`` device. Name= space +identifers are allocated automatically, starting from ``1``. + +There are a number of parameters available: + +``nsid`` (default: ``0``) + Explicitly set the namespace identifier. + +``uuid`` (default: *autogenerated*) + Set the UUID of the namespace. This will be reported as a "Namespace UUI= D" + descriptor in the Namespace Identification Descriptor List. + +``bus`` + If there are more ``nvme`` devices defined, this parameter may be used to + attach the namespace to a specific ``nvme`` device (identified by an ``i= d`` + parameter on the controller device). + +NVM Subsystems +-------------- + +Additional features becomes available if the controller device (``nvme``) = is +linked to an NVM Subsystem device (``nvme-subsys``). + +The NVM Subsystem emulation allows features such as shared namespaces and +multipath I/O. + +.. code-block:: console + + -device nvme-subsys,id=3Dnvme-subsys-0,nqn=3Dsubsys0 + -device nvme,serial=3Da,subsys=3Dnvme-subsys-0 + -device nvme,serial=3Db,subsys=3Dnvme-subsys-0 + +This will create an NVM subsystem with two controllers. Having controllers +linked to an ``nvme-subsys`` device allows additional ``nvme-ns`` paramete= rs: + +``shared`` (default: ``off``) + Specifies that the namespace will be attached to all controllers in the + subsystem. If set to ``off`` (the default), the namespace will remain a + private namespace and may only be attached to a single controller at a t= ime. + +``detached`` (default: ``off``) + If set to ``on``, the namespace will be be available in the subsystem, b= ut + not attached to any controllers initially. + +Thus, adding + +.. code-block:: console + + -drive file=3Dnvm-1.img,if=3Dnone,id=3Dnvm-1 + -device nvme-ns,drive=3Dnvm-1,nsid=3D1,shared=3Don + -drive file=3Dnvm-2.img,if=3Dnone,id=3Dnvm-2 + -device nvme-ns,drive=3Dnvm-2,nsid=3D3,detached=3Don + +will cause NSID 1 will be a shared namespace (due to ``shared=3Don``) that= is +initially attached to both controllers. NSID 3 will be a private namespace +(i.e. only attachable to a single controller at a time) and will not be +attached to any controller initially (due to ``detached=3Don``). + +Optional Features +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +Controller Memory Buffer +------------------------ + +``nvme`` device parameters related to the Controller Memory Buffer support: + +``cmb_size_mb=3DUINT32`` (default: ``0``) + This adds a Controller Memory Buffer of the given size at offset zero in= BAR + 2. + +``legacy-cmb`` (default: ``off``) + By default, the device uses the "v1.4 scheme" for the Controller Memory + Buffer support (i.e, the CMB is initially disabled and must be explicitly + enabled by the host). Set this to ``on`` to behave as a v1.3 device wrt.= the + CMB. + +Simple Copy +----------- + +The device includes support for TP 4065 ("Simple Copy Command"). A number = of +additional ``nvme-ns`` device parameters may be used to control the Copy +command limits: + +``mssrl=3DUINT16`` (default: ``128``) + Set the Maximum Single Source Range Length (``MSSRL``). This is the maxi= mum + number of logical blocks that may be specified in each source range. + +``mcl=3DUINT32`` (default: ``128``) + Set the Maximum Copy Length (``MCL``). This is the maximum number of log= ical + blocks that may be specified in a Copy command (the total for all source + ranges). + +``msrc=3DUINT8`` (default: ``127``) + Set the Maximum Source Range Count (``MSRC``). This is the maximum numbe= r of + source ranges that may be used in a Copy command. This is a 0's based va= lue. + +Zoned Namespaces +---------------- + +A namespaces may be "Zoned" as defined by TP 4053 ("Zoned Namespaces"). Set +``zoned=3Don`` on an ``nvme-ns`` device to configure it as a zoned namespa= ce. + +The namespace may be configured with additional parameters + +``zoned.zone_size=3DSIZE`` (default: ``128MiB``) + Define the zone size (``ZSZE``). + +``zoned.zone_capacity=3DSIZE`` (default: ``0``) + Define the zone capacity (``ZCAP``). If left at the default (``0``), the= zone + capacity will equal the zone size. + +``zoned.descr_ext_size=3DUINT32`` (default: ``0``) + Set the Zone Descriptor Extension Size (``ZDES``). Must be a multiple of= 64 + bytes. + +``zoned.cross_read=3DBOOL`` (default: ``off``) + Set to ``on`` to allow reads to cross zone boundaries. + +``zoned.max_active=3DUINT32`` (default: ``0``) + Set the maximum number of active resources (``MAR``). The default (``0``) + allows all zones to be active. + +``zoned.max_open=3DUINT32`` (default: ``0``) + Set the maximum number of open resources (``MOR``). The default (``0``) + allows all zones to be open. If ``zoned.max_active`` is specified, this = value + must be less than or equal to that. + +Metadata +-------- + +The virtual namespace device supports LBA metadata in the form separate +metadata (``MPTR``-based) and extended LBAs. + +``ms=3DUINT16`` (default: ``0``) + Defines the number of metadata bytes per LBA. + +``mset=3DUINT8`` (default: ``0``) + Set to ``1`` to enable extended LBAs. + +End-to-End Data Protection +-------------------------- + +The virtual namespace device supports DIF- and DIX-based protection inform= ation +(depending on ``mset``). + +``pi=3DUINT8`` (default: ``0``) + Enable protection information of the specified type (type ``1``, ``2`` or + ``3``). + +``pil=3DUINT8`` (default: ``0``) + Controls the location of the protection information within the metadata.= Set + to ``1`` to transfer protection information as the first eight bytes of + metadata. Otherwise, the protection information is transferred as the la= st + eight bytes. diff --git a/MAINTAINERS b/MAINTAINERS index 58f342108e9e..04beb34e7ec4 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1974,7 +1974,7 @@ S: Supported F: hw/block/nvme* F: include/block/nvme.h F: tests/qtest/nvme-test.c -F: docs/specs/nvme.txt +F: docs/system/nvme.rst T: git git://git.infradead.org/qemu-nvme.git nvme-next =20 megasas --=20 2.31.1 From nobody Thu May 16 01:44:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1618211808; cv=none; d=zohomail.com; s=zohoarc; b=LA6k4iSh6MfKlE+s2yWp3mkRMG6wm+jnSzxtKN9i/ys4P5rvQJ+piUey2ABKVB8cx2JsB/i2aI11vRRCvfwUSyDalRa4SP/XUYacdv4pWHeE+26vwJDrSkFkuv9Rup9SZxiRrRgEzVoe34lkcvUpTZr6h4cMAIqciyZxjNwxO5k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618211808; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/CEJA/YAR48FT9+ttjSyf+0MgTH7ZgkpEno9B+yacrc=; b=fzXJm7CX6D5ekJ0xNHomFJBUNrpY4OyFOaBKyt6ycQrSr8sN57YKr3QVKBiWK02ldTfrIfyuCHeKZJ53KR18g02Fz5GX0Aji+eRJT07c2WDiRDH1skcQK7JxT5N74tBYNjc8yUawRRlQZD1R6fC8Xv/+Bo2WIma21o3MDBi9h7M= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1618211808728451.7088685760664; Mon, 12 Apr 2021 00:16:48 -0700 (PDT) Received: from localhost ([::1]:33088 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lVqoR-00018b-K5 for importer@patchew.org; Mon, 12 Apr 2021 03:16:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42054) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVqa0-0001Iz-Df; Mon, 12 Apr 2021 03:01:52 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:47263) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVqZx-0000va-5p; Mon, 12 Apr 2021 03:01:52 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 358505C00B0; Mon, 12 Apr 2021 03:01:47 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 12 Apr 2021 03:01:47 -0400 Received: from apples.local (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by mail.messagingengine.com (Postfix) with ESMTPA id E153C240057; Mon, 12 Apr 2021 03:01:45 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=/CEJA/YAR48FT 9+ttjSyf+0MgTH7ZgkpEno9B+yacrc=; b=AsNDZatE9Us02xHMQpwHTGO4W6cDZ h1FUUHz8uoe1IPUEEN0tBrPAS/hFA/8HqvTBVPL+vuJoRV9OLLBlQV4Y6HT/zEG1 XNsSPXTGZwsYWb2ot/E3aDmO4+lhsJM8ZEMtU3XL9DIjns1lBmbcFxzlD1qdwuhg ZrBPPnGi1SGRBcc7UDrMiXDirmFKvq1Iq+WyQca3rF19Djo66wh71SznXmjUOG4V LV500zziwguSkZx+SE7myYb+wRtwMIOTcnQa7DI0wuAk4hrqbSdprM8gUxynmtXg F+1MwMryT0ehCB/t12CascYr3J9zi9AD6fl9RMT4cJ+8Pga58aFfHlDmA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=/CEJA/YAR48FT9+ttjSyf+0MgTH7ZgkpEno9B+yacrc=; b=omgurPdT rMB5OVKH8VgSlG7ZDxBtgascl1nbt95ryJBBvq+muc2qoBCpXWyN6A5g7zUJFW2d w+EqS/bGL44m+w6ULINosn0/LzoWYdInQNXXIHJWUoDjsrO8fERsee21EdG8RWMG qclwLq9mX9+zLngEdnDz8f2AXAq6x9NS++kdARtoMsw9Dy8uXXlOQn281Pf509vh rXsGEN5rMLaNIAie6wAIyERs/Aegb8pRLACk/dFHXve+MrzIRW9+aYZg8MXoNlLo myn9+k8iPPaGLYmA7u0cozIUDM02zgziTbJ0/2vgrZ8d+BUduUJ9EoZHX7tlXbv/ EYhoEIc3+CcMJg== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudekiedguddufecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepueelteegieeuhffgkeefgfevjeeigfetkeeitdfgtdeifefhtdfhfeeuffev gfeknecukfhppeektddrudeijedrleekrdduledtnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepihhtshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL for-6.0 2/4] hw/block/nvme: map prp fix if prp2 contains non-zero offset Date: Mon, 12 Apr 2021 09:01:39 +0200 Message-Id: <20210412070141.521593-3-its@irrelevant.dk> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412070141.521593-1-its@irrelevant.dk> References: <20210412070141.521593-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.26; envelope-from=its@irrelevant.dk; helo=out2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Klaus Jensen , Max Reitz , Keith Busch , Padmakar Kalghatgi , Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Padmakar Kalghatgi nvme_map_prp needs to calculate the number of list entries based on the offset value. For the subsequent PRP2 list, need to ensure the number of entries is within the MAX number of PRP entries for a page. Signed-off-by: Padmakar Kalghatgi Signed-off-by: Klaus Jensen --- hw/block/nvme.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 6b1f056a0ebc..86336152a378 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -655,7 +655,12 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, NvmeSg *sg, = uint64_t prp1, uint32_t nents, prp_trans; int i =3D 0; =20 - nents =3D (len + n->page_size - 1) >> n->page_bits; + /* + * The first PRP list entry, pointed to by PRP2 may contain of= fset. + * Hence, we need to calculate the number of entries in based = on + * that offset. + */ + nents =3D (n->page_size - (prp2 & (n->page_size - 1))) >> 3; prp_trans =3D MIN(n->max_prp_ents, nents) * sizeof(uint64_t); ret =3D nvme_addr_read(n, prp2, (void *)prp_list, prp_trans); if (ret) { @@ -666,7 +671,7 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, NvmeSg *sg, u= int64_t prp1, while (len !=3D 0) { uint64_t prp_ent =3D le64_to_cpu(prp_list[i]); =20 - if (i =3D=3D n->max_prp_ents - 1 && len > n->page_size) { + if (i =3D=3D nents - 1 && len > n->page_size) { if (unlikely(prp_ent & (n->page_size - 1))) { trace_pci_nvme_err_invalid_prplist_ent(prp_ent); status =3D NVME_INVALID_PRP_OFFSET | NVME_DNR; @@ -675,7 +680,8 @@ static uint16_t nvme_map_prp(NvmeCtrl *n, NvmeSg *sg, u= int64_t prp1, =20 i =3D 0; nents =3D (len + n->page_size - 1) >> n->page_bits; - prp_trans =3D MIN(n->max_prp_ents, nents) * sizeof(uin= t64_t); + nents =3D MIN(nents, n->max_prp_ents); + prp_trans =3D nents * sizeof(uint64_t); ret =3D nvme_addr_read(n, prp_ent, (void *)prp_list, prp_trans); if (ret) { --=20 2.31.1 From nobody Thu May 16 01:44:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1618211534; cv=none; d=zohomail.com; s=zohoarc; b=CDrDQY3Nc9qQqulkSqyCXObZTTWbndsbjnYKUDOgTPAyGGkCYi/nz7K61Dmhhgf2y5XpZRCFsa6p97Xiugn474tuxD+PVlZWhSC71mtxuO5cNnDIWeUb+HliffjgQbGNw2KNWA1VodYj7gbRg4LTkktXShDZgW9YzPU06PY2S/M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618211534; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=QLONTOFIWkVp7yK8a1EuNcdrv1jRQLPcI61rtcjCcxE=; b=E9Ns5IAlOWhPbMFtMZxqZLz3QJM+Rv0ZCz3SYzjp1wRXtTgH5vmMOfvXAh0j0FZg0wFrckzIS09uqqmiDo9UMlrEyDjmqPPZ7Jd/fW454utBUIbg0ZhyJfcZGNgI2Vljz3qZsZfW1HEKYB0eIwUmZVGI/4/F6HkGVFbr4L7k6Ho= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1618211533994934.564370549612; Mon, 12 Apr 2021 00:12:13 -0700 (PDT) Received: from localhost ([::1]:56844 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lVqk0-0007ZP-JY for importer@patchew.org; Mon, 12 Apr 2021 03:12:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42058) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVqa0-0001J7-LC; Mon, 12 Apr 2021 03:01:52 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:36081) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVqZx-0000wT-JL; Mon, 12 Apr 2021 03:01:52 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id A38205C00A5; Mon, 12 Apr 2021 03:01:48 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 12 Apr 2021 03:01:48 -0400 Received: from apples.local (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by mail.messagingengine.com (Postfix) with ESMTPA id 420B0240057; Mon, 12 Apr 2021 03:01:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=QLONTOFIWkVp7 yK8a1EuNcdrv1jRQLPcI61rtcjCcxE=; b=UnCZBNE8ib2rZKfdd9atV+5JNJYKJ YDkJiDwRbXktBW+p2wlCuBvQFRu/sEcIS9LdDfhJX3bZCoVxjX8DqaamCgIdscCq BL7ggH+sPM/qFBLYdnDv5oDVeeTlA8m+KpaNDwRyG01Z6HHw5sjoX+cAndj62iRJ JWCt7I5IZTG6e3VN3V8xIUcMQb5LE9FZP5tT1S84qGfcl0jundiurWSZxrwryG5t BsrBVXqL72wq7dXw3/+451+mmkoPpihjGv5oo2fflbQMpYRCLN0h7/lPhcbxycYf VNnRjrspbODPJ6gIStTU+52Umn2c5f0QZ5Z/KDaN8LzxANdz42ZJJaQiA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=QLONTOFIWkVp7yK8a1EuNcdrv1jRQLPcI61rtcjCcxE=; b=nu/Bgeso bQ5NqkzN6GiFiZ4OK/zpaFrsUnjetU3bF5Uz3mGASsHtbR1PJI0OhhAurYb3WmsO MBngSQZvgYmlwtPItckdkxPRrBQp7y9dIJPzSiyK/l5MISZ/HINfJNpVdgMsUYW9 5Tq1XpYcBe3uWwYOWPhUGAEni556LM6nITmgwj0hmmExXgQtp2+wXJ9Z9MtWJhRV RgmdpPBYzl1qMLInJ3p+yDJa3hOfxRwOX6EPFZ54vC6fqNvBBvOipLZRe87TxwBP u5a2p2PeKoyDWl6piS0ttg31C8R4vSpygkVpoPxHaXxI6sASYYYOZzmmSHN0+7K5 aLkE7iromSgwyw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudekiedguddufecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepueelteegieeuhffgkeefgfevjeeigfetkeeitdfgtdeifefhtdfhfeeuffev gfeknecukfhppeektddrudeijedrleekrdduledtnecuvehluhhsthgvrhfuihiivgepud enucfrrghrrghmpehmrghilhhfrhhomhepihhtshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL for-6.0 3/4] hw/block/nvme: store aiocb in compare Date: Mon, 12 Apr 2021 09:01:40 +0200 Message-Id: <20210412070141.521593-4-its@irrelevant.dk> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412070141.521593-1-its@irrelevant.dk> References: <20210412070141.521593-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.26; envelope-from=its@irrelevant.dk; helo=out2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Klaus Jensen , Gollu Appalanaidu , Max Reitz , Keith Busch , Minwoo Im , Klaus Jensen Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Klaus Jensen nvme_compare() fails to store the aiocb from the blk_aio_preadv() call. Fix this. Fixes: 0a384f923f51 ("hw/block/nvme: add compare command") Cc: Gollu Appalanaidu Signed-off-by: Klaus Jensen Reviewed-by: Gollu Appalanaidu Reviewed-by: Minwoo Im --- hw/block/nvme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 86336152a378..65bb2cfc21d7 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -2843,7 +2843,8 @@ static uint16_t nvme_compare(NvmeCtrl *n, NvmeRequest= *req) =20 block_acct_start(blk_get_stats(blk), &req->acct, data_len, BLOCK_ACCT_READ); - blk_aio_preadv(blk, offset, &ctx->data.iov, 0, nvme_compare_data_cb, r= eq); + req->aiocb =3D blk_aio_preadv(blk, offset, &ctx->data.iov, 0, + nvme_compare_data_cb, req); =20 return NVME_NO_COMPLETE; } --=20 2.31.1 From nobody Thu May 16 01:44:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1618211332; cv=none; d=zohomail.com; s=zohoarc; b=C856B5ZBE4+EZJnGkPyD5gGWTKue+0KG6aXWMAu3led5vLeqAsJMlffxzQ9nvBJzT0uUuiHZufIthDOnD1fN1/DR27tT/xqojDIrvZJ3XRfjGC44oN7BlnW16+fKxp0FBQGDmH7RQmVkl68wQSwAYv5dwlIdhuDjQwGFr3AkIL0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1618211332; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=qZSzm+tovoA8dCMHk+Jdzm94xRHG3eleFyAGs9vwcKU=; b=k2b7mVf5J4opveohI1Lrqq6Jwafg3FG/U/qyN9RjuUrk8rBQvYTxsHxsupTI44AC9N0fDydBssLCWioUSFKLcjaJV6nGmv1wOyIYGbdSD5ZrCwT3UTSiKXuV96s0r8Cnqovf1FsyKI1ax/f6h8xfWzI5YgcCCYFJ64Rfc+h09oA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 161821133209293.06909048674856; Mon, 12 Apr 2021 00:08:52 -0700 (PDT) Received: from localhost ([::1]:52764 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lVqgk-0005d7-U9 for importer@patchew.org; Mon, 12 Apr 2021 03:08:51 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVqa1-0001KQ-6a; Mon, 12 Apr 2021 03:01:53 -0400 Received: from new1-smtp.messagingengine.com ([66.111.4.221]:52753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lVqZz-0000xU-6B; Mon, 12 Apr 2021 03:01:52 -0400 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailnew.nyi.internal (Postfix) with ESMTP id 3961458083C; Mon, 12 Apr 2021 03:01:50 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Mon, 12 Apr 2021 03:01:50 -0400 Received: from apples.local (80-167-98-190-cable.dk.customer.tdc.net [80.167.98.190]) by mail.messagingengine.com (Postfix) with ESMTPA id B399A240057; Mon, 12 Apr 2021 03:01:48 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=irrelevant.dk; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=fm2; bh=qZSzm+tovoA8d CMHk+Jdzm94xRHG3eleFyAGs9vwcKU=; b=KXXTLsUeX4A8xqqY+SHm2iZFtgn8V D/oPyHicXvgerOtdfN1w/ZfFVkbGERkDRWPtKriSHvQneW9PRA1zpZtksEeiEGdd c0jTMWsvZhDSJRWsSfIH7/zCsrhzYML27CGtIg4F/9oCKNqZNXDzapUx7OLdiEPt C0+k6jOYWFoh6qCdwWUI1kQ65SluVZDLRvtAGzffmYoNqBCRTITmsNr/sPGxed3k tGn9P8xrrZUWaBdrkhzVgKininDeXPZ7PgNW5kzWBtbJUuDdjlASBz3h7YUUABx0 2++PzKUvDv97qS97/+ui0BCXle8JwGQ//Wlk2eAwrqV+CMppHhFByYQHg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :in-reply-to:message-id:mime-version:references:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; bh=qZSzm+tovoA8dCMHk+Jdzm94xRHG3eleFyAGs9vwcKU=; b=jeaAAilw jldmnTyU+cvjgtsQCEHOxNtiiGZlEqBlJwXS8eiaiwXGDcT25L96Kpo32VJ6qPWv 85EOJvbHVAfnqmZrxSmUoaaV2L72LvhZHjZrATCUmLJrWW5C74UrD1a4CrO1VzSL JBs7CpouiWLguMA52pXgFwrJZaG3WxG5pSzimsdTXg5n0u5WQ/QZu733lbyUK8nc 1clrabLlUkqBEaovgeBxFX9DJxK3rWZWcdWT0znpUnCWGUcIse9MDUDsNbdgPZHX spTwQbbWjMTuSq386pxNtY3RaoSErhQfJOae9sngZZ1qtlbdxCDWEVnGDNNZV0VW GpNfjo7Lk9T9/Q== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrudekiedguddufecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufffkofgjfhgggfestdekredtredttdenucfhrhhomhepmfhlrghu shculfgvnhhsvghnuceoihhtshesihhrrhgvlhgvvhgrnhhtrdgukheqnecuggftrfgrth htvghrnhepueelteegieeuhffgkeefgfevjeeigfetkeeitdfgtdeifefhtdfhfeeuffev gfeknecukfhppeektddrudeijedrleekrdduledtnecuvehluhhsthgvrhfuihiivgepud enucfrrghrrghmpehmrghilhhfrhhomhepihhtshesihhrrhgvlhgvvhgrnhhtrdgukh X-ME-Proxy: From: Klaus Jensen To: qemu-devel@nongnu.org, peter.maydell@linaro.org Subject: [PULL for-6.0 4/4] hw/block/nvme: drain namespaces on sq deletion Date: Mon, 12 Apr 2021 09:01:41 +0200 Message-Id: <20210412070141.521593-5-its@irrelevant.dk> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412070141.521593-1-its@irrelevant.dk> References: <20210412070141.521593-1-its@irrelevant.dk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.221; envelope-from=its@irrelevant.dk; helo=new1-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 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_LOW=-0.7, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , qemu-block@nongnu.org, Klaus Jensen , Gollu Appalanaidu , Max Reitz , Keith Busch , Minwoo Im , Klaus Jensen , Minwoo Im Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" From: Klaus Jensen For most commands, when issuing an AIO, the BlockAIOCB is stored in the NvmeRequest aiocb pointer when the AIO is issued. The main use of this is cancelling AIOs when deleting submission queues (it is currently not used for Abort). However, some commands like Dataset Management Zone Management Send (zone reset) may involve more than one AIO and here the AIOs are issued without saving a reference to the BlockAIOCB. This is a problem since nvme_del_sq() will attempt to cancel outstanding AIOs, potentially with an invalid BlockAIOCB since the aiocb pointer is not NULL'ed when the request structure is recycled. Fix this by 1. making sure the aiocb pointer is NULL'ed when requests are recycled 2. only attempt to cancel the AIO if the aiocb is non-NULL 3. if any AIOs could not be cancelled, drain all aio as a last resort. Fixes: dc04d25e2f3f ("hw/block/nvme: add support for the format nvm command= ") Fixes: c94973288cd9 ("hw/block/nvme: add broadcast nsid support flush comma= nd") Fixes: e4e430b3d6ba ("hw/block/nvme: add simple copy command") Fixes: 5f5dc4c6a942 ("hw/block/nvme: zero out zones on reset") Fixes: 2605257a26b8 ("hw/block/nvme: add the dataset management command") Cc: Gollu Appalanaidu Cc: Minwoo Im Signed-off-by: Klaus Jensen Reviewed-by: Minwoo Im --- hw/block/nvme.c | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/hw/block/nvme.c b/hw/block/nvme.c index 65bb2cfc21d7..624a1431d072 100644 --- a/hw/block/nvme.c +++ b/hw/block/nvme.c @@ -470,6 +470,7 @@ static void nvme_req_clear(NvmeRequest *req) { req->ns =3D NULL; req->opaque =3D NULL; + req->aiocb =3D NULL; memset(&req->cqe, 0x0, sizeof(req->cqe)); req->status =3D NVME_SUCCESS; } @@ -3687,6 +3688,7 @@ static uint16_t nvme_del_sq(NvmeCtrl *n, NvmeRequest = *req) NvmeSQueue *sq; NvmeCQueue *cq; uint16_t qid =3D le16_to_cpu(c->qid); + uint32_t nsid; =20 if (unlikely(!qid || nvme_check_sqid(n, qid))) { trace_pci_nvme_err_invalid_del_sq(qid); @@ -3698,9 +3700,26 @@ static uint16_t nvme_del_sq(NvmeCtrl *n, NvmeRequest= *req) sq =3D n->sq[qid]; while (!QTAILQ_EMPTY(&sq->out_req_list)) { r =3D QTAILQ_FIRST(&sq->out_req_list); - assert(r->aiocb); - blk_aio_cancel(r->aiocb); + if (r->aiocb) { + blk_aio_cancel(r->aiocb); + } } + + /* + * Drain all namespaces if there are still outstanding requests that we + * could not cancel explicitly. + */ + if (!QTAILQ_EMPTY(&sq->out_req_list)) { + for (nsid =3D 1; nsid <=3D NVME_MAX_NAMESPACES; nsid++) { + NvmeNamespace *ns =3D nvme_ns(n, nsid); + if (ns) { + nvme_ns_drain(ns); + } + } + } + + assert(QTAILQ_EMPTY(&sq->out_req_list)); + if (!nvme_check_cqid(n, sq->cqid)) { cq =3D n->cq[sq->cqid]; QTAILQ_REMOVE(&cq->sq_list, sq, entry); --=20 2.31.1