diff mbox

[v2,0/9] sparc: unify sparc/boot/piggyback

Message ID AANLkTimBUYuXHp4QdTb8ifQPeqYwgS9O=VKEmZ5wYZ9p@mail.gmail.com
State RFC
Delegated to: David Miller
Headers show

Commit Message

Julian Calaby Jan. 3, 2011, 7:31 a.m. UTC
On Mon, Jan 3, 2011 at 02:50, Sam Ravnborg <sam@ravnborg.org> wrote:
>>
>> That said, I know that my old endian fixed version of piggyback_64
>> works, so I'll do a quick check first to ensure that your version
>> produces the same output.
>
> Testing like this would be great.

Update:

I've found an old laptop with a serial port to use as a serial console
and resurrected my Ultra 1e. I decided to upgrade it to the latest
Debian Squeeze, and it now won't load SILO. *sigh*. On boot, it fails
with the message "Fast data access MMU miss" before SILO even prints
anything. Apparently these messages are due to things being too large
according to the ubuntu forums, but this occurs before SILO even
loads, which makes me suspicious. I'll have to investigate further,
but that means I'll have to take a trip to an installer environment -
and given that I now lack the machine I had set up for installing them
off, that's going to be difficult at best. I'm thinking a complete
re-install might be an idea, but I've had persistent issues getting my
Ultra 5 to install in the past, so I'm concerned that this might not
happen.

So, the net result of that machine becoming FUBAR is that I now have
no way to compile anything for SPARC as that was my last working SPARC
compilation platform. ARGH!

I've attached my endian fix patch for piggyback_64.c. I have
previously confirmed - by generating piggyback files with an empty
root-image - that this produces identical files (same SHA1 sums) to
the original version before any cleanup patches under a sparc64
environment. If you'd perform the same test between the output of a
version with this patch and your new version you should be able to
confirm that it's working properly.

Sorry about all this fuckup, but .... that's life =(

