Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp572632rdb; Mon, 29 Jan 2024 10:50:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSwjmlWdGBP+gGH2Cw9LX09iZaV+kLtEbq1Q5UqVGp8caoOeMGdttBJcOhPqdwD6HZ6b3g X-Received: by 2002:a05:622a:a:b0:42a:8b47:6981 with SMTP id x10-20020a05622a000a00b0042a8b476981mr5144664qtw.26.1706554237970; Mon, 29 Jan 2024 10:50:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706554237; cv=pass; d=google.com; s=arc-20160816; b=ZG3F7Lsu/Ea1oPz55FEwecBGH63XEw7hO+CRMk57ZU0ms8ipzmgGIXt/Ae9DhenTVq R6KmtzKAdW2QDz12GtlE3Af2anDAMzXHHjCrUA/P2EGh82QJ+O2K6VdSXXHOLLT7PJIB xmEtufn0U/pX5YaFCGj0liAfFwu6cvTgrM3DwBkqKGCcT494ka1Dpm42vven4nHx8G5N x0dXYejqRjBNnVlBX0AH2T/PAoaWYVVZB464Yu6Keab22UVcNKmPSlh/ekvb6NDA6ALn PXk2unrpfjQWG+dFDeRuTEvnc1gt6VyGzjCpjVpuXgY3VK4UZwCbYjK8OA/2pb8gW4AM sD7w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-transfer-encoding :content-disposition:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:references:message-id:subject:cc:to:from:date :dkim-signature; bh=gjKi5TE/VnNiog7WcdloF19iU0fUVwx7qzJtoTXTRgU=; fh=zthxUB1W60uXCQFExG2c+R9dQFBcTp9Unq+SRILGPnQ=; b=S5n7I63t4heyPut/UYnLDiyWitqJgLKSNSxBBAkLZuv8N0iG+n3zxqZOsYt8BSfjbv z7QGmxN65TEc1vaV7w/MyoyAmqoFYocbQz73BYj2Ik608i/tMS/rZWl1HJzrg7u4SXq/ vygjKjyqQLtNY/K+efSHySpJz9BAEtgTZUfCgQunCi0zDl8KKYOA0b4XDmq6pO9Zt/9a GbyquKiN0KGi63Y2RxLkJgw6ZldFJasQI2ZvnURplTyFo42vW4S5FJbKxh7LMVhnXd8c riBzgO4Lr0rTz3UXmGGaQ3lrjgaPmSvDvx+lteTKD6/NBQgcU3aXRHUMlJsBDrAbtx2i s6Hw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PVUXvJb6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-43362-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43362-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 c11-20020a05622a058b00b0042a7431a4b7si8244614qtb.240.2024.01.29.10.50.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 10:50:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43362-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=PVUXvJb6; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-43362-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43362-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 73AF91C23F29 for ; Mon, 29 Jan 2024 18:50:17 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 82C7515AABE; Mon, 29 Jan 2024 18:43:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="PVUXvJb6" 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 A3A461D687; Mon, 29 Jan 2024 18:43:01 +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=1706553781; cv=none; b=ZtjerE+lVMMAGAA5EWb1nzKv4KWSjPCxf19UlrmD8ZHVDWWYbCA1JZVWoTmuAB0jbMnfBqTaaRnSUvuRfcu1F43pgvHWeSrTjAgsmR9c1wa0JYHFcIwuxKmpfcCTwVIBRT3epq4XfTm0YSKGhPaMU9U+K1IxqybaHMtAYb1rpmU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706553781; c=relaxed/simple; bh=z7dp0Qp1EQQ9w5NACKTKcarqslU07mgnpi1r9oGaWNk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=g2agmi7ayDhVSfZvz4WuvSjcCTpTX20FJwaFiGYI0EqLsFjqB+yS7kqvuzz5WQTZcwWX9r6cGNToNZWWbAvgtdNSkEICet0P2GMz4lywQR0oICYzjfOfdYmSaJy0J+OvWFjY6eKrLSErjUOFHSdltZ1afjePPyTgwsnfRrIjaJI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=PVUXvJb6; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6BDAFC433F1; Mon, 29 Jan 2024 18:42:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706553781; bh=z7dp0Qp1EQQ9w5NACKTKcarqslU07mgnpi1r9oGaWNk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=PVUXvJb6ySWYAAxbqDKL6OJ/BobhrZ8237AfXIQgG8zeN5Ctj/2pizHrxxIB32HwZ F8JEPBRwcnAQumtPxB33p2Ve8tSmT4iDMeCQ5M557UA4JnQoJyc3oI0kagNUvSmpDn iEtWRnUyElx0m+iKjzFdrMk2399ddHsNYfWx2qbbU2KzLzFdfQDD4j+UcrBni4Pgu6 z3zBM9WCb8kMHtONTIIVEWh1tm/toZa6sKSE51TuzivTdjpbKGWN6kkQGVpgohmuVM ooCV/N0mgJgtMZ+4nYY37NinsGLgi6NjErWZJ/BMgmkrGEbXzqs2TMrU/oU66CXygF z1A5/Wmvsospw== Date: Mon, 29 Jan 2024 18:42:55 +0000 From: Will Deacon To: Petr =?utf-8?B?VGVzYcWZw61r?= Cc: linux-kernel@vger.kernel.org, kernel-team@android.com, iommu@lists.linux.dev, Christoph Hellwig , Marek Szyprowski , Robin Murphy , Petr Tesarik , Dexuan Cui Subject: Re: [PATCH 0/2] Fix double allocation in swiotlb_alloc() Message-ID: <20240129184255.GA12631@willie-the-truck> References: <20240126151956.10014-1-will@kernel.org> <20240126172059.48ad7b9f@meshulam.tesarici.cz> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20240126172059.48ad7b9f@meshulam.tesarici.cz> User-Agent: Mutt/1.10.1 (2018-07-13) On Fri, Jan 26, 2024 at 05:20:59PM +0100, Petr Tesařík wrote: > On Fri, 26 Jan 2024 15:19:54 +0000 > Will Deacon wrote: > > > Hi folks, > > > > These two patches fix a nasty double allocation problem in swiotlb_alloc() > > and add a diagnostic to help catch any similar issues in future. This was > > a royal pain to track down and I've had to make a bit of a leap at the > > correct alignment semantics (i.e. iotlb_align_mask vs alloc_align_mask). > > Welcome to the club. I believe you had to re-discover what I described here: > > https://lore.kernel.org/linux-iommu/20231108101347.77cab795@meshulam.tesarici.cz/ Lucky me... > The relevant part would be this: > > To sum it up, there are two types of alignment: > > 1. specified by a device's min_align_mask; this says how many low > bits of a buffer's physical address must be preserved, > > 2. specified by allocation size and/or the alignment parameter; > this says how many low bits in the first IO TLB slot's physical > address must be zero. > > Fix for that has been sitting on my TODO list for too long. :-( FWIW, it did _used_ to work (or appear to work), so it would be good to at least get it back to the old behaviour if nothing else. Anyway, cheers for reviewing the patches. I'll go through your comments now... Will