]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
powerpc/64: Handle linker stubs in low .text code
authorNicholas Piggin <npiggin@gmail.com>
Mon, 29 May 2017 07:39:40 +0000 (17:39 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 30 May 2017 04:59:51 +0000 (14:59 +1000)
Very large kernels may require linker stubs for branches from HEAD
text code. The linker may place these stubs before the HEAD text
sections, which breaks the assumption that HEAD text is located at 0
(or the .text section being located at 0x7000/0x8000 on Book3S
kernels).

Provide an option to create a small section just before the .text
section with an empty 256 - 4 bytes, and adjust the start of the .text
section to match. The linker will tend to put stubs in that section
and not break our relative-to-absolute offset assumptions.

This causes a small waste of space on common kernels, but allows large
kernels to build and boot. For now, it is an EXPERT config option,
defaulting to =n, but a reference is provided for it in the build-time
check for such breakage. This is good enough for allyesconfig and
custom users / hackers.

Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/Kconfig
arch/powerpc/include/asm/head-64.h
arch/powerpc/kernel/vmlinux.lds.S

index d090275ace4422067994e3f292bb785ff94bed75..0153275e9f7516df039b9dc0c3c673166ede3db3 100644 (file)
@@ -455,6 +455,17 @@ config PPC_TRANSACTIONAL_MEM
        ---help---
          Support user-mode Transactional Memory on POWERPC.
 
+config LD_HEAD_STUB_CATCH
+       bool "Reserve 256 bytes to cope with linker stubs in HEAD text" if EXPERT
+       depends on PPC64
+       default n
+       help
+         Very large kernels can cause linker branch stubs to be generated by
+         code in head_64.S, which moves the head text sections out of their
+         specified location. This option can work around the problem.
+
+         If unsure, say "N".
+
 config DISABLE_MPROFILE_KERNEL
        bool "Disable use of mprofile-kernel for kernel tracing"
        depends on PPC64 && CPU_LITTLE_ENDIAN
index 86eb87382031dfff0d40db1d52ada5d18b450d93..68828aa6e056230bf237a654e9ebab01883e561b 100644 (file)
        . = 0x0;                                                \
 start_##sname:
 
+/*
+ * .linker_stub_catch section is used to catch linker stubs from being
+ * inserted in our .text section, above the start_text label (which breaks
+ * the ABS_ADDR calculation). See kernel/vmlinux.lds.S and tools/head_check.sh
+ * for more details. We would prefer to just keep a cacheline (0x80), but
+ * 0x100 seems to be how the linker aligns branch stub groups.
+ */
+#ifdef CONFIG_LD_HEAD_STUB_CATCH
+#define OPEN_TEXT_SECTION(start)                               \
+       .section ".linker_stub_catch","ax",@progbits;           \
+linker_stub_catch:                                             \
+       . = 0x4;                                                \
+       text_start = (start) + 0x100;                           \
+       .section ".text","ax",@progbits;                        \
+       .balign 0x100;                                          \
+start_text:
+#else
 #define OPEN_TEXT_SECTION(start)                               \
        text_start = (start);                                   \
        .section ".text","ax",@progbits;                        \
        . = 0x0;                                                \
 start_text:
+#endif
 
 #define ZERO_FIXED_SECTION(sname, start, end)                  \
        sname##_start = (start);                                \
index bcfda21c3179b6b6e5e077c1ec413c2d1a0a3873..be8578e02ab652f077f27ebb78953c4e1dc34ed8 100644 (file)
@@ -103,6 +103,11 @@ SECTIONS
         * section placement to work.
         */
        .text BLOCK(0) : AT(ADDR(.text) - LOAD_OFFSET) {
+#ifdef CONFIG_LD_HEAD_STUB_CATCH
+               *(.linker_stub_catch);
+               . = . ;
+#endif
+
 #else
        .text : AT(ADDR(.text) - LOAD_OFFSET) {
                ALIGN_FUNCTION();