From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0E8DD3D8901 for ; Tue, 23 Jun 2026 15:25:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=13.77.154.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782228306; cv=none; b=LJDM9CRaGtBFihJMNrezbPhSI5e05GMkOvyk0lCS1NSTcMdXerSn+vQdHci0/43YHlUz7PUpRf016LkPxYKI5ZMNC1Ga2sAwzWg14kcDIX1vug97Ne2veyTH6YR4WtcXKqmiDFa1nbVmcIVcmFm5x2Udyqy0cIqYhoTUfqhi2X4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782228306; c=relaxed/simple; bh=398MH+0H43V5kSY0nQdQq0nr8tFErYDblW8tFEM4YJI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=SeoV1UAkRvyj5xiJznxtgGykFnk7++xQVHhtqp9Cw4dRFGU1VvxoTR9YJfYXDCiO/23RSnRqB22vUwQe+uVgIyc7T79sRLx95uoOOzG5pZQCBHW6U4t6IwTaskrWCFFsenaQ2fuiwcfd9t8WzhgmU3McOH9Kuy6XYf0F6BmKMXs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com; spf=pass smtp.mailfrom=linux.microsoft.com; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b=J1QX+6ex; arc=none smtp.client-ip=13.77.154.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.microsoft.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.microsoft.com header.i=@linux.microsoft.com header.b="J1QX+6ex" Received: by linux.microsoft.com (Postfix, from userid 1216) id 14D5E20B7169; Tue, 23 Jun 2026 08:25:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 14D5E20B7169 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1782228301; bh=NDGjnDDbHZmAZotRPI878m/r+XuDXlxTF31JBbT9VqM=; h=From:To:Cc:Subject:Date:From; b=J1QX+6exn5BZdF92+WU0J0T7P5a1clSr0kxQsxnaM4ywfe67xBhzgGSm5h8umsu/R 70Hrme5pzXKSj65zysTvWX/OXWZvKnUOQ+oNsR7d69aSaM3HaDCBvZ8eir1V/hiqzv 78KyjDTH6y2SsKOziQI+83ygJZi+qim6AhbLDu7o= From: Hamza Mahfooz To: x86@kernel.org Cc: Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , "H. Peter Anvin" , Andy Lutomirski , Peter Zijlstra , Ard Biesheuvel , Nathan Chancellor , linux-kernel@vger.kernel.org, Hamza Mahfooz , Jared White Subject: [PATCH v2 1/2] x86/build: only align ENTRY_TEXT to PMD_SIZE if necessary Date: Tue, 23 Jun 2026 11:24:29 -0400 Message-ID: <20260623152430.1473481-1-hamzamahfooz@linux.microsoft.com> X-Mailer: git-send-email 2.43.7 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit PTI requires the begin and end of ENTRY_TEXT be aligned to PMD_SIZE. SRSO requires srso_alias_untrain_ret to be 2M aligned. This costs between 2-4 MiB of RAM (depending on the size of the preceding section). So, only align when PTI is enabled or SRSO is enabled. Co-developed-by: Jared White Signed-off-by: Jared White Signed-off-by: Hamza Mahfooz --- arch/x86/kernel/vmlinux.lds.S | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/x86/kernel/vmlinux.lds.S b/arch/x86/kernel/vmlinux.lds.S index 4711a35e706c..53519fa7c772 100644 --- a/arch/x86/kernel/vmlinux.lds.S +++ b/arch/x86/kernel/vmlinux.lds.S @@ -65,8 +65,14 @@ const_cpu_current_top_of_stack = cpu_current_top_of_stack; __end_rodata_hpage_align = .; \ __end_rodata_aligned = .; +#if defined(CONFIG_MITIGATION_PAGE_TABLE_ISOLATION) || defined(CONFIG_MITIGATION_SRSO) #define ALIGN_ENTRY_TEXT_BEGIN . = ALIGN(PMD_SIZE); #define ALIGN_ENTRY_TEXT_END . = ALIGN(PMD_SIZE); +#else +#define ALIGN_ENTRY_TEXT_BEGIN +#define ALIGN_ENTRY_TEXT_END +#endif + #else #define X86_ALIGN_RODATA_BEGIN -- 2.54.0