From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from stravinsky.debian.org (stravinsky.debian.org [82.195.75.108]) (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 BE87C3C6A52 for ; Wed, 4 Mar 2026 17:37:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=82.195.75.108 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772645866; cv=none; b=aKfbL8yt81j54LEM97tH+rw2Aa1cfOQpoafZkamGbMJUOE5y6GSdb/GtW4asYQCVxHcuhX6Ilogf0I7V8TmYpzAgVxtg9RDTPyEadg4Vqwks3wwPz+72Eo7tw2D4oRtFg8QZT1LvrKm30O7Xfl5U5KUf5ckITYc/fPxnnI3uvBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772645866; c=relaxed/simple; bh=4+T5OqdTxq8diftvlnFqCYYi7M7F6QcKejkiNQzF0qs=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Q3auSQIg0XcwQSPWJLRrEq9x6IKx/ZiVRPiYjGXZ5QuLeho7FO00/wQSfS34L4o2m/eBsZmLHo1cTk8Hv2RbELkr94kXN16xp8T0hklTmT/cJinPk90FCpdSuhzOP6nqUiOHrLxdVThCaGOf7qb3hA4rDUoyyX6EuhcAJoPD7YI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org; spf=none smtp.mailfrom=debian.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b=caze7pYF; arc=none smtp.client-ip=82.195.75.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=debian.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=debian.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=debian.org header.i=@debian.org header.b="caze7pYF" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=debian.org; s=smtpauto.stravinsky; h=X-Debian-User:In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=uuyCsr5o+JidLSWRw/91AGUcrNTLFhdmWYvBwfnlct0=; b=caze7pYFvcyVMiEYXzYpXuTAXQ tdP41ORKTes8QS0ud/mQoCbt/xBsvN79xXVvRHWv7XyfbPUVrV9zRVSNIZCJzkbnKdWbsgC/oyxK7 RSZ73r181y7XF1WFFjBfNnWtVli1OZ0Rkg8Lh6HH8IG3spYaENh+j2UCmHzm5iXRddOKKXLAR7bY2 0lDo3psav2Ty0zNVYaDnfjSgZdeQWxLjWDClJobF0JueVolpH48n2l1f460wqCYYK+riGdDVqlK2y Axv2+7D3yHkzAMQ31ly7/393EV5Bnsh1tR4GolA0TsX6PFuWptCebIbnLuvG/3/PQKhR6OaWzPRLj Cp7X3V2Q==; Received: from authenticated user by stravinsky.debian.org with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.94.2) (envelope-from ) id 1vxqA6-00G7Tn-Ka; Wed, 04 Mar 2026 17:37:30 +0000 Date: Wed, 4 Mar 2026 09:37:25 -0800 From: Breno Leitao To: Piotr Jaroszynski Cc: Ryan Roberts , Will Deacon , Catalin Marinas , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, Alistair Popple , Jason Gunthorpe , John Hubbard , Zi Yan , stable@vger.kernel.org Subject: Re: [PATCH] arm64: contpte: fix set_access_flags() no-op check for SMMU/ATS faults Message-ID: References: <20260303063751.2531716-1-pjaroszynski@nvidia.com> Precedence: bulk X-Mailing-List: stable@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: <20260303063751.2531716-1-pjaroszynski@nvidia.com> X-Debian-User: leitao On Mon, Mar 02, 2026 at 10:37:51PM -0800, Piotr Jaroszynski wrote: > contpte_ptep_set_access_flags() compared the gathered ptep_get() value > against the requested entry to detect no-ops. ptep_get() ORs AF/dirty > from all sub-PTEs in the CONT block, so a dirty sibling can make the > target appear already-dirty. When the gathered value matches entry, the > function returns 0 even though the target sub-PTE still has PTE_RDONLY > set in hardware. > > For CPU page-table walks this is benign: with FEAT_HAFDBS the hardware > may set AF/dirty on any sub-PTE and the CPU TLB treats the gathered > result as authoritative for the entire range. But an SMMU without HTTU > (or with HA/HD disabled in CD.TCR) evaluates each descriptor > individually and will keep raising F_PERMISSION on the unchanged target > sub-PTE, causing an infinite fault loop. > > Gathering can therefore cause false no-ops when only a sibling has been > updated: > - write faults: target still has PTE_RDONLY (needs PTE_RDONLY cleared) > - read faults: target still lacks PTE_AF > > Fix by checking all sub-PTEs' access flags individually (not via the > gathered view) before returning no-op, and use the raw target PTE for > the write-bit unfold decision. The access-flag mask matches the one > used by __ptep_set_access_flags(). > > Per Arm ARM (DDI 0487) D8.7.1 ("The Contiguous bit"), any sub-PTE in a CONT > range may become the effective cached translation and software must > maintain consistent attributes across the range. > > Fixes: 4602e5757bcc ("arm64/mm: wire up PTE_CONT for user mappings") > > Reviewed-by: Alistair Popple > Cc: Ryan Roberts > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Jason Gunthorpe > Cc: John Hubbard > Cc: Zi Yan > Cc: Breno Leitao > Cc: stable@vger.kernel.org > Signed-off-by: Piotr Jaroszynski Tested-by: Breno Leitao