From patchwork Thu May 11 14:12:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13238086 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 2D392C7EE22 for ; Thu, 11 May 2023 14:40:28 +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:References:In-Reply-To: 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: List-Owner; bh=elrMnsn6lyEXGToIo7LhEPZFhsdO2Z/wCdR/gpo2FGQ=; b=UdeXXgeNffYSiz 8TXUzxW8L4nqr06bMGDuVQ49zkKotbxrWeR/WagmSkF1lejJgmMZR8niggtie6sMIMQm9+qiRiB6B nbJzpdG2BP+YypLfsmsjTHlTa/EtF6Jz2aCYJPlIKrZprVA+X3IMBf3kcqDINmZFld5fCp9Dtrm6C fkvfFnj0Ki4apkEEgyFK+LnXP7vUlFNYz9TQTxozd+2fdZgeac5VXEx29EATy5z2BWLsJR3Ja17xQ cFFLmpdrbUMGu0uU52WKrK7AKbJuzZfsgm/CaWLiWvCGm5lyp6MH47u3sxCNANnZLuDzFisg088fY AxLZqYqTHJkaZ14rNhug==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1px7St-0095S8-28; Thu, 11 May 2023 14:40:19 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1px7Ss-0095QT-1q for linux-riscv@bombadil.infradead.org; Thu, 11 May 2023 14:40:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=dz7XGCHjq1dzsPGGS4F6j4OR5rErWwXp5TUKHxoryWE=; b=S8G47aRSj3yxJv98hixbpHusyV IISWXebofxVZXNSjVeK6/ujr7QEimzgONW8hZeOkR57bIIKxi+2yv1PDYEDNP5pdqRVD+jPensx/r yoEEYtGP2joshFTk1yIrQgioxEuOwcEpFZOOOng7tpIdKGIEPTDF89FO/LNA8ATsFCMtX0dhLlLzW nRcROLfsYr2lN9tnwQyi4CKKfk8NiCcmlf3NiVAUneRWRJFkvZ1HLE8nlSBej4yBTlmmgERZBz2eG PhV9fJNyJUjdqaPHSzNblU4CnreZcJlAHZuh74XEH8082SZE5V8vnFOf8Z4unLvZSDBQCdUfpfPZ9 D8Q0dGVg==; Received: from dfw.source.kernel.org ([139.178.84.217]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1px7CW-008GAH-0K for linux-riscv@lists.infradead.org; Thu, 11 May 2023 14:23:27 +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 0E08964DEE; Thu, 11 May 2023 14:23:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 991FBC433D2; Thu, 11 May 2023 14:23:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683815000; bh=RBBjQJhyNTq4SLepJRhrNnLCCMrJFLXtNe6TLcXndOU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=DuTL2omz4fj1qRlJSZXZGLrBNoL39rBeuQpXk/KjnbC+dCNf4/gp6IJF22P4VJuTU 5Kur7PM3FMd7AFMbVodq9zu/bH7kktW8XkJ/+PzymDCAmEDBvrAVzrwE0/Mpf1vDE1 Q2XB19rffNaqwD2DN8kZ6kNDnulVKfEHfvS3yxAbb1XgXJ5V+R3dx3NRkVLL0mar8Z +ajhWfJ0YLRTSbzTAv/aBaYgFmApf55tt4Rj18Bw1AzC6bbl+43pkg3Jr3oihI0ArN QM1onojNiOUFyt2IN193TDX3CeEGQXKyAnG5QVCT98vT4fjeFY9pIUDhiRljGoGKi4 0MOl+1qd56rVw== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 1/4] riscv: vmlinux-xip.lds.S: remove .alternative section Date: Thu, 11 May 2023 22:12:08 +0800 Message-Id: <20230511141211.2418-2-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230511141211.2418-1-jszhang@kernel.org> References: <20230511141211.2418-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230511_152324_327536_60904598 X-CRM114-Status: UNSURE ( 8.58 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org ALTERNATIVE mechanism can't work on XIP, and this is also reflected by below Kconfig dependency: RISCV_ALTERNATIVE ... depends on !XIP_KERNEL ... So there's no .alternative section at all for XIP case, remove it. Signed-off-by: Jisheng Zhang Reviewed-by: Conor Dooley --- arch/riscv/kernel/vmlinux-xip.lds.S | 6 ------ 1 file changed, 6 deletions(-) diff --git a/arch/riscv/kernel/vmlinux-xip.lds.S b/arch/riscv/kernel/vmlinux-xip.lds.S index eab9edc3b631..50767647fbc6 100644 --- a/arch/riscv/kernel/vmlinux-xip.lds.S +++ b/arch/riscv/kernel/vmlinux-xip.lds.S @@ -98,12 +98,6 @@ SECTIONS __soc_builtin_dtb_table_end = .; } - . = ALIGN(8); - .alternative : { - __alt_start = .; - *(.alternative) - __alt_end = .; - } __init_end = .; . = ALIGN(16); From patchwork Thu May 11 14:12:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13238088 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 E6A48C7EE22 for ; Thu, 11 May 2023 14:40:34 +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:References:In-Reply-To: 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: List-Owner; bh=zaWZ+8wJYBZz9G5LLDGNA4ZtexUeSiyIw1rn+hTq7Y0=; b=3RsTizhmYdJxPf 4nEUBCZbYPhN8RkIBU1el4eg8ZyBYijhIihHbzOXg46PovbhSLUmyWgQ6KOJG/47osvQlUe2XyCho mZXIihlWh2TgRZg86B8CCoXZCuLVokpwgt05wccID0+bFoTbrSwfrAbn0XYINPc+XH/Vn6Y+qrCwE b79Td9+XyvyZxTjyudT0HlfAZiDPYyOd4mzDfak34/3/UiPjwlXwScM9Ndvc8Pc5cpTFn1/m80uGc AGI6Fqdc2vhZC91yqc/VTGben1mcj2d0Mb9ebC6GW9DEVcJmf+uDgIc6HgTLB30y9lZeSkLjCLQ6i s/aQFS6Odpp4y+PZ/Wlg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1px7Su-0095SP-0g; Thu, 11 May 2023 14:40:20 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1px7Ss-0095QT-2g for linux-riscv@bombadil.infradead.org; Thu, 11 May 2023 14:40:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=KQLkrzwE28w39a6wsJfGHr8VTTBSiVuuIFiMskHqSL0=; b=XbX7DaaUfDdTVQ7E1c3NebSQ0p 0OO3VUlyE0G7Bk06MSj3dbcQVp6QP0RcTSSSlx0PK+lUViTluKh95VsAspBLl7B0y+J3iXhwJUjI9 /BVJ87rVBYBt0KTaGRV42jrmlBF6/5M0TiPlq8bHpM3V0ve4HhbnyHLG6esYL8nvMhCz+eo8U/1uo L2lnd5MlO/aiufzWVfArNWdLWEFxBgn6QQ/K0fH2HwceYkCp0vhr/jWqBoIXzmozNJG8DGsBORYL5 9BLBwXtRVl52vNSUZhimBiSvfcxcOWlGao5T6AwZKmH9l1CnrmKN9HXjqaWgO+5wyfhDwVgQ6el3R Hko8CJUw==; Received: from dfw.source.kernel.org ([139.178.84.217]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1px7CW-008GAI-0K for linux-riscv@lists.infradead.org; Thu, 11 May 2023 14:23: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 E91A664E03; Thu, 11 May 2023 14:23:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DCFA2C433EF; Thu, 11 May 2023 14:23:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683815002; bh=Qsoh2DY7RYTsIMpTH0GDqs55ax7692t2wbeau6VO2qk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uXb2rCTojbnqqTn8P5YlUMw1+SbNkb9+0LGdTYGVAsGB5VW7NiYN9ojgrezU7ny/I /4/MfKa1ZkIhiwP4Pxwvia4Fb44hFJFum1axBzCT0AunQRiQJYmqbeHky99hKG3Y4y hnlCgZd4yJo767E4hiQTcj2oSoQZWYDf4edI6H05y3e8Axa8JuV6dUrNTeQFkv/82C WFc2+SUJR7u6hIGjtwp9qNR+SpzY6xENyrESHr4WgLFQdLbO+yqP06u2gCFY0fWZZD EvQeqAUKXv2u3eUDWLZl+kZdcJYBvi+BLAY6Rch79ST0BeLCol71cqzKsN5l2GhPpX WYB2MfCiS68NQ== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 2/4] riscv: move HAVE_RETHOOK to keep entries sorted Date: Thu, 11 May 2023 22:12:09 +0800 Message-Id: <20230511141211.2418-3-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230511141211.2418-1-jszhang@kernel.org> References: <20230511141211.2418-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230511_152324_318661_3F0F6C53 X-CRM114-Status: GOOD ( 11.89 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Commit b57c2f124098 ("riscv: add riscv rethook implementation") selects the HAVE_RETHOOK option for the first time in riscv, but it breaks the entries order. Properly move its location to keep entries sorted. Signed-off-by: Jisheng Zhang Reviewed-by: Conor Dooley --- arch/riscv/Kconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 348c0fa1fc8c..f0663b52d052 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -110,7 +110,6 @@ config RISCV select HAVE_KPROBES if !XIP_KERNEL select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL select HAVE_KRETPROBES if !XIP_KERNEL - select HAVE_RETHOOK if !XIP_KERNEL select HAVE_MOVE_PMD select HAVE_MOVE_PUD select HAVE_PCI @@ -119,6 +118,7 @@ config RISCV select HAVE_PERF_USER_STACK_DUMP select HAVE_POSIX_CPU_TIMERS_TASK_WORK select HAVE_REGS_AND_STACK_ACCESS_API + select HAVE_RETHOOK if !XIP_KERNEL select HAVE_RSEQ select HAVE_STACKPROTECTOR select HAVE_SYSCALL_TRACEPOINTS From patchwork Thu May 11 14:12:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13238143 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 B0F25C77B7F for ; Thu, 11 May 2023 15:31:12 +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:References:In-Reply-To: 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: List-Owner; bh=Xve3aSYVASxQmW4GwuuoBNOc96C62kSjvZUPVa+S7a0=; b=fZZcspUsxijjTz A5U/+W+8ugulCyyLmfAosFlU3atO0b0ye+7KlTmtjYT44zP2SWqCTez86gpYDPDjFb9gnLxd4C9i4 kRToC8u8O0JRP0jsFGW9YyPKIjk4FK+8ie1FSCJXsoegJAbQCnrgfO4YuptB0x0LwJYghGeOn4vmB 36S5Oo+bBGr/PTCgAsJ/YNOU7vxt1vmQG+JRNp1of0XSL0RS2r1m1xv0deV40FAFj9LXbQjG55iUZ fgH6gbR9zjMbFvRcf9NaV77AR61Hlr2jFiPNFwC/mTfz6rZWQxASJDls3LiW+tghY4rW0AKpJp3pa tahKZZ1l6yYjUk7r+Lwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1px8G4-009DHN-2N; Thu, 11 May 2023 15:31:08 +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 1px7CX-00921g-2X for linux-riscv@lists.infradead.org; Thu, 11 May 2023 14:23:27 +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 D25B664E00; Thu, 11 May 2023 14:23:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C6235C433D2; Thu, 11 May 2023 14:23:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683815004; bh=XDpfU4QGkxHCk0PcVXqfWjLiQT8efnUkxx2g6qxryQw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qQiuEKd25qGNxzMC/VzrANFNkwAxyE7/iChs3QZIM0Bl4Uf4R84Ga0Dk42m888RVb fZ5NEuJv2QYk/nbcRcn0laW4g0chl+t0F6Ys/PVmoOzQFtoKnV8Cwq2Hnz1p/qyEdN 3VslTOtUm1M6/+smqskiwzYeuZtAeIFuxw5iJK6IfppnovvZMeSW+/RWvMFQmkKWsA QFVLYHSkX3p/xZVTibvWsP7LuGrv+ede51WSunQKrRYZ12ZZ1TEAs9KJkoCICil8WS NsAELJWQYEM/WSNI8mrXsecWykxDQQlRdYYIWKMGZ/9YsQWUpbJ9GfilidJPpuTkBl wkEaw9Qq3jlYw== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 3/4] vmlinux.lds.h: use correct .init.data.* section name Date: Thu, 11 May 2023 22:12:10 +0800 Message-Id: <20230511141211.2418-4-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230511141211.2418-1-jszhang@kernel.org> References: <20230511141211.2418-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230511_072325_865791_A3AB8AF2 X-CRM114-Status: GOOD ( 11.37 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org If building with -fdata-sections on riscv, LD_ORPHAN_WARN will warn similar as below: riscv64-linux-gnu-ld: warning: orphan section `.init.data.efi_loglevel' from `./drivers/firmware/efi/libstub/printk.stub.o' being placed in section `.init.data.efi_loglevel' I believe this is caused by a a typo: init.data.* should be .init.data.* Signed-off-by: Jisheng Zhang --- include/asm-generic/vmlinux.lds.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h index d1f57e4868ed..371026ca7221 100644 --- a/include/asm-generic/vmlinux.lds.h +++ b/include/asm-generic/vmlinux.lds.h @@ -688,7 +688,7 @@ /* init and exit section handling */ #define INIT_DATA \ KEEP(*(SORT(___kentry+*))) \ - *(.init.data init.data.*) \ + *(.init.data .init.data.*) \ MEM_DISCARD(init.data*) \ KERNEL_CTORS() \ MCOUNT_REC() \ From patchwork Thu May 11 14:12:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jisheng Zhang X-Patchwork-Id: 13238144 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 4F4C2C77B7C for ; Thu, 11 May 2023 15:31:13 +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:References:In-Reply-To: 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: List-Owner; bh=C1KpgZN1/7zk6HjL14wvQu4sm3Q3axxGYv4Ttj0Enao=; b=EuKWtGOImaP8fv pOOC98+p/Dz2ga2mki7PkogkL0KyPRJtgyPGVFUngiipmLEcaN67a4hW9Qi1j4EioiVwdCyAoXSDF KK5GX9PJUmwiUzl46ek05ckbVZXf7YRgVhsQaKojcD/S6g0iFLOnVRBSoLXptGIK8Mb0aiDj9s6H5 has7W1reucnFyrAeaPbidtn9t5f9eZoOVsx1PKXBKeGHqr0VboiiT+Gi/EdTjV2pCcwSooUpcRbEF 3llEY/YXykybBIDfZqarW9tiiZjgk1GdMl3F2MgFfS2D6LMDq2uwPJplvTQanT/srcbH4q6RiFgG/ CEFVTP73/oMhsMDHIfIA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1px8G5-009DHg-0j; Thu, 11 May 2023 15:31:09 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1px7Ca-00922v-0y for linux-riscv@lists.infradead.org; Thu, 11 May 2023 14:23:29 +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 3E428636FC; Thu, 11 May 2023 14:23:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AEFB6C433EF; Thu, 11 May 2023 14:23:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1683815006; bh=EAl7BYyGkHSJ9u4z4v03MJVzoloTTUlxQ/6IkxdvXp8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aQAlhdryVtLrijn4plCYeD8GrNC3jkYYQfYYiLdqFuCbLL01xeMxATi5/b0BGkM3s 9pL1vpl41G7btsU04qC3KrO87rvLds7PncrgXtCzI0TzlLyAxUfqxe9l6sJ8pXHMhd yhQTtQsY8s1Rz8rB2ADYYC5lq2GjgG6p1lMoJRviovB4jhO0IgiPOanGPdogFRFGKf M8lKdsRm3s25cOtf3C6WMjn6jdc7/xNC+H3pGs4NafKn5ftut5UIqYwf1d8y4dUyr/ 48sWhQwCzLUjfP7GoO7r/wnUGOitDR2Mu+i737iw2WCUlf+W9v8lzun7HeOBvYMGVS PA6Eg16UdnlTQ== From: Jisheng Zhang To: Paul Walmsley , Palmer Dabbelt , Albert Ou , Arnd Bergmann Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org Subject: [PATCH 4/4] riscv: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION Date: Thu, 11 May 2023 22:12:11 +0800 Message-Id: <20230511141211.2418-5-jszhang@kernel.org> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230511141211.2418-1-jszhang@kernel.org> References: <20230511141211.2418-1-jszhang@kernel.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230511_072328_380488_5CB9144F X-CRM114-Status: GOOD ( 12.74 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org When trying to run linux with various opensource riscv core on resource limited FPGA platforms, for example, those FPGAs with less than 16MB SDRAM, I want to save mem as much as possible. One of the major technologies is kernel size optimizations, I found that riscv does not currently support HAVE_LD_DEAD_CODE_DATA_ELIMINATION, which passes -fdata-sections, -ffunction-sections to CFLAGS and passes the --gc-sections flag to the linker. This not only benefits my case on FPGA but also benefits defconfigs. Here are some notable improvements from enabling this with defconfigs: nommu_k210_defconfig: text data bss dec hex 1112009 410288 59837 1582134 182436 before 962838 376656 51285 1390779 1538bb after rv32_defconfig: text data bss dec hex 8804455 2816544 290577 11911576 b5c198 before 8692295 2779872 288977 11761144 b375f8 after defconfig: text data bss dec hex 9438267 3391332 485333 13314932 cb2b74 before 9285914 3350052 483349 13119315 c82f53 after Signed-off-by: Jisheng Zhang --- arch/riscv/Kconfig | 1 + arch/riscv/kernel/vmlinux.lds.S | 6 +++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index f0663b52d052..a5feab2c3037 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -110,6 +110,7 @@ config RISCV select HAVE_KPROBES if !XIP_KERNEL select HAVE_KPROBES_ON_FTRACE if !XIP_KERNEL select HAVE_KRETPROBES if !XIP_KERNEL + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION select HAVE_MOVE_PMD select HAVE_MOVE_PUD select HAVE_PCI diff --git a/arch/riscv/kernel/vmlinux.lds.S b/arch/riscv/kernel/vmlinux.lds.S index e5f9f4677bbf..492dd4b8f3d6 100644 --- a/arch/riscv/kernel/vmlinux.lds.S +++ b/arch/riscv/kernel/vmlinux.lds.S @@ -85,11 +85,11 @@ SECTIONS INIT_DATA_SECTION(16) .init.pi : { - *(.init.pi*) + KEEP(*(.init.pi*)) } .init.bss : { - *(.init.bss) /* from the EFI stub */ + KEEP(*(.init.bss*)) /* from the EFI stub */ } .exit.data : { @@ -112,7 +112,7 @@ SECTIONS . = ALIGN(8); .alternative : { __alt_start = .; - *(.alternative) + KEEP(*(.alternative)) __alt_end = .; } __init_end = .;