]> Git Repo - linux.git/commitdiff
init/modpost: conditionally check section mismatch to __meminit*
authorMasahiro Yamada <[email protected]>
Sat, 6 Jul 2024 16:05:06 +0000 (01:05 +0900)
committerAndrew Morton <[email protected]>
Fri, 12 Jul 2024 23:39:52 +0000 (16:39 -0700)
This reverts commit eb8f689046b8 ("Use separate sections for __dev/
_cpu/__mem code/data").

Check section mismatch to __meminit* only when CONFIG_MEMORY_HOTPLUG=n.

With this change, the linker script and modpost become simpler, and we
can get rid of the __ref annotations from the memory hotplug code.

[[email protected]: remove MEM_KEEP from arch/powerpc/kernel/vmlinux.lds.S]
Link: https://lkml.kernel.org/r/[email protected]
Link: https://lkml.kernel.org/r/[email protected]
Signed-off-by: Masahiro Yamada <[email protected]>
Signed-off-by: Stephen Rothwell <[email protected]>
Reviewed-by: Wei Yang <[email protected]>
Cc: Stephen Rothwell <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
arch/powerpc/kernel/vmlinux.lds.S
include/asm-generic/vmlinux.lds.h
include/linux/init.h
scripts/mod/modpost.c

index f420df7888a75c5f515a3457708c3188661fa331..7ab4e2fb28b1e3a595f67e93086415cb3a4f0372 100644 (file)
@@ -123,8 +123,6 @@ SECTIONS
                 */
                *(.sfpr);
                *(.text.asan.* .text.tsan.*)
-               MEM_KEEP(init.text)
-               MEM_KEEP(exit.text)
        } :text
 
        . = ALIGN(PAGE_SIZE);
index 5703526d6ebf13bcca1d092edcffd0180db48bad..0db89c0aa2cccca48c1c04ba2e0030dfaf5f9086 100644 (file)
  * often happens at runtime)
  */
 
-#if defined(CONFIG_MEMORY_HOTPLUG)
-#define MEM_KEEP(sec)    *(.mem##sec)
-#define MEM_DISCARD(sec)
-#else
-#define MEM_KEEP(sec)
-#define MEM_DISCARD(sec) *(.mem##sec)
-#endif
-
 #ifndef CONFIG_HAVE_DYNAMIC_FTRACE_NO_PATCHABLE
 #define KEEP_PATCHABLE         KEEP(*(__patchable_function_entries))
 #define PATCHABLE_DISCARDS
        *(.data..decrypted)                                             \
        *(.ref.data)                                                    \
        *(.data..shared_aligned) /* percpu related */                   \
-       MEM_KEEP(init.data*)                                            \
        *(.data.unlikely)                                               \
        __start_once = .;                                               \
        *(.data.once)                                                   \
        /* __*init sections */                                          \
        __init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) {         \
                *(.ref.rodata)                                          \
-               MEM_KEEP(init.rodata)                                   \
        }                                                               \
                                                                        \
        /* Built-in module parameters. */                               \
                *(.text.unknown .text.unknown.*)                        \
                NOINSTR_TEXT                                            \
                *(.ref.text)                                            \
