Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2302429rdb; Wed, 21 Feb 2024 03:35:19 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWx1PMSeckPC56vQBVCgxxX47YsWqzno5YNZEM8/mMudBrGyCYE1M07D8u4Xf8RG9fvNfAXf1qPed7hsa0yMd0pdWqBy025UyrSSyu7SQ== X-Google-Smtp-Source: AGHT+IFwh3JsRjrB6vWbvMjammnNmk1EM8S4FO+1KgDse5R301acqrETm6jK+ZbInA9dFVCd1b0e X-Received: by 2002:ae9:c20d:0:b0:787:3aee:32dd with SMTP id j13-20020ae9c20d000000b007873aee32ddmr16232735qkg.57.1708515319677; Wed, 21 Feb 2024 03:35:19 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708515319; cv=pass; d=google.com; s=arc-20160816; b=cmPUNzv0TJwNmQjn4lhb98iVp3xlDLZwXeI5wb42oshJG8PpxO0z9saHlGa0oIdJLM zrgrvdkB8LktvVEGPwUekEOItUS2EJuKOn9ruaQBtwhl5ZywhbvctS/SHwivvc5g5ZJc sxRzYLZ8WUvqVbL1/blm12RRk0qGB+xkIEDyw1Dlnl55Gfm3RC0FXw0R6jpGwKy4t8ll iVTugCheDQtWQeMKannshw882fXKP0Cidi1uqDtWbq138zfjLDdZYZ69NP+Hdo71svVc gsCcnMBXdg42mBJCrZSGyQObVlXBUqAdRZfUr9U/L20uqOPOXM1k22JC3GofFmgbWqoJ mtbw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=FTh6aYSv0hm3nbBrbyl+V0T3PsYT4Y70rFUk4Yx4LL8=; fh=E8F5/vp/nAcPVJWJwVt5RE8c2HME7kVqVeSMFxe8huE=; b=XZ31kr6gpDAqHelp2tVT8H2q6j9BIt3JF9yWI7Uq0JuaT4PrXVH4LhmUZ+DBjkToQa b1+HWAWGWAUDCXeJryXKnfcSPeaVK5HVB8RnCeG+Xq90jHbB35t07pLs/SEKIUavk2kC +7cCbM5vmviTKnQy7PRsHIardR+6AMtj/0N4cSrNeZxKI1OkMeBonKxV1ti933xl7vxx /0Mf5Ke8JbAFDGPLMJgIqHdMSBglPeKayH3LGDwyPYt4mkySiPFiJZubjjUjyLhi7ELA c2IPWJOttTiV2NGCC2EvFwBCTi6tJG/7JnfHkDv/uoarZSUQHJJxYm/ySdLJyigpH+dC bMIA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZRZJaowg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-74624-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74624-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k21-20020a05620a07f500b007832941b17csi10397041qkk.173.2024.02.21.03.35.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 03:35:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74624-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=ZRZJaowg; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-74624-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74624-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 61E271C20DAF for ; Wed, 21 Feb 2024 11:35:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 356354176B; Wed, 21 Feb 2024 11:35:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZRZJaowg" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E9184122C; Wed, 21 Feb 2024 11:35:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708515312; cv=none; b=ki6EdzV43HBY8wFmBWSrgTztEy/mIPTr/PigaZeWdlbsBWV9vCy5Z9u4QE8CLY4GQaK7toxfSw2FBo+Q1/iHj5LqE2XG79FplhVFD52fh0ERH0qMUjQlBRfrxMWDe4NHhFjVAeU/y1qzTPjLhKkMypsmJjZ8hzGx3CT3/3r46xc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708515312; c=relaxed/simple; bh=LrEFrcKQxsI5oLBY8Ymc3PVuMOoyMrYqGkDaTet93Jg=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ligHBuyVz1OI/lWBNBjU9qeCey34cr69MGXk+MWF8iiksOWc86sQv6mjOaIEzEmRtkjX129Rr9FRAIh5SeAjRhFVktvOdqnx2beIcKDGIxIezNsvhlgpiJdafxKu/y+NvR/smTJdmbufXmXvlg9K9qnMX/+bsZz3Gl07cfia92E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZRZJaowg; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2E13C433F1; Wed, 21 Feb 2024 11:35:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1708515312; bh=LrEFrcKQxsI5oLBY8Ymc3PVuMOoyMrYqGkDaTet93Jg=; h=From:To:Cc:Subject:Date:From; b=ZRZJaowgWMfnb/UMCjsVUWzFbDnhSdGO16nSgaywmGCTXV5P4a1dZ4t2F7pWsvoXu vDOYmGRbuRUpA65PV01CowgPJ5gFhdTFuegSVK7HhBp9vz87+zuCdF1E15teqU3+pm eDpbf869okiuHAL152YxYK4zGXuGgdMBGUrkFYAuOyIKGBuOzC45197d8GA8pDdBTQ 90QGo/OjSWxNoEYIBfURsoHaTUI4zIISXDy/D7o2PGqNFT+MErX6NQYzg7TZBFMwtl 1EIzHub3brycH8f+Vsp36jLyicWBClxzpz9kJEU/HE2aNMR/zxKdwohELFY7Sxuhu7 fBpKY2D6LFFMw== From: Will Deacon To: linux-kernel@vger.kernel.org Cc: kernel-team@android.com, Will Deacon , iommu@lists.linux.dev, Christoph Hellwig , Marek Szyprowski , Robin Murphy , Petr Tesarik , Dexuan Cui , Nicolin Chen , Michael Kelley Subject: [PATCH v4 0/5] Fix double allocation in swiotlb_alloc() Date: Wed, 21 Feb 2024 11:34:59 +0000 Message-Id: <20240221113504.7161-1-will@kernel.org> X-Mailer: git-send-email 2.20.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Hi again, folks, This is version four of the patches which I previously posted at: v1: https://lore.kernel.org/r/20240126151956.10014-1-will@kernel.org v2: https://lore.kernel.org/r/20240131122543.14791-1-will@kernel.org v3: https://lore.kernel.org/r/20240205190127.20685-1-will@kernel.org Thanks to Petr for his Reviewed-by tag on the first three. Changes since v3 include: - Use umax() instead of max() to fix a build warning if the first patch is applied to older kernels which warn on signedness mismatches. - Add two new patches to the end of the series to resolve some additional issues with NVME and 64KiB pages, reported by Nicolin. I've added them to this series, as the first three patches make it easier to fix this problem in the SWIOTLB code. - Add Reviewed-by tags from Petr Cheers, Will Cc: iommu@lists.linux.dev Cc: Christoph Hellwig Cc: Marek Szyprowski Cc: Robin Murphy Cc: Petr Tesarik Cc: Dexuan Cui Cc: Nicolin Chen Cc: Michael Kelley --->8 Nicolin Chen (1): iommu/dma: Force swiotlb_max_mapping_size on an untrusted device Will Deacon (4): swiotlb: Fix double-allocation of slots due to broken alignment handling swiotlb: Enforce page alignment in swiotlb_alloc() swiotlb: Honour dma_alloc_coherent() alignment in swiotlb_alloc() swiotlb: Fix alignment checks when both allocation and DMA masks are present drivers/iommu/dma-iommu.c | 8 ++++++++ kernel/dma/swiotlb.c | 43 +++++++++++++++++++++++++++------------ 2 files changed, 38 insertions(+), 13 deletions(-) -- 2.44.0.rc0.258.g7320e95886-goog