Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp2552782rbb; Wed, 28 Feb 2024 05:39:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWwB4vLYEFeBu865FIZ4vQZWFoieTtULP3SCxv7Q0Lq97ASTqgOKhBlhKJl4LO3ZW0EMUwDTv3pEMo6553Qj4HLVEsNT7BSdSHlYLxOqw== X-Google-Smtp-Source: AGHT+IG9kHYEe9bNtMVV702jlc6hPgOsBVO4Ft11n7SDHBeH5jBY905cNGQB+woYGG67qNHxXHI/ X-Received: by 2002:a05:6402:d76:b0:566:3d19:9058 with SMTP id ec54-20020a0564020d7600b005663d199058mr3038778edb.33.1709127588490; Wed, 28 Feb 2024 05:39:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709127588; cv=pass; d=google.com; s=arc-20160816; b=j/KqPCO7UBmZ7Oggcy6t8XGLdIH4/xArFZQHdK9+7tRYEZl9kZu3CTDRYp8h9LLnfb SW1DfZCLUGswKSuxNsOMqCpl0CZdZ6cwhYgTn9zB0ka4/v/7Pjz/uezyjGQZvyVNbuQ5 HC7OPmeCq9s74g69ooAW4nqPaeisV9Vvj+xJaJUVIvrgAgfkqIdN6gcdzgdFqOrqSFc9 brPguDXwQtlsbJx1oGMp54DBvqh4m7b5vPPdpJTujmpDK3WaiW8l6kQBebpVZm1StW87 f9bzhKun2vGfvAmI0daMAfA2/RfmA653XC9MOqlFTTp9Keqrd+LL15qmdWoIlHK6s3hv ZAYw== 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=iaxJXiyqojhw1e/6wwArxR90FFLV2Ab4/bX8whTZL+E=; fh=E8F5/vp/nAcPVJWJwVt5RE8c2HME7kVqVeSMFxe8huE=; b=D9n9p5qwlD4Rh/S8uPzijOpDTqL4g16+qD1VHfbOFgew0wwVWcjVPx2vyndyqmhS3E D7TnTZtNBwa17w0/YEt0ZnsrY115jGKiHx3vyjrHz6+5TVakkvrPqhYVKqbUJDhyQmlP 62V2qwTMU3hHLyretTvnBdB4EwSFhuyc0GfhQUPckm3eKFkpo70ZHBdXIMTQP8R3Bog9 LPdt5KMOGLcP0ZKNIom/2+FSRq8Z/pYT9o2RVd3AI3vQLWRNOzeOS5MayHymKu0UWwIC /nt/loKmiu4UuLgF6rzCqj5yaYSIb2l6QNrh1u5UCJfrucyrOIWqoVVJprUd+U+61jVm 9pIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cW0JH05C; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85108-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ba14-20020a0564021ace00b005655dc8d470si1720274edb.611.2024.02.28.05.39.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Feb 2024 05:39:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-85108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=cW0JH05C; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-85108-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-85108-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 37F521F28B2C for ; Wed, 28 Feb 2024 13:39:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E8A9714DFC4; Wed, 28 Feb 2024 13:39:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="cW0JH05C" 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 1876614AD07; Wed, 28 Feb 2024 13:39:36 +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=1709127577; cv=none; b=krx7+4sGD7piDDlwCy+9YJB0I52fRhYujwdyLZqzrr9mjnyix6flJeghiEXP09BscxrtLwfUaS2q7nIrKfZhONr/mJ6obctoEtM2z+U9yWYgB2IdvHcgFcWNME1+w4MoCH7owCTghoN9z0RNxBNpK5dhhVbmOlFb5xqvLOpMPy0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709127577; c=relaxed/simple; bh=9M5IeUXf3IQoeSYqVlOLU709MVkE93Tw2opRABbT/bs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=C9drTXMmEcJJtB2fvPrmZM+1OXYsm5S4BkjjOyht7sXd1iDjzbvwIjO6Q7oAulIa7HUdJdVx11iWkeyrz+w1zT5BD2YAg1M33jFbDi0B+H+onIYMT4o3FaT/ywQ+n5QCTMwSmiQw8gSIJy0dD9L8A7s82fjMNio5XxzLtWD1Tn0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=cW0JH05C; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8FEE5C433F1; Wed, 28 Feb 2024 13:39:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1709127576; bh=9M5IeUXf3IQoeSYqVlOLU709MVkE93Tw2opRABbT/bs=; h=From:To:Cc:Subject:Date:From; b=cW0JH05Cslh9hwgukH/5vLo/F5orXfPEP+8a7EHwdeehPxmWkap/0tEVqXTtv9pns 98mvJ19iHQ/ltGsOEQvIReTkQxhbSKJmeOXc6BYj/A0X8xuNVtf2KDhgssuKh0Qp+t 4sYuVtBBveyEYvccu9XT4erREGsWwxnNUF84TgA5D78cPy/2iOg1K5oCeYyMjPDgSr bg3JJ3M2mcYK7mqzts4irrJpnN6IaHNs8VUZo2CVsIxwfVamxI39kAWRXSOUGy7RWx CJ5KKhPOY/9kJhGIvggJHF2HGI5k+4/w+9Av1vc3zjfw6otCXmNy5rQ50rRXKbuXlH b/TUkZ73XzlCQ== 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 v5 0/6] Fix double allocation in swiotlb_alloc() Date: Wed, 28 Feb 2024 13:39:24 +0000 Message-Id: <20240228133930.15400-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 all, This is version five 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 v4: https://lore.kernel.org/r/20240221113504.7161-1-will@kernel.org Cheers again to everybody who helped to review and test the last version. Changes since v4 include: - Remove unnecessary 'is_swiotlb_active()' from patch 5. Nicolin: I didn't add your Tested-by because of this, so if you can take it for another spin, that would be fantastic. - New patch removing redundant stride adjustment for allocations of PAGE_SIZE or more. - Commit message tweaks and addition of tags from reviewers and testers. The final patch is a cleanup, so I'm happy to post it again after the merge window if it doesn't make it this time around. The rest are fixes and, even though patch five doesn't solve the general problem, it's sufficient to fix NVME for Nicolin and is definitely an improvement over what we currently have. Thanks, 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 (5): 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 swiotlb: Remove pointless stride adjustment for allocations >= PAGE_SIZE drivers/iommu/dma-iommu.c | 9 +++++++++ kernel/dma/swiotlb.c | 36 +++++++++++++++++++++++------------- 2 files changed, 32 insertions(+), 13 deletions(-) -- 2.44.0.rc1.240.g4c46232300-goog