Browse Source

[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>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
aa11f5deda
1 changed files with 5 additions and 3 deletions
  1. 5
    3
      src/arch/x86/image/bzimage.c

+ 5
- 3
src/arch/x86/image/bzimage.c View File

522
 
522
 
523
 	/* Find highest usable address */
523
 	/* Find highest usable address */
524
 	top = userptr_add ( highest->data, bzimage_align ( highest->len ) );
524
 	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
+	}
527
 	DBGC ( image, "bzImage %p loading initrds from %#08lx downwards\n",
529
 	DBGC ( image, "bzImage %p loading initrds from %#08lx downwards\n",
528
-	       image, user_to_phys ( top, 0 ) );
530
+	       image, user_to_phys ( top, -1 ) );
529
 
531
 
530
 	/* Load initrds in order */
532
 	/* Load initrds in order */
531
 	for_each_image ( initrd ) {
533
 	for_each_image ( initrd ) {

Loading…
Cancel
Save