Browse Source

[multiboot] Work around raw-flag bug in Solaris kernels

Solaris kernels are multiboot images with the "raw" flag set,
indicating that the loader should use the raw address fields within
the multiboot header rather than looking for an ELF header.  However,
the Solaris kernel contains garbage data in the raw address fields,
and requires us to use the ELF header instead.

Work around this by always using the ELF header if present.  This
renders the "raw" flag somewhat redundant.
tags/v0.9.8
Michael Brown 15 years ago
parent
commit
e960fac8d0
1 changed files with 15 additions and 8 deletions
  1. 15
    8
      src/arch/i386/image/multiboot.c

+ 15
- 8
src/arch/i386/image/multiboot.c View File

360
 	userptr_t buffer;
360
 	userptr_t buffer;
361
 	int rc;
361
 	int rc;
362
 
362
 
363
+	/* Sanity check */
364
+	if ( ! ( hdr->mb.flags & MB_FLAG_RAW ) ) {
365
+		DBGC ( image, "MULTIBOOT %p is not flagged as a raw image\n",
366
+		       image );
367
+		return -EINVAL;
368
+	}
369
+
363
 	/* Verify and prepare segment */
370
 	/* Verify and prepare segment */
364
 	offset = ( hdr->offset - hdr->mb.header_addr + hdr->mb.load_addr );
371
 	offset = ( hdr->offset - hdr->mb.header_addr + hdr->mb.load_addr );
365
 	filesz = ( hdr->mb.load_end_addr ?
372
 	filesz = ( hdr->mb.load_end_addr ?
432
 		return -ENOTSUP;
439
 		return -ENOTSUP;
433
 	}
440
 	}
434
 
441
 
435
-	/* Load the actual image */
436
-	if ( hdr.mb.flags & MB_FLAG_RAW ) {
437
-		if ( ( rc = multiboot_load_raw ( image, &hdr ) ) != 0 )
438
-			return rc;
439
-	} else {
440
-		if ( ( rc = multiboot_load_elf ( image ) ) != 0 )
441
-			return rc;
442
-	}
442
+	/* There is technically a bit MB_FLAG_RAW to indicate whether
443
+	 * this is an ELF or a raw image.  In practice, grub will use
444
+	 * the ELF header if present, and Solaris relies on this
445
+	 * behaviour.
446
+	 */
447
+	if ( ( ( rc = multiboot_load_elf ( image ) ) != 0 ) &&
448
+	     ( ( rc = multiboot_load_raw ( image, &hdr ) ) != 0 ) )
449
+		return rc;
443
 
450
 
444
 	return 0;
451
 	return 0;
445
 }
452
 }

Loading…
Cancel
Save