Don't use the "rep ss movsb" trick to copy the RM stack to the PM
stack; it breaks vmxassist.
This commit is contained in:
parent
0ed066bc50
commit
42d96bcb07
|
@ -186,9 +186,14 @@ real_to_prot:
|
||||||
pushl _data16
|
pushl _data16
|
||||||
addw $16, %cx /* %ecx must be less than 64kB anyway */
|
addw $16, %cx /* %ecx must be less than 64kB anyway */
|
||||||
|
|
||||||
/* Real-mode %ss:%sp => %bp:%esi */
|
/* Real-mode %ss:%sp => %ebp:%edx and virtual address => %esi */
|
||||||
|
xorl %ebp, %ebp
|
||||||
movw %ss, %bp
|
movw %ss, %bp
|
||||||
movzwl %sp, %esi
|
movzwl %sp, %edx
|
||||||
|
movl %ebp, %eax
|
||||||
|
shll $4, %eax
|
||||||
|
leal (%eax,%edx), %esi
|
||||||
|
subl _virt_offset, %esi
|
||||||
|
|
||||||
/* Switch to protected mode */
|
/* Switch to protected mode */
|
||||||
cli
|
cli
|
||||||
|
@ -200,23 +205,24 @@ real_to_prot:
|
||||||
.section ".text"
|
.section ".text"
|
||||||
.code32
|
.code32
|
||||||
1:
|
1:
|
||||||
/* Set up protected-mode data segments */
|
/* Set up protected-mode data segments and stack pointer */
|
||||||
movw $VIRTUAL_DS, %ax
|
movw $VIRTUAL_DS, %ax
|
||||||
movw %ax, %ds
|
movw %ax, %ds
|
||||||
movw %ax, %es
|
movw %ax, %es
|
||||||
movw %ax, %fs
|
movw %ax, %fs
|
||||||
movw %ax, %gs
|
movw %ax, %gs
|
||||||
|
|
||||||
/* Move data from RM stack to PM stack and set up PM stack */
|
|
||||||
movl pm_esp, %esp
|
|
||||||
subl %ecx, %esp
|
|
||||||
movl %esp, %edi
|
|
||||||
rep ss movsb
|
|
||||||
movw %ax, %ss
|
movw %ax, %ss
|
||||||
|
movl pm_esp, %esp
|
||||||
|
|
||||||
/* Record real-mode %ss:sp (after removal of data) */
|
/* Record real-mode %ss:sp (after removal of data) */
|
||||||
movw %bp, rm_ss
|
movl %ebp, rm_ss
|
||||||
movw %si, rm_sp
|
addl %ecx, %edx
|
||||||
|
movl %edx, rm_sp
|
||||||
|
|
||||||
|
/* Move data from RM stack to PM stack */
|
||||||
|
subl %ecx, %esp
|
||||||
|
movl %esp, %edi
|
||||||
|
rep movsb
|
||||||
|
|
||||||
/* Publish virt_offset, text16 and data16 for PM code to use */
|
/* Publish virt_offset, text16 and data16 for PM code to use */
|
||||||
popl data16
|
popl data16
|
||||||
|
@ -251,16 +257,16 @@ prot_to_real:
|
||||||
/* Add return address to data to be moved to RM stack */
|
/* Add return address to data to be moved to RM stack */
|
||||||
addl $4, %ecx
|
addl $4, %ecx
|
||||||
|
|
||||||
/* Real-mode %ss:sp => %ebp:edx */
|
/* Real-mode %ss:sp => %ebp:edx and virtual address => %edi */
|
||||||
movzwl rm_ss, %ebp
|
movl rm_ss, %ebp
|
||||||
movzwl rm_sp, %edx
|
movl rm_sp, %edx
|
||||||
subl %ecx, %edx
|
subl %ecx, %edx
|
||||||
|
|
||||||
/* Move data from PM stack to RM stack */
|
|
||||||
movl %ebp, %eax
|
movl %ebp, %eax
|
||||||
shll $4, %eax
|
shll $4, %eax
|
||||||
leal (%eax,%edx), %edi
|
leal (%eax,%edx), %edi
|
||||||
subl virt_offset, %edi
|
subl virt_offset, %edi
|
||||||
|
|
||||||
|
/* Move data from PM stack to RM stack */
|
||||||
movl %esp, %esi
|
movl %esp, %esi
|
||||||
rep movsb
|
rep movsb
|
||||||
|
|
||||||
|
@ -285,16 +291,14 @@ prot_to_real:
|
||||||
ljmp *p2r_jump_vector
|
ljmp *p2r_jump_vector
|
||||||
p2r_jump_target:
|
p2r_jump_target:
|
||||||
|
|
||||||
/* Set up real-mode stack */
|
/* Set up real-mode data segments and stack pointer */
|
||||||
movw %bp, %ss
|
|
||||||
movl %edx, %esp
|
|
||||||
|
|
||||||
/* Set up real-mode data segments */
|
|
||||||
movw %cs:rm_ds, %ax
|
movw %cs:rm_ds, %ax
|
||||||
movw %ax, %ds
|
movw %ax, %ds
|
||||||
movw %ax, %es
|
movw %ax, %es
|
||||||
movw %ax, %fs
|
movw %ax, %fs
|
||||||
movw %ax, %gs
|
movw %ax, %gs
|
||||||
|
movw %bp, %ss
|
||||||
|
movl %edx, %esp
|
||||||
|
|
||||||
/* Return to real-mode address */
|
/* Return to real-mode address */
|
||||||
data32 ret
|
data32 ret
|
||||||
|
@ -398,9 +402,7 @@ prot_call:
|
||||||
.section ".text16"
|
.section ".text16"
|
||||||
.code16
|
.code16
|
||||||
1:
|
1:
|
||||||
/* Reload GDT, restore registers and flags and return. Note
|
/* Reload GDT, restore registers and flags and return */
|
||||||
* that %esp is restored manually, since popal discards it.
|
|
||||||
*/
|
|
||||||
movw %sp, %bp
|
movw %sp, %bp
|
||||||
lgdt (%bp)
|
lgdt (%bp)
|
||||||
addw $12, %sp /* also skip %cs and %ss */
|
addw $12, %sp /* also skip %cs and %ss */
|
||||||
|
@ -409,11 +411,12 @@ prot_call:
|
||||||
popw %fs
|
popw %fs
|
||||||
popw %gs
|
popw %gs
|
||||||
popal
|
popal
|
||||||
addr32 movl -20(%esp), %esp /* -20(%sp) is not a valid 80386
|
/* popal skips %esp. We therefore want to do "movl -20(%sp),
|
||||||
* expression. -20(%esp) is safe
|
* %esp", but -20(%sp) is not a valid 80386 expression.
|
||||||
* because prot_to_real zeroes the
|
* Fortunately, pot_to_real() zeroes the high word of %esp, so
|
||||||
* high word of %esp, and interrupts
|
* we can just use -20(%esp) instead.
|
||||||
* are still disabled at this point. */
|
*/
|
||||||
|
addr32 movl -20(%esp), %esp
|
||||||
popfl
|
popfl
|
||||||
lret
|
lret
|
||||||
|
|
||||||
|
@ -528,8 +531,8 @@ rc_function: .word 0, 0
|
||||||
****************************************************************************
|
****************************************************************************
|
||||||
*/
|
*/
|
||||||
.section ".data"
|
.section ".data"
|
||||||
rm_sp: .word 0
|
rm_sp: .long 0
|
||||||
rm_ss: .word 0
|
rm_ss: .long 0
|
||||||
pm_esp: .long _estack
|
pm_esp: .long _estack
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
Reference in New Issue