-               *(.text.asan.* .text.tsan.*)                            \
-       MEM_KEEP(init.text*)                                            \
+               *(.text.asan.* .text.tsan.*)
 
 
 /* sched.text is aling to function alignment to secure we have same
 #define INIT_DATA                                                      \
        KEEP(*(SORT(___kentry+*)))                                      \
        *(.init.data .init.data.*)                                      \
-       MEM_DISCARD(init.data*)                                         \
        KERNEL_CTORS()                                                  \
        MCOUNT_REC()                                                    \
        *(.init.rodata .init.rodata.*)                                  \
        TRACE_SYSCALLS()                                                \
        KPROBE_BLACKLIST()                                              \
        ERROR_INJECT_WHITELIST()                                        \
-       MEM_DISCARD(init.rodata)                                        \
        CLK_OF_TABLES()                                                 \
        RESERVEDMEM_OF_TABLES()                                         \
        TIMER_OF_TABLES()                                               \
 
 #define INIT_TEXT                                                      \
        *(.init.text .init.text.*)                                      \
-       *(.text.startup)                                                \
-       MEM_DISCARD(init.text*)
+       *(.text.startup)
 
 #define EXIT_DATA                                                      \
        *(.exit.data .exit.data.*)                                      \
index b2e9dfff86911a5409236661bfed443a1ee82b4b..ee1309473bc626745284d50128a5272ea65ff10e 100644 (file)
 
 #define __exit          __section(".exit.text") __exitused __cold notrace
 
-/* Used for MEMORY_HOTPLUG */
-#define __meminit        __section(".meminit.text") __cold notrace \
-                                                 __latent_entropy
-#define __meminitdata    __section(".meminit.data")
-#define __meminitconst   __section(".meminit.rodata")
+#ifdef CONFIG_MEMORY_HOTPLUG
+#define __meminit
+#define __meminitdata
+#define __meminitconst
+#else
+#define __meminit      __init
+#define __meminitdata  __initdata
+#define __meminitconst __initconst
+#endif
 
 /* For assembly routines */
 #define __HEAD         .section        ".head.text","ax"
index f48d72d22dc2a627994ede651994929ba23c5d97..4b1edb2576181c8e9f7133c82e542653730a5f69 100644 (file)
@@ -776,17 +776,14 @@ static void check_section(const char *modname, struct elf_info *elf,
 
 
 #define ALL_INIT_DATA_SECTIONS \
-       ".init.setup", ".init.rodata", ".meminit.rodata", \
-       ".init.data", ".meminit.data"
+       ".init.setup", ".init.rodata", ".init.data"
 
 #define ALL_PCI_INIT_SECTIONS  \
        ".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \
        ".pci_fixup_enable", ".pci_fixup_resume", \
        ".pci_fixup_resume_early", ".pci_fixup_suspend"
 
-#define ALL_XXXINIT_SECTIONS ".meminit.*"
-
-#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS
+#define ALL_INIT_SECTIONS ".init.*"
 #define ALL_EXIT_SECTIONS ".exit.*"
 
 #define DATA_SECTIONS ".data", ".data.rel"
@@ -797,9 +794,7 @@ static void check_section(const char *modname, struct elf_info *elf,
                ".fixup", ".entry.text", ".exception.text", \
                ".coldtext", ".softirqentry.text"
 
-#define INIT_SECTIONS      ".init.*"
-
-#define ALL_TEXT_SECTIONS  ".init.text", ".meminit.text", ".exit.text", \
+#define ALL_TEXT_SECTIONS  ".init.text", ".exit.text", \
                TEXT_SECTIONS, OTHER_TEXT_SECTIONS
 
 enum mismatch {
@@ -839,12 +834,6 @@ static const struct sectioncheck sectioncheck[] = {
        .bad_tosec = { ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL },
        .mismatch = TEXTDATA_TO_ANY_INIT_EXIT,
 },
-/* Do not reference init code/data from meminit code/data */
-{
-       .fromsec = { ALL_XXXINIT_SECTIONS, NULL },
-       .bad_tosec = { INIT_SECTIONS, NULL },
-       .mismatch = XXXINIT_TO_SOME_INIT,
-},
 /* Do not use exit code/data from init code */
 {
        .fromsec = { ALL_INIT_SECTIONS, NULL },
@@ -859,7 +848,7 @@ static const struct sectioncheck sectioncheck[] = {
 },
 {
        .fromsec = { ALL_PCI_INIT_SECTIONS, NULL },
-       .bad_tosec = { INIT_SECTIONS, NULL },
+       .bad_tosec = { ALL_INIT_SECTIONS, NULL },
        .mismatch = ANY_INIT_TO_ANY_EXIT,
 },
 {
This page took 0.098074 seconds and 4 git commands to generate.