Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp816382rwb; Mon, 26 Sep 2022 06:17:19 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Fl3h2vdFY6Oyy2UQc/Tq90s+p/SQHH2lid4B40QlLGoX+HwvvjPy2cC36yWI9kv+E4oJk X-Received: by 2002:a05:6402:2793:b0:451:fd7d:fc0b with SMTP id b19-20020a056402279300b00451fd7dfc0bmr22573162ede.13.1664198239233; Mon, 26 Sep 2022 06:17:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664198239; cv=none; d=google.com; s=arc-20160816; b=d7dKilVDci3bTyYxAjpsz0K8FqkLyQEW313pDNDMrKMYaEABSJsa4YnraDapsNFuvW fGPhrv7gyatrulz7YYFWpF1ltWZ/7ff7uIgplXD7jBeLh47TRuUWF1qtXRhmeLG7RkI8 I5l+OP07vsLFfH4TgB3Elror5xjHFTIXcwQ2L88b0Wq/jtbJ0KjDvCsElAgkfUSzlWJw sZMu0gsoJfH9l+uVGC9TAzNBe5QB6Cwc77BiIulKwi/t2epGLRfo48rR1twqN0KQvDJD f61NU7+6PXABc5QZsB0AgiXxrOYRitD6JMwt88h99COP5SiGjByx246oFvIjIw+Tdm0f PeTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=NT2YNJD8P59ITH0Ll1Q+KaC3TWkj/lYfewayZrMZWMQ=; b=nPqihAxgnwsLKsd7kI1s73GlvS4ad9h18/mbKh72/TSIFy+9kmHKYFfaTFuv4AKFXX S48GayupxSNivwrAdotvIxnc45nsRsvAd4BFaKqyrlEhPw1IjXxYJeyd5rdFUaFs4nAY Nhbva5JuyoSL9+93RWGilFVOOdvHlrWhU+7rT8iUILioBQkjOuQ3pbXD3da72J9eJJfL EfquK3llCuLkpm3+jjP2fQW9eFmvAUAUhpnaBUY3uL5u7/NKQA1r1Wte0440H9+IUSGw zJCasiX/k05rlhQDxSGz5NVGuTdDU4vZs9APubo37q5d2J4pSTwNOlaWi09c08alWdJX +2bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xqKBYzTx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g9-20020a056402090900b00451a9bc10casi18241074edz.196.2022.09.26.06.16.53; Mon, 26 Sep 2022 06:17:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=xqKBYzTx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234037AbiIZLWb (ORCPT + 99 others); Mon, 26 Sep 2022 07:22:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52212 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237789AbiIZLVD (ORCPT ); Mon, 26 Sep 2022 07:21:03 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E87F53031; Mon, 26 Sep 2022 03:39:13 -0700 (PDT) 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 3654660AF5; Mon, 26 Sep 2022 10:38:00 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A397C433D6; Mon, 26 Sep 2022 10:37:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1664188679; bh=R4uEFQXXft9s+qEOUmUElH92LOwYOg5bBGOVc1VHW+E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xqKBYzTxDKolVLxS3FKMp+jAOXBTkFP247tWeFuGnZw2TN2f5Cbowtw38u9NyCINi +L9oYFVAHcitZ7lTPbcqOvtpV/Am7vKiWp4BWB6zZhX/VuoXZzSbnu5c2yUte2Q3AJ bpBYelCtuvNj5qOvUgd5F5XGUhNjHkLYJpim3k2g= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sami Tolvanen , Mark Rutland , "Mohan Rao .vanimina" , Kees Cook , Nathan Chancellor , Will Deacon Subject: [PATCH 5.15 054/148] vmlinux.lds.h: CFI: Reduce alignment of jump-table to function alignment Date: Mon, 26 Sep 2022 12:11:28 +0200 Message-Id: <20220926100758.045992970@linuxfoundation.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220926100756.074519146@linuxfoundation.org> References: <20220926100756.074519146@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon commit 13b0566962914e167cb3238fbe29ced618f07a27 upstream. 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 Cc: Link: https://lore.kernel.org/all/CAL_GTzigiNOMYkOPX1KDnagPhJtFNqSK=1USNbS0wUL4PW6-Uw@mail.gmail.com/ Fixes: cf68fffb66d6 ("add support for Clang CFI") Reviewed-by: Mark Rutland Tested-by: Mark Rutland Reviewed-by: Sami Tolvanen Reviewed-by: Kees Cook Link: https://lore.kernel.org/r/20220922215715.13345-1-will@kernel.org Signed-off-by: Will Deacon Signed-off-by: Greg Kroah-Hartman --- include/asm-generic/vmlinux.lds.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -549,10 +549,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