Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[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.
  • Loading branch information
Michael Brown committed Apr 24, 2009
1 parent ad027e4 commit e960fac
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/arch/i386/image/multiboot.c
Expand Up @@ -360,6 +360,13 @@ static int multiboot_load_raw ( struct image *image,
userptr_t buffer;
int rc;

/* Sanity check */
if ( ! ( hdr->mb.flags & MB_FLAG_RAW ) ) {
DBGC ( image, "MULTIBOOT %p is not flagged as a raw image\n",
image );
return -EINVAL;
}

/* Verify and prepare segment */
offset = ( hdr->offset - hdr->mb.header_addr + hdr->mb.load_addr );
filesz = ( hdr->mb.load_end_addr ?
Expand Down Expand Up @@ -432,14 +439,14 @@ static int multiboot_load ( struct image *image ) {
return -ENOTSUP;
}

/* Load the actual image */
if ( hdr.mb.flags & MB_FLAG_RAW ) {
if ( ( rc = multiboot_load_raw ( image, &hdr ) ) != 0 )
return rc;
} else {
if ( ( rc = multiboot_load_elf ( image ) ) != 0 )
return rc;
}
/* There is technically a bit MB_FLAG_RAW to indicate whether
* this is an ELF or a raw image. In practice, grub will use
* the ELF header if present, and Solaris relies on this
* behaviour.
*/
if ( ( ( rc = multiboot_load_elf ( image ) ) != 0 ) &&
( ( rc = multiboot_load_raw ( image, &hdr ) ) != 0 ) )
return rc;

return 0;
}
Expand Down

0 comments on commit e960fac

Please sign in to comment.