nullplan wrote:
You told us neither the code after the divide error nor the callback is executed, so what does happen instead?
RIP is exactly 1519 bytes after my exception handler. This is Qemu's output:
Qemu wrote:
check_exception old: 0xffffffff new 0x0
327: v=00 e=0000 i=0 cpl=0 IP=0038:0000000006b469c7 pc=0000000006b469c7 SP=0030:0000000007f0eaa0 env->regs[R_EAX]=000000000000002a
RAX=000000000000002a RBX=0000000007333f98 RCX=0000000006b52004 RDX=0000000000000000
RSI=0000000000000009 RDI=0000000007336018 RBP=0000000007f0eb20 RSP=0000000007f0eaa0
R8 =000000000000023e R9 =000000000000001b R10=0000000007e72080 R11=00000000ffbf826d
R12=0000000007337640 R13=0000000007337648 R14=0000000007f24b60 R15=0000000007336018
RIP=0000000006b469c7 RFL=00000006 [-----P-] CPL=0 II=0 A20=1 SMM=0 HLT=0
exceptionDiv() is at 0x6b463cf.
I did change my code a little bit, no change though.
Code:
VOID EFIAPI exceptionDiv (IN EFI_EXCEPTION_TYPE InterruptType, IN EFI_SYSTEM_CONTEXT SystemContext) {
printf("Exception!\n");
while (1==1);
return;
}
EFI_DEBUG_SUPPORT_PROTOCOL *dsp;
EFI_GUID dspGUID = EFI_DEBUG_SUPPORT_PROTOCOL_GUID;
ST->BootServices->LocateProtocol(&dspGUID, NULL, (void**) &dsp);
dsp->Isa = IsaX64; // Setting the instruction set to x64
dsp->RegisterExceptionCallback(dsp, 0, NULL, EXCEPT_EBC_DIVIDE_ERROR); // Unregister old callback
dsp->RegisterExceptionCallback(dsp, 0, exceptionDiv, EXCEPT_EBC_DIVIDE_ERROR); // Register new callback
dsp->RegisterExceptionCallback(dsp, 0, NULL, EXCEPT_X64_DIVIDE_ERROR);
dsp->RegisterExceptionCallback(dsp, 0, exceptionDiv, EXCEPT_X64_DIVIDE_ERROR);
dsp->RegisterExceptionCallback(dsp, 0, NULL, EXCEPT_IA32_DIVIDE_ERROR);
dsp->RegisterExceptionCallback(dsp, 0, exceptionDiv, EXCEPT_IA32_DIVIDE_ERROR);
RegisterExeptionCallback() returns "EFI_SUCCESS" in all cases.