All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Brandt <chris.brandt@renesas.com>
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] ARM: xip: Use correct symbol for end of ROM marker
Date: Thu, 12 Nov 2015 21:01:48 +0000	[thread overview]
Message-ID: <1447362108-4333-1-git-send-email-chris.brandt@renesas.com> (raw)
In-Reply-To: <1447251455-22731-1-git-send-email-chris.brandt@renesas.com>

For an XIP build, _edata_loc, not _etext, represents the end of the
binary image that will be programmed into ROM and mapped into the
MODULES_VADDR area.
With an XIP kernel, nothing is loaded into RAM before boot, meaning
you have to take into account the size of the entire binary image
that was programmed, including the init data values that will be copied
to RAM during kernel boot.

This fixes the bug where you might lose the end of your kernel area
after page table setup is complete.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
v2
* Added change for MODULES_VADDR
* Moved extern to new file asm/sections.h
---
 arch/arm/include/asm/sections.h |    8 ++++++++
 arch/arm/kernel/module.c        |    2 +-
 arch/arm/mm/mmu.c               |    4 ++--
 3 files changed, 11 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/include/asm/sections.h

diff --git a/arch/arm/include/asm/sections.h b/arch/arm/include/asm/sections.h
new file mode 100644
index 0000000..401eb3c2
--- /dev/null
+++ b/arch/arm/include/asm/sections.h
@@ -0,0 +1,8 @@
+#ifndef _ASM_ARM_SECTIONS_H
+#define _ASM_ARM_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+extern char _edata_loc[];
+
+#endif	/* _ASM_ARM_SECTIONS_H */
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index efdddcb..41ae2cc 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -34,7 +34,7 @@
  * recompiling the whole kernel when CONFIG_XIP_KERNEL is turned on/off.
  */
 #undef MODULES_VADDR
-#define MODULES_VADDR	(((unsigned long)_etext + ~PMD_MASK) & PMD_MASK)
+#define MODULES_VADDR	(((unsigned long)_edata_loc + ~PMD_MASK) & PMD_MASK)
 #endif
 
 #ifdef CONFIG_MMU
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 4867f5d..dd5a56b 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1210,7 +1210,7 @@ static inline void prepare_page_table(void)
 
 #ifdef CONFIG_XIP_KERNEL
 	/* The XIP kernel is mapped in the module area -- skip over it */
-	addr = ((unsigned long)_etext + PMD_SIZE - 1) & PMD_MASK;
+	addr = ((unsigned long)_edata_loc + PMD_SIZE - 1) & PMD_MASK;
 #endif
 	for ( ; addr < PAGE_OFFSET; addr += PMD_SIZE)
 		pmd_clear(pmd_off_k(addr));
@@ -1292,7 +1292,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
 #ifdef CONFIG_XIP_KERNEL
 	map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
 	map.virtual = MODULES_VADDR;
-	map.length = ((unsigned long)_etext - map.virtual + ~SECTION_MASK) & SECTION_MASK;
+	map.length = ((unsigned long)_edata_loc - map.virtual + ~SECTION_MASK) & SECTION_MASK;
 	map.type = MT_ROM;
 	create_mapping(&map);
 #endif
-- 
1.7.9.5



WARNING: multiple messages have this Message-ID (diff)
From: chris.brandt@renesas.com (Chris Brandt)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2] ARM: xip: Use correct symbol for end of ROM marker
Date: Thu, 12 Nov 2015 16:01:48 -0500	[thread overview]
Message-ID: <1447362108-4333-1-git-send-email-chris.brandt@renesas.com> (raw)
In-Reply-To: <1447251455-22731-1-git-send-email-chris.brandt@renesas.com>

For an XIP build, _edata_loc, not _etext, represents the end of the
binary image that will be programmed into ROM and mapped into the
MODULES_VADDR area.
With an XIP kernel, nothing is loaded into RAM before boot, meaning
you have to take into account the size of the entire binary image
that was programmed, including the init data values that will be copied
to RAM during kernel boot.

This fixes the bug where you might lose the end of your kernel area
after page table setup is complete.

Signed-off-by: Chris Brandt <chris.brandt@renesas.com>
---
v2
* Added change for MODULES_VADDR
* Moved extern to new file asm/sections.h
---
 arch/arm/include/asm/sections.h |    8 ++++++++
 arch/arm/kernel/module.c        |    2 +-
 arch/arm/mm/mmu.c               |    4 ++--
 3 files changed, 11 insertions(+), 3 deletions(-)
 create mode 100644 arch/arm/include/asm/sections.h

