aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/arch/i386/image/bzimage.c30
-rw-r--r--src/arch/i386/include/initrd.h5
2 files changed, 16 insertions, 19 deletions
diff --git a/src/arch/i386/image/bzimage.c b/src/arch/i386/image/bzimage.c
index 12be1779..3b484b17 100644
--- a/src/arch/i386/image/bzimage.c
+++ b/src/arch/i386/image/bzimage.c
@@ -360,7 +360,7 @@ static size_t bzimage_load_initrd ( struct image *image,
char *filename = initrd->cmdline;
char *cmdline;
struct cpio_header cpio;
- size_t offset = 0;
+ size_t offset;
size_t name_len;
size_t pad_len;
@@ -368,7 +368,7 @@ static size_t bzimage_load_initrd ( struct image *image,
if ( initrd == image )
return 0;
- /* Create cpio header before non-prebuilt images */
+ /* Create cpio header for non-prebuilt images */
if ( filename && filename[0] ) {
cmdline = strchr ( filename, ' ' );
name_len = ( ( cmdline ? ( ( size_t ) ( cmdline - filename ) )
@@ -383,24 +383,20 @@ static size_t bzimage_load_initrd ( struct image *image,
bzimage_parse_cpio_cmdline ( image, &cpio,
( cmdline + 1 /* ' ' */ ));
}
- if ( address ) {
- copy_to_user ( address, offset, &cpio,
- sizeof ( cpio ) );
- }
- offset += sizeof ( cpio );
- if ( address ) {
- memset_user ( address, offset, 0, name_len );
- copy_to_user ( address, offset, filename,
- ( name_len - 1 /* NUL (or space) */ ) );
- }
- offset += name_len;
- offset = ( ( offset + 0x03 ) & ~0x03 );
+ offset = ( ( sizeof ( cpio ) + name_len + 0x03 ) & ~0x03 );
+ } else {
+ offset = 0;
}
- /* Copy in initrd image body */
- if ( address )
- memmove_user ( address, offset, initrd->data, 0, initrd->len );
+ /* Copy in initrd image body (and cpio header if applicable) */
if ( address ) {
+ memmove_user ( address, offset, initrd->data, 0, initrd->len );
+ if ( offset ) {
+ memset_user ( address, 0, 0, offset );
+ copy_to_user ( address, 0, &cpio, sizeof ( cpio ) );
+ copy_to_user ( address, sizeof ( cpio ), filename,
+ ( name_len - 1 /* NUL (or space) */ ) );
+ }
DBGC ( image, "bzImage %p initrd %p [%#08lx,%#08lx,%#08lx)"
"%s%s\n", image, initrd, user_to_phys ( address, 0 ),
user_to_phys ( address, offset ),
diff --git a/src/arch/i386/include/initrd.h b/src/arch/i386/include/initrd.h
index c25d0924..a5659f43 100644
--- a/src/arch/i386/include/initrd.h
+++ b/src/arch/i386/include/initrd.h
@@ -13,9 +13,10 @@ FILE_LICENCE ( GPL2_OR_LATER );
/** Minimum alignment for initrds
*
- * Chosen to maximise memcpy() speeds
+ * Some versions of Linux complain about initrds that are not
+ * page-aligned.
*/
-#define INITRD_ALIGN 4
+#define INITRD_ALIGN 4096
/** Minimum free space required to reshuffle initrds
*