Sfoglia il codice sorgente

[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 anni fa
parent
commit
aa11f5deda
1 ha cambiato i file con 5 aggiunte e 3 eliminazioni
  1. 5
    3
      src/arch/x86/image/bzimage.c

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

@@ -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 ) {

Loading…
Annulla
Salva