Skip to content

Commit 73db3ab

Browse files
masahir0yakpm00
authored andcommitted
init/modpost: conditionally check section mismatch to __meminit*
This reverts commit eb8f689 ("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]>
1 parent 7a7127a commit 73db3ab

File tree

4 files changed

+15
-38
lines changed

4 files changed

+15
-38
lines changed

arch/powerpc/kernel/vmlinux.lds.S

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,6 @@ SECTIONS
123123
*/
124124
*(.sfpr);
125125
*(.text.asan.* .text.tsan.*)
126-
MEM_KEEP(init.text)
127-
MEM_KEEP(exit.text)
128126
} :text
129127

130128
. = ALIGN(PAGE_SIZE);

include/asm-generic/vmlinux.lds.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -141,14 +141,6 @@
141141
* often happens at runtime)
142142
*/
143143

144-
#if defined(CONFIG_MEMORY_HOTPLUG)
145-
#define MEM_KEEP(sec) *(.mem##sec)
146-
#define MEM_DISCARD(sec)
147-
#else
148-
#define MEM_KEEP(sec)
149-
#define MEM_DISCARD(sec) *(.mem##sec)
150-
#endif
151-
152144
#ifndef CONFIG_HAVE_DYNAMIC_FTRACE_NO_PATCHABLE
153145
#define KEEP_PATCHABLE KEEP(*(__patchable_function_entries))
154146
#define PATCHABLE_DISCARDS
@@ -357,7 +349,6 @@
357349
*(.data..decrypted) \
358350
*(.ref.data) \
359351
*(.data..shared_aligned) /* percpu related */ \
360-
MEM_KEEP(init.data*) \
361352
*(.data.unlikely) \
362353
__start_once = .; \
363354
*(.data.once) \
@@ -542,7 +533,6 @@
542533
/* __*init sections */ \
543534
__init_rodata : AT(ADDR(__init_rodata) - LOAD_OFFSET) { \
544535
*(.ref.rodata) \
545-
MEM_KEEP(init.rodata) \
546536
} \
547537
\
548538
/* Built-in module parameters. */ \
@@ -593,8 +583,7 @@
593583
*(.text.unknown .text.unknown.*) \
594584
NOINSTR_TEXT \
595585
*(.ref.text) \
596-
*(.text.asan.* .text.tsan.*) \
597-
MEM_KEEP(init.text*) \
586+
*(.text.asan.* .text.tsan.*)
598587

599588

600589
/* sched.text is aling to function alignment to secure we have same
@@ -701,15 +690,13 @@
701690
#define INIT_DATA \
702691
KEEP(*(SORT(___kentry+*))) \
703692
*(.init.data .init.data.*) \
704-
MEM_DISCARD(init.data*) \
705693
KERNEL_CTORS() \
706694
MCOUNT_REC() \
707695
*(.init.rodata .init.rodata.*) \
708696
FTRACE_EVENTS() \
709697
TRACE_SYSCALLS() \
710698
KPROBE_BLACKLIST() \
711699
ERROR_INJECT_WHITELIST() \
712-
MEM_DISCARD(init.rodata) \
713700
CLK_OF_TABLES() \
714701
RESERVEDMEM_OF_TABLES() \
715702
TIMER_OF_TABLES() \
@@ -727,8 +714,7 @@
727714

728715
#define INIT_TEXT \
729716
*(.init.text .init.text.*) \
730-
*(.text.startup) \
731-
MEM_DISCARD(init.text*)
717+
*(.text.startup)
732718

733719
#define EXIT_DATA \
734720
*(.exit.data .exit.data.*) \

include/linux/init.h

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,15 @@
8484

8585
#define __exit __section(".exit.text") __exitused __cold notrace
8686

87-
/* Used for MEMORY_HOTPLUG */
88-
#define __meminit __section(".meminit.text") __cold notrace \
89-
__latent_entropy
90-
#define __meminitdata __section(".meminit.data")
91-
#define __meminitconst __section(".meminit.rodata")
87+
#ifdef CONFIG_MEMORY_HOTPLUG
88+
#define __meminit
89+
#define __meminitdata
90+
#define __meminitconst
91+
#else
92+
#define __meminit __init
93+
#define __meminitdata __initdata
94+
#define __meminitconst __initconst
95+
#endif
9296

9397
/* For assembly routines */
9498
#define __HEAD .section ".head.text","ax"

scripts/mod/modpost.c

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -776,17 +776,14 @@ static void check_section(const char *modname, struct elf_info *elf,
776776

777777

778778
#define ALL_INIT_DATA_SECTIONS \
779-
".init.setup", ".init.rodata", ".meminit.rodata", \
780-
".init.data", ".meminit.data"
779+
".init.setup", ".init.rodata", ".init.data"
781780

782781
#define ALL_PCI_INIT_SECTIONS \
783782
".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \
784783
".pci_fixup_enable", ".pci_fixup_resume", \
785784
".pci_fixup_resume_early", ".pci_fixup_suspend"
786785

787-
#define ALL_XXXINIT_SECTIONS ".meminit.*"
788-
789-
#define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS
786+
#define ALL_INIT_SECTIONS ".init.*"
790787
#define ALL_EXIT_SECTIONS ".exit.*"
791788

792789
#define DATA_SECTIONS ".data", ".data.rel"
@@ -797,9 +794,7 @@ static void check_section(const char *modname, struct elf_info *elf,
797794
".fixup", ".entry.text", ".exception.text", \
798795
".coldtext", ".softirqentry.text"
799796

800-
#define INIT_SECTIONS ".init.*"
801-
802-
#define ALL_TEXT_SECTIONS ".init.text", ".meminit.text", ".exit.text", \
797+
#define ALL_TEXT_SECTIONS ".init.text", ".exit.text", \
803798
TEXT_SECTIONS, OTHER_TEXT_SECTIONS
804799

805800
enum mismatch {
@@ -839,12 +834,6 @@ static const struct sectioncheck sectioncheck[] = {
839834
.bad_tosec = { ALL_INIT_SECTIONS, ALL_EXIT_SECTIONS, NULL },
840835
.mismatch = TEXTDATA_TO_ANY_INIT_EXIT,
841836
},
842-
/* Do not reference init code/data from meminit code/data */
843-
{
844-
.fromsec = { ALL_XXXINIT_SECTIONS, NULL },
845-
.bad_tosec = { INIT_SECTIONS, NULL },
846-
.mismatch = XXXINIT_TO_SOME_INIT,
847-
},
848837
/* Do not use exit code/data from init code */
849838
{
850839
.fromsec = { ALL_INIT_SECTIONS, NULL },
@@ -859,7 +848,7 @@ static const struct sectioncheck sectioncheck[] = {
859848
},
860849
{
861850
.fromsec = { ALL_PCI_INIT_SECTIONS, NULL },
862-
.bad_tosec = { INIT_SECTIONS, NULL },
851+
.bad_tosec = { ALL_INIT_SECTIONS, NULL },
863852
.mismatch = ANY_INIT_TO_ANY_EXIT,
864853
},
865854
{

0 commit comments

Comments
 (0)