Explorar el Código

[i386] Add data32 prefixes to all lgdt/lidt instructions

With a 16-bit operand, lgdt/lidt will load only a 24-bit base address,
ignoring the high-order bits.  This meant that we could fail to fully
restore the GDT across a call into gPXE, if the GDT happened to be
located above the 16MB mark.

Not all of our lgdt/lidt instructions require a data32 prefix (for
example, reloading the real-mode IDT can never require a 32-bit base
address), but by adding them everywhere we will hopefully not forget
the necessary ones in future.
tags/v0.9.6
Michael Brown hace 16 años
padre
commit
29e6f9835e
Se han modificado 2 ficheros con 7 adiciones y 7 borrados
  1. 2
    2
      src/arch/i386/prefix/libprefix.S
  2. 5
    5
      src/arch/i386/transitions/librm.S

+ 2
- 2
src/arch/i386/prefix/libprefix.S Ver fichero

@@ -341,7 +341,7 @@ pm_call:
341 341
 	/* Switch CPU to protected mode and load up segment registers */
342 342
 	pushl	%eax
343 343
 	cli
344
-	lgdt	PM_CALL_VAR(gdt)(%bp)
344
+	data32 lgdt PM_CALL_VAR(gdt)(%bp)
345 345
 	movl	%cr0, %eax
346 346
 	orb	$CR0_PE, %al
347 347
 	movl	%eax, %cr0
@@ -377,7 +377,7 @@ pm_call:
377 377
 	popw	%es
378 378
 	popw	%fs
379 379
 	popw	%gs
380
-	lgdt	PM_CALL_VAR(pm_saved_gdt)(%bp)
380
+	data32 lgdt PM_CALL_VAR(pm_saved_gdt)(%bp)
381 381
 	popfl
382 382
 	movw	%bp, %sp
383 383
 	popw	%bp

+ 5
- 5
src/arch/i386/transitions/librm.S Ver fichero

@@ -203,8 +203,8 @@ real_to_prot:
203 203
 
204 204
 	/* Switch to protected mode */
205 205
 	cli
206
-	data32 lgdt	gdtr
207
-	data32 lidt	idtr
206
+	data32 lgdt gdtr
207
+	data32 lidt idtr
208 208
 	movl	%cr0, %eax
209 209
 	orb	$CR0_PE, %al
210 210
 	movl	%eax, %cr0
@@ -316,7 +316,7 @@ p2r_jump_target:
316 316
 	movl	%edx, %esp
317 317
 
318 318
 	/* Reset IDTR to the real-mode defaults */
319
-	lidt	rm_idtr
319
+	data32 lidt rm_idtr
320 320
 
321 321
 	/* Return to real-mode address */
322 322
 	data32 ret
@@ -424,8 +424,8 @@ prot_call:
424 424
 1:	
425 425
 	/* Reload GDT and IDT, restore registers and flags and return */
426 426
 	movw	%sp, %bp
427
-	lgdt	(%bp)
428
-	lidt	8(%bp)
427
+	data32 lgdt (%bp)
428
+	data32 lidt 8(%bp)
429 429
 	addw	$20, %sp /* also skip %cs and %ss */
430 430
 	popw	%ds
431 431
 	popw	%es

Loading…
Cancelar
Guardar