initrd allocation

Nathan Lynch ntl at pobox.com
Fri Jan 13 15:54:32 EST 2006


Hi-

I have a system where claim is failing for an initrd only slightly
larger than 4096K.  The initial 4MB allocation succeeds, but when we
try to grab another 4MB, the claim fails.  However, yaboot doesn't
seem to handle this case properly and continues to boot the kernel
with a truncated initrd.

This is with a vendor version of yaboot based on 1.3.12, but looks
like upstream would have the same problem.

second/yaboot.c:
<snip>
#define INITRD_CHUNKSIZE 0x400000
		    initrd_base = prom_claim(loadinfo.base+loadinfo.memsize, INITRD_CHUNKSIZE, 0);
		    if (initrd_base == (void *)-1) {
			 prom_printf("Claim failed for initrd memory\n");
			 initrd_base = 0;
		    } else {
			 initrd_size = file.fs->read(&file, INITRD_CHUNKSIZE, initrd_base);
			 if (initrd_size == 0)
			      initrd_base = 0;
			 initrd_read = initrd_size;
			 initrd_more = initrd_base;
			 while (initrd_read == INITRD_CHUNKSIZE ) { /* need to read more? */
			      initrd_want = (void *)((unsigned long)initrd_more+INITRD_CHUNKSIZE);
			      initrd_more = prom_claim(initrd_want, INITRD_CHUNKSIZE, 0);
			      if (initrd_more != initrd_want) {
				   prom_printf("Claim failed for initrd memory at %p rc=%p\n",initrd_want,initrd_more);
				   break;
			      }
			      initrd_read = file.fs->read(&file, INITRD_CHUNKSIZE, initrd_more);
			      DEBUG_F("  block at %p rc=%lu\n",initrd_more,initrd_read);
			      initrd_size += initrd_read;
			 }
		    }
		    file.fs->close(&file);
		    memset(&file, 0, sizeof(file));
	       }
	       if (initrd_base)
		    prom_printf("ramdisk loaded at %p, size: %lu Kbytes\n",
				initrd_base, initrd_size >> 10);
	       else {
		    prom_printf("ramdisk load failed !\n");
		    prom_pause();
	       }
</snip>

Couple of questions:

1) Is there some historical reason for INITRD_CHUNKSIZE to be as large
   as it is?  I have worked around the issue by defining it to
   0x100000.

2) If a "secondary" claim fails, shouldn't we assert/prom_pause or
   something?


Thanks,
Nathan



More information about the Yaboot-devel mailing list