Skip to contentSkip to conversation

Added arch_lmb_reserve to allow arch specific memory regions protection

PATCH Superseded Kumar Gala 1 participant 2 messages Oct 14, 2008 – Oct 15, 2008

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/1 Added arch_lmb_reserve to allow arch specific memory regions protection

Each architecture has different ways of determine what regions of memory might not be valid to get overwritten when we boot. This provides a hook to allow them to reserve any regions they care about. Currently only ppc, m68k and sparc need/use this.

---
 lib_m68k/bootm.c  |   29 ++++++++++++++++-------------
 lib_ppc/bootm.c   |   50 ++++++++++++++++++++++++++++----------------------
 lib_sparc/bootm.c |   16 +++++++++-------
 3 files changed, 53 insertions(+), 42 deletions(-)
lib_m68k/bootm.c +16 -13
index 6504cc9..1d773d3 100644
@@ -43,22 +43,10 @@ DECLARE_GLOBAL_DATA_PTR;
 static ulong get_sp (void);
 static void set_clocks_in_mhz (bd_t *kbd);
 
-int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
+void arch_lmb_reserve(struct lmb *lmb)
 {
 	ulong sp;
 
-	ulong rd_len;
-	ulong initrd_start, initrd_end;
-	int ret;
-
-	ulong cmd_start, cmd_end;
-	ulong bootmap_base;
-	bd_t  *kbd;
-	void  (*kernel) (bd_t *, ulong, ulong, ulong, ulong);
-	struct lmb *lmb = &images->lmb;
-
-	bootmap_base = getenv_bootm_low();
-
 	/*
 	 * Booting a (Linux) kernel image
 	 *
@@ -74,6 +62,21 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
 	/* adjust sp by 1K to be safe */
 	sp -= 1024;
 	lmb_reserve(lmb, sp, (CFG_SDRAM_BASE + gd->ram_size - sp));
+}
+
+int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)
+{
+	ulong rd_len;
+	ulong initrd_start, initrd_end;
+	int ret;
+
+	ulong cmd_start, cmd_end;
+	ulong bootmap_base;
+	bd_t  *kbd;
+	void  (*kernel) (bd_t *, ulong, ulong, ulong, ulong);
+	struct lmb *lmb = &images->lmb;
+
+	bootmap_base = getenv_bootm_low();
 
 	/* allocate space and init command line */
 	ret = boot_get_cmdline (lmb, &cmd_start, &cmd_end, bootmap_base);
lib_ppc/bootm.c +28 -22

64 lines not on this page · raw message

lib_sparc/bootm.c +9 -7
index 4e8c920..d6b2e98 100644
@@ -81,6 +81,15 @@ struct __attribute__ ((packed)) {
 /* temporary initrd image holder */
 image_header_t ihdr;
 
+void arch_lmb_reserve(struct lmb *lmb)
+{
+	/* Reserve the space used by PROM and stack. This is done
+	 * to avoid that the RAM image is copied over stack or
+	 * PROM.
+	 */
+	lmb_reserve(lmb, CFG_RELOC_MONITOR_BASE, CFG_RAM_END);
+}
+
 /* boot the linux kernel */
 int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t * images)
 {
@@ -124,13 +133,6 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t * images)
 	rd_len = images->rd_end - images->rd_start;
 
 	if (rd_len) {
-
-		/* Reserve the space used by PROM and stack. This is done
-		 * to avoid that the RAM image is copied over stack or
-		 * PROM.
-		 */
-		lmb_reserve(lmb, CFG_RELOC_MONITOR_BASE, CFG_RAM_END);
-
 		ret = boot_ramdisk_high(lmb, images->rd_start, rd_len,
 					&initrd_start, &initrd_end);
 		if (ret) {
Signature · 1 line
1.5.5.1
author
#1 lore raw

PATCH 1/1 Added arch_lmb_reserve to allow arch specific memory regions protection

Quoted 6 lines · Kumar Gala

Each architecture has different ways of determine what regions of memory
might not be valid to get overwritten when we boot. This provides a hook to allow them to reserve any regions they care about. Currently only ppc, m68k and sparc need/use this.

Quoted 7 lines

---

lib_m68k/bootm.c  |   29 ++++++++++++++++-------------
lib_ppc/bootm.c   |   50 +++++++++++++++++++++++++++ 
+----------------------
lib_sparc/bootm.c |   16 +++++++++-------
3 files changed, 53 insertions(+), 42 deletions(-)

Do not apply this version.. forgot the changes to cmd_bootm.c

- k