mirror of
https://github.com/ipxe/ipxe
synced 2025-12-14 07:50:43 +03:00
[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.
This commit is contained in:
@@ -341,7 +341,7 @@ pm_call:
|
|||||||
/* Switch CPU to protected mode and load up segment registers */
|
/* Switch CPU to protected mode and load up segment registers */
|
||||||
pushl %eax
|
pushl %eax
|
||||||
cli
|
cli
|
||||||
lgdt PM_CALL_VAR(gdt)(%bp)
|
data32 lgdt PM_CALL_VAR(gdt)(%bp)
|
||||||
movl %cr0, %eax
|
movl %cr0, %eax
|
||||||
orb $CR0_PE, %al
|
orb $CR0_PE, %al
|
||||||
movl %eax, %cr0
|
movl %eax, %cr0
|
||||||
@@ -377,7 +377,7 @@ pm_call:
|
|||||||
popw %es
|
popw %es
|
||||||
popw %fs
|
popw %fs
|
||||||
popw %gs
|
popw %gs
|
||||||
lgdt PM_CALL_VAR(pm_saved_gdt)(%bp)
|
data32 lgdt PM_CALL_VAR(pm_saved_gdt)(%bp)
|
||||||
popfl
|
popfl
|
||||||
movw %bp, %sp
|
movw %bp, %sp
|
||||||
popw %bp
|
popw %bp
|
||||||
|
|||||||
@@ -316,7 +316,7 @@ p2r_jump_target:
|
|||||||
movl %edx, %esp
|
movl %edx, %esp
|
||||||
|
|
||||||
/* Reset IDTR to the real-mode defaults */
|
/* Reset IDTR to the real-mode defaults */
|
||||||
lidt rm_idtr
|
data32 lidt rm_idtr
|
||||||
|
|
||||||
/* Return to real-mode address */
|
/* Return to real-mode address */
|
||||||
data32 ret
|
data32 ret
|
||||||
@@ -424,8 +424,8 @@ prot_call:
|
|||||||
1:
|
1:
|
||||||
/* Reload GDT and IDT, restore registers and flags and return */
|
/* Reload GDT and IDT, restore registers and flags and return */
|
||||||
movw %sp, %bp
|
movw %sp, %bp
|
||||||
lgdt (%bp)
|
data32 lgdt (%bp)
|
||||||
lidt 8(%bp)
|
data32 lidt 8(%bp)
|
||||||
addw $20, %sp /* also skip %cs and %ss */
|
addw $20, %sp /* also skip %cs and %ss */
|
||||||
popw %ds
|
popw %ds
|
||||||
popw %es
|
popw %es
|
||||||
|
|||||||
Reference in New Issue
Block a user