Parcourir la source

[romprefix] Report an optimistic runtime size estimate

Commit 5de45cd ("[romprefix] Report a pessimistic runtime size
estimate") set the PCI3.0 "runtime size" field equal to the worst-case
runtime size, on the basis that there is no guarantee that PMM
allocation will succeed and hence no guarantee that we will be able to
shrink the ROM image.

On a PCI3.0 system where PMM allocation would succeed, this can cause
the BIOS to unnecessarily refuse to initialise the iPXE ROM due to a
perceived shortage of option ROM space.

Fix by reporting the best-case runtime size via the PCI header, and
checking that we have sufficient runtime space (if applicable).  This
allows iPXE ROMs to initialise on PCI3.0 systems that might otherwise
fail due to a shortage of option ROM space.

This may cause iPXE ROMs to fail to initialise on PCI3.0 systems where
PMM is broken.  (Pre-PCI3.0 systems are unaffected since there must
already have been sufficient option ROM space available for the
initialisation entry point to be called.)

On balance, it seems preferable to avoid breaking "good" systems
(PCI3.0 with working PMM) at the cost of potentially breaking "bad"
systems (PCI3.0 with broken PMM).

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown il y a 9 ans
Parent
révision
173c48a57e
1 fichiers modifiés avec 16 ajouts et 4 suppressions
  1. 16
    4
      src/arch/i386/prefix/romprefix.S

+ 16
- 4
src/arch/i386/prefix/romprefix.S Voir le fichier

@@ -123,7 +123,7 @@ pci_devlist_end:
123 123
 	.long	pciheader_image_length
124 124
 	.long	512
125 125
 	.long	0
126
-	.ascii	ZINFO_TYPE_ADxW
126
+	.ascii	"ADHW"
127 127
 	.long	pciheader_runtime_length
128 128
 	.long	512
129 129
 	.long	0
@@ -435,13 +435,25 @@ no_pmm:
435 435
 	 * memory.  Will be a no-op for lower PCI versions.
436 436
 	 */
437 437
 .ifeqs	BUSTYPE, "PCIR"
438
+	/* Get runtime segment address and length */
439
+	movw	%gs, %ax
440
+	movw	%ax, %es
441
+	movzbw	romheader_size, %cx
442
+	/* Print runtime segment address */
438 443
 	xorw	%di, %di
439 444
 	call	print_space
440
-	movw	%gs, %ax
441 445
 	call	print_hex_word
442
-	movzbw	romheader_size, %cx
446
+	/* Fail if we have insufficient space in final location */
447
+	movw	%cs, %si
448
+	cmpw	%si, %ax
449
+	je	1f
450
+	cmpw	pciheader_runtime_length, %cx
451
+	jbe	1f
452
+	movb	$( '!' ), %al
453
+	call	print_character
454
+	xorw	%cx, %cx
455
+1:	/* Copy to final location */
443 456
 	shlw	$9, %cx
444
-	movw	%ax, %es
445 457
 	xorw	%si, %si
446 458
 	xorw	%di, %di
447 459
 	cs rep	movsb

Chargement…
Annuler
Enregistrer