From patchwork Mon Oct 14 10:58:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ryan Roberts X-Patchwork-Id: 13834712 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D95C3D1A43B for ; Mon, 14 Oct 2024 11:01:46 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E350D6B00D6; Mon, 14 Oct 2024 07:01:45 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id DBC876B00D8; Mon, 14 Oct 2024 07:01:45 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C5F536B00D9; Mon, 14 Oct 2024 07:01:45 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id A3FA36B00D6 for ; Mon, 14 Oct 2024 07:01:45 -0400 (EDT) Received: from smtpin08.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id 35178ABCB3 for ; Mon, 14 Oct 2024 11:01:30 +0000 (UTC) X-FDA: 82671917118.08.3B0F186 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by imf28.hostedemail.com (Postfix) with ESMTP id C8244C001A for ; Mon, 14 Oct 2024 11:01:37 +0000 (UTC) Authentication-Results: imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf28.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728903672; a=rsa-sha256; cv=none; b=1tDy2cchji7/WcIi242EbFSx/H1jnpUcglz5aDABNSFNtwrf3MdMqZ4oNPl+nV4y2LS5Kf fVCdBQhBdrMjn1PCCwVyfX5MGymgwhd9oIyCinGiWet8Vs3pj5xWvn0Z1smMdwv1BLb6Xm 0VSoa8MOCEU1kQB04WB6Ii1tAy0zsU0= ARC-Authentication-Results: i=1; imf28.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=arm.com; spf=pass (imf28.hostedemail.com: domain of ryan.roberts@arm.com designates 217.140.110.172 as permitted sender) smtp.mailfrom=ryan.roberts@arm.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728903672; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XkvwSRpxq/ReVb2KZsrYsZWT5AXEytyt77PllAZm++A=; b=3kxTJ0jBzOR0GuppQX6yteezCcrUYEKbGYOK017lHoeGGOxmqYyFNrPTrjhDYTz4sn/iPQ T5iJfndppGul9/cpSdwt8tkO/w7kVKzgD+TkSZwCYXTtjcaW4v/H700sah9EfJC0cixUsy xT0SxnbO2kiEF6Igy/loIQaPqO26Uy8= Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AEC241763; Mon, 14 Oct 2024 04:02:12 -0700 (PDT) Received: from e125769.cambridge.arm.com (e125769.cambridge.arm.com [10.1.196.27]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 722EB3F51B; Mon, 14 Oct 2024 04:01:40 -0700 (PDT) From: Ryan Roberts To: Andrew Morton , Anshuman Khandual , Ard Biesheuvel , Catalin Marinas , David Hildenbrand , Greg Marsden , Ivan Ivanov , Kalesh Singh , Marc Zyngier , Mark Rutland , Matthias Brugger , Miroslav Benes , Oliver Upton , Will Deacon Cc: Ryan Roberts , kvmarm@lists.linux.dev, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Subject: [RFC PATCH v1 44/57] arm64: Align sections to PAGE_SIZE_MAX Date: Mon, 14 Oct 2024 11:58:51 +0100 Message-ID: <20241014105912.3207374-44-ryan.roberts@arm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241014105912.3207374-1-ryan.roberts@arm.com> References: <20241014105514.3206191-1-ryan.roberts@arm.com> <20241014105912.3207374-1-ryan.roberts@arm.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: su7jrfy91smegafs4izhzrbor9coigfd X-Rspamd-Queue-Id: C8244C001A X-Rspamd-Server: rspam02 X-HE-Tag: 1728903697-563734 X-HE-Meta: U2FsdGVkX18UMajl+fb/ZgqPEO/YCVsI866Y5UB5nWZc9WClPhaSXOWNziBRBo9WOBRwPv4XRIshhy5vPAKLy9A3/PH3MH/fl2H0Aoh12lTyQy2k+Dcf6AgEvsNcyAoJE/TsEM8fJ7oc/a3t6ZSmlEZo8l/PJWOhvkwRRm4XX/BuwhPinMqzlEqXVrmG9sILo4nrR1ul2dpbggz06VYK/YT06Vm8XbxZZNE/+mBnqeWFQFSeQGERizWfZXk5V5OBCpxPs2bvs+jf+n5etBEUoIOelNlndFD2krh1U7il5fmN6aNbP7tGINh4O/4kz2WIieksvmJ3LwsS+L+GF09gUOEtL7fT4uX4xFNtl0sDretB8e+tGutzdgbbp1rkL7YzaPSXilgUMNMv9vj0/9e8Gy4GAyHIYa4aU7XRKR7oYKDONWDvrgD4k78+mvtS3/RDIeNLjdgviFl9wKHXDrpxKaidx5Tjk3bqe8xfSk3lZaE5L2aSxAuwAQx0ePmXUCDRA6ojzARfeT3woPBZKQRrXtv+eIXtfJz8j9GIbpE3Ip2IHj9SuJlSaFhpcifyiB8JrfwWWjzlrAqHlcltJNzkKa6gG1Q+wPnZg9ievRtfGb3Xnl43hn1j91oQwmXg2eI2UhJdg2WhYaDMAgxlR/tk0BTXwBoMizwlW3nu/cQDdeHPEYnNq6kB16oYVM9QzZvgbDizAurySV6kbQRw2ybG/3Ly8npekAxZr0Li73XmSNQfAklcu1m8GAXPRAYAycZMJbJ/k6L48CG8RGrSLT5nf/x5PIxNh+g5AsKLDpL6OAJ/9LVGsO+GsAjNJItzwGzkvJRg16DftXjplHkU9qgIOBTV04if1sEdtifURT9Q4vXz1VnY70m3lhYua2JrU1EEd5VKMWFRr8WpkKOKNbACEqtgfjTJA8hXI+qcWnr5BiK83TF4gJXHULUxxHu1m0IJt6I7MxhWER97gNjKed3 TE4hnUoy 767sFTOUH3fKxmx98z0g/HcZJTmToN4ZkpohrEy8tL4K7wbrmYGOkwuoRhZ4uKFEnZhbJEIp6dWIfQYYkrDFJetHKLp17mp2YR1hjFHBDf6M16pn9I5Zrl1FQyjNgWNMi927vSKe9Y5RY/VM4PPojNXZIkFqg7TWHbqsmWrG9aUb468hxdw2BzkFAXhJhvNs5efZAN7CcSSzht2dsng0ndQND6RId1TyFehsQ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Increase alignment of sections in nvhe hyp, vdso and final vmlinux image from PAGE_SIZE to PAGE_SIZE_MAX. For compile-time PAGE_SIZE, PAGE_SIZE_MAX == PAGE_SIZE so there is no change. For boot-time PAGE_SIZE, PAGE_SIZE_MAX is the largest selectable page size. For a boot-time page size build, image size is comparable to a 64K page size compile-time build. In future, it may be desirable to optimize run-time memory consumption by freeing unused padding pages when the boot-time selected page size is less than PAGE_SIZE_MAX. Signed-off-by: Ryan Roberts --- ***NOTE*** Any confused maintainers may want to read the cover note here for context: https://lore.kernel.org/all/20241014105514.3206191-1-ryan.roberts@arm.com/ arch/arm64/include/asm/memory.h | 4 +-- arch/arm64/kernel/vdso-wrap.S | 4 +-- arch/arm64/kernel/vdso.c | 7 +++--- arch/arm64/kernel/vdso/vdso.lds.S | 4 +-- arch/arm64/kernel/vdso32-wrap.S | 4 +-- arch/arm64/kernel/vdso32/vdso.lds.S | 4 +-- arch/arm64/kernel/vmlinux.lds.S | 38 ++++++++++++++--------------- arch/arm64/kvm/hyp/nvhe/hyp.lds.S | 2 +- 8 files changed, 34 insertions(+), 33 deletions(-) diff --git a/arch/arm64/include/asm/memory.h b/arch/arm64/include/asm/memory.h index 6aa97fa22dc30..5393a859183f7 100644 --- a/arch/arm64/include/asm/memory.h +++ b/arch/arm64/include/asm/memory.h @@ -195,13 +195,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 __ASSEMBLY__ diff --git a/arch/arm64/kernel/vdso-wrap.S b/arch/arm64/kernel/vdso-wrap.S index c4b1990bf2be0..79fa77628199b 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 89b6e78400023..1efe98909a2e0 100644 --- a/arch/arm64/kernel/vdso.c +++ b/arch/arm64/kernel/vdso.c @@ -195,7 +195,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 + VVAR_NR_PAGES * PAGE_SIZE; + vdso_mapping_len = vdso_text_len + VVAR_NR_PAGES * PAGE_SIZE_MAX; vdso_base = get_unmapped_area(NULL, 0, vdso_mapping_len, 0, 0); if (IS_ERR_VALUE(vdso_base)) { @@ -203,7 +203,8 @@ static int __setup_additional_pages(enum vdso_abi abi, goto up_fail; } - ret = _install_special_mapping(mm, vdso_base, VVAR_NR_PAGES * PAGE_SIZE, + ret = _install_special_mapping(mm, vdso_base, + VVAR_NR_PAGES * PAGE_SIZE_MAX, VM_READ|VM_MAYREAD|VM_PFNMAP, vdso_info[abi].dm); if (IS_ERR(ret)) @@ -212,7 +213,7 @@ static int __setup_additional_pages(enum vdso_abi abi, if (system_supports_bti_kernel()) gp_flags = VM_ARM64_BTI; - vdso_base += VVAR_NR_PAGES * PAGE_SIZE; + vdso_base += VVAR_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/vdso/vdso.lds.S b/arch/arm64/kernel/vdso/vdso.lds.S index 45354f2ddf706..f7d1537a689e8 100644 --- a/arch/arm64/kernel/vdso/vdso.lds.S +++ b/arch/arm64/kernel/vdso/vdso.lds.S @@ -18,9 +18,9 @@ OUTPUT_ARCH(aarch64) SECTIONS { - PROVIDE(_vdso_data = . - __VVAR_PAGES * PAGE_SIZE); + PROVIDE(_vdso_data = . - __VVAR_PAGES * PAGE_SIZE_MAX); #ifdef CONFIG_TIME_NS - PROVIDE(_timens_data = _vdso_data + PAGE_SIZE); + PROVIDE(_timens_data = _vdso_data + PAGE_SIZE_MAX); #endif . = VDSO_LBASE + SIZEOF_HEADERS; diff --git a/arch/arm64/kernel/vdso32-wrap.S b/arch/arm64/kernel/vdso32-wrap.S index e72ac7bc4c04f..1c6069d6c457e 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/vdso32/vdso.lds.S b/arch/arm64/kernel/vdso32/vdso.lds.S index 8d95d7d35057d..c46d18a69d1ce 100644 --- a/arch/arm64/kernel/vdso32/vdso.lds.S +++ b/arch/arm64/kernel/vdso32/vdso.lds.S @@ -18,9 +18,9 @@ OUTPUT_ARCH(arm) SECTIONS { - PROVIDE_HIDDEN(_vdso_data = . - __VVAR_PAGES * PAGE_SIZE); + PROVIDE_HIDDEN(_vdso_data = . - __VVAR_PAGES * PAGE_SIZE_MAX); #ifdef CONFIG_TIME_NS - PROVIDE_HIDDEN(_timens_data = _vdso_data + PAGE_SIZE); + PROVIDE_HIDDEN(_timens_data = _vdso_data + PAGE_SIZE_MAX); #endif . = VDSO_LBASE + SIZEOF_HEADERS; diff --git a/arch/arm64/kernel/vmlinux.lds.S b/arch/arm64/kernel/vmlinux.lds.S index 7f3f6d709ae73..1ef6dea13b57c 100644 --- a/arch/arm64/kernel/vmlinux.lds.S +++ b/arch/arm64/kernel/vmlinux.lds.S @@ -15,16 +15,16 @@ #define HYPERVISOR_DATA_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)) \ - . = ALIGN(PAGE_SIZE); \ + . = ALIGN(PAGE_SIZE_MAX); \ __hyp_rodata_end = .; \ } #define HYPERVISOR_PERCPU_SECTION \ - . = ALIGN(PAGE_SIZE); \ + . = ALIGN(PAGE_SIZE_MAX); \ HYP_SECTION_NAME(.data..percpu) : { \ *(HYP_SECTION_NAME(.data..percpu)) \ } @@ -39,7 +39,7 @@ #define BSS_FIRST_SECTIONS \ __hyp_bss_start = .; \ *(HYP_SECTION_NAME(.bss)) \ - . = ALIGN(PAGE_SIZE); \ + . = ALIGN(PAGE_SIZE_MAX); \ __hyp_bss_end = .; /* @@ -48,7 +48,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_DATA_SECTIONS @@ -75,14 +75,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 \ @@ -113,11 +113,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 @@ -187,7 +187,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_DATA_SECTIONS @@ -206,22 +206,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 = .; @@ -290,7 +290,7 @@ SECTIONS _data = .; _sdata = .; - RW_DATA(L1_CACHE_BYTES, PAGE_SIZE, THREAD_ALIGN) + RW_DATA(L1_CACHE_BYTES, PAGE_SIZE_MAX, THREAD_ALIGN) /* * Data written with the MMU off but read with the MMU on requires @@ -317,7 +317,7 @@ SECTIONS /* start of zero-init region */ BSS_SECTION(SBSS_ALIGN, 0, 0) - . = ALIGN(PAGE_SIZE); + . = ALIGN(PAGE_SIZE_MAX); init_pg_dir = .; . += INIT_DIR_SIZE_MAX; init_pg_end = .; @@ -356,7 +356,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 <= SZ_4K, "HYP init code too big") ASSERT(__idmap_text_end - (__idmap_text_start & ~(SZ_4K - 1)) <= SZ_4K, "ID map text too big or misaligned") @@ -367,7 +367,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 * SZ_4K, "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 f4562f417d3fc..74c7c21626270 100644 --- a/arch/arm64/kvm/hyp/nvhe/hyp.lds.S +++ b/arch/arm64/kvm/hyp/nvhe/hyp.lds.S @@ -21,7 +21,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