Browse Source

[romprefix] Avoid unaligned accesses within ROM headers

Ensure that all headers (PCI, UNDI, PnP, iPXE) are aligned to at least
four bytes, so that all accesses to header fields will be correctly
aligned even when reading directly from the expansion ROM BAR.

Reported-by: Peter von Konigsmark <peter@exablaze.com>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 6 years ago
parent
commit
75acb3c775
2 changed files with 4 additions and 0 deletions
  1. 1
    0
      src/arch/x86/prefix/mromprefix.S
  2. 3
    0
      src/arch/x86/prefix/romprefix.S

+ 1
- 0
src/arch/x86/prefix/mromprefix.S View File

@@ -492,6 +492,7 @@ mromheader:
492 492
 	.word	0
493 493
 	.size	mromheader, . - mromheader
494 494
 
495
+	.align	4
495 496
 mpciheader:
496 497
 	.ascii	"PCIR"			/* Signature */
497 498
 	.word	pci_vendor_id		/* Vendor identification */

+ 3
- 0
src/arch/x86/prefix/romprefix.S View File

@@ -88,6 +88,7 @@ checksum:
88 88
 	.previous
89 89
 
90 90
 .ifeqs	BUSTYPE, "PCIR"
91
+	.align	4
91 92
 pciheader:
92 93
 	.ascii	"PCIR"			/* Signature */
93 94
 	.word	pci_vendor_id		/* Vendor identification */ 
@@ -183,6 +184,7 @@ prodstr_pci_id:
183 184
 
184 185
 	.globl	undiheader	
185 186
 	.weak	undiloader
187
+	.align	4
186 188
 undiheader:
187 189
 	.ascii	"UNDI"			/* Signature */
188 190
 	.byte	undiheader_len		/* Length of structure */
@@ -197,6 +199,7 @@ undiheader:
197 199
 	.equ undiheader_len, . - undiheader
198 200
 	.size undiheader, . - undiheader
199 201
 
202
+	.align	4
200 203
 ipxeheader:
201 204
 	.ascii	"iPXE"			/* Signature */
202 205
 	.byte	ipxeheader_len		/* Length of structure */

Loading…
Cancel
Save