mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
[NTOS:KE/x64] Clean up EnterTrap/ExitTrap
- Always save and restore all non-volatile registers, including xmm - Remove the obsolete flags
This commit is contained in:
parent
05456808e8
commit
8d459f2820
2 changed files with 35 additions and 47 deletions
|
@ -15,9 +15,9 @@
|
|||
#include <trapamd64.inc>
|
||||
.code
|
||||
|
||||
TRAP_ENTRY HalpClockInterrupt, (TF_VOLATILES OR TF_SEND_EOI)
|
||||
TRAP_ENTRY HalpClockIpi, (TF_VOLATILES OR TF_SEND_EOI)
|
||||
TRAP_ENTRY HalpProfileInterrupt, (TF_VOLATILES OR TF_SEND_EOI)
|
||||
TRAP_ENTRY HalpClockInterrupt, TF_SEND_EOI
|
||||
TRAP_ENTRY HalpClockIpi, TF_SEND_EOI
|
||||
TRAP_ENTRY HalpProfileInterrupt, TF_SEND_EOI
|
||||
|
||||
PUBLIC ApicSpuriousService
|
||||
ApicSpuriousService:
|
||||
|
|
|
@ -52,13 +52,10 @@ ENDM
|
|||
|
||||
APIC_EOI = HEX(0FFFFFFFFFFFE00B0)
|
||||
|
||||
TF_VOLATILES = HEX(01)
|
||||
TF_NONVOLATILES = HEX(02)
|
||||
TF_XMM = HEX(04)
|
||||
TF_SEGMENTS = HEX(08)
|
||||
TF_DEBUG = HEX(10)
|
||||
TF_IRQL = HEX(20)
|
||||
TF_SAVE_ALL = (TF_VOLATILES OR TF_NONVOLATILES OR TF_XMM OR TF_SEGMENTS)
|
||||
TF_SAVE_ALL = (TF_SEGMENTS)
|
||||
TF_HAS_ERROR_CODE = HEX(40)
|
||||
TF_SEND_EOI = HEX(80)
|
||||
//TF_SYSTEMSERVICE = (TRAPFLAG_VOLATILES or TRAPFLAG_DEBUG)
|
||||
|
@ -98,11 +95,9 @@ MACRO(EnterTrap, Flags)
|
|||
sub rsp, (KTRAP_FRAME_LENGTH - SIZE_INITIAL_FRAME)
|
||||
.allocstack (KTRAP_FRAME_LENGTH - SIZE_INITIAL_FRAME)
|
||||
|
||||
/* Save rbp and rax */
|
||||
/* Save rbp */
|
||||
mov [rsp + KTRAP_FRAME_Rbp], rbp
|
||||
.savereg rbp, KTRAP_FRAME_Rbp
|
||||
mov [rsp + KTRAP_FRAME_Rax], rax
|
||||
.savereg rax, KTRAP_FRAME_Rax
|
||||
|
||||
/* Point rbp to the KTRAP_FRAME */
|
||||
lea rbp, [rsp]
|
||||
|
@ -110,25 +105,22 @@ MACRO(EnterTrap, Flags)
|
|||
|
||||
.endprolog
|
||||
|
||||
if (Flags AND TF_VOLATILES)
|
||||
/* Save volatile registers */
|
||||
mov [rbp + KTRAP_FRAME_Rax], rax
|
||||
mov [rbp + KTRAP_FRAME_Rcx], rcx
|
||||
mov [rbp + KTRAP_FRAME_Rdx], rdx
|
||||
mov [rbp + KTRAP_FRAME_R8], r8
|
||||
mov [rbp + KTRAP_FRAME_R9], r9
|
||||
mov [rbp + KTRAP_FRAME_R10], r10
|
||||
mov [rbp + KTRAP_FRAME_R11], r11
|
||||
endif
|
||||
|
||||
if (Flags AND TF_XMM)
|
||||
/* Save xmm registers */
|
||||
/* Save volatile xmm registers */
|
||||
movdqa [rbp + KTRAP_FRAME_Xmm0], xmm0
|
||||
movdqa [rbp + KTRAP_FRAME_Xmm1], xmm1
|
||||
movdqa [rbp + KTRAP_FRAME_Xmm2], xmm2
|
||||
movdqa [rbp + KTRAP_FRAME_Xmm3], xmm3
|
||||
movdqa [rbp + KTRAP_FRAME_Xmm4], xmm4
|
||||
movdqa [rbp + KTRAP_FRAME_Xmm5], xmm5
|
||||
endif
|
||||
|
||||
if (Flags AND TF_SEGMENTS)
|
||||
/* Save segment selectors */
|
||||
|
@ -233,7 +225,6 @@ MACRO(ExitTrap, Flags)
|
|||
|
||||
kernel_mode_return:
|
||||
|
||||
if (Flags AND TF_VOLATILES)
|
||||
/* Restore volatile registers */
|
||||
mov rax, [rbp + KTRAP_FRAME_Rax]
|
||||
mov rcx, [rbp + KTRAP_FRAME_Rcx]
|
||||
|
@ -242,9 +233,7 @@ kernel_mode_return:
|
|||
mov r9, [rbp + KTRAP_FRAME_R9]
|
||||
mov r10, [rbp + KTRAP_FRAME_R10]
|
||||
mov r11, [rbp + KTRAP_FRAME_R11]
|
||||
endif
|
||||
|
||||
if (Flags AND TF_XMM)
|
||||
/* Restore xmm registers */
|
||||
movdqa xmm0, [rbp + KTRAP_FRAME_Xmm0]
|
||||
movdqa xmm1, [rbp + KTRAP_FRAME_Xmm1]
|
||||
|
@ -252,7 +241,6 @@ kernel_mode_return:
|
|||
movdqa xmm3, [rbp + KTRAP_FRAME_Xmm3]
|
||||
movdqa xmm4, [rbp + KTRAP_FRAME_Xmm4]
|
||||
movdqa xmm5, [rbp + KTRAP_FRAME_Xmm5]
|
||||
endif
|
||||
|
||||
/* Restore MCXSR */
|
||||
ldmxcsr [rbp + KTRAP_FRAME_MxCsr]
|
||||
|
|
Loading…
Reference in a new issue