linux/arch/arm64/mm
Piotr Jaroszynski 97c5550b76 arm64: contpte: fix set_access_flags() no-op check for SMMU/ATS faults
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 a CPU with FEAT_HAFDBS this gathered view is fine, since hardware may
set AF/dirty on any sub-PTE and CPU TLB behavior is effectively gathered
across the CONT range. But page-table walkers that evaluate each
descriptor individually (e.g. a CPU without DBM support, or an SMMU
without HTTU, or with HA/HD disabled in CD.TCR) can keep faulting 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 each sub-PTE against the requested AF/dirty/write state
(the same bits consumed by __ptep_set_access_flags()), using raw
per-PTE values rather than the gathered ptep_get() view, before
returning no-op. Keep using the raw target PTE for the write-bit unfold
decision.

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: 4602e5757b ("arm64/mm: wire up PTE_CONT for user mappings")
Cc: Ryan Roberts <ryan.roberts@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Cc: Will Deacon <will@kernel.org>
Cc: Jason Gunthorpe <jgg@nvidia.com>
Cc: John Hubbard <jhubbard@nvidia.com>
Cc: Zi Yan <ziy@nvidia.com>
Cc: Breno Leitao <leitao@debian.org>
Cc: stable@vger.kernel.org
Reviewed-by: Alistair Popple <apopple@nvidia.com>
Reviewed-by: James Houghton <jthoughton@google.com>
Reviewed-by: Ryan Roberts <ryan.roberts@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: Breno Leitao <leitao@debian.org>
Signed-off-by: Piotr Jaroszynski <pjaroszynski@nvidia.com>
Acked-by: Balbir Singh <balbirs@nvidia.com>
Signed-off-by: Will Deacon <will@kernel.org>
2026-03-06 11:25:59 +00:00
..
cache.S efi: arm64: enter with MMU and caches enabled 2023-01-24 11:51:08 +00:00
context.c arm64: Ensure bits ASID[15:8] are masked out when the kernel uses 8-bit ASIDs 2024-12-05 11:24:38 +00:00
contpte.c arm64: contpte: fix set_access_flags() no-op check for SMMU/ATS faults 2026-03-06 11:25:59 +00:00
copypage.c arm64: mte: Do not warn if the page is already tagged in copy_highpage() 2025-10-23 17:34:58 +01:00
dma-mapping.c arm64: Properly clean up iommu-dma remnants 2024-05-10 09:04:25 +02:00
extable.c arm64: mm: Handle PAN faults on uaccess CPY* instructions 2025-03-07 18:28:29 +00:00
fault.c arm64 updates for 6.19: 2025-12-02 17:03:55 -08:00
fixmap.c arm64: Add support for FEAT_HAFT 2024-11-05 13:18:35 +00:00
flush.c mm: introduce memdesc_flags_t 2025-09-13 16:55:07 -07:00
gcs.c arm64/gcs: Fix error handling in arch_set_shadow_stack_status() 2026-02-03 09:30:20 +00:00
hugetlbpage.c arm64/mm: add addr parameter to __ptep_get_and_clear_anysz() 2026-01-26 20:02:33 -08:00
init.c mm, arch: consolidate hugetlb CMA reservation 2026-01-26 20:02:19 -08:00
ioremap.c arm64: io: Rename ioremap_prot() to __ioremap_prot() 2026-02-25 19:49:51 +00:00
kasan_init.c kasan: call kasan_init_generic in kasan_init 2025-09-21 14:21:58 -07:00
Makefile mm: rename GENERIC_PTDUMP and PTDUMP_CORE 2025-03-17 00:05:32 -07:00
mem_encrypt.c arm64: mm: Add top-level dispatcher for internal mem_encrypt API 2024-08-30 16:30:41 +01:00
mmap.c arm64: gcs: Honour mprotect(PROT_NONE) on shadow stack mappings 2026-02-25 19:53:58 +00:00
mmu.c mm: introduce generic lazy_mmu helpers 2026-01-20 19:24:33 -08:00
mteswap.c arm64: mm: swap: support THP_SWAP on hardware with MTE 2024-04-25 20:56:07 -07:00
pageattr.c mm: introduce generic lazy_mmu helpers 2026-01-20 19:24:33 -08:00
pgd.c arm64/mm: Ensure PGD_SIZE is aligned to 64 bytes when PA_BITS = 52 2025-11-11 19:13:03 +00:00
physaddr.c arm64: mm: Don't use %pK through printk 2025-03-20 15:34:53 +00:00
proc.S arm64 updates for 7.0 2026-02-09 20:28:45 -08:00
ptdump.c arm64: Enable vmalloc-huge with ptdump 2025-09-22 11:53:24 +01:00
ptdump_debugfs.c mm/ptdump: take the memory hotplug lock inside ptdump_walk_pgd() 2025-07-09 22:42:20 -07:00
trans_pgd-asm.S arm64: kexec: configure EL2 vectors for kexec 2021-10-01 13:31:00 +01:00
trans_pgd.c arm64: Fix 5-level paging support in kexec/hibernate trampoline 2025-02-04 12:23:09 +00:00