Browse Source

[romprefix] Sanity-check the runtime segment address for PCI 3

Some PCI 3 BIOSes seem to provide a garbage value in %bx, which should
contain the runtime segment address.  Perform a basic sanity check: we
reject the segment if it is below the start of option ROM space.  If
the sanity check fails, we assume that the BIOS was not expecting us
to be a PCI 3 ROM, and we just leave our image in situ.
tags/v0.9.6
Michael Brown 16 years ago
parent
commit
5600955bdd
1 changed files with 9 additions and 0 deletions
  1. 9
    0
      src/arch/i386/prefix/romprefix.S

+ 9
- 0
src/arch/i386/prefix/romprefix.S View File

205
 	movb	%bl, %al
205
 	movb	%bl, %al
206
 	call	print_hex_byte
206
 	call	print_hex_byte
207
 	cmpb	$3, %bh
207
 	cmpb	$3, %bh
208
+	jb	1f
209
+	/* PCI >=3.0: leave %gs as-is if sane */
210
+	movw	%gs, %ax
211
+	cmpw	$0xc000, %ax
208
 	jae	2f
212
 	jae	2f
213
+	/* PCI 3.0 with insane %gs value: print error and ignore %gs */
214
+	movb	$'!', %al
215
+	call	print_character
216
+	movw	%gs, %ax
217
+	call	print_hex_word
209
 1:	/* PCI <3.0: set %gs (runtime segment) = %cs (init-time segment) */
218
 1:	/* PCI <3.0: set %gs (runtime segment) = %cs (init-time segment) */
210
 	pushw	%cs
219
 	pushw	%cs
211
 	popw	%gs
220
 	popw	%gs

Loading…
Cancel
Save