Skip to content

Commit aa11f5d

Browse files
committed
[bzimage] Fix page alignment of initrd images
The initrd_addr_max field represents the highest byte address that may be used to hold initrd images, and is therefore almost certainly not aligned to a page boundary: a typical value might be 0x7fffffff. Fix the address calculations to ensure that the initrd images are always aligned to a page boundary. Reported-by: Sitsofe Wheeler <sitsofe@gmail.com> Signed-off-by: Michael Brown <mcb30@ipxe.org>
1 parent 0be77e9 commit aa11f5d

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/arch/x86/image/bzimage.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -522,10 +522,12 @@ static void bzimage_load_initrds ( struct image *image,
522522

523523
/* Find highest usable address */
524524
top = userptr_add ( highest->data, bzimage_align ( highest->len ) );
525-
if ( user_to_phys ( top, 0 ) > bzimg->mem_limit )
526-
top = phys_to_user ( bzimg->mem_limit );
525+
if ( user_to_phys ( top, -1 ) > bzimg->mem_limit ) {
526+
top = phys_to_user ( ( bzimg->mem_limit + 1 ) &
527+
~( INITRD_ALIGN - 1 ) );
528+
}
527529
DBGC ( image, "bzImage %p loading initrds from %#08lx downwards\n",
528-
image, user_to_phys ( top, 0 ) );
530+
image, user_to_phys ( top, -1 ) );
529531

530532
/* Load initrds in order */
531533
for_each_image ( initrd ) {

0 commit comments

Comments
 (0)