From patchwork Mon Jun 19 14:37:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 13284595 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 31DB7EB64D9 for ; Mon, 19 Jun 2023 14:37:57 +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=FNVufbRrWdYwnzgtKxl+xbZgFTkhd3B02Zxe9ViJhLg=; b=vpARWLXtow81vM YX1jl1J5hbT8w9xqk0ZeFSW7gVyW2WhK1QnbVmcc31JBu+oNXb7eG4A6j3Dh/X2+HYRq3np1sz7XA Iv57w9B/jDgPh/m/KFHeXWDuvsf1h0e5jEMEtCacME0n24tGrMC/VPeQv46sj4+HicURvcw7zrEMR Yhh4t4+IlsoAAZDqZytWr3ooSGKm+O3ltZJzDoj9SfItNgWtb0AIwGv/EKsr5DeAaIMMqBuWwXVF/ qFWdbAeR6Wm22kgga4zmTJ8zECJDeZrYQogzNoD5aiG5EdwgDqWlUucZmo52tTGf5zCLkDpYfY9pk 86DXaxKzfdjCua99WQzQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qBG0d-008evR-23; Mon, 19 Jun 2023 14:37:35 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qBG0a-008ev3-1J for linux-arm-kernel@lists.infradead.org; Mon, 19 Jun 2023 14:37:33 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 94AA760C7B; Mon, 19 Jun 2023 14:37:31 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54BD1C433C0; Mon, 19 Jun 2023 14:37:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1687185451; bh=cKXZj60yRSK1IRgf3ZaAN3xJcXaOIkypoexKrxHMOhs=; h=From:To:Cc:Subject:Date:From; b=QH0bwh7t/Urer7GKMlsBQid+Lf8kVUaQTAtIDH76W4UJYv1gGjxTg2yNqLDo4zKnz ToVQqgo1qSFzOkQNm5YHLgf/0lrDc1nZdm/XZ7NNiFHck64gJC98ol21RnDSTu2I7k 9Fw3L5OVAk68dKIr1AB5nxJEB+/70lbS9KUQdz+MpacjJz0uZ1WKiHVt2vsv/p1hwF S0IM1Pbh+CgIaC0SupzbmqAHH6pz5mhSZ7B/+snZsvIdSTdSnvlKz36n31ILHDk4GS 2ZoY5kBKGu5kpL6ANlRpeJ1V48gghKpjehS27GNYhxmgp/rx3dPYqNPP1blHJjeUrM wtpYhJa6QQk8w== From: Masahiro Yamada To: linux-arm-kernel@lists.infradead.org, linux-kbuild@vger.kernel.org, Russell King Cc: linux-kernel@vger.kernel.org, Ard Biesheuvel , Nick Desaulniers , Masahiro Yamada Subject: [PATCH] ARM: change link order of $(mmy-y) to avoid veneers Date: Mon, 19 Jun 2023 23:37:25 +0900 Message-Id: <20230619143725.57967-1-masahiroy@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230619_073732_511357_BCC457E4 X-CRM114-Status: GOOD ( 15.69 ) 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 The kernel compiled with multi_v7_defconfig + CONFIG_KASAN=y + CONFIG_KASAN_INLINE=y does not boot. I do not think KASAN is the direct reason of the boot failure. CONFIG_KASAN_INLINE is just one example configuration that grows the image size significantly and makes a big distance between function callers and callees. I see some veneers for __get_user_* in the bad kernel image. I am not perfectly clear, but __get_user_* may not work with veneers for some reasons. If I move the link order of arch/arm/lib/getuser.S, the veneers are gone, and the kernel gets working again. I do not see a good reason that $(mmu-y) must be added to lib-y because all the code in $(mmu-y) is mandatory. Add it to obj-y to move the code to lower address. [1] multi_v7_defconfig (works) $ arm-linux-gnueabihf-nm vmlinux | grep __get_user_1 c072a450 T __get_user_1 c17ea033 r __kstrtab___get_user_1 c18119fe r __kstrtabns___get_user_1 c17c4878 r __ksymtab___get_user_1 [2] multi_v7_defconfig + CONFIG_KASAN_INLINE (does not work) $ arm-linux-gnueabihf-nm vmlinux | grep __get_user_1 c341ec2c T __get_user_1 c06e3580 t ____get_user_1_veneer c0adc6c0 t ____get_user_1_veneer c12cf054 t ____get_user_1_veneer c43f42cc r __kstrtab___get_user_1 c441c128 r __kstrtabns___get_user_1 c43cead8 r __ksymtab___get_user_1 [3] multi_v7_defconfig + CONFIG_KASAN_INLINE + this patch (works) $ arm-linux-gnueabihf-nm vmlinux | grep __get_user_1 c10975b0 T __get_user_1 c43f42cc r __kstrtab___get_user_1 c441c128 r __kstrtabns___get_user_1 c43cead8 r __ksymtab___get_user_1 Signed-off-by: Masahiro Yamada --- arch/arm/lib/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm/lib/Makefile b/arch/arm/lib/Makefile index 650404be6768..4d092ef87a1d 100644 --- a/arch/arm/lib/Makefile +++ b/arch/arm/lib/Makefile @@ -28,7 +28,7 @@ endif # using lib_ here won't override already available weak symbols obj-$(CONFIG_UACCESS_WITH_MEMCPY) += uaccess_with_memcpy.o -lib-$(CONFIG_MMU) += $(mmu-y) +obj-$(CONFIG_MMU) += $(mmu-y) ifeq ($(CONFIG_CPU_32v3),y) lib-y += io-readsw-armv3.o io-writesw-armv3.o