Bläddra i källkod

[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 år sedan
förälder
incheckning
aa11f5deda
1 ändrade filer med 5 tillägg och 3 borttagningar
  1. 5
    3
      src/arch/x86/image/bzimage.c

+ 5
- 3
src/arch/x86/image/bzimage.c Visa fil

@@ -522,10 +522,12 @@ static void bzimage_load_initrds ( struct image *image,
522 522
 
523 523
 	/* Find highest usable address */
524 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 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 532
 	/* Load initrds in order */
531 533
 	for_each_image ( initrd ) {

Laddar…
Avbryt
Spara