Commit graph

80 commits

Author SHA1 Message Date
Jérôme Gardou 3726b992ed [NTOS:KDBG] Begin port for amd64.
Not really functional, but it prints debug output.
Take this as an opportunity to add consistancy between some i386 & amd64 intrinsics
2021-04-28 13:10:23 +02:00
Jérôme Gardou 5e29e98f91 [NTOS:KE] Explicitly use sysretq instruction 2021-04-28 13:10:23 +02:00
Hermès Bélusca-Maïto 3ad573f92f
[NTOS:KE] Both KeFindConfigurationEntry() and KeFindConfigurationNextEntry() functions are exported by NTOSKRNL, so they definitively must NOT be in the discardable INIT section!!
Noticed while reviewing c7d1ff4a.
2021-04-10 00:43:52 +02:00
Jérôme Gardou 0d3825862f [NTOS:KE] Rewrite KiSystemCallTrampoline in assembly
Instead of making assumptions about what the compiler does with forced-inline functions
2021-04-06 17:57:18 +02:00
Jérôme Gardou 187ca32175 [NTOS:KE] Use PNT_TIB as argument in KeSetTebBase 2021-03-24 11:09:20 +01:00
Serge Gautherie e0400e7810 [NTOS:KE] KiIdleLoop(): Propagate DECLSPEC_NORETURN to callers 2021-03-05 00:43:15 +03:00
Serge Gautherie 5f1d79f0c5 [NTOS:KE] KiIdleLoop(): Add DECLSPEC_NORETURN, Remove FASTCALL 2021-03-05 00:43:15 +03:00
Jérôme Gardou 4e4c47cccc [NTOS:KE] Generate proper frame info for trap handler in GCC builds
CORE-8531
2021-03-02 14:37:39 +01:00
Jérôme Gardou 158235bdd5 [NTOS:KE] Fix EIP only when the breakpoint is a break
Fixes ntdll:exception winetest crash
ROSTESTS-80
2021-02-01 16:39:39 +01:00
Hervé Poussineau ae4ce99e00 [ASM x64] Fix usage of macro .allocstack
.allocstack only accepts one 'size' parameter."
2021-01-28 20:31:16 +01: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 e581123c35 [NTOSKRNL] Correctly use SEH2 macros (fixes GCC x64 compilation) 2021-01-05 19:24:23 +01:00
Hervé Poussineau c2946ced92 [NTOS:KD] Remove some now useless tests on _WINKD_ 2020-11-16 08:55:03 +01:00
Victor Perevertkin 5c7ce4475e
[REACTOS] Cleanup INIT and some PAGE section allocations
- Change INIT_FUNCTION and INIT_SECTION to CODE_SEG("INIT") and DATA_SEG("INIT") respectively
- Remove INIT_FUNCTION from function prototypes
- Remove alloc_text pragma calls as they are not needed anymore
2020-11-02 21:45:31 +03:00
Timo Kreuzer bdd4d5d8d8 [NTOS:KE:X64] Set the exception frame as well in KiInitializeContextThread 2020-10-31 14:23:16 +01:00
Timo Kreuzer f66a7e2e48 [NTOS:KE:X64] Zero out the context in KiDispatchException 2020-10-31 14:23:16 +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 2a8c680dbe [NTOS:KE:X64][NTDLL:X64] Implement KiUserExceptionDispatcher and fix KiDispatchExceptionToUser 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 52d1bb5ec9 [NTOS:KE:X64] Simplify KiInitializeUserApc 2020-10-31 14:23:16 +01:00
Timo Kreuzer aaa86d078e [NTOS:KE:X64] Move KiInitializeUserApc to usercall.c 2020-10-31 14:23:16 +01:00
Timo Kreuzer fbdff437fd [NTOS:KE:X64] Implement flushing the GDI batch 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 fe6752f852 [NTOS:KE:X64] Fix bugs in KeContextToTrapFrame and KeTrapFrameToContext
Set valid EFlags, the non-volatiles need to be taken from the exception frame, because the ones from the trap frame might not be set.
2020-10-31 14:23:16 +01:00
Timo Kreuzer eda01e5be7 [NTOS:KE:X64] Fix KiWriteSystemTime 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
Thomas Faber 6b3f309a08
[NTOS] Consistently use MUTANT_INCREMENT.
Spotted by Hermès.
2020-10-16 16:09:54 +02:00
Timo Kreuzer 04f0c7d0d7 [NTOS:KE] Zero out ExceptionFrame member in Syscall handler 2020-09-20 23:08:17 +02:00
Timo Kreuzer 366e8a840c [NTOS:KE] Disable interrupts before lowering IRQL in KiDpcInterruptHandler to avoid stacking up DPC interrupts 2020-09-20 23:08:17 +02: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 2aca4b2795 [ASM] Fix boot with VS 16.7.3 / MSVC 19.27
See https://developercommunity.visualstudio.com/content/problem/1180800/ml-x86-assume-directive-causes-invalid-code-genera.html
2020-09-12 15:01:04 +02:00
Nguyen Trung Khanh 9d2ecd3a13
[NTOS:KE] Fix stack memory disclosure in KiInitializeUserApc (#2988) 2020-07-27 03:39:48 +03:00
Serge Gautherie 3051eb0e48
[NTOSKRNL] Add 'DECLSPEC_NORETURN' to a few 'KeBugCheck*()' (#2896) 2020-06-06 17:50:14 +02:00
Thomas Faber d40ff3ca98
[NTOS:KE] Split KiCheckForSListFault into its own function. CORE-15723
This avoids SEH in a trap handler.
See the following commit for more details.
2020-06-06 08:42:22 +02:00
Serge Gautherie b20f815126
[NTOSKRNL] Place INIT_FUNCTION before the return type (#2823)
(but after 'static' or SAL 2 annotation.)
Follow-up to 71fefa32, which mentions that it's actually required by the compiler in some circumstances.
2020-05-23 15:56:10 +02:00
Stanislav Motylkov cd91271796
[NTOSKRNL][HAL][BOOTVID] Some more code refactoring
- Add boot video color constants
- Refactor palette initialization
- Move some common stuff in right place
- Get rid of some magic constants and hardcoded values
- Get rid of TopDelta variable (calculated at compile time)
- Update SAL annotations

Addendum to 5f2ca473. CORE-16216 CORE-16219
2020-05-12 15:56:37 +03:00
Serge Gautherie 37d5522dfb [NTOS:KE] KiTrap0DHandler(): Fix a copypasta
Addendum to r45038.
2020-04-26 17:32:40 +02:00
Dmitry Borisov 1610367fe2
[BOOTVID][NTOSKRNL][HALX86] Move hardcoded coordinates of bootvid into one place. (#2504)
Co-Authored-By: Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
2020-04-09 15:17:48 +02:00
Hervé Poussineau 76a41370d0 [NTOS:KD] Move dump of stack trace on crash to debugger
Release builds now show again the bugcheck screen, instead of freezing.
2020-03-30 15:23:34 +02:00
Hervé Poussineau fd8cacae4c [NTOS:KE] Remove dead code 2020-03-30 15:23:25 +02:00
Thomas Faber 07de9d1da3
[NTOS:KE] In KiExitV86Mode, restore KTSS::Esp0 to its standard value. CORE-16531
The trap frame is in a random location on the stack, and setting Esp0 there
wastes significant amounts of space and may lead to unexpected stack overflows.

Also use a more descriptive expression for the V86 members of the KTRAP_FRAME.
2020-01-03 11:28:09 +01:00
Timo Kreuzer 7523a7b138 [NTOS:KE] Rename some locking functions to reflect the IRQL level changes
* KiAcquireApcLock -> KiAcquireApcLockRaiseToSynch
* KiAcquireApcLockAtDpcLevel -> KiAcquireApcLockAtSynchLevel
* KiReleaseApcLockFromDpcLevel -> KiReleaseApcLockFromSynchLevel
* KiAcquireApcLockAtApcLevel -> KiAcquireApcLockRaiseToDpc
* KiAcquireProcessLock -> KiAcquireProcessLockRaiseToSynch
* KiReleaseProcessLockFromDpcLevel -> KiReleaseProcessLockFromSynchLevel
* KiAcquireDispatcherLockAtDpcLevel -> KiAcquireDispatcherLockAtSynchLevel
* KiReleaseDispatcherLockFromDpcLevel -> KiReleaseDispatcherLockFromSynchLevel
* Add some ASSERTs
2019-12-31 15:30:27 +01:00
Timo Kreuzer f944f3a6cd [NTOS] In KeWaitFor*Object(s) assert that the current IRQL is SYNCH_LEVEL. not DISPATCH_LEVEL, since acquiring the dispatcher lock raises to SYNCH_LEVEL, which is != DISPATCH_LEVEL on x64 and SMP builds. 2019-12-31 09:43:14 +01:00
Hermès Bélusca-Maïto 03a9ccce65
[NTOS:KE] Explicitly use IOPM_SIZE for initializing the IO map, that is indeed also equal to PAGE_SIZE * 2 but is self-documented. 2019-11-25 00:41:54 +01:00
Hermès Bélusca-Maïto b2ca7d3ed9
[NTOS:KE] Minor formatting fixes. 2019-11-25 00:41:54 +01:00