Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.128.50 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796090006; b=LjcnS2JmoZQ5HQ5uVMTvPDU9GHyaMF3VX+n0EqZS6FOqNVi1pYD6EQBEa/0XFKiq5V0L JMk87nbu1UBe5bQTH3mCvBJXA0Crj4GZguqzCQpXK5KUkEStkZX3X1VLysgRhjnkilh/p eESSdncvqAuvWO5gLNLUDzcKBHcjntNKs2hZY2u5dSvsRCcekKg8jx7UGxKh4Xzc22Ak5 TkSBbiggVkydZF9lx4S1mRg1UIX0i4p6X/uXlPe0GO5uyjSBO0PuqBuqNHtqVeZY2Sm7a ZMOJfe6dhd6RnpWnFHLi8xVGAwcgTkD/YUfj2NQIUfyUnduB3nz49ovTWYNsrIwE0nw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796090006; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: From:To:Cc:Subject:Date:Message-ID:X-Mailer:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; bh=pmXwNInIwHCtxv7bMlWMAzicejrWnjoX2ivjbAlxQIc=; b=nikP96l6D2G1vgEp+LBzGLyD7jDc+u3z2YR2UDIC3Ie5xC876mxEwpivyQwgpCnUESYy fabHaAanRVPqQ+urb7IyG43NWb3UrPv3AbHtBANRs0YFkiv2JeiYrkDp8SI4dZXVp75jF 8Xqey54NDXp9Pz1bnx01LeAaYXmF3xzUNxhcDHHm3cLmyVB+4SH9CdhU1R6TK/FEgojSs HS02DH28wTh8JuV80b7lH7xPocLxC6CwLDHVgqslJBbHD4S4lEmAfpWvrKF1JRxIAbZgV 0c8C3oA2kwSvO5+Genzm0gROY/5+k2wjy3cSxYke7opNw3Dd0fqaIP6MK+xfEW/qoEQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=RiaGmQTv; arc=none smtp.remote-ip=209.85.128.50 Received: from mail-wm1-f50.google.com (mail-wm1-f50.google.com [209.85.128.50]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 02CFF606A331 for ; Tue, 1 Dec 2026 01:53:25 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 02CFF606A331 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20260707 header.b=RiaGmQTv Received: by mail-wm1-f50.google.com with SMTP id 5b1f17b1804b1-4a214c5c4c0so108629405e9.3 for ; Mon, 30 Nov 2026 17:53:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20260707; t=1796090004; x=1796694804; darn=lists.linux.dev; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=pmXwNInIwHCtxv7bMlWMAzicejrWnjoX2ivjbAlxQIc=; b=RiaGmQTvps4HcSOKnCuAhxnKACQHFBKEy2AlYeut8/SjhLN7QSpsCz7Ez80lmCLn/K k2yP7GUOYhfdYBXQMtAhpvDxYtEChvg0yMIRDrozTQJMI24KE5vAvFmOj4wbDRKxAf2c z/gkPoPqAnHInJJErmjesIZOPsGuX8ov+uJVNUByyjD7mF/WnpR3O4/QvINn9faK7EOI MQN3xdnrCREPm9QNEJUthXXYM73SVvhxl4xB7oSA4atjKfqLeT+dKV6tEuZtG/zqHqEX bj6sX7acGbNiD1NmHIXOOj+/PUmuMsjogVEF1faiBm3XdyeApOn/34lbaOzf4zesSzbP FdnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796090004; x=1796694804; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=pmXwNInIwHCtxv7bMlWMAzicejrWnjoX2ivjbAlxQIc=; b=TBKoeTgTEZbJ4Z0L1xKXRN1+uBdBRqgdw08+tdXkaygC6ZXqfeGYMVxT35E70vuxLI WlHg//bNEVodqqOI2pnZ+U8SYklGoOFMRtmKDRcECZHvJSxj09GXABs23ft4TtZIDCdR YJE8SDpDT1lJWgRWvPOVJLTKMDuRcadIPUSczhICkiwwwnr4J6ouHG560Cx3qAQx4TXv OVOdsS2oaCEq5/bKJLVTC9muX/bAbz/bZsHny4dtSdr5+3V7lpwMNsYKeRKjivGzsmvA QgHBW6WAReOh4r4u43qfTfY3bPklbq9BOj4fp3LIGCMqyUhp1jEMN7ynQQzEGPYkgmKr p/LA== X-Forwarded-Encrypted: i=1; AL+hErF4nRGMVL7GoPtrU9WucjTLKZR3+PpfwEuE3dtdtSVUArAPLMzc0mK3GajKKcnqcwZDrnZxM/4=@lists.linux.dev X-Gm-Message-State: APuU4Z9TJvo37ank5SdD6JJBvRn9KHyMkUSoCprIgGs4OE+dwXYbyZqG g/q5T0DBzHYNRLN7xpQnFYZg0kgs1KkIBeMRySwQW0bE6BIkpKS/x5fp X-Gm-Gg: AZFdTZcgGTCUhj8mLRinX9utYqi5vFR0y3bNrnuCy5y8jChCbt81RXbQdT3wTAU+LwV /5pgj+5UlCfXrN+wXwoaOm2kdFfFeuwCnU1yBboVvWqUIW4mUScVkUeED0cVV8pI/1xeSI2A/NA X84eLrlw2d1al6eDjjPOBCk9QuHGXTdD7M4vftQABScoMMrdmaswvgJypuTw6O0Mk0F5wy8sU2w lLjUlX7hRFWpJU+YpPCyyzvzBnPLgmkZM83mYrYoNN3IyNP2s7ziMqFlnJFywxknx5pjgSpjLtu nGu2bKqwggOuBTu3C9pMd8qzJt1k/fR16Rdl8gJ0wJzLrgi6J1ES8tMo5a9DhDSxNn/uJj8cPsK iSfM7PXYLYMcDBiP9lrZjYt6lRdFgqMV8T3UmAlahsnP+7YxS/B9lqehwOukV2eYHsmZQOyUhWN UR3TDJGc8nlVj/DTS15yq30HsvAYgP2VBlNCj6dK1WrlGaMO4gR/BIw8oFDZKkviLju82DDp9Zg pPGXZ0kiM7aBdgV6/l67jAtGr+Zvr4NvmoDYWnsF5Cr3GSesdr29wuH8HaCHuiiMRKOZ/u92fni tOvWvRe9E9pcWo1tYI2r3dgrdvGhSXDUhNiMH60= X-Received: by 2002:a05:600c:4fd6:b0:4bb:aa4f:c027 with SMTP id 5b1f17b1804b1-4bbca9a47f9mr55998795e9.0.1796090004067; Mon, 30 Nov 2026 17:53:24 -0800 (PST) Received: from NULL.Home.net ([2001:8a0:7280:4000:12d:c3b9:cecc:8966]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4bb884911e3sm1199037055e9.6.2026.11.30.17.53.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 17:53:23 -0800 (PST) From: Eric Curtin To: linux-arm-kernel@lists.infradead.org Cc: Ryan Roberts , Catalin Marinas , Will Deacon , Mark Rutland , Marc Zyngier , Oliver Upton , Fuad Tabba , Joey Gouly , Steffen Eiden , Suzuki K Poulose , Zenghui Yu , kvmarm@lists.linux.dev Subject: [RFC PATCH v2 22/43] arm64: Align image sections to PAGE_SIZE_MAX Date: Tue, 1 Dec 2026 01:51:54 +0000 Message-ID: <20261201015240.1017259-23-ericcurtin17@gmail.com> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261201015240.1017259-1-ericcurtin17@gmail.com> References: <20261201015240.1017259-1-ericcurtin17@gmail.com> X-Mailing-List: kvmarm@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 From: Ryan Roberts With boot-time page size selection the sections that are mapped with page granularity, such as the hyp sections, the vDSO images, the page table directories and the data and BSS regions, must be aligned for the largest page size that may be selected. PAGE_SIZE is not a constant in the linker script or assembly, so use PAGE_SIZE_MAX instead. Switch ALIGN(), RO_DATA(), RW_DATA(), BSS_SECTION(), the reserved, swapper and trampoline directory offsets, the hyp.lds.S percpu section and the vDSO .balign directives from PAGE_SIZE to PAGE_SIZE_MAX. The vDSO data mapping length in vdso.c is changed to match. The trampoline text, which has to fit the smallest page, keeps a limit based on PAGE_SIZE_MIN in the "HYP init code too big" and "Entry trampoline text too big" assertions, and the alignment that followed the trampoline text is moved to after __entry_tramp_text_end. For a compile-time page size PAGE_SIZE_MAX equals PAGE_SIZE and the image is unchanged. For a boot-time page size build the image is comparable in size to one built for 64K pages. Signed-off-by: Ryan Roberts Signed-off-by: Eric Curtin (cherry picked from commit f2ff15f09dae013f6c02715972759154ae9a000c) --- arch/arm64/include/asm/memory.h | 4 +-- arch/arm64/kernel/vdso-wrap.S | 4 +-- arch/arm64/kernel/vdso.c | 4 +-- arch/arm64/kernel/vdso32-wrap.S | 4 +-- arch/arm64/kernel/vmlinux.lds.S | 46 +++++++++++++++---------------- arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 2 +- 6 files changed, 32 insertions(+), 32 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index a6df911206ff..05a8efc6810d 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -201,13 +201,13 @@ * Open-coded (swapper_pg_dir - reserved_pg_dir) as this cannot be calculated * until link time. */ -#define RESERVED_SWAPPER_OFFSET (PAGE_SIZE) +#define RESERVED_SWAPPER_OFFSET (PAGE_SIZE_MAX) /* * Open-coded (swapper_pg_dir - tramp_pg_dir) as this cannot be calculated * until link time. */ -#define TRAMP_SWAPPER_OFFSET (2 * PAGE_SIZE) +#define TRAMP_SWAPPER_OFFSET (2 * PAGE_SIZE_MAX) #ifndef __ASSEMBLER__ diff --git a/arch/arm64/kernel/vdso-wrap.S b/arch/arm64/kernel/vdso-wrap.S index c4b1990bf2be..79fa77628199 100644 --- a/arch/arm64/kernel/vdso-wrap.S +++ b/arch/arm64/kernel/vdso-wrap.S @@ -13,10 +13,10 @@ .globl vdso_start, vdso_end .section .rodata - .balign PAGE_SIZE + .balign PAGE_SIZE_MAX vdso_start: .incbin "arch/arm64/kernel/vdso/vdso.so" - .balign PAGE_SIZE + .balign PAGE_SIZE_MAX vdso_end: .previous diff --git a/arch/arm64/kernel/vdso.c b/arch/arm64/kernel/vdso.c index 50596dab23f9..8459ac3288cf 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -108,7 +108,7 @@ static int __setup_additional_pages(enum vdso_abi abi, vdso_text_len = vdso_info[abi].vdso_pages << PAGE_SHIFT; /* Be sure to map the data page */ - vdso_mapping_len = vdso_text_len + VDSO_NR_PAGES * PAGE_SIZE; + vdso_mapping_len = vdso_text_len + VDSO_NR_PAGES * PAGE_SIZE_MAX; vdso_base = get_unmapped_area(NULL, 0, vdso_mapping_len, 0, 0); if (IS_ERR_VALUE(vdso_base)) { @@ -123,7 +123,7 @@ static int __setup_additional_pages(enum vdso_abi abi, if (system_supports_bti_kernel()) gp_flags = VM_ARM64_BTI; - vdso_base += VDSO_NR_PAGES * PAGE_SIZE; + vdso_base += VDSO_NR_PAGES * PAGE_SIZE_MAX; mm->context.vdso = (void *)vdso_base; ret = _install_special_mapping(mm, vdso_base, vdso_text_len, VM_READ|VM_EXEC|gp_flags| diff --git a/arch/arm64/kernel/vdso32-wrap.S b/arch/arm64/kernel/vdso32-wrap.S index e72ac7bc4c04..1c6069d6c457 100644 --- a/arch/arm64/kernel/vdso32-wrap.S +++ b/arch/arm64/kernel/vdso32-wrap.S @@ -10,10 +10,10 @@ .globl vdso32_start, vdso32_end .section .rodata - .balign PAGE_SIZE + .balign PAGE_SIZE_MAX vdso32_start: .incbin "arch/arm64/kernel/vdso32/vdso.so" - .balign PAGE_SIZE + .balign PAGE_SIZE_MAX vdso32_end: .previous diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index ca3016f284d5..eb253341711c 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -25,26 +25,26 @@ #define HYPERVISOR_RODATA_SECTIONS \ HYP_SECTION_NAME(.rodata) : { \ - . = ALIGN(PAGE_SIZE); \ + . = ALIGN(PAGE_SIZE_MAX); \ __hyp_rodata_start = .; \ *(HYP_SECTION_NAME(.data..ro_after_init)) \ *(HYP_SECTION_NAME(.rodata)) \ HYPERVISOR_EVENT_IDS \ - . = ALIGN(PAGE_SIZE); \ + . = ALIGN(PAGE_SIZE_MAX); \ __hyp_rodata_end = .; \ } #define HYPERVISOR_DATA_SECTION \ HYP_SECTION_NAME(.data) : { \ - . = ALIGN(PAGE_SIZE); \ + . = ALIGN(PAGE_SIZE_MAX); \ __hyp_data_start = .; \ *(HYP_SECTION_NAME(.data)) \ - . = ALIGN(PAGE_SIZE); \ + . = ALIGN(PAGE_SIZE_MAX); \ __hyp_data_end = .; \ } #define HYPERVISOR_PERCPU_SECTION \ - . = ALIGN(PAGE_SIZE); \ + . = ALIGN(PAGE_SIZE_MAX); \ HYP_SECTION_NAME(.data..percpu) : { \ *(HYP_SECTION_NAME(.data..percpu)) \ } @@ -59,7 +59,7 @@ #define BSS_FIRST_SECTIONS \ __hyp_bss_start = .; \ *(HYP_SECTION_NAME(.bss)) \ - . = ALIGN(PAGE_SIZE); \ + . = ALIGN(PAGE_SIZE_MAX); \ __hyp_bss_end = .; /* @@ -68,7 +68,7 @@ * between them, which can in some cases cause the linker to misalign them. To * work around the issue, force a page alignment for __bss_start. */ -#define SBSS_ALIGN PAGE_SIZE +#define SBSS_ALIGN PAGE_SIZE_MAX #else /* CONFIG_KVM */ #define HYPERVISOR_EXTABLE #define HYPERVISOR_RODATA_SECTIONS @@ -96,14 +96,14 @@ ENTRY(_text) jiffies = jiffies_64; #define HYPERVISOR_TEXT \ - . = ALIGN(PAGE_SIZE); \ + . = ALIGN(PAGE_SIZE_MAX); \ __hyp_idmap_text_start = .; \ *(.hyp.idmap.text) \ __hyp_idmap_text_end = .; \ __hyp_text_start = .; \ *(.hyp.text) \ HYPERVISOR_EXTABLE \ - . = ALIGN(PAGE_SIZE); \ + . = ALIGN(PAGE_SIZE_MAX); \ __hyp_text_end = .; #define IDMAP_TEXT \ @@ -134,11 +134,11 @@ jiffies = jiffies_64; #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 #define TRAMP_TEXT \ - . = ALIGN(PAGE_SIZE); \ + . = ALIGN(PAGE_SIZE_MAX); \ __entry_tramp_text_start = .; \ *(.entry.tramp.text) \ - . = ALIGN(PAGE_SIZE); \ __entry_tramp_text_end = .; \ + . = ALIGN(PAGE_SIZE_MAX); \ *(.entry.tramp.rodata) #else #define TRAMP_TEXT @@ -210,7 +210,7 @@ SECTIONS _etext = .; /* End of text section */ /* everything from this point to __init_begin will be marked RO NX */ - RO_DATA(PAGE_SIZE) + RO_DATA(PAGE_SIZE_MAX) HYPERVISOR_RODATA_SECTIONS @@ -237,22 +237,22 @@ SECTIONS HIBERNATE_TEXT KEXEC_TEXT IDMAP_TEXT - . = ALIGN(PAGE_SIZE); + . = ALIGN(PAGE_SIZE_MAX); } idmap_pg_dir = .; - . += PAGE_SIZE; + . += PAGE_SIZE_MAX; #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 tramp_pg_dir = .; - . += PAGE_SIZE; + . += PAGE_SIZE_MAX; #endif reserved_pg_dir = .; - . += PAGE_SIZE; + . += PAGE_SIZE_MAX; swapper_pg_dir = .; - . += PAGE_SIZE; + . += PAGE_SIZE_MAX; . = ALIGN(SEGMENT_ALIGN); __init_begin = .; @@ -323,7 +323,7 @@ SECTIONS _data = .; _sdata = .; - RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN) + RW_DATA(L1_CACHE_BYTES, PAGE_SIZE_MAX, THREAD_ALIGN) HYPERVISOR_DATA_SECTION @@ -357,16 +357,16 @@ SECTIONS _edata = .; /* start of zero-init region */ - BSS_SECTION(SBSS_ALIGN, 0, PAGE_SIZE) + BSS_SECTION(SBSS_ALIGN, 0, PAGE_SIZE_MAX) __pi___bss_start = __bss_start; /* page table BSS starts here - preceding data/BSS is omitted from the linear map */ - .pgtbl : ALIGN(PAGE_SIZE) { + .pgtbl : ALIGN(PAGE_SIZE_MAX) { *(.bss..pgtbl) } ASSERT(ADDR(.pgtbl) == __bss_stop, ".pgtbl must follow BSS") - . = ALIGN(PAGE_SIZE); + . = ALIGN(PAGE_SIZE_MAX); __pi_init_pg_dir = .; . += INIT_DIR_SIZE_MAX; __pi_init_pg_end = .; @@ -405,7 +405,7 @@ SECTIONS * former is page-aligned, but the latter may not be with 16K or 64K pages, so * it should also not cross a page boundary. */ -ASSERT(__hyp_idmap_text_end - __hyp_idmap_text_start <= PAGE_SIZE, +ASSERT(__hyp_idmap_text_end - __hyp_idmap_text_start <= PAGE_SIZE_MIN, "HYP init code too big") ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K, "ID map text too big or misaligned") @@ -416,7 +416,7 @@ ASSERT(__hibernate_exit_text_start == swsusp_arch_suspend_exit, "Hibernate exit text does not start with swsusp_arch_suspend_exit") #endif #ifdef CONFIG_UNMAP_KERNEL_AT_EL0 -ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) <= 3*PAGE_SIZE, +ASSERT((__entry_tramp_text_end - __entry_tramp_text_start) <= 3 * PAGE_SIZE_MIN, "Entry trampoline text too big") #endif #ifdef CONFIG_KVM diff --git a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S index 89222425359a..69b8fdbc977e 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S @@ -26,7 +26,7 @@ SECTIONS { * .hyp..data..percpu needs to be page aligned to maintain the same * alignment for when linking into vmlinux. */ - . = ALIGN(PAGE_SIZE); + . = ALIGN(PAGE_SIZE_MAX); BEGIN_HYP_SECTION(.data..percpu) PERCPU_INPUT(L1_CACHE_BYTES) END_HYP_SECTION