From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qv1-f47.google.com (mail-qv1-f47.google.com [209.85.219.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54E8C47D47D for ; Thu, 13 Aug 2026 13:34:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.219.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786628061; cv=none; b=PCuB5D/P6+1yxDIGyUPFhtxUsTnzpd5zmwbyJbnk82eHfXuDIODwPs+NiljCUcW0GwcMF8Uo3+0H1rpmwhJcwqR7rXbg7TiuchDp+96Y+X4Nhhc8zkYSqOgFQJgrIQfEdCcV+cTU9Rlj+jP/t56H8+ipXIgNUnhTfk3uum+TYVY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786628061; c=relaxed/simple; bh=OcEezsanPwyYtHJiGOZFG+K3KM7vvhSN97luIVPI1Ng=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=MIqt8dORUr1iD68nHA4mGyCX1eLPM+k2Cp97L1FwokW7FA+Bvnx+suEbE+8Rulns9cgS1T+PF96VB1AS108fj5nbgt+PXRq8/nq6bhOg8EBlc5JzcPvVBNv8j31zRAE3R4nhC1ZBsb+QUDA1AqwWYuOOFazUDKzE87pJIcZYC70= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca; spf=pass smtp.mailfrom=ziepe.ca; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b=CcjQFiP0; arc=none smtp.client-ip=209.85.219.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ziepe.ca Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ziepe.ca header.i=@ziepe.ca header.b="CcjQFiP0" Received: by mail-qv1-f47.google.com with SMTP id 6a1803df08f44-8f032b47e3cso13912456d6.0 for ; Thu, 13 Aug 2026 06:34:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ziepe.ca; s=google; t=1786628057; x=1787232857; darn=vger.kernel.org; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=b7FsOVpsR2u+8zsOB4pxP+7DxIyGo4TmTgnx74/xvuo=; b=CcjQFiP0ctTj0Le2Ky8m6tyQQqz01JPLLWNocwgNl4gLqqqfEgww/MR21xUeoijZXk 4p/FO56zAe/dL4giGgvD0YAe+r1BXIOaJQGtiiMbU04Rpm+4e2FDKm4oZlaO3A7ECfD4 FuYlPDfMTXWj7EZj8Lwmtl+3MhNXGPjhMuajuRd3EilDvaBnASsNfWyOxAM8h0/vET8Y pBaVdf1nGyaj54If4XHck++6BFpnKnyxysS6aVJHVTy6oPws0u30L2YdZDUc0V8KuH86 1ov4gX0PId7yRqdgl8G0aTOUM4mx1sS/ZB4mRG+ufQNeMOh8xTWV1FGkOfTiwurZaYOs S0oA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786628057; x=1787232857; h=in-reply-to:content-disposition:content-type:mime-version :references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=b7FsOVpsR2u+8zsOB4pxP+7DxIyGo4TmTgnx74/xvuo=; b=DXTNA5tknE9WX7Wg0KWfYJylrX0/5pyoQ2FQL3UQe6/6pItBFZlJv1srKDQ1RO8+r6 n2p3hgant22VyIDTaH6YDBsEJxlJotMRmuhOwHv1i1v79GkEhMVkz7UegkwlfcdzytYa BxBRHP9Kcpsf60wiARZDOWte8hhx6/1NnhwML9L+uz9zmRdjf82xrocgYWuPtw8Ed8qb 6wdNC9fUh4FGxQpylSHUYQ37QX6tP08XxMonGIY0QNeLVuZqMe843ztUAT+tePNS+ODM +qXJakeDDrBfYA4XcQJmnCiaDn4a0HrWNXrOayFPS1brT6bO437ApvCLD20FIWnO1xbg SRfg== X-Forwarded-Encrypted: i=1; AHgh+RqVRVj1VdlOXNhyt+i7SFRJ5O/mThT/b2NzmUPzCLWY9gyHD+1qnwyOyHBTm0fCuzgHPfTcvKvyT/l3BdE=@vger.kernel.org X-Gm-Message-State: AOJu0YyBvT+mCUAKcliqCEyGO38hy7nGBOG8xtW8FwpJuNJECzPsP7Fr 37NsaM6UUvq3EKBtZbRujiQqTJtsNUpN5l5UK1FoBDUA1JY66DnBpBZyr2mxg/K3RHY= X-Gm-Gg: AR+sD110xD5FTIHohDZF0LDAjegzEoSghGrdWAGvC0dcvfT/HvYnBL0VI4D3o+oFRmg LYfO9iNcsMz1YZ3TyZyNLru3JRw/gBuiap45bV/WoRaKtm/fbQrFHN0cENsqRKxunxGEAE6gQy1 nxsW5bdQ1ldtcW/iDerYjsrxONhQsCr3nPYyUiHqm0FJFQljFoPv7SabfX7M77aeObj5wpU3KP3 3P3Si08OjwpGLUOIDgPVjzyMgl6zCQvg1hd+EmRyMB13o2h0RmpggufgcWMlk7YKhZURTfSihzg h0Kz104rbzv87QMNNehb9dMxzjqCb/VJhZWnVedDj2NxdPlBLWHLzd3BTPN2Bu+lIiEbiIubbmQ y5EQEK6jgedvreXT4R25bs4wmAOgoO3MORFJF1JvvI6YHeEjDth24eYzt+7XeFLHMR4WwGa/V/8 ShVt3eznBycsczqNbejKD0gJVp/PnzifXB1yJrOA== X-Received: by 2002:a05:6214:5d10:b0:8fb:7e7c:b494 with SMTP id 6a1803df08f44-90a80bdf66fmr57373736d6.26.1786628057084; Thu, 13 Aug 2026 06:34:17 -0700 (PDT) Received: from ziepe.ca ([142.166.156.215]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-90a81aba04bsm14700066d6.44.2026.08.13.06.34.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Aug 2026 06:34:16 -0700 (PDT) Received: from jgg by wakko with local (Exim 4.97) (envelope-from ) id 1wuVZX-00000003nJq-3M6L; Thu, 13 Aug 2026 10:34:15 -0300 Date: Thu, 13 Aug 2026 10:34:15 -0300 From: Jason Gunthorpe To: "Jose Fernandez (Anthropic)" Cc: David Woodhouse , Lu Baolu , Joerg Roedel , Will Deacon , Robin Murphy , Tom Murphy , iommu@lists.linux.dev, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Mohammed Almaroof , Ben Cressey Subject: Re: [PATCH 6.18.y] iommu/vt-d: Gather the unmapped range before freeing its page tables Message-ID: <20260813133415.GK662699@ziepe.ca> References: <20260813-b4-vtd-unmap-gather-v1-1-4c52f4a7a1ac@linux.dev> 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=us-ascii Content-Disposition: inline In-Reply-To: <20260813-b4-vtd-unmap-gather-v1-1-4c52f4a7a1ac@linux.dev> On Thu, Aug 13, 2026 at 12:05:26AM +0000, Jose Fernandez (Anthropic) wrote: > Under a userspace driver that maps and unmaps DMA buffers through VFIO > type1 continuously, this shows up as wrong data in device reads and > writes. An occasional DMAR fault on a mapped IOVA is the only thing in > the logs. With an Intel DSA engine assigned through vfio-pci, remapping > a 16 MiB buffer at a fixed IOVA and reading it through the device > returned data from the wrong pages in 280 of 400 iterations. With a > fresh IOVA per iteration it never did. > > Add the range to the gather first and splice the freed tables into > gather->freelist afterwards, so that they are only freed by a sync that > also invalidates their range. > > Mainline removed this code in v6.19 with commit d373449d8e97 > ("iommu/vt-d: Use the generic iommu page table") and is not affected. Yeah, I noticed this bug category in iommupt at some point, I didn't realize there was long existing errors in the drivers. I don't know what the process is to put a unique patch into stable (backporting the upstream iommupt based fix is not reasonable), but this looks correct to me, it follows the pattern iommupt is using and I have now extensively tested. Reviewed-by: Jason Gunthorpe Jason