[PATCH v2 1/3] modpost: check section mismatch in reference to .dtb.init.rodata

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

 



Built-in DTB files are discarded because KERNEL_DTB() is a part of
INIT_DATA, as defined in include/asm-generic/vmlinux.lds.h.

Currently, modpost warns about mismatched section references to init
data only when the destination section is prefixed with ".init.".
However, ".dtb.init.rodata" is also discarded.

This commit has revealed some missing annotations.

overlays[] references builtin DTBs, which become dangling pointers
after early boot.

testdrv_probe() is not an __init function, yet it holds a reference to
overlays[]. The assumption is that this function is executed only at
the boot time even though it remains in memory. I annotated it as __ref
because otherwise I do not know how to suppress the modpost warning.

I marked the dtb_start as __initdata in the Xtensa boot code, although
modpost does not warn about it because __dtb_start is not yet defined
at the time of modpost.

Signed-off-by: Masahiro Yamada <masahiroy@xxxxxxxxxx>
---

Changes in v2:
  - New patch

 arch/xtensa/kernel/setup.c | 2 +-
 drivers/of/unittest.c      | 5 +++--
 scripts/mod/modpost.c      | 2 +-
 3 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/arch/xtensa/kernel/setup.c b/arch/xtensa/kernel/setup.c
index bdec4a773af0..d9f290cf726e 100644
--- a/arch/xtensa/kernel/setup.c
+++ b/arch/xtensa/kernel/setup.c
@@ -55,7 +55,7 @@ extern int initrd_below_start_ok;
 #endif
 
 #ifdef CONFIG_USE_OF
-void *dtb_start = __dtb_start;
+static __initdata void *dtb_start = __dtb_start;
 #endif
 
 extern unsigned long loops_per_jiffy;
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c
index fd8cb931b1cc..56516bf4171d 100644
--- a/drivers/of/unittest.c
+++ b/drivers/of/unittest.c
@@ -3585,7 +3585,7 @@ OVERLAY_INFO_EXTERN(overlay_bad_symbol);
 OVERLAY_INFO_EXTERN(overlay_bad_unresolved);
 
 /* entries found by name */
-static struct overlay_info overlays[] = {
+static __initdata struct overlay_info overlays[] = {
 	OVERLAY_INFO(overlay_base, -9999, 0),
 	OVERLAY_INFO(overlay, 0, 0),
 	OVERLAY_INFO(overlay_0, 0, 0),
@@ -4054,7 +4054,8 @@ static const struct pci_device_id testdrv_pci_ids[] = {
 	{ 0, }
 };
 
-static int testdrv_probe(struct pci_dev *pdev, const struct pci_device_id *id)
+/* testdrv_probe() references overlays[], which is discarded data  */
+static int __ref testdrv_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 {
 	struct overlay_info *info;
 	struct device_node *dn;
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 107393a8c48a..2e4b0816fdc1 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -776,7 +776,7 @@ static void check_section(const char *modname, struct elf_info *elf,
 	".pci_fixup_enable", ".pci_fixup_resume", \
 	".pci_fixup_resume_early", ".pci_fixup_suspend"
 
-#define ALL_INIT_SECTIONS ".init.*"
+#define ALL_INIT_SECTIONS ".init.*", ".dtb.init.rodata"
 #define ALL_EXIT_SECTIONS ".exit.*"
 
 #define DATA_SECTIONS ".data", ".data.rel"
-- 
2.43.0





[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux