From patchwork Thu Sep 22 21:57:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 12985840 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3D79EC54EE9 for ; Thu, 22 Sep 2022 21:58:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=HazwPPirxLtkUYBbg2MlsMJW0ZxQeHenxFjb62OJf+c=; b=3Wr901U4mQ69KR 4ay6sklqH9h7musOGmmkFcgg5TetIdm4cfTZhAP/E5VgCqi74zd0/wTA0IST1eSJmJo0nmQ9wQsR8 zz6vZCyLdnoxT5O+vNhqETh8/J6FQ++2+PzJzkx+4iATG3JQr+654CUf3htlqQFak2krs5MOOeZwX IrHjMjkQ6UG0Tp/z5opwOlcgeXZPlksjMWwBKv1diBBK/QhZ4nzC7JLt/+zy4Qoh9RJftsUF7QcBe AGJI0oVHsho8eaQAxoC7cQiAApf/qFdnVn3rjuojbNyhMViBdthE4kh5+2k63mJ4cAQUpjC3SC6dY SO/497NYvfEjlbYGxsJQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1obUCG-000QSD-Gn; Thu, 22 Sep 2022 21:57:28 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1obUCC-000QRU-Px for linux-arm-kernel@lists.infradead.org; Thu, 22 Sep 2022 21:57:26 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id C905F61232; Thu, 22 Sep 2022 21:57:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 982C0C433C1; Thu, 22 Sep 2022 21:57:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1663883841; bh=kqodCzuwqlqJ5UyM36OG0YSUsgR4TArBAX8DBB1ASFU=; h=From:To:Cc:Subject:Date:From; b=PTfjnG2iEDg1ssayJZVxAqy0W9aPqVt10MfyjVKPXoq11fVr6Q8RDDgZVcATF8mMO J25acTm6gBUiDZq/PE2jfd/pRhvYJFD3vm8teudftvby2xL8x4+SjrTulp0thVal0w Z40GVwbDH4KH3HK2tiBxGjQAYP8+e4EcP7/uDYoKc3rkxzg9X4qpfnvJcQYGKF+tc8 g7CohjrrX6CtoWDIGECvqeZvaHnSpx2jAuUvxJP89BMvduMqwa2PPApe3D4DRxwxQF LKIjQBbuEG3mg4yCfLaiXmLour9jOhiQ2T6RMxdlR8wi6GvufleDAnheAQ3pozGrQW OBFbcYDXMjRkA== From: Will Deacon To: linux-kernel@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Will Deacon , Sami Tolvanen , Mark Rutland , "Mohan Rao .vanimina" , Kees Cook , Nathan Chancellor Subject: [PATCH] vmlinux.lds.h: CFI: Reduce alignment of jump-table to function alignment Date: Thu, 22 Sep 2022 22:57:15 +0100 Message-Id: <20220922215715.13345-1-will@kernel.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220922_145724_902838_10BE9BDE X-CRM114-Status: GOOD ( 14.26 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Due to undocumented, hysterical raisins on x86, the CFI jump-table sections in .text are needlessly aligned to PMD_SIZE in the vmlinux linker script. When compiling a CFI-enabled arm64 kernel with a 64KiB page-size, a PMD maps 512MiB of virtual memory and so the .text section increases to a whopping 940MiB and blows the final Image up to 960MiB. Others report a link failure. Since the CFI jump-table requires only instruction alignment, reduce the alignment directives to function alignment for parity with other parts of the .text section. This reduces the size of the .text section for the aforementioned 64KiB page size arm64 kernel to 19MiB for a much more reasonable total Image size of 39MiB. Cc: Sami Tolvanen Cc: Mark Rutland Cc: "Mohan Rao .vanimina" Cc: Kees Cook Cc: Nathan Chancellor Link: https://lore.kernel.org/all/CAL_GTzigiNOMYkOPX1KDnagPhJtFNqSK=1USNbS0wUL4PW6-Uw@mail.gmail.com/ Fixes: cf68fffb66d60 ("add support for Clang CFI") Signed-off-by: Will Deacon Reviewed-by: Sami Tolvanen Reviewed-by: Kees Cook Reviewed-by: Mark Rutland Tested-by: Mark Rutland --- include/asm-generic/vmlinux.lds.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index 7515a465ec03..7c90b1ab3e00 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -543,10 +543,9 @@ */ #ifdef CONFIG_CFI_CLANG #define TEXT_CFI_JT \ - . = ALIGN(PMD_SIZE); \ + ALIGN_FUNCTION(); \ __cfi_jt_start = .; \ *(.text..L.cfi.jumptable .text..L.cfi.jumptable.*) \ - . = ALIGN(PMD_SIZE); \ __cfi_jt_end = .; #else #define TEXT_CFI_JT