public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/2] fix detection of redboot fis partition table
@ 2004-10-29 13:50 Ian Campbell
  2004-11-22 11:08 ` David Woodhouse
  0 siblings, 1 reply; 4+ messages in thread
From: Ian Campbell @ 2004-10-29 13:50 UTC (permalink / raw)
  To: linux-mtd

I think I sent this via our regular mail-server (that adds legal rubbish
to the bottom of mails) the first time so it won't get through to the
list. Apologies if it comes through twice.

Hi all,

The redboot partitioning code currently searches for a FIS table entry
named "RedBoot" (including the trailing \0) in one of the first three
entries to try and verify that the sector it is looking at really is a
FIS partition table.

Firstly it fails when RedBoot is stored in some other Flash chip such as
a boot PROM, in this case there is no "RedBoot" entry in the partition
table. However there will always be a "FIS directory" entry in any valid
FIS directory.
        
Secondly it can fail since the RedBoot entry is not always in the first
3 slots -- this can happen for example on an x86 based platform where
the processor expects the boot device to be at the top of memory rather
than the bottom and so RedBoot is at the end of the flash device.
Equally when using "FIS directory" as the entry to search for it very
likely is not in the first three since the directory is typically at the
end of the flash.

The patch (against BK) below sorts these out. Is it OK to commit to MTD
CVS and then send to Linus?

Ian.

%patch
Index: 2.6-bk/drivers/mtd/redboot.c
===================================================================
--- 2.6-bk.orig/drivers/mtd/redboot.c	2004-09-15 11:00:22.000000000 +0100
+++ 2.6-bk/drivers/mtd/redboot.c	2004-10-29 14:21:33.018453911 +0100
@@ -50,6 +50,7 @@
 	char *nullname;
 	int namelen = 0;
 	int nulllen = 0;
+	int numslots;
 #ifdef CONFIG_MTD_REDBOOT_PARTS_UNALLOCATED
 	static char nullstring[] = "unallocated";
 #endif
@@ -71,12 +72,16 @@
 		goto out;
 	}
 
-	/* RedBoot image could appear in any of the first three slots */
-	for (i = 0; i < 3; i++) {
-		if (!memcmp(buf[i].name, "RedBoot", 8))
+	numslots = (master->erasesize / sizeof(struct fis_image_desc));
+	for (i = 0; i < numslots; i++) {
+		if (buf[i].name[0] == 0xff) {
+			i = numslots;
+			break;
+		}
+		if (!memcmp(buf[i].name, "FIS directory", 14))
 			break;
 	}
-	if (i == 3) {
+	if (i == numslots) {
 		/* Didn't find it */
 		printk(KERN_NOTICE "No RedBoot partition table detected in %s\n",
 		       master->name);
@@ -84,7 +89,7 @@
 		goto out;
 	}
 
-	for (i = 0; i < master->erasesize / sizeof(struct fis_image_desc); i++) {
+	for (i = 0; i < numslots; i++) {
 		struct fis_list *new_fl, **prev;
 
 		if (buf[i].name[0] == 0xff)



-- 
Ian Campbell, Senior Design Engineer
                                        Web: http://www.arcom.com
Arcom, Clifton Road, 			Direct: +44 (0)1223 403 465
Cambridge CB1 7EA, United Kingdom	Phone:  +44 (0)1223 411 200
-- 
Ian Campbell, Senior Design Engineer
                                        Web: http://www.arcom.com
Arcom, Clifton Road, 			Direct: +44 (0)1223 403 465
Cambridge CB1 7EA, United Kingdom	Phone:  +44 (0)1223 411 200

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-22 11:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-10-29 13:50 [PATCH 1/2] fix detection of redboot fis partition table Ian Campbell
2004-11-22 11:08 ` David Woodhouse
2004-11-22 11:40   ` Ian Campbell
2004-11-22 11:42     ` David Woodhouse

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox