Cxbx-Reloaded / xbox_kernel_test_suite

Xbox kernel APIs tester written using nxdk
GNU General Public License v3.0
22 stars 6 forks source link

Incompatibilty when running in Cxbx-R #60

Closed ergo720 closed 5 years ago

ergo720 commented 5 years ago

When running the test suite in Cxbx-R, the application freezes and never produces any test log results. Looking at the kernel log generated by Cxbx-R, this happens because it hits an unhandled HLT instruction which is spammed forever, like shown below.

[0x237C] VMEM    AllocateZeroed returns 0x0B93B000
[0x237C] KE      KeInitializeTimer forwarding to "KeInitializeTimerEx"...
[0x237C] KE      KeInitializeTimerEx(
   Timer                : 0B93B088
   Type                 : (TIMER_TYPE)0x00000000 = NotificationTimer
);
[0x237C] FS      Installed KPCR in TIB_ArbitraryDataSlot (with pTLS = 0x00015674)
[0x18D0] PS      Xbox proxy thread is started.
[0x18D0] PS      Created Xbox proxy thread. Handle : 0x428, ThreadId : [0x237C]
[0x237C] KE      KeGetCurrentThread();
[0x237C] KE      KeGetCurrentThread returns 0B93B000
[0x237C] KE      KeGetCurrentThread();
[0x237C] KE      KeGetCurrentThread returns 0B93B000
[0x237C] DEBUG: X86     Starting instruction emulation from 0x00037C87
[0x237C] DEBUG: X86     Disassembly : 00037C87 FA                   CLI         // Privileged ring 0 instruction
[0x237C] DEBUG: X86     Starting instruction emulation from 0x00037C88
[0x237C] DEBUG: X86     Disassembly : 00037C88 F4                   HLT         // Privileged ring 0 instruction
[0x237C] DEBUG: X86     Unhandled instruction : HLT (482)
[0x237C] DEBUG: X86     Starting instruction emulation from 0x00037C88
[0x237C] DEBUG: X86     Disassembly : 00037C88 F4                   HLT        
[0x237C] DEBUG: X86     Unhandled instruction : HLT (482)
[0x237C] DEBUG: X86     Starting instruction emulation from 0x00037C88
[0x237C] DEBUG: X86     Disassembly : 00037C88 F4                   HLT        
[0x237C] DEBUG: X86     Unhandled instruction : HLT (482)

The HLT instruction comes from this assertion here https://github.com/XboxDev/nxdk-pdclib/blob/1040a66ded634793a29a2ee80385d524c29ab05f/platform/xbox/functions/threads/thrd_create.c#L47. Commenting it out or building with –DNDEBUG “fixes” the problem and allows the test suite to work correctly, but it’s just a workaround. The real solution is to fix this properly in Cxbx-R.

Luca1991 commented 5 years ago

I think that this issue should be opened in CxBx-R repository to get better visibility

ergo720 commented 5 years ago

I submitted a fix to Cxbx-R and tested with https://github.com/Cxbx-Reloaded/Cxbx-Reloaded/commit/e37de96ed2aec1450df6c6b5eaf533628364ae4e and I can confirm that it does indeed solve this problem. Closing.