Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795041602; b=DWI6yTXfQ9kqn4/TyFivdbxZM3tfyQgYATThl8+2QhdDMxcC+HACGw5PSCnZ7bu2pGK+ PxBt5T2433FKUhNbY/dO8Mkmn/hpahic/lpiWAQ0SpokGYUxYtOmhqZ00AhpQBqI6BS7F vaLtKTNI/SwX7wwDoIBjkdXb/dGlZPpKGeOASK77pJ3yvGaXUOBiBgjRnUN6wxAMwlzZb Kd3Z3QqxY9NV1STilVnMxKyhua8qDUZiN3nksNna3yfCPV3fxsVUsS8aXaSwdvGRyqKSN NtoomlNepoF+VM0ndgnFE2svXmi81LS+kDs/n7m/CTPFQSM0uWisHzAjXYkv/w5ynRQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795041602; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=w/p4ytgCcogE2VFSFRlmtuDXhhtfEYRRH3hdf3F+GvM=; b=z0rvMhn+Zlj+hrYBpiSsTXGZtqeA1urbJk6pYHRrGE+Cxa7CKY+al8jZrBHGSQOSqHlD lFP0/+JrCCarPDPaNiKRo3IePioDDyjmQDE0SmsxwqEuZfuNfBn5Y+UdYrItOcbXdUkrX rpAitQ7PowMMH4JRn2T5P4asWd8zi5vi5AP0De5vKiq4gSZgGctrhTSxSRnnFV5SdGcja 2zjgVlRrwvke3bFovnULGe034+8gjBRsg9/Do7g0JenxNAK1WRjD3Dh53ChVgm0E/SjZi J7Djg0Q4qtfj0J1RoaLZ/UCt/kGfIs9Gk6QnmKaK7H8b6CRqfphhKMY4S0vHyTrzdRA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=dV4FCXLF; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4B362606A334; Wed, 18 Nov 2026 22:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=dV4FCXLF Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9C3A41F000C4; Wed, 18 Nov 2026 22:40:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1795041602; bh=w/p4ytgCcogE2VFSFRlmtuDXhhtfEYRRH3hdf3F+GvM=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=dV4FCXLFEpFVWqstglFjdHSPp7czDfuLpoj1wMhe8V/XQzVZ0cLU1KEXBPS3vTQD7 qTyRRiKgu2LN3UaoUkNzifEp9MeIADSvtb3XERFGRrflzkskfDrrvWz/npLiBZ3R/C 0CXMs8TeLFYBm8nLvvDvDUcg9MzEM8X1uaL3QfAg= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Karl Mehltretter , Arnd Bergmann , Russell King , Sasha Levin Subject: [PATCH 6.6 2872/3318] ARM: 9486/1: set !LPAE MAX_PHYSMEM_BITS to 32 and remove supersection mappings Date: Wed, 18 Nov 2026 15:58:14 +0100 Message-ID: <20261118150446.715646860@linuxfoundation.org> X-Mailer: git-send-email 2.56.0 In-Reply-To: <20261118150313.527275416@linuxfoundation.org> References: <20261118150313.527275416@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.6-stable review patch. If anyone has any objections, please let me know. ------------------ From: Karl Mehltretter [ Upstream commit 787a3446cafee59e31deaec662d74f86bff38999 ] An ARM randconfig with CONFIG_GET_FREE_REGION=y and CONFIG_WERROR=y fails to build: include/linux/minmax.h:86:37: error: conversion from 'long long unsigned int' to 'resource_size_t' {aka 'unsigned int'} changes value from '68719476735' to '4294967295' [-Werror=overflow] Commit 14b80582c43e ("resource: Introduce alloc_free_mem_region()") made kernel/resource.c clamp against (1ULL << MAX_PHYSMEM_BITS) - 1. resource_size_t is 32-bit without LPAE, but ARM's default MAX_PHYSMEM_BITS is 36. That default was added by commit db57f88e4ccb ("ARM: 8411/1: Add default SPARSEMEM settings") because several platforms needed at least 36 physical address bits. !LPAE could map addresses above 32 bits only through supersections. CONFIG_IO_36, added by commit 23bdf86aa06e ("[ARM] 3377/2: add support for intel xsc3 core"), enabled these for XSC3 I/O. IXP23xx placed static I/O mappings above 4GiB until its removal in 2012, and IOP13xx ioremap()ed its PCIe windows there until its removal in 2019. The only remaining XSC3 platform, PXA3xx, has nothing above 4GiB. Supersection address bits overlap the descriptor domain field, so IO_36 also renumbered the domains to make DOMAIN_IO zero. Remove IO_36, the alternate domain numbering, and ioremap()'s supersection path. Reject !LPAE ioremap ranges extending past 4GiB before phys_addr_t truncation, drop the now-unneeded high static-mapping exclusion, and reduce ioremap alignment from 16MiB to the 2MiB covered by a PMD's pair of sections. The other supersection user, create_36bit_mapping(), was added by commit 0b7cd62ecdc1 ("[ARM] 3017/1: Add support for 36-bit addresses to create_mapping()") for IXP2350 and carried IXP23xx's high static mappings. Before this change, its only remaining call path was efi_create_mapping() -> create_mapping_late(), for an EFI runtime region above 4GiB. No real-world user of this !LPAE path is known. AArch32 UEFI requires RAM described by its memory map to be identity-mapped during boot services, which a 32-bit virtual address space cannot provide above 4GiB. Systems needing wider physical addressing are expected to use LPAE. Remove create_36bit_mapping() and the supersection definitions. If firmware nevertheless advertises such a region on !LPAE, efi_create_mapping() rejects it before __pfn_to_phys() truncates its address to a low alias. EFI runtime services remain disabled, but the kernel continues to boot. LPAE kernels are unaffected. With no remaining !LPAE mappings above 4GiB, set MAX_PHYSMEM_BITS to 32 for !LPAE and retain 36 for LPAE, where phys_addr_t is 64-bit. Assisted-by: Claude:claude-fable-5 Link: https://lore.kernel.org/all/3c79d2dc-8fbd-40fc-8b2d-9d1b4f8ed34e@app.fastmail.com/ Link: https://lore.kernel.org/all/CAK8P3a2MCdUbN0QSb+M3g5_6HjPsaQwtKxFjADMZWomdry4-Ww@mail.gmail.com/ Fixes: 14b80582c43e ("resource: Introduce alloc_free_mem_region()") Signed-off-by: Karl Mehltretter Reviewed-by: Arnd Bergmann Signed-off-by: Russell King Signed-off-by: Sasha Levin --- arch/arm/include/asm/domain.h | 17 ----- arch/arm/include/asm/memory.h | 4 +- arch/arm/include/asm/pgtable-2level-hwdef.h | 1 - arch/arm/include/asm/pgtable-2level.h | 7 -- arch/arm/include/asm/sparsemem.h | 4 ++ arch/arm/kernel/efi.c | 13 ++++ arch/arm/mm/Kconfig | 7 -- arch/arm/mm/ioremap.c | 53 ++------------ arch/arm/mm/mmu.c | 76 +-------------------- 9 files changed, 27 insertions(+), 155 deletions(-) diff --git a/arch/arm/include/asm/domain.h b/arch/arm/include/asm/domain.h index 41536feb43921..02f235f51aedb 100644 --- a/arch/arm/include/asm/domain.h +++ b/arch/arm/include/asm/domain.h @@ -18,27 +18,10 @@ * DOMAIN_IO - domain 2 includes all IO only * DOMAIN_USER - domain 1 includes all user memory only * DOMAIN_KERNEL - domain 0 includes all kernel memory only - * - * The domain numbering depends on whether we support 36 physical - * address for I/O or not. Addresses above the 32 bit boundary can - * only be mapped using supersections and supersections can only - * be set for domain 0. We could just default to DOMAIN_IO as zero, - * but there may be systems with supersection support and no 36-bit - * addressing. In such cases, we want to map system memory with - * supersections to reduce TLB misses and footprint. - * - * 36-bit addressing and supersections are only available on - * CPUs based on ARMv6+ or the Intel XSC3 core. */ -#ifndef CONFIG_IO_36 #define DOMAIN_KERNEL 0 #define DOMAIN_USER 1 #define DOMAIN_IO 2 -#else -#define DOMAIN_KERNEL 2 -#define DOMAIN_USER 1 -#define DOMAIN_IO 0 -#endif #define DOMAIN_VECTORS 3 /* diff --git a/arch/arm/include/asm/memory.h b/arch/arm/include/asm/memory.h index ef2aa79ece5ad..8cf515e28bd94 100644 --- a/arch/arm/include/asm/memory.h +++ b/arch/arm/include/asm/memory.h @@ -89,9 +89,9 @@ #if !defined(CONFIG_SMP) && !defined(CONFIG_ARM_LPAE) /* - * Allow 16MB-aligned ioremap pages + * Allow 2MB-aligned ioremap pages */ -#define IOREMAP_MAX_ORDER 24 +#define IOREMAP_MAX_ORDER 21 #endif #define VECTORS_BASE UL(0xffff0000) diff --git a/arch/arm/include/asm/pgtable-2level-hwdef.h b/arch/arm/include/asm/pgtable-2level-hwdef.h index 556937e1790ee..3fa254ac8a265 100644 --- a/arch/arm/include/asm/pgtable-2level-hwdef.h +++ b/arch/arm/include/asm/pgtable-2level-hwdef.h @@ -35,7 +35,6 @@ #define PMD_SECT_APX (_AT(pmdval_t, 1) << 15) /* v6 */ #define PMD_SECT_S (_AT(pmdval_t, 1) << 16) /* v6 */ #define PMD_SECT_nG (_AT(pmdval_t, 1) << 17) /* v6 */ -#define PMD_SECT_SUPER (_AT(pmdval_t, 1) << 18) /* v6 */ #define PMD_SECT_AF (_AT(pmdval_t, 0)) #define PMD_SECT_UNCACHED (_AT(pmdval_t, 0)) diff --git a/arch/arm/include/asm/pgtable-2level.h b/arch/arm/include/asm/pgtable-2level.h index ce543cd9380cd..361f10db143a2 100644 --- a/arch/arm/include/asm/pgtable-2level.h +++ b/arch/arm/include/asm/pgtable-2level.h @@ -96,13 +96,6 @@ #define SECTION_SIZE (1UL << SECTION_SHIFT) #define SECTION_MASK (~(SECTION_SIZE-1)) -/* - * ARMv6 supersection address mask and size definitions. - */ -#define SUPERSECTION_SHIFT 24 -#define SUPERSECTION_SIZE (1UL << SUPERSECTION_SHIFT) -#define SUPERSECTION_MASK (~(SUPERSECTION_SIZE-1)) - #define USER_PTRS_PER_PGD (TASK_SIZE / PGDIR_SIZE) /* diff --git a/arch/arm/include/asm/sparsemem.h b/arch/arm/include/asm/sparsemem.h index 421e3415338ac..6b512be3a34a0 100644 --- a/arch/arm/include/asm/sparsemem.h +++ b/arch/arm/include/asm/sparsemem.h @@ -19,7 +19,11 @@ * These can be overridden in your mach/memory.h. */ #if !defined(MAX_PHYSMEM_BITS) || !defined(SECTION_SIZE_BITS) +#ifdef CONFIG_ARM_LPAE #define MAX_PHYSMEM_BITS 36 +#else +#define MAX_PHYSMEM_BITS 32 +#endif #define SECTION_SIZE_BITS 28 #endif diff --git a/arch/arm/kernel/efi.c b/arch/arm/kernel/efi.c index e94655ef16bb3..43fa65c2258d7 100644 --- a/arch/arm/kernel/efi.c +++ b/arch/arm/kernel/efi.c @@ -6,6 +6,7 @@ #include #include #include +#include #include #include @@ -54,6 +55,18 @@ int __init efi_create_mapping(struct mm_struct *mm, efi_memory_desc_t *md) .length = md->num_pages * EFI_PAGE_SIZE, }; + /* + * Non-LPAE page tables cannot map EFI runtime regions extending + * beyond the 32-bit physical address space. + */ + if (!IS_ENABLED(CONFIG_ARM_LPAE) && + (md->phys_addr >= SZ_4G || + md->num_pages > (SZ_4G - md->phys_addr) / EFI_PAGE_SIZE)) { + pr_warn("EFI runtime region at 0x%llx exceeds 32-bit physical address space\n", + md->phys_addr); + return -ERANGE; + } + /* * Order is important here: memory regions may have all of the * bits below set (and usually do), so we check them in order of diff --git a/arch/arm/mm/Kconfig b/arch/arm/mm/Kconfig index c164cde502434..3e3b36be3e2f0 100644 --- a/arch/arm/mm/Kconfig +++ b/arch/arm/mm/Kconfig @@ -328,7 +328,6 @@ config CPU_XSC3 select CPU_PABRT_LEGACY select CPU_THUMB_CAPABLE select CPU_TLB_V4WBI if MMU - select IO_36 # Marvell PJ1 (Mohawk) config CPU_MOHAWK @@ -652,12 +651,6 @@ config CPU_V7M_NUM_IRQ If unsure, keep default value. -# -# CPU supports 36-bit I/O -# -config IO_36 - bool - comment "Processor Features" config ARM_LPAE diff --git a/arch/arm/mm/ioremap.c b/arch/arm/mm/ioremap.c index 7801c5bb775d9..88c6e67e6df9e 100644 --- a/arch/arm/mm/ioremap.c +++ b/arch/arm/mm/ioremap.c @@ -30,8 +30,6 @@ #include #include -#include -#include #include #include #include @@ -236,39 +234,6 @@ remap_area_sections(unsigned long virt, unsigned long pfn, return 0; } -static int -remap_area_supersections(unsigned long virt, unsigned long pfn, - size_t size, const struct mem_type *type) -{ - unsigned long addr = virt, end = virt + size; - pmd_t *pmd = pmd_off_k(addr); - - /* - * Remove and free any PTE-based mapping, and - * sync the current kernel mapping. - */ - unmap_area_sections(virt, size); - do { - unsigned long super_pmd_val, i; - - super_pmd_val = __pfn_to_phys(pfn) | type->prot_sect | - PMD_SECT_SUPER; - super_pmd_val |= ((pfn >> (32 - PAGE_SHIFT)) & 0xf) << 20; - - for (i = 0; i < 8; i++) { - pmd[0] = __pmd(super_pmd_val); - pmd[1] = __pmd(super_pmd_val); - flush_pmd_entry(pmd); - - addr += PMD_SIZE; - pmd += 2; - } - - pfn += SUPERSECTION_SIZE >> PAGE_SHIFT; - } while (addr < end); - - return 0; -} #endif static void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn, @@ -278,15 +243,17 @@ static void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn, int err; unsigned long addr; struct vm_struct *area; - phys_addr_t paddr = __pfn_to_phys(pfn); + phys_addr_t paddr; #ifndef CONFIG_ARM_LPAE /* - * High mappings must be supersection aligned + * The physical range must not extend beyond the 32-bit + * phys_addr_t */ - if (pfn >= 0x100000 && (paddr & ~SUPERSECTION_MASK)) + if (((u64)pfn << PAGE_SHIFT) + offset + size > SZ_4G) return NULL; #endif + paddr = __pfn_to_phys(pfn); type = get_mem_type(mtype); if (!type) @@ -300,7 +267,7 @@ static void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn, /* * Try to reuse one of the static mapping whenever possible. */ - if (size && !(sizeof(phys_addr_t) == 4 && pfn >= 0x100000)) { + if (size) { struct static_vm *svm; svm = find_static_vm_paddr(paddr, size, mtype); @@ -326,13 +293,7 @@ static void __iomem * __arm_ioremap_pfn_caller(unsigned long pfn, area->phys_addr = paddr; #if !defined(CONFIG_SMP) && !defined(CONFIG_ARM_LPAE) - if (DOMAIN_IO == 0 && - (((cpu_architecture() >= CPU_ARCH_ARMv6) && (get_cr() & CR_XP)) || - cpu_is_xsc3()) && pfn >= 0x100000 && - !((paddr | size | addr) & ~SUPERSECTION_MASK)) { - area->flags |= VM_ARM_SECTION_MAPPING; - err = remap_area_supersections(addr, pfn, size, type); - } else if (!((paddr | size | addr) & ~PMD_MASK)) { + if (!((paddr | size | addr) & ~PMD_MASK)) { area->flags |= VM_ARM_SECTION_MAPPING; err = remap_area_sections(addr, pfn, size, type); } else diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c index 073de5b24560d..d72d9b7b478ba 100644 --- a/arch/arm/mm/mmu.c +++ b/arch/arm/mm/mmu.c @@ -866,69 +866,6 @@ static void __init alloc_init_p4d(pgd_t *pgd, unsigned long addr, } while (p4d++, addr = next, addr != end); } -#ifndef CONFIG_ARM_LPAE -static void __init create_36bit_mapping(struct mm_struct *mm, - struct map_desc *md, - const struct mem_type *type, - bool ng) -{ - unsigned long addr, length, end; - phys_addr_t phys; - pgd_t *pgd; - - addr = md->virtual; - phys = __pfn_to_phys(md->pfn); - length = PAGE_ALIGN(md->length); - - if (!(cpu_architecture() >= CPU_ARCH_ARMv6 || cpu_is_xsc3())) { - pr_err("MM: CPU does not support supersection mapping for 0x%08llx at 0x%08lx\n", - (long long)__pfn_to_phys((u64)md->pfn), addr); - return; - } - - /* N.B. ARMv6 supersections are only defined to work with domain 0. - * Since domain assignments can in fact be arbitrary, the - * 'domain == 0' check below is required to insure that ARMv6 - * supersections are only allocated for domain 0 regardless - * of the actual domain assignments in use. - */ - if (type->domain) { - pr_err("MM: invalid domain in supersection mapping for 0x%08llx at 0x%08lx\n", - (long long)__pfn_to_phys((u64)md->pfn), addr); - return; - } - - if ((addr | length | __pfn_to_phys(md->pfn)) & ~SUPERSECTION_MASK) { - pr_err("MM: cannot create mapping for 0x%08llx at 0x%08lx invalid alignment\n", - (long long)__pfn_to_phys((u64)md->pfn), addr); - return; - } - - /* - * Shift bits [35:32] of address into bits [23:20] of PMD - * (See ARMv6 spec). - */ - phys |= (((md->pfn >> (32 - PAGE_SHIFT)) & 0xF) << 20); - - pgd = pgd_offset(mm, addr); - end = addr + length; - do { - p4d_t *p4d = p4d_offset(pgd, addr); - pud_t *pud = pud_offset(p4d, addr); - pmd_t *pmd = pmd_offset(pud, addr); - int i; - - for (i = 0; i < 16; i++) - *pmd++ = __pmd(phys | type->prot_sect | PMD_SECT_SUPER | - (ng ? PMD_SECT_nG : 0)); - - addr += SUPERSECTION_SIZE; - phys += SUPERSECTION_SIZE; - pgd += SUPERSECTION_SIZE >> PGDIR_SHIFT; - } while (addr != end); -} -#endif /* !CONFIG_ARM_LPAE */ - static void __init __create_mapping(struct mm_struct *mm, struct map_desc *md, void *(*alloc)(unsigned long sz), bool ng) @@ -940,16 +877,6 @@ static void __init __create_mapping(struct mm_struct *mm, struct map_desc *md, type = &mem_types[md->type]; -#ifndef CONFIG_ARM_LPAE - /* - * Catch 36-bit addresses - */ - if (md->pfn >= 0x100000) { - create_36bit_mapping(mm, md, type, ng); - return; - } -#endif - addr = md->virtual & PAGE_MASK; phys = __pfn_to_phys(md->pfn); length = PAGE_ALIGN(md->length + (md->virtual & ~PAGE_MASK)); @@ -976,8 +903,7 @@ static void __init __create_mapping(struct mm_struct *mm, struct map_desc *md, * Create the page directory entries and any necessary * page tables for the mapping specified by `md'. We * are able to cope here with varying sizes and address - * offsets, and we take full advantage of sections and - * supersections. + * offsets, and we take full advantage of sections. */ static void __init create_mapping(struct map_desc *md) { -- 2.53.0