[NTOS] Add MxCsr handling to trap handlers

This commit is contained in:
Timo Kreuzer 2022-07-23 13:31:48 +02:00
parent 92c798c657
commit 620f9ee71a
3 changed files with 17 additions and 1 deletions

View file

@ -822,6 +822,10 @@ PUBLIC KiSystemCallEntry64
mov ds, ax
mov es, ax
/* Save MCXSR and set kernel value */
stmxcsr [rsp + MAX_SYSCALL_PARAM_SIZE + KTRAP_FRAME_MxCsr]
ldmxcsr gs:[PcMxCsr]
#if DBG
/* Check IRQL */
mov rax, cr8
@ -861,6 +865,9 @@ no_user_apc_pending:
/* Disable interrupts for return */
cli
/* Restore MCXSR */
ldmxcsr [rsp + MAX_SYSCALL_PARAM_SIZE + KTRAP_FRAME_MxCsr]
/* Restore old trap frame */
mov rcx, gs:[PcCurrentThread]
mov rdx, [rsp + MAX_SYSCALL_PARAM_SIZE + KTRAP_FRAME_TrapFrame]

View file

@ -586,7 +586,7 @@ OFFSET(PcIrql, KPCR, Irql),
OFFSET(PcStallScaleFactor, KPCR, StallScaleFactor),
OFFSET(PcHalReserved, KPCR, HalReserved),
//OFFSET(PcPrcb, KPCR, Prcb),
//OFFSET(PcMxCsr, KPCR, MxCsr),
OFFSET(PcMxCsr, KIPCR, Prcb.MxCsr),
//OFFSET(PcNumber, KPCR, Number),
//OFFSET(PcInterruptRequest, KPCR, InterruptRequest),
//OFFSET(PcIdleHalt, KPCR, IdleHalt),

View file

@ -97,6 +97,9 @@ MACRO(EnterTrap, Flags)
mov [rbp + KTRAP_FRAME_SegGs], gs
endif
/* Save MCXSR */
stmxcsr [rbp + KTRAP_FRAME_MxCsr]
#if DBG
mov ecx, MSR_GS_BASE
rdmsr
@ -116,6 +119,9 @@ MACRO(EnterTrap, Flags)
mov es, ax
swapgs
/* Load kernel MXCSR */
ldmxcsr gs:[PcMxCsr]
#if DBG
/* Check IRQL */
mov rax, cr8
@ -255,6 +261,9 @@ kernel_mode_return:
movdqa xmm5, [rbp + KTRAP_FRAME_Xmm5]
endif
/* Restore MCXSR */
ldmxcsr [rbp + KTRAP_FRAME_MxCsr]
/* Restore rbp */
mov rbp, [rbp + KTRAP_FRAME_Rbp]