Browse Source

[romprefix] Round up PMM allocation sizes to nearest 4kB

Some AMI BIOSes apparently break in exciting ways when asked for PMM
allocations for sizes that are not multiples of 4kB.

Fix by rounding up the image source area to the nearest 4kB.  (The
temporary decompression area is already rounded up to the nearest
128kB, to facilitate sharing between multiple iPXE ROMs.)

Reported-by: Itay Gazit <itayg@mellanox.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 12 years ago
parent
commit
1f88e9c8ea
1 changed files with 5 additions and 1 deletions
  1. 5
    1
      src/arch/i386/prefix/romprefix.S

+ 5
- 1
src/arch/i386/prefix/romprefix.S View File

352
 	call	print_message
352
 	call	print_message
353
 	/* We have PMM and so a 1kB stack: preserve whole registers */
353
 	/* We have PMM and so a 1kB stack: preserve whole registers */
354
 	pushal
354
 	pushal
355
-	/* Allocate image source PMM block */
355
+	/* Allocate image source PMM block.  Round up the size to the
356
+	 * nearest 4kB (8 512-byte sectors) to work around AMI BIOS bugs.
357
+	 */
356
 	movzbl	romheader_size, %ecx
358
 	movzbl	romheader_size, %ecx
357
 	addw	extra_size, %cx
359
 	addw	extra_size, %cx
360
+	addw	$0x0007, %cx	/* Round up to multiple of 8 512-byte sectors */
361
+	andw	$0xfff8, %cx
358
 	shll	$5, %ecx
362
 	shll	$5, %ecx
359
 	movl	$PMM_HANDLE_BASE_IMAGE_SOURCE, %ebx
363
 	movl	$PMM_HANDLE_BASE_IMAGE_SOURCE, %ebx
360
 	movw	$get_pmm_image_source, %bp
364
 	movw	$get_pmm_image_source, %bp

Loading…
Cancel
Save