diff --git a/src/arch/i386/image/multiboot.c b/src/arch/i386/image/multiboot.c index 7e89fef7..a198ef74 100644 --- a/src/arch/i386/image/multiboot.c +++ b/src/arch/i386/image/multiboot.c @@ -218,6 +218,7 @@ static struct multiboot_module __data16_array ( mbmodules, [MAX_MODULES] ); * @ret rc Return status code */ static int multiboot_exec ( struct image *image ) { + physaddr_t entry = image->priv.phys; /* Populate multiboot information structure */ memset ( &mbinfo, 0, sizeof ( mbinfo ) ); @@ -241,7 +242,7 @@ static int multiboot_exec ( struct image *image ) { __asm__ __volatile__ ( PHYS_CODE ( "call *%%edi\n\t" ) : : "a" ( MULTIBOOT_BOOTLOADER_MAGIC ), "b" ( virt_to_phys ( &mbinfo ) ), - "D" ( image->entry ) + "D" ( entry ) : "ecx", "edx", "esi", "ebp", "memory" ); DBGC ( image, "MULTIBOOT %p returned\n", image ); @@ -328,8 +329,8 @@ static int multiboot_load_raw ( struct image *image, /* Copy image to segment */ memcpy_user ( buffer, 0, image->data, offset, filesz ); - /* Record execution entry point */ - image->entry = hdr->mb.entry_addr; + /* Record execution entry point in image private data field */ + image->priv.phys = hdr->mb.entry_addr; return 0; } diff --git a/src/arch/i386/image/nbi.c b/src/arch/i386/image/nbi.c index 974b1b05..ad483b4f 100644 --- a/src/arch/i386/image/nbi.c +++ b/src/arch/i386/image/nbi.c @@ -277,6 +277,10 @@ int nbi_load ( struct image *image ) { nbi_load_segment ) ) != 0 ) return rc; + /* Record header address in image private data field */ + image->priv.user = real_to_user ( imgheader.location.segment, + imgheader.location.offset ); + return 0; } @@ -370,7 +374,7 @@ static int nbi_boot32 ( struct image *image, struct imgheader *imgheader ) { static int nbi_exec ( struct image *image ) { struct imgheader imgheader; - copy_from_user ( &imgheader, phys_to_user ( image->entry ), 0, + copy_from_user ( &imgheader, image->priv.user, 0, sizeof ( imgheader ) ); if ( NBI_LINEAR_EXEC_ADDR ( imgheader.flags ) ) { diff --git a/src/image/elf.c b/src/image/elf.c index 167ef2bf..75c976ea 100644 --- a/src/image/elf.c +++ b/src/image/elf.c @@ -136,8 +136,8 @@ int elf_load ( struct image *image ) { return rc; } - /* Fill in entry point address */ - image->entry = ehdr.e_entry; + /* Record execution entry point in image private data field */ + image->priv.phys = ehdr.e_entry; return 0; } diff --git a/src/include/gpxe/image.h b/src/include/gpxe/image.h index de10c369..3bfe834e 100644 --- a/src/include/gpxe/image.h +++ b/src/include/gpxe/image.h @@ -35,8 +35,11 @@ struct image { /** Image type, if known */ struct image_type *type; - /** Entry point */ - physaddr_t entry; + /** Image type private data */ + union { + physaddr_t phys; + userptr_t user; + } priv; }; /** Image is loaded */