Pārlūkot izejas kodu

[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 gadus atpakaļ
vecāks
revīzija
e960fac8d0
1 mainītis faili ar 15 papildinājumiem un 8 dzēšanām
  1. 15
    8
      src/arch/i386/image/multiboot.c

+ 15
- 8
src/arch/i386/image/multiboot.c Parādīt failu

@@ -360,6 +360,13 @@ static int multiboot_load_raw ( struct image *image,
360 360
 	userptr_t buffer;
361 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 370
 	/* Verify and prepare segment */
364 371
 	offset = ( hdr->offset - hdr->mb.header_addr + hdr->mb.load_addr );
365 372
 	filesz = ( hdr->mb.load_end_addr ?
@@ -432,14 +439,14 @@ static int multiboot_load ( struct image *image ) {
432 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 451
 	return 0;
445 452
 }

Notiek ielāde…
Atcelt
Saglabāt