Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp116494rwb; Thu, 22 Sep 2022 15:21:54 -0700 (PDT) X-Google-Smtp-Source: AMsMyM432XAYMMyfAJSyaK+sXxHbqhWCapkV01od+GxikK4trtS1fw4+6rPHM568NOSgzuiZuAUh X-Received: by 2002:a17:902:e5c2:b0:178:2eca:9dea with SMTP id u2-20020a170902e5c200b001782eca9deamr5500822plf.73.1663885314574; Thu, 22 Sep 2022 15:21:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663885314; cv=none; d=google.com; s=arc-20160816; b=e/UP77SqzoanTB0sCEH35mxItcjlZMFmE8+yeWMaqf6Y4l4Y3rZEudBnHPPMPaGJ2q gsyFMIEMyNnirUbQVjs8of0e00wiJYYcMeUv2TT8PiUveVvxrG6OXxGAxYGzImteY/yS q6hZoWTjd7sxXyZaIx6hL/F0mUqzUTvB+3tLcoC3zH48iN19pPKLQkkO37GjKLBILHxy Iinih/BZW1/HRm2Iswx8BK8oce+PzcNBTUWPQbkhDXzAYYv/gj0PYl1n+cYaauigcOe3 zOGY9ZO2WQfmnen0Sz2yalcZRl+8BHVX5ghtrmmq7NfxTnMGKlJqRPXwPO5MU6TGr0H1 UipQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=8mmDzTjTwdyVCkuv2LhLaN7iv9xpdvt5u1R+GMpWPbI=; b=MJf3VJCp7WVHY8PSognti96U3u1C0lYdoS9xfGXi3dqKZKwj28X8M3TGWnSvdM9tw/ S870A+P0a9O1QfbRF30bVpvP/KElIaDZNZ6CrJX6KV5ymYWyWI6y23IAvv9fI2K2aX5m du4FGmzdoqLetOZ6OkRv53RIujhZ7JIvzTx9zGr+BC/8v23qQF+YHE9hOOh5fhF6ictN vWRJM2XV9JIi/BKhxPN8h1FhtS97vWQ3mVNt7oPQNgUCe82c1eNs5tXm4lQBpVfjOlqr UvEGwqLvBq2hWpRtq6yfYKlx2sIFStuUAV3HBp/xAqhDcT8puGaUxi7ZVF8YTPTNlQlQ DvUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=PTfjnG2i; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qe6-20020a17090b4f8600b002033d9e3618si878533pjb.154.2022.09.22.15.21.42; Thu, 22 Sep 2022 15:21:54 -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=@kernel.org header.s=k20201202 header.b=PTfjnG2i; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230129AbiIVV50 (ORCPT + 99 others); Thu, 22 Sep 2022 17:57:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229993AbiIVV5Y (ORCPT ); Thu, 22 Sep 2022 17:57:24 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D40CA109779 for ; Thu, 22 Sep 2022 14:57:23 -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 ams.source.kernel.org (Postfix) with ESMTPS id 8C123B835BE for ; Thu, 22 Sep 2022 21:57:22 +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 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 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 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 --- 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 -- 2.37.3.998.g577e59143f-goog