diff --git a/arch/arm/include/asm/sections.h b/arch/arm/include/asm/sections.h
new file mode 100644
index 0000000..401eb3c2
--- /dev/null
+++ b/arch/arm/include/asm/sections.h
@@ -0,0 +1,8 @@
+#ifndef _ASM_ARM_SECTIONS_H
+#define _ASM_ARM_SECTIONS_H
+
+#include <asm-generic/sections.h>
+
+extern char _edata_loc[];
+
+#endif	/* _ASM_ARM_SECTIONS_H */
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c
index efdddcb..41ae2cc 100644
--- a/arch/arm/kernel/module.c
+++ b/arch/arm/kernel/module.c
@@ -34,7 +34,7 @@
  * recompiling the whole kernel when CONFIG_XIP_KERNEL is turned on/off.
  */
 #undef MODULES_VADDR
-#define MODULES_VADDR	(((unsigned long)_etext + ~PMD_MASK) & PMD_MASK)
+#define MODULES_VADDR	(((unsigned long)_edata_loc + ~PMD_MASK) & PMD_MASK)
 #endif
 
 #ifdef CONFIG_MMU
diff --git a/arch/arm/mm/mmu.c b/arch/arm/mm/mmu.c
index 4867f5d..dd5a56b 100644
--- a/arch/arm/mm/mmu.c
+++ b/arch/arm/mm/mmu.c
@@ -1210,7 +1210,7 @@ static inline void prepare_page_table(void)
 
 #ifdef CONFIG_XIP_KERNEL
 	/* The XIP kernel is mapped in the module area -- skip over it */
-	addr = ((unsigned long)_etext + PMD_SIZE - 1) & PMD_MASK;
+	addr = ((unsigned long)_edata_loc + PMD_SIZE - 1) & PMD_MASK;
 #endif
 	for ( ; addr < PAGE_OFFSET; addr += PMD_SIZE)
 		pmd_clear(pmd_off_k(addr));
@@ -1292,7 +1292,7 @@ static void __init devicemaps_init(const struct machine_desc *mdesc)
 #ifdef CONFIG_XIP_KERNEL
 	map.pfn = __phys_to_pfn(CONFIG_XIP_PHYS_ADDR & SECTION_MASK);
 	map.virtual = MODULES_VADDR;
-	map.length = ((unsigned long)_etext - map.virtual + ~SECTION_MASK) & SECTION_MASK;
+	map.length = ((unsigned long)_edata_loc - map.virtual + ~SECTION_MASK) & SECTION_MASK;
 	map.type = MT_ROM;
 	create_mapping(&map);
 #endif
