From patchwork Mon Nov 6 17:12:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Mikulas Patocka X-Patchwork-Id: 13447199 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 322D0C4332F for ; Mon, 6 Nov 2023 17:12:37 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A457B6B0182; Mon, 6 Nov 2023 12:12:36 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 9CF9E6B0183; Mon, 6 Nov 2023 12:12:36 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 848C56B0184; Mon, 6 Nov 2023 12:12:36 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 6DD8A6B0182 for ; Mon, 6 Nov 2023 12:12:36 -0500 (EST) Received: from smtpin16.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 3917DC07A8 for ; Mon, 6 Nov 2023 17:12:36 +0000 (UTC) X-FDA: 81428173512.16.9A3C7BB Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf17.hostedemail.com (Postfix) with ESMTP id F272E4000D for ; Mon, 6 Nov 2023 17:12:33 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WzHCMESu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of mpatocka@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mpatocka@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1699290754; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=xtsXGyrCZBmUJfCxzrPKMMdVxxHur1sL8JecsuLgwa0=; b=FWJGSObDWPK+VbeEoHV0qak2WAE/1tpufHxPtC+9u7hJlbQIPeAFc9PQ+UzBJvSKHPtYwM 8dwfYiSExCMWk1IJl1sKKfLrB/913H13Y9OxjNnvlJyJ0dUrELjA54jS8GG6Cp2f6hvXbP IW873qmkRNXnafN91kpBW4Yd3dLxOoE= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=WzHCMESu; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of mpatocka@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=mpatocka@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1699290754; a=rsa-sha256; cv=none; b=UxyMid7oM/1/As8v/gQZwxLnYgG5yjBnq3IIuVhR7biorl9isq2qpxEjcbEETJ3jF6w/Zd KuDFmbg1RybO1xSRGorkEuq4Vf7CDAzk2trPsfcXafLbW34E9+P69dQpu3kdC8iCtNaPQc nXNEhIynJMX5XGbKLwzfX9UGFAIN79w= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1699290753; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=xtsXGyrCZBmUJfCxzrPKMMdVxxHur1sL8JecsuLgwa0=; b=WzHCMESu9k+eg00UhiR4622uMFbucoZwsL6pGEMqESZuurTTnhmGq3BgUPna91VtbEarRB UzAhiRSn9YYzxxUf3848v+epRNADIrnYyZqIwvhjYWgcIYrDlH9XKAGbanv0YJvPzCtYe+ 6Ws/J4xEPLM3RkJHzIKFGnlaqEPl4sA= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-632-_45CrAGuNjOuxKLbB7FT_Q-1; Mon, 06 Nov 2023 12:12:31 -0500 X-MC-Unique: _45CrAGuNjOuxKLbB7FT_Q-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 674ED3821568; Mon, 6 Nov 2023 17:12:30 +0000 (UTC) Received: from file1-rdu.file-001.prod.rdu2.dc.redhat.com (unknown [10.11.5.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 47C5D1121308; Mon, 6 Nov 2023 17:12:30 +0000 (UTC) Received: by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix, from userid 12668) id 3227530C72A7; Mon, 6 Nov 2023 17:12:30 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by file1-rdu.file-001.prod.rdu2.dc.redhat.com (Postfix) with ESMTP id 2E33F3FD16; Mon, 6 Nov 2023 18:12:30 +0100 (CET) Date: Mon, 6 Nov 2023 18:12:30 +0100 (CET) From: Mikulas Patocka To: Mike Snitzer cc: Keith Busch , Christoph Hellwig , Juergen Gross , Stefano Stabellini , xen-devel@lists.xenproject.org, iommu@lists.linux.dev, Marek Marczykowski-G'orecki , Jens Axboe , Sagi Grimberg , Jan Kara , Vlastimil Babka , Andrew Morton , Matthew Wilcox , Michal Hocko , stable@vger.kernel.org, regressions@lists.linux.dev, Alasdair Kergon , dm-devel@lists.linux.dev, linux-mm@kvack.org Subject: [PATCH v2] swiotlb-xen: provide the "max_mapping_size" method In-Reply-To: Message-ID: <151bef41-e817-aea9-675-a35fdac4ed@redhat.com> References: <3cb4133c-b6db-9187-a678-11ed8c9456e@redhat.com> <11a9886d-316c-edcd-d6da-24ad0b9a2b4@redhat.com> <20231106071008.GB17022@lst.de> <928b5df7-fada-cf2f-6f6a-257a84547c3@redhat.com> MIME-Version: 1.0 Content-ID: <478c056-3a19-eb50-34da-911cf13fc558@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Rspamd-Queue-Id: F272E4000D X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: 7agwkhz6qpissrziujeddb3xj1qt11nu X-HE-Tag: 1699290753-268868 X-HE-Meta: U2FsdGVkX18gWPRRGth9t9yWiZ9/V8qQf/4bB4H6z6PxRJvI7kzqXHplAA5lPkuSBXylY4vCzI8KvINy+RzBn1odnUcx+HQOX0Zdz3U8tlzzqedV33mTBwIoCPg0yml+6Z4zEDaWuVV/S7fgI9DSGgRRcyM6azKZ+kwjxEuReEDV1zOmFId+jIUX+udzOEUQWHW9CmCfLVAqtngQsjVdDfU6FFHbtu6BjaDQnW8jpDTVjHmZLR3vU12S8P7N8++c58PyCvt6jdLBlevu2weGTN+lzbTkFaBtXiEN3FSn7dci/Qe9ZTjjY6VrjDtHAfAdvmlKmLnPZi421YyJYEDkXsBPQAvcAdqeAUiK+qZbWVekEYRrvd9SQjX8v2RAsiGYrjnIOnc2dfLWwScFNhAAclfZoIR5jucgUivOW+bgqozpXdkWdRB3o5xjw3yBeDxVy75Pw2n79dM4XrFvZJGlcynytLLuqK49dy5wF+swpjqyh2+xyAxxga8fovCMnrVdf1KvNgLtb0azO0Betnh4/VPnH7NI8U1d18UDhm8zcmwCl00Bg4NltpgciBVg3NaYsrWUfwrfpTnPg1blHeh0w3qIMI3W0VWAQOl8Fijq/5aZl61M8VY04Xy+hVZfbNysNizuG7MVGoqh+Rarn1QaAbFdnFVHls4sMdsIWULUiA4uZ8sOwSGoToPx4zXuc4o3BaZdcc7TS99yqZp2hbDn9UERMrC6ppDrUsqCXI2R6mR2GJv40ixAB7OgVkuuQ/LhbFVkaQvfvORhxgkIwY8e0EOiq6IMsZ2do1ttyrwVbnlRMf5Wny5yx0gITlWe+0oSVbHLdRcavCHRNuPuECw3fluVBAZStmt/ZULHgWrErrMye6JQv0ctJv0uqu7oubqN49LwSNVq9Nos9fOPAgqUU80vI+nTUmaHnTwcfO7JBx1UgziLvcJRtJTtcEhvYDDevwtURmtWWoTUHw300TX RmUwk8XI t17H1uJe00rZUP6vsHmeCPV6EWAilhndIxlsIw5vvKXRxZ+/UTw4b1LIy7Mh/jSnDKBrZ+A0Ctb1lYBUlZqbKn7ByrOZP2NnpcTKp54yE84AhBVN76tKhEdMtBpPf704V8UNkEzAYI5v2J+qemnIDEsxC8jipf/JynmKS6hkeAoBWPV9EkZTT1cCWLsdnXtvdrnGImzfcg2LrAMSa/LWM1/VB7BoaH/Ct9lTeg+WCoQ6t935mQcpenXxug4K1H4uWKn6a7iM98/cz6sdTbGm6wquUOl8t4KF208kl847IVMbGvRc2SWsixLlx7dze3ME+XBxHInB/yeq7gJZKEKAdZGqUKm2gZDWw9giKBvQ4r5Asz+Nq3c5b+iAZc1l9oNGQQCaDvszXobvM+/hN2iUf/BZHxfoA0yuVWQN4di8TwnwkwKs= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: From: Keith Busch There's a bug that when using the XEN hypervisor with bios with large multi-page bio vectors on NVMe, the kernel deadlocks [1]. The deadlocks are caused by inability to map a large bio vector - dma_map_sgtable always returns an error, this gets propagated to the block layer as BLK_STS_RESOURCE and the block layer retries the request indefinitely. XEN uses the swiotlb framework to map discontiguous pages into contiguous runs that are submitted to the PCIe device. The swiotlb framework has a limitation on the length of a mapping - this needs to be announced with the max_mapping_size method to make sure that the hardware drivers do not create larger mappings. Without max_mapping_size, the NVMe block driver would create large mappings that overrun the maximum mapping size. Reported-by: Marek Marczykowski-Górecki Link: https://lore.kernel.org/stable/ZTNH0qtmint%2FzLJZ@mail-itl/ [1] Tested-by: Marek Marczykowski-Górecki Suggested-by: Christoph Hellwig Cc: stable@vger.kernel.org Signed-off-by: Keith Busch Signed-off-by: Mikulas Patocka Acked-by: Stefano Stabellini Reviewed-by: Christoph Hellwig --- drivers/xen/swiotlb-xen.c | 1 + 1 file changed, 1 insertion(+) Index: linux-stable/drivers/xen/swiotlb-xen.c =================================================================== --- linux-stable.orig/drivers/xen/swiotlb-xen.c 2023-11-03 17:57:18.000000000 +0100 +++ linux-stable/drivers/xen/swiotlb-xen.c 2023-11-06 15:30:59.000000000 +0100 @@ -405,4 +405,5 @@ const struct dma_map_ops xen_swiotlb_dma .get_sgtable = dma_common_get_sgtable, .alloc_pages = dma_common_alloc_pages, .free_pages = dma_common_free_pages, + .max_mapping_size = swiotlb_max_mapping_size, };