Messages in this thread Patches in this message | | | From | Sedat Dilek <> | Date | Sat, 27 Feb 2021 21:13:54 +0100 | Subject | Re: [PATCH] [RFC] arm64: enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION |
| |
On Fri, Feb 26, 2021 at 11:02 AM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > On Fri, Feb 26, 2021 at 10:51 AM Arnd Bergmann <arnd@kernel.org> wrote: > > > > On Fri, Feb 26, 2021 at 10:05 AM Sedat Dilek <sedat.dilek@gmail.com> wrote: > > > On Fri, Feb 26, 2021 at 9:14 AM Arnd Bergmann <arnd@kernel.org> wrote: > > > > > > > > BTW, is CONFIG_LD_DEAD_CODE_DATA_ELIMINATION=y setable for x86 (64bit)? > > > > > ( Did not look or check for it. ) > > > > > > > > No, in mainline, HAVE_LD_DEAD_CODE_DATA_ELIMINATION is currently > > > > only selected on MIPS and PowerPC. I only sent experimental patches to > > > > enable it on arm64 and m68k, but have not tried booting them. If you > > > > select the symbol on x86, you should see similar results. > > > > > > > > > > OK, i see: > > > > > > $ git grep HAVE_LD_DEAD_CODE_DATA_ELIMINATION arch/mips/ > > > arch/mips/Kconfig: select HAVE_LD_DEAD_CODE_DATA_ELIMINATION > > > > > > $ git grep HAVE_LD_DEAD_CODE_DATA_ELIMINATION arch/powerpc/ > > > arch/powerpc/Kconfig: select HAVE_LD_DEAD_CODE_DATA_ELIMINATION > > > > > > So, I need to add this to arch/x86/Kconfig. > > > > > > You happen to know if changes to arch/x86/kernel/vmlinux.lds.S > > > (sections) are needed? > > > > No idea. I'm still debugging a possible regression on arm64, but both > > issues I found for arm64 are specific to that architecture and won't > > happen on x86. It's likely that something else breaks though. > > > > My first experiences with gc were with the freetz project (mips > embedded router) and don't ask me what GCC version. > > I will try with gc + trim + cfi later after my current build has finished. > > > > Last question: > > > The last days I see a lot of fixes touching inlining with LLVM/Clang v13-git. > > > What git tag are you using? > > > What are your experiences? > > > Pending patches (kernel-side)? > > > > > > I use: > > > $ /opt/llvm-toolchain/bin/clang --version > > > dileks clang version 13.0.0 (https://github.com/llvm/llvm-project.git > > > c465429f286f50e52a8d2b3b39f38344f3381cce) > > > > This is what I have on the build box: > > Ubuntu clang version > > 13.0.0-++20210223104451+ebca13c66504-1~exp1~20210223095200.234 > > > > Distro-clang takes much longer here. > Selfmade stage1-only LLVM toolchain compiles here 10% faster. > cfi takes approx. 20% longer. > With trim + gc I suppose it will take much longer. > > Let me test. > Will report later. >
With the attached patch and diff (some modules need whitelisted symbols) I was able to compile an x86-64 Linux-kernel. It does not boot on bare metal.
If someone wants to play with it.
- Sedat - From d5fce344393bb76b2370f09a0eb80a137c0047f7 Mon Sep 17 00:00:00 2001 From: Sedat Dilek <sedat.dilek@gmail.com> Date: Fri, 26 Feb 2021 14:32:12 +0100 Subject: [PATCH] x86: kconfig: Enable HAVE_LD_DEAD_CODE_DATA_ELIMINATION
Signed-off-by: Sedat Dilek <sedat.dilek@gmail.com> --- arch/x86/Kconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index cd4b9b1204a8..d5f5f296f92f 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -205,6 +205,7 @@ config X86 select HAVE_FUNCTION_ERROR_INJECTION select HAVE_KRETPROBES select HAVE_KVM + select HAVE_LD_DEAD_CODE_DATA_ELIMINATION select HAVE_LIVEPATCH if X86_64 select HAVE_MIXED_BREAKPOINTS_REGS select HAVE_MOD_ARCH_SPECIFIC -- 2.30.1 diff --git a/scripts/gen_autoksyms.sh b/scripts/gen_autoksyms.sh index da320151e7c3..4e3360c6e5ea 100755 --- a/scripts/gen_autoksyms.sh +++ b/scripts/gen_autoksyms.sh @@ -36,7 +36,28 @@ if [ -n "$CONFIG_LTO_CLANG" ]; then needed_symbols="$needed_symbols _mcount" # stack protector symbols needed_symbols="$needed_symbols __stack_chk_fail __stack_chk_guard" -fi + if [ -n "CONFIG_LD_DEAD_CODE_DATA_ELIMINATION" ] && [ -n "CONFIG_TRIM_UNUSED_KSYMS" ]; then + # ex_handler_XXX symbols + needed_symbols="$needed_symbols ex_handler_uaccess ex_handler_clear_fs ex_handler_fprestore ex_handler_rdmsr_unsafe ex_handler_wrmsr_unsafe" + # __fentry__ symbol + needed_symbols="$needed_symbols __fentry__" + # __get_user_XXX and __put_user_XXX symbols + needed_symbols="$needed_symbols __get_user_1 __get_user_2 __get_user_4 __get_user_8" + needed_symbols="$needed_symbols __put_user_1 __put_user_2 __put_user_4 __put_user_8" + needed_symbols="$needed_symbols __get_user_nocheck_1 __get_user_nocheck_2 __get_user_nocheck_4 __get_user_nocheck_8" + needed_symbols="$needed_symbols __put_user_nocheck_1 __put_user_nocheck_2 __put_user_nocheck_4 __put_user_nocheck_8" + # __sw_hweight32 and __sw_hweight64 symbols + needed_symbols="$needed_symbols __sw_hweight32 __sw_hweight64" + # __x86_indirect_thunk_r11 symbol + needed_symbols="$needed_symbols __x86_indirect_thunk_r11" + # __x86_retpoline_rax and __x86_retpoline_rsi symbols + needed_symbols="$needed_symbols __x86_retpoline_rax __x86_retpoline_rsi" + fi # CONFIG_LD_DEAD_CODE_DATA_ELIMINATION && CONFIG_TRIM_UNUSED_KSYMS + if [ -n "$CONFIG_CFI_CLANG" ]; then + # __ubsan_handle_cfi_check_fail_abort symbol + needed_symbols="$needed_symbols __ubsan_handle_cfi_check_fail_abort" + fi # CONFIG_CFI_CLANG +fi # CONFIG_LTO_CLANG ksym_wl= if [ -n "$CONFIG_UNUSED_KSYMS_WHITELIST" ]; then[unhandled content-type:application/octet-stream] | |