-- 
1.7.9.5

  parent reply	other threads:[~2015-11-12 21:01 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-11 14:17 [PATCH] ARM: xip: Use correct symbol for end of ROM marker Chris Brandt
2015-11-11 14:17 ` Chris Brandt
2015-11-11 14:17 ` Chris Brandt
2015-11-12 12:17 ` Peter Hurley
2015-11-12 12:17   ` Peter Hurley
2015-11-12 12:17   ` Peter Hurley
2015-11-12 13:15   ` Chris Brandt
2015-11-12 13:15     ` Chris Brandt
2015-11-12 13:15     ` Chris Brandt
2015-11-12 16:32 ` Russell King - ARM Linux
2015-11-12 16:32   ` Russell King - ARM Linux
2015-11-12 16:32   ` Russell King - ARM Linux
2015-11-12 21:01 ` Chris Brandt [this message]
2015-11-12 21:01   ` [PATCH v2] " Chris Brandt
2015-11-13  7:46   ` Geert Uytterhoeven
2015-11-13  7:46     ` Geert Uytterhoeven
2015-11-13 20:03     ` Chris Brandt
2015-11-13 20:03       ` Chris Brandt
2015-11-16 18:05   ` [PATCH v3] " Chris Brandt
2015-11-16 18:05     ` Chris Brandt
2015-11-16 18:17     ` Russell King - ARM Linux
2015-11-16 18:17       ` Russell King - ARM Linux
2015-11-16 19:46       ` Chris Brandt
2015-11-16 19:46         ` Chris Brandt
2015-11-16 19:53         ` Russell King - ARM Linux
2015-11-16 19:53           ` Russell King - ARM Linux
2015-11-16 20:18           ` Chris Brandt
2015-11-16 20:18             ` Chris Brandt
2015-11-16 20:30             ` Russell King - ARM Linux
2015-11-16 20:30               ` Russell King - ARM Linux
2015-11-16 20:57       ` Nicolas Pitre
2015-11-16 20:57         ` Nicolas Pitre
2015-11-16 21:09         ` Chris Brandt
2015-11-16 21:09           ` Chris Brandt
2015-11-16 20:27     ` Nicolas Pitre
2015-11-16 20:27       ` Nicolas Pitre
2015-11-16 21:02       ` Chris Brandt
2015-11-16 21:02         ` Chris Brandt
2015-11-16 21:47         ` Nicolas Pitre
2015-11-16 21:47           ` Nicolas Pitre
2015-11-16 22:19           ` Chris Brandt
2015-11-16 22:19             ` Chris Brandt
2015-11-17  0:48             ` Nicolas Pitre
2015-11-17  0:48               ` Nicolas Pitre
2015-11-17  2:11               ` Chris Brandt
2015-11-17  2:11                 ` Chris Brandt
2015-11-17  2:37                 ` Nicolas Pitre
2015-11-17  2:37                   ` Nicolas Pitre
2015-11-17 16:56                   ` Chris Brandt
2015-11-17 16:56                     ` Chris Brandt
2015-11-17 17:24                     ` Nicolas Pitre
2015-11-17 17:24                       ` Nicolas Pitre
2015-11-18  3:58                     ` Nicolas Pitre
2015-11-18  3:58                       ` Nicolas Pitre
2015-11-18  5:12                       ` Magnus Damm
2015-11-18  5:12                         ` Magnus Damm
2015-11-18 13:45                         ` Nicolas Pitre
2015-11-18 13:45                           ` Nicolas Pitre
2015-11-18 17:01                           ` Nicolas Pitre
2015-11-18 17:01                             ` Nicolas Pitre
2015-11-18 19:12                             ` Chris Brandt
2015-11-18 19:12                               ` Chris Brandt
2015-11-18 20:23                               ` Nicolas Pitre
2015-11-18 20:23                                 ` Nicolas Pitre
2015-11-18 20:51                                 ` Chris Brandt
2015-11-18 20:51                                   ` Chris Brandt
2015-11-18 21:36                                   ` Nicolas Pitre
2015-11-18 21:36                                     ` Nicolas Pitre
2016-01-29 21:12                                     ` Chris Brandt
2016-01-29 21:12                                       ` Chris Brandt
2016-01-29 21:17                                       ` Nicolas Pitre
2016-01-29 21:17                                         ` Nicolas Pitre
2015-11-17 16:45           ` Chris Brandt
2015-11-17 16:45             ` Chris Brandt
2015-11-17 16:57             ` Nicolas Pitre
2015-11-17 16:57               ` Nicolas Pitre
2015-11-18  2:09               ` Chris Brandt
2015-11-18  2:09                 ` Chris Brandt
2015-11-18  3:17                 ` Nicolas Pitre
2015-11-18  3:17                   ` Nicolas Pitre
2015-11-18  8:30                   ` Arnd Bergmann
2015-11-18  8:30                     ` Arnd Bergmann
2015-11-18 15:28                     ` Chris Brandt
2015-11-18 15:28                       ` Chris Brandt
2015-11-18 15:16                   ` Chris Brandt
2015-11-18 15:16                     ` Chris Brandt
2015-11-18 17:07                     ` Nicolas Pitre
2015-11-18 17:07                       ` Nicolas Pitre
2015-11-18 19:36                       ` Chris Brandt
2015-11-18 19:36                         ` Chris Brandt
2015-11-18 19:44                         ` Nicolas Pitre
2015-11-18 19:44                           ` Nicolas Pitre
2015-11-18 20:00                           ` Chris Brandt
2015-11-18 20:00                             ` Chris Brandt
2015-11-17 17:33           ` Russell King - ARM Linux
2015-11-17 17:33             ` Russell King - ARM Linux
2016-02-01 17:52     ` [PATCH v4] " Chris Brandt
2016-02-01 19:12       ` Nicolas Pitre
2016-02-01 19:41         ` Chris Brandt
2016-02-01 20:23           ` Nicolas Pitre
2016-02-02 17:05             ` Chris Brandt
2016-02-02 17:19       ` [PATCH v5] " Chris Brandt
2016-02-02 17:35         ` Nicolas Pitre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1447362108-4333-1-git-send-email-chris.brandt@renesas.com \
    --to=chris.brandt@renesas.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.