Skip to contentSkip to conversation

sh: Remove hardcoded PAGE_SIZE in NetBSD loader

PATCH In review Paul Mundt 2 participants 2 messages Feb 4, 2008 – Feb 19, 2008

Subsystems (2)
lore
Share & tools
lore

Paul Mundt

author
#0 lore raw

PATCH 1/1 sh: Remove hardcoded PAGE_SIZE in NetBSD loader

The Linux host supports a multitude of page sizes, so having this hardcoded doesn't really help matters. This also has the benefit of killing off dependence on asm/ headers when none is needed. While I'm not suggesting that anyone actually boot NetBSD, without this, my build also ends up breaking.

---

 kexec/arch/sh/kexec-netbsd-sh.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
kexec/arch/sh/kexec-netbsd-sh.c +6 -6
index a751420..07c7f26 100644
@@ -25,13 +25,10 @@
 #include "../../kexec.h"
 #include "../../kexec-elf.h"
 #include <arch/options.h>
-#include <asm/page.h>
 
 static const int probe_debug = 0;
 const extern unsigned char netbsd_booter[];
 
-#define PAGE_ALIGN(addr)        (((addr)+PAGE_SIZE-1)&PAGE_MASK)
-
 /*
  * netbsd_sh_probe - sanity check the elf image
  *
@@ -62,7 +59,7 @@ int netbsd_sh_load(int argc, char **argv, const char *buf, off_t len,
 	struct kexec_info *info)
 {
 	const char *howto, *miniroot;
-	unsigned long entry, start, size;
+	unsigned long entry, start, size, psz;
 	char *miniroot_buf;
 	off_t miniroot_length;
 	unsigned int howto_value;
@@ -105,6 +102,8 @@ int netbsd_sh_load(int argc, char **argv, const char *buf, off_t len,
 	        howto_value = strtol(howto, NULL, 0);
 	}
 
+	psz = getpagesize();
+
 	/* Parse the Elf file */
 	{
 	        Elf32_Ehdr *ehdr;
@@ -122,7 +121,8 @@ int netbsd_sh_load(int argc, char **argv, const char *buf, off_t len,
 		if(size < bbs){
 		        size = bbs;
 		}
-		size  = PAGE_ALIGN(size);
+
+		size = (size + psz - 1) & ~(psz - 1);
 		memset(&img[bbs], 0, size-bbs);
 		add_segment(info, img, size, start, size);
 		start += size;
@@ -133,7 +133,7 @@ int netbsd_sh_load(int argc, char **argv, const char *buf, off_t len,
 	if (miniroot) {
 		miniroot_buf = slurp_file(miniroot, &miniroot_length);
 		howto_value |= 0x200;
-		size = PAGE_ALIGN(miniroot_length);
+		size = (miniroot_length + psz - 1) & ~(psz - 1);
 		add_segment(info, miniroot_buf, size, start, size);
 		start += size;
 	}

_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

#1 lore raw
Quoted 5 lines · Paul Mundt

The Linux host supports a multitude of page sizes, so having this hardcoded doesn't really help matters. This also has the benefit of killing off dependence on asm/ headers when none is needed. While I'm not suggesting that anyone actually boot NetBSD, without this, my build also ends up breaking.

Thanks, Paul. Applied.

Signature · 7 lines
Horms


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec