I use the local APIC as the high precise timer to trigger Interrupt periodically to do something (for now, I just print "Hello World").
The problem is: The interrupt can be periodically triggered and can print "Hello World" normally with low CPU usage . But if the CPU usage is high (running AIDA64 CPU test), the PC will automatically reboot, and WinDbg on my host has no error information or dump files.
And I try to solve this problem by giving APIC long period, it doesn't work.
My OS is Windows 7 x64, I modified this code from Windows 7 default APC ISR.
Thank you guys.
This is my ISR code:
Code: Select all
#pragma LOCKEDCODE
void Dispatch()
{
DbgPrint("Hello World\n");
//InitScheduler();
return;
}
#pragma LOCKEDCODE
__declspec (naked) interrupt()
{
_asm
{
sub rsp, 8
push rbp
sub rsp, 158h
lea rbp, [rsp + 80h]
mov byte ptr[rbp - 55h], 0
mov qword ptr[rbp - 50h], rax
mov qword ptr[rbp - 48h], rcx
mov qword ptr[rbp - 40h], rdx
mov qword ptr[rbp - 38h], r8
mov qword ptr[rbp - 30h], r9
mov qword ptr[rbp - 28h], r10
mov qword ptr[rbp - 20h], r11
cld
stmxcsr dword ptr[rbp - 54h]
ldmxcsr dword ptr gs : [180h]
movaps xmmword ptr[rbp - 10h], xmm0
movaps xmmword ptr[rbp], xmm1
movaps xmmword ptr[rbp + 10h], xmm2
movaps xmmword ptr[rbp + 20h], xmm3
movaps xmmword ptr[rbp + 30h], xmm4
movaps xmmword ptr[rbp + 40h], xmm5
inc dword ptr gs : [4880h]
mov ecx, 0eh
mov rax, cr8
mov cr8, rcx
mov byte ptr[rbp - 57h], al
push rcx
mov rcx, qword ptr[pHalPerformEndOfInterrupt]
call qword ptr[rcx]
sti
call Dispatch
cli
movzx ecx, byte ptr[rbp - 57h]
mov cr8, rcx
ldmxcsr dword ptr[rbp - 54h]
movaps xmm0, xmmword ptr[rbp - 10h]
movaps xmm1, xmmword ptr[rbp]
movaps xmm2, xmmword ptr[rbp + 10h]
movaps xmm3, xmmword ptr[rbp + 20h]
movaps xmm4, xmmword ptr[rbp + 30h]
movaps xmm5, xmmword ptr[rbp + 40h]
mov r11, qword ptr[rbp - 20h]
mov r10, qword ptr[rbp - 28h]
mov r9, qword ptr[rbp - 30h]
mov r8, qword ptr[rbp - 38h]
mov rdx, qword ptr[rbp - 40h]
mov rcx, qword ptr[rbp - 48h]
mov rax, qword ptr[rbp - 50h]
mov rsp, rbp
mov rbp, qword ptr [rbp + 0d8h]
add rsp, 0e8h
iretq
}
}