At least it gives me more reason to get my Ultra 5 running. (It's the
one that I've been unable to install)

Thanks,

Comments

Frans van Berckel Jan. 3, 2011, 8:52 a.m. UTC | #1
On Mon, 2011-01-03 at 18:31 +1100, Julian Calaby wrote:
> I've found an old laptop with a serial port to use as a serial console
> and resurrected my Ultra 1e. I decided to upgrade it to the latest
> Debian Squeeze, and it now won't load SILO. *sigh*. On boot, it fails
> with the message "Fast data access MMU miss" before SILO even prints
> anything. Apparently these messages are due to things being too large
> according to the ubuntu forums, but this occurs before SILO even
> loads, which makes me suspicious. I'll have to investigate further,
> but that means I'll have to take a trip to an installer environment -
> and given that I now lack the machine I had set up for installing them
> off, that's going to be difficult at best. I'm thinking a complete
> re-install might be an idea, but I've had persistent issues getting my
> Ultra 5 to install in the past, so I'm concerned that this might not
> happen.

Have seen this happening on different sparc boxes, several times.

Boot the install cd, now in rescue mode. Chrooting the installed
partition and run # silo -u -f again. Next reboot the Ultra.

Thanks,

Frans van Berckel

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Frans van Berckel Jan. 3, 2011, 9:15 a.m. UTC | #2
On Mon, 2011-01-03 at 09:52 +0100, Frans van Berckel wrote:
> Have seen this happening on different sparc boxes, several times.
> 
> Boot the install cd, now in rescue mode. Chrooting the installed
> partition and run # silo -u -f again. Next reboot the Ultra.

You can find more about it ... http://tinyurl.com/382l2sf

"The Debian bug was caused by kernel 2.6.30 incorrectly reporting the
machine type via uname, so SILO was installing the 32-bit second stage
boot loader instead of 64-bit one, which leads to a failure like that"

Thanks,

Frans van Berckel

--
To unsubscribe from this list: send the line "unsubscribe sparclinux" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Julian Calaby Jan. 5, 2011, 1:20 p.m. UTC | #3
On Mon, Jan 3, 2011 at 19:52, Frans van Berckel <fberckel@xs4all.nl> wrote:
> On Mon, 2011-01-03 at 18:31 +1100, Julian Calaby wrote:
>> I've found an old laptop with a serial port to use as a serial console
>> and resurrected my Ultra 1e. I decided to upgrade it to the latest
>> Debian Squeeze, and it now won't load SILO. *sigh*. On boot, it fails
>> with the message "Fast data access MMU miss" before SILO even prints
>> anything. Apparently these messages are due to things being too large
>> according to the ubuntu forums, but this occurs before SILO even
>> loads, which makes me suspicious. I'll have to investigate further,
>> but that means I'll have to take a trip to an installer environment -
>> and given that I now lack the machine I had set up for installing them
>> off, that's going to be difficult at best. I'm thinking a complete
>> re-install might be an idea, but I've had persistent issues getting my
>> Ultra 5 to install in the past, so I'm concerned that this might not
>> happen.
>
> Have seen this happening on different sparc boxes, several times.
>
> Boot the install cd, now in rescue mode. Chrooting the installed
> partition and run # silo -u -f again. Next reboot the Ultra.

Thanks!!!!!

After a bit of stuffing around involving a broken CD-ROM drive, a very
slow laptop, broken installer images and the realisation that TFTPboot
images are not ISOs, I managed to finally get in and do that and it
works like a charm

Thanks!
diff mbox

Patch

diff --git a/arch/sparc/boot/piggyback_64.c b/arch/sparc/boot/piggyback_64.c
index a26a686..06e0917 100644
--- a/arch/sparc/boot/piggyback_64.c
+++ b/arch/sparc/boot/piggyback_64.c
@@ -32,6 +32,24 @@ 
 /* Note: run this on an a.out kernel (use elftoaout for it), as PROM looks for a.out image onlly
    usage: piggyback vmlinux System.map tail, where tail is gzipped fs of the initial ramdisk */
 
+unsigned short ld2(char *p)
+{
+	return (p[0] << 8) | p[1];
+}
+
+unsigned int ld4(char *p)
+{
+	return (p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3];
+}
+
+void st4(char *p, unsigned int x)
+{
+	p[0] = x >> 24;
+	p[1] = x >> 16;
+	p[2] = x >> 8;
+	p[3] = x;
+}
+
 static void die(char *str)
 {
 	perror (str);
@@ -40,6 +58,7 @@  static void die(char *str)
 
 int main(int argc,char **argv)
 {
+	static char aout_magic[] = { 0x01, 0x03, 0x01, 0x07 };
 	char buffer [1024], *q, *r;
 	unsigned int i, j, k, start, end, offset;
 	FILE *map;
@@ -60,13 +79,12 @@  int main(int argc,char **argv)
 	if ((image = open(argv[1],O_RDWR)) < 0) die(argv[1]);
 	if (read(image,buffer,512) != 512) die(argv[1]);
 	if (!memcmp (buffer, "\177ELF", 4)) {
-		unsigned int *p = (unsigned int *)(buffer + *(unsigned int *)(buffer + 28));
-		
-		i = p[1] + *(unsigned int *)(buffer + 24) - p[2];
+		q = buffer + ld4(buffer + 28);
+		i = ld4(q + 4) + ld4(buffer + 24) - ld4(q + 8);
 		if (lseek(image,i,0) < 0) die("lseek");
 		if (read(image,buffer,512) != 512) die(argv[1]);
 		j = 0;
-	} else if (*(unsigned int *)buffer == 0x01030107) {
+	} else if (memcmp(buffer, aout_magic, 4) == 0) {
 		i = j = 32;
 	} else {
 		fprintf (stderr, "Not ELF nor a.out. Don't blame me.\n");
@@ -76,7 +94,7 @@  int main(int argc,char **argv)
 	if (j == 32 && buffer[40] == 'H' && buffer[41] == 'd' && buffer[42] == 'r' && buffer[43] == 'S') {
 		offset = 40 + 10;
 	} else {
-		i += ((*(unsigned short *)(buffer + j + 2))<<2) - 512;
+		i += (ld2(buffer + j + 2) << 2) - 512;
 		if (lseek(image,i,0) < 0) die("lseek");
 		if (read(image,buffer,1024) != 1024) die(argv[1]);
 		for (q = buffer, r = q + 512; q < r; q += 4) {
@@ -90,15 +108,15 @@  int main(int argc,char **argv)
 		offset = i + (q - buffer) + 10;
 	}
 	if (lseek(image, offset, 0) < 0) die ("lseek");
-	*(unsigned *)buffer = 0;
-	*(unsigned *)(buffer + 4) = 0x01000000;
-	*(unsigned *)(buffer + 8) = ((end + 32 + 8191) & ~8191);
-	*(unsigned *)(buffer + 12) = s.st_size;
+	st4(buffer, 0);
+	st4(buffer + 4, 0x01000000);
+	st4(buffer + 8, (end + 32 + 8191) & ~8191);
+	st4(buffer + 12, s.st_size);
 	if (write(image,buffer+2,14) != 14) die (argv[1]);
 	if (lseek(image, 4, 0) < 0) die ("lseek");
-	*(unsigned *)buffer = ((end + 32 + 8191) & ~8191) - (start & ~0x3fffffUL) + s.st_size;
-	*(unsigned *)(buffer + 4) = 0;
-	*(unsigned *)(buffer + 8) = 0;
+	st4(buffer, ((end + 32 + 8191) & ~8191) - (start & ~0x3fffffUL) + s.st_size);
+	st4(buffer + 4, 0);
+	st4(buffer + 8, 0);
 	if (write(image,buffer,12) != 12) die (argv[1]);
 	if (lseek(image, k - start + ((end + 32 + 8191) & ~8191), 0) < 0) die ("lseek");
 	if ((tail = open(argv[3],O_RDONLY)) < 0) die(argv[3]);