mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
Fixed the stack switching.
It isn't possible to access memory between changing the stack and setting the cr3 register. A page fault needs a valid kmode stack which is possible not available. svn path=/trunk/; revision=15129
This commit is contained in:
parent
f4ce8b5664
commit
6e529ef561
1 changed files with 13 additions and 12 deletions
|
@ -152,26 +152,27 @@ SaveTrapFrameForKDB_Return:
|
||||||
/* Save the stack pointer in this processors TSS */
|
/* Save the stack pointer in this processors TSS */
|
||||||
mov ebp, [ebx+KPCR_TSS]
|
mov ebp, [ebx+KPCR_TSS]
|
||||||
push ss:[ebp+KTSS_ESP0]
|
push ss:[ebp+KTSS_ESP0]
|
||||||
|
|
||||||
|
/* Check if address space switch is needed */
|
||||||
|
mov eax, [esi+KTHREAD_APCSTATE_PROCESS]
|
||||||
|
cmp eax, [edi+KTHREAD_APCSTATE_PROCESS]
|
||||||
|
mov eax, [eax+KPROCESS_DIRECTORY_TABLE_BASE]
|
||||||
|
|
||||||
/* Switch stacks */
|
/* Switch stacks */
|
||||||
mov [edi+KTHREAD_KERNEL_STACK], esp
|
mov [edi+KTHREAD_KERNEL_STACK], esp
|
||||||
mov esp, [esi+KTHREAD_KERNEL_STACK]
|
mov esp, [esi+KTHREAD_KERNEL_STACK]
|
||||||
|
|
||||||
/*
|
|
||||||
* Sadly, ROS memory management is screwed up, so
|
|
||||||
* we must change the address space here.
|
|
||||||
*/
|
|
||||||
mov eax, [esi+KTHREAD_APCSTATE_PROCESS]
|
|
||||||
mov eax, [eax+KPROCESS_DIRECTORY_TABLE_BASE]
|
|
||||||
mov cr3, eax
|
|
||||||
|
|
||||||
|
jz NoAddressSpaceSwitch
|
||||||
|
|
||||||
|
/* Switch address space */
|
||||||
|
mov cr3, eax
|
||||||
|
|
||||||
|
NoAddressSpaceSwitch:
|
||||||
|
|
||||||
/* Stack is OK, safe to enable interrupts now */
|
/* Stack is OK, safe to enable interrupts now */
|
||||||
sti
|
sti
|
||||||
|
|
||||||
/* Check if address space switch is needed */
|
/* Check if address space switch is needed (the result from above is valid) */
|
||||||
mov eax, [edi+KTHREAD_APCSTATE_PROCESS]
|
|
||||||
cmp eax, [esi+KTHREAD_APCSTATE_PROCESS]
|
|
||||||
|
|
||||||
/* If they match, then use the fast-path and skip all this */
|
/* If they match, then use the fast-path and skip all this */
|
||||||
jz SameProcess
|
jz SameProcess
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue