Patch "x86/purgatory: Remove LTO flags" has been added to the 5.15-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    x86/purgatory: Remove LTO flags

to the 5.15-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     x86-purgatory-remove-lto-flags.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit c7114e3b4cb26973bc083984b73f4aa580ef946e
Author: Song Liu <song@xxxxxxxxxx>
Date:   Thu Sep 14 10:01:38 2023 -0700

    x86/purgatory: Remove LTO flags
    
    [ Upstream commit 75b2f7e4c9e0fd750a5a27ca9736d1daa7a3762a ]
    
    -flto* implies -ffunction-sections. With LTO enabled, ld.lld generates
    multiple .text sections for purgatory.ro:
    
      $ readelf -S purgatory.ro  | grep " .text"
        [ 1] .text             PROGBITS         0000000000000000  00000040
        [ 7] .text.purgatory   PROGBITS         0000000000000000  000020e0
        [ 9] .text.warn        PROGBITS         0000000000000000  000021c0
        [13] .text.sha256_upda PROGBITS         0000000000000000  000022f0
        [15] .text.sha224_upda PROGBITS         0000000000000000  00002be0
        [17] .text.sha256_fina PROGBITS         0000000000000000  00002bf0
        [19] .text.sha224_fina PROGBITS         0000000000000000  00002cc0
    
    This causes WARNING from kexec_purgatory_setup_sechdrs():
    
      WARNING: CPU: 26 PID: 110894 at kernel/kexec_file.c:919
      kexec_load_purgatory+0x37f/0x390
    
    Fix this by disabling LTO for purgatory.
    
    [ AFAICT, x86 is the only arch that supports LTO and purgatory. ]
    
    We could also fix this with an explicit linker script to rejoin .text.*
    sections back into .text. However, given the benefit of LTOing purgatory
    is small, simply disable the production of more .text.* sections for now.
    
    Fixes: b33fff07e3e3 ("x86, build: allow LTO to be selected")
    Signed-off-by: Song Liu <song@xxxxxxxxxx>
    Signed-off-by: Ingo Molnar <mingo@xxxxxxxxxx>
    Reviewed-by: Nick Desaulniers <ndesaulniers@xxxxxxxxxx>
    Reviewed-by: Sami Tolvanen <samitolvanen@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230914170138.995606-1-song@xxxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/arch/x86/purgatory/Makefile b/arch/x86/purgatory/Makefile
index dc0b91c1db04b..7a7701d1e18d0 100644
--- a/arch/x86/purgatory/Makefile
+++ b/arch/x86/purgatory/Makefile
@@ -19,6 +19,10 @@ CFLAGS_sha256.o := -D__DISABLE_EXPORTS
 # optimization flags.
 KBUILD_CFLAGS := $(filter-out -fprofile-sample-use=% -fprofile-use=%,$(KBUILD_CFLAGS))
 
+# When LTO is enabled, llvm emits many text sections, which is not supported
+# by kexec. Remove -flto=* flags.
+KBUILD_CFLAGS := $(filter-out $(CC_FLAGS_LTO),$(KBUILD_CFLAGS))
+
 # When linking purgatory.ro with -r unresolved symbols are not checked,
 # also link a purgatory.chk binary without -r to check for unresolved symbols.
 PURGATORY_LDFLAGS := -e purgatory_start -nostdlib -z nodefaultlib



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux