Commit graph

35 commits

Author SHA1 Message Date
Timo Kreuzer 2ed8541dc8 [NTOS:KE/x64] Remove duplicated REX prefix from sysretq 2024-03-28 21:37:25 +01:00
Timo Kreuzer 36fa628605 [NTOS:KE/x64] Loop in KiInitiateUserApc
This is required since while interrupts are enabled, another user APC could get queued and we want to guarantee that those are all delivered before returning to user mode.
2024-03-27 22:11:07 +01:00
Timo Kreuzer 26a64324e7 [NTOSKRNL/x64] Fix a bug in KeSwitchKernelStack
Don't safe anything in the callee's home space, because the callee can overwrite it. Use the functions home space instead.
2023-09-17 10:37:50 +03:00
Timo Kreuzer 15fbcc19b9 [NTOS:KE/x64] Fix KiConvertToGuiThread
- Do not allocate a new stack, if the thread already has a large one. This prevents the function from freeing a large stack as a normal stack and subsequently leaking system PTEs.
- Fix the check for failure of PsConvertToGuiThread (test eax, not rax, for being negative, because by default rax is zero extended from eax, not sign extended). This fixes an infinite loop on failure.
2023-05-16 22:03:13 +03:00
Timo Kreuzer 12ed9f30a7 [NTOS] Fix interrupt flag handling in KiPageFault
This fixes a crash in kmtest:ZwAllocateVirtualMemory
2023-01-04 10:32:28 +01:00
Timo Kreuzer 5b6e7eceda [NTOS] Fix KiGeneralProtectionFault 2023-01-04 10:32:28 +01:00
Timo Kreuzer 2e3fe5de90 [NTOS] Fix saving of XMM registers on some trap handlers 2022-12-13 07:18:24 +01:00
Timo Kreuzer e923912f94 [NTOS] Fix unwinding through KiThreadStartup 2022-11-24 21:17:58 +02:00
Timo Kreuzer 620f9ee71a [NTOS] Add MxCsr handling to trap handlers 2022-08-22 11:22:08 +02:00
Timo Kreuzer 92c798c657 [NTOSKRNL] Implement KiXmmExceptionHandler 2022-08-22 11:22:08 +02:00
Timo Kreuzer b3a8f8611d [NTOS] Treat page faults with interrupts disabled as access violation 2022-08-04 16:15:24 +02:00
Timo Kreuzer ae39ad4d10 [NTOS] Add a hack for VBox 2022-08-04 16:15:24 +02:00
Timo Kreuzer 45f75d5d32 [NTOS:KE/x64] Handle user faults in KiGeneralProtectionFaultHandler 2022-07-14 18:35:28 +02:00
Victor Perevertkin 34593d933b
[FORMATTING][NTOS][HAL][DRIVERS][SDK] Fix trailing spaces 2021-06-11 15:33:08 +03:00
Timo Kreuzer 7f2e0ece5a [NTOS:KE/x64] Handle shared interrupts 2021-06-04 09:19:13 +02:00
Timo Kreuzer f1ed97d6cc [NTOS:KE/x64] Implement KiSetTrapContext
KiSetTrapContext is an asm wrapper around RtlSetUnwindContext, which first stores an exception frame to assure that all non-volatile registers were put on the stack, then calls RtlSetUnwindContext to update their first saving positions on the stack and finally restore the exception frame to potentially load any updated registers, that haven't been saved elsewhere on the stack.
2021-06-02 18:25:36 +02:00
Timo Kreuzer 90a0e426ed [NTOS:KE] Add IRQL checks and fix KiInitiateUserApc 2021-05-28 11:52:42 +02:00
Timo Kreuzer 3d18831c19 [NTOS:KE] Improve KiSystemCallEntry64 2021-05-28 11:52:42 +02:00
Timo Kreuzer 69e8cb635a [NTOS:KE] Fix stack alignment issues 2021-05-28 11:52:42 +02:00
Jérôme Gardou 5e29e98f91 [NTOS:KE] Explicitly use sysretq instruction 2021-04-28 13:10:23 +02:00
Hervé Poussineau ff7035d940 [ASM x64] Change ; by /* */ for comments
Syntax with semi-colon is not supported by gas.
2021-01-07 21:12:11 +01:00
Hervé Poussineau c2946ced92 [NTOS:KD] Remove some now useless tests on _WINKD_ 2020-11-16 08:55:03 +01:00
Timo Kreuzer 637183a12c [NTOS:KE:X64] Handle pending user APC on syscall exit (should be done on trap exit, too) 2020-10-31 14:23:16 +01:00
Timo Kreuzer 1bfacf06f7 [NTOS:KE:X64] Zero out volatiles when returning from a system call 2020-10-31 14:23:16 +01:00
Timo Kreuzer a016ccd117 [NTOS:KE:X64][ASM:X64] Fix delivery of APCs
- Deliver pending APCs on trap exit
- Pass the trapframe of KiApcInterrupt to KiDeliverApcs, not NULL.
- Fix parameter passing from KiSwapContext to KiSwapContextInternal and KiSwapContextResume, so that the ApcBypass parameter is not uninitialized
- Fix return value of KiSwapContextResume to correctly indicate whether we want to have APCs directly delivered or not (when there are non, or when delivery is suppressed)
2020-10-31 14:23:16 +01:00
Timo Kreuzer fdc1261fb7 [NTOS:KE:X64][NTDLL:X64] Implement x64 version of user callback code 2020-10-31 14:23:16 +01:00
Timo Kreuzer c86c55ace7 [NTOS:KE:X64] Change the logic of KeSwitchKernelStack and friends to be standards conforming
The previous version (like the x86 one) used a combination of C and asm code, called from C code to switch the stack. This is problematic, since there is no guarantee what assumptions C code makes about the stack (i.e. it can place any kind of stack pointers into registers or on the stack itself.) The new algorithm returns back to the systemcall entry point in asm, which then calls KiConvertToGuiThread, which is also asm and calls KeSwitchKernelStack ...
2020-10-31 14:23:16 +01:00
Timo Kreuzer 18b1aafd82 [NTOS:KE:X64] Improve kernel stack switching on GUI system calls
To be 100% correct and not rely on assumptions, stack switching can only be done when all previous code - starting with the syscall entry point - is pure asm code, since we can't rely on the C compiler to not use stack addresses in a way that is not transparent. Therefore the new code uses the same mechanism as for normal system calls, returning the address of the asm function KiConvertToGuiThread, which is then called like an Nt* function would be called normally. KiConvertToGuiThread then allocated a new stack, switches to it (which is now fine, since all the code is asm), frees the old stack, calls PsConvertToGuiThread (which now will not try to allocate another stack, since we already have one) and then jumps into the middle of KiSystemCallEntry64, where the system call is handled again.
Also simplify KiSystemCallEntry64 a bit by copying the first parameters into the trap frame, avoiding to allocate additional stack space for the call to KiSystemCallHandler, which now overlaps with the space that is allocated for the Nt* function.
Finally fix the locations where r10 and r11 are stored, which is TrapFrame->Rcx and TrapFrame->EFlags, based on the situation in user mode.
2020-10-31 14:23:16 +01:00
Timo Kreuzer a6732905b8 [NTOS:KE:X64] Implement KiConvertToGuiThread, KeSwitchKernelStack and support for win32k syscalls in KiSystemCallHandler 2020-10-31 14:23:16 +01:00
Timo Kreuzer 8ec888487a [ASM:X64] ASSERT that interrupts are enabled, when returning to user mode 2020-10-31 14:23:16 +01:00
Timo Kreuzer 3aaee35629 [NTOS:KE] Save and restore previous mode in KiZwSystemService and fix restoring the trap frame 2020-09-20 23:08:17 +02:00
Timo Kreuzer b2a483b9ea [NTOS:KE] Don't use FrLdrDbgPrint anymore. It served us well, but now it's time to go away. 2020-09-20 23:08:17 +02:00
Timo Kreuzer 3021c2d571 [NTOS:MM] Pass page fault code to MmAccessFault
Note: before we had a BOOLEAN parameter called StoreInstruction, but in reality it was not specifying whether the fault was from a store store instruction, but whether it was an access violation rather than a page-not-present fault. On x86 without PAE there are only 2 kinds of access violations: (1) Access of a kernel mode page from user mode, which is handled early and (2) access of a read-only (or COW) page with a writing instruction. Therefore we could get away with this, even though it relied on the wrong assumption that a fault, which was not a page-not-present-fault, was automatically a write access. This commit only changes one thing: we pass the full fault-code to MmAccessFault and handle the rest from there in exactly the same way as before. More changes are coming to make things clear.
2018-01-06 18:20:24 +01:00
Timo Kreuzer c4d6c2c3f1 [NTOS:KE] Fix pushing of fake error code in KiDoubleFaultAbort (amd64) 2018-01-01 12:09:38 +01:00
Colin Finck c2c66aff7d Git conversion: Make reactos the root directory, move rosapps, rostests, wallpapers into modules, and delete rossubsys. 2017-10-03 07:45:34 +00:00
Renamed from reactos/ntoskrnl/ke/amd64/trap.S (Browse further)