Skip to contentSkip to conversation

Re. [SPARC32]: Fix bogus ramdisk image location check.

DISCUSSION Robert Reif 3 participants 7 messages Aug 20, 2007 – Aug 30, 2007 SPARC + UltraSPARC (sparc/sparc64)

lore
Share & tools
lore
#0 lore raw

commit f642b263800e6e57c377d630be6d2a999683b579

This patch causes sparc32 SMP to watchdog fail on boot.

Reverting it lets the system boot.

maintainer
#1 lore raw

From: Robert Reif <[email protected]>
Date: Mon, 20 Aug 2007 18:46:54 -0400

Quoted 5 lines

commit f642b263800e6e57c377d630be6d2a999683b579

This patch causes sparc32 SMP to watchdog fail on boot.

Reverting it lets the system boot.

Thanks I'll revert this.

Mark, please work with Robert to figure out what we should do about this if you want to try and make this change again.

I think this shows that SILO can in fact provide ramdisk addresses which should not be normalized by KERNBASE in the kernel.

#2 lore raw
In reply to Robert Reif

Hi Robert,

Can you put some prom_printf's or printk's in to find out where your initrd ramdisk is ending up.

The code relies on ordering/alignment in the linker script which is not a good idear so the aim needs to be to create some code that correctly identifies the location of the ramdisk without using hard coded offsets based on '&end' and 2*4096 :). I will have another look at the code later on this week and see if I can work out somthing that does the same thing but with more flexibility in what can be done to the linker script (i.e. does not rely on specific alignments and ordering in the linker script).

The information about where the ramdisk is may present a simple solution.

Regards
Mark Fortescue.

#3 lore raw
In reply to Robert Reif
Quoted 14 lines · [email protected] wrote:

Hi Robert,

Can you put some prom_printf's or printk's in to find out where your initrd ramdisk is ending up.

The code relies on ordering/alignment in the linker script which is not a good idear so the aim needs to be to create some code that correctly identifies the location of the ramdisk without using hard coded offsets based on '&end' and 2*4096 :). I will have another look at the code later on this week and see if I can work out somthing that does the same thing but with more flexibility in what can be done to the linker script (i.e. does not rely on specific alignments and ordering in the linker script).

The information about where the ramdisk is may present a simple solution.

Regards
Mark Fortescue.

The following patch gives these numbers:

sparc_ramdisk_image = 3000000, &_end = f028bde0, phys_base = 0, sparc_ramdisk_size = 3064303 initrd_start = 3000000, initrd_end = 32ec1ef

arch/sparc/mm/init.c +5 -1
@@ -206,9 +206,13 @@ unsigned long __init bootmem_init(unsigned long *pages_avail)
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* Now have to check initial ramdisk, so that bootmap does not overwrite it */
 	if (sparc_ramdisk_image) {
-		sparc_ramdisk_image -= KERNBASE;
+printk("sparc_ramdisk_image = %x, &_end = %p, phys_base = %lx, sparc_ramdisk_size = %u\n", 
+sparc_ramdisk_image, &_end, phys_base, sparc_ramdisk_size);
+		if (sparc_ramdisk_image >= (unsigned long)&_end - 2 * PAGE_SIZE)
+			sparc_ramdisk_image -= KERNBASE;
 		initrd_start = sparc_ramdisk_image + phys_base;
 		initrd_end = initrd_start + sparc_ramdisk_size;
+printk("initrd_start = %lx, initrd_end = %lx\n", initrd_start, initrd_end);
 		if (initrd_end > end_of_phys_memory) {
 			printk(KERN_CRIT "initrd extends beyond end of memory "
 		                 	 "(0x%016lx > 0x%016lx)\ndisabling initrd\n",
#4 lore raw
In reply to Robert Reif

Hi Robert,

I beleive that the attached+inserted patch should have the desired characteristics. Can you check it out to ensure it does nothing silly.

(This same check may also be valid for SPARC64)

arch/sparc/mm/init.c +1 -1
@@ -206,7 +206,7 @@ unsigned long __init bootmem_init(unsign
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* Now have to check initial ramdisk, so that bootmap does not overwrite it */
 	if (sparc_ramdisk_image) {
-		if (sparc_ramdisk_image >= (unsigned long)&_end - 2 * PAGE_SIZE)
+		if (sparc_ramdisk_image >= KERNBASE)
 			sparc_ramdisk_image -= KERNBASE;
 		initrd_start = sparc_ramdisk_image + phys_base;
 		initrd_end = initrd_start + sparc_ramdisk_size;

From: Mark Fortescue <[email protected]>

[SPARC32]: Fix bogus ramdisk image location check.

It was originally thought that sparc_ramdisk_image should always be decremented by KERNBASE so the check could just be dropped, but it turns out that this is not the case. Just checking if the image is greater than KERNBASE should be sufficient to correctly identify if the correction is needed and avoids any posible issues with changes to the linker script ordering that are present if &end is used with a fixed 2 page offset.

---
This same check may also be valid for SPARC64

arch/sparc/mm/init.c +1 -1
@@ -206,7 +206,7 @@ unsigned long __init bootmem_init(unsign
 #ifdef CONFIG_BLK_DEV_INITRD
 	/* Now have to check initial ramdisk, so that bootmap does not overwrite it */
 	if (sparc_ramdisk_image) {
-		if (sparc_ramdisk_image >= (unsigned long)&_end - 2 * PAGE_SIZE)
+		if (sparc_ramdisk_image >= KERNBASE)
 			sparc_ramdisk_image -= KERNBASE;
 		initrd_start = sparc_ramdisk_image + phys_base;
 		initrd_end = initrd_start + sparc_ramdisk_size;
#5 lore raw
In reply to Robert Reif
Quoted 4 lines · Mark Fortescue

Hi Robert,

I beleive that the attached+inserted patch should have the desired characteristics. Can you check it out to ensure it does nothing silly.

Works with current git SMP.

#6 lore raw
In reply to Robert Reif
Quoted 6 lines
Quoted 3 lines

I beleive that the attached+inserted patch should have the desired characteristics. Can you check it out to ensure it does nothing silly.

Works with current git SMP.

Thanks for testing.