Commit graph

136 commits

Author SHA1 Message Date
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
Justin Miller 24d124f99f [NTOS] Set SwapBusy properly for i386
Co-authored-by: Hermès BÉLUSCA - MAÏTO <hermes.belusca-maito@reactos.org>
2022-12-28 21:09:41 +01:00
Justin Miller 2a33aed7cf [NTOS] Increment ActiveProcessors accurately 2022-12-28 21:09:41 +01:00
Justin Miller fbd033df0a [NTOS] fix timer lock data and hardcod 2022-12-28 21:09:41 +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 9658c6a220 [NTOSKRNL] Print boot cycles on x64 just like on x86 2022-11-24 21:17:58 +02:00
Timo Kreuzer 225e0c89d9 [NTOS] Fix a bug in KiPrepareUserDebugData 2022-11-24 21:17:58 +02:00
Timo Kreuzer e923912f94 [NTOS] Fix unwinding through KiThreadStartup 2022-11-24 21:17:58 +02:00
Timo Kreuzer a007f5e490 [NTOS] Fix NtContinue for x64 2022-11-24 21:17:58 +02:00
Marcin Jabłoński edb7575faa
[NTOS:KE/x64] Implement KeDisconnectInterrupt() for amd64 (#4883)
Choose the correct element of the KiUnexpectedRange array,
depending on the interrupt vector, the same way as here:
a2c6af0da4/ntoskrnl/ke/amd64/except.c (L77)

And guard KeConnectInterrupt() execution with dispatcher lock.

CORE-14922
2022-11-22 23:52:18 +03: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 39f11249ff [NTOS][RTL] Initialize MxCsr where missing 2022-08-22 11:22:08 +02:00
Timo Kreuzer 786017c5b6 [NTOS] Don't assert, when dispatching an exception to user mode fails
Instead continue with second chance handling.
2022-08-04 16:15:24 +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 e45af60560 [NTOS:KE/X64] Enable interrupts when accessing user mode memory 2022-08-04 16:15:24 +02:00
Timo Kreuzer 902c6eee1e [NTOS:KE] Restore interrupts in KiSwitchKernelStack 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
George Bișoc 064a35dc67
[NTOS:KE] Fully implement FPU Save/Restore mechanism
This commit fully implements the inner logic of KeSaveFloatingPointState and KeRestoreFloatingPointState routines. On ReactOS we're currently simply doing a FNSAVE operation whereas on Windows it is a lot more than that.

On Windows Server 2003 the logic more or less goes like this. In order to save the FPU state the NPX state of the current thread has to be checked first, that is, if NPX is loaded and currently charged for the current thread then the system will acquire the NPX registers actively present. From that point it performs either a FNSAVE or FXSAVE
if FX is actually supported. Otherwise the control word and MXCsr registers are obtained.

FXSAVE/FNSAVE operation is done solely if the FX save area is held up in a pool allocation. Pool allocation occurs if it's been found out that the NPX IRQL of the thread is not the same as the current thread which from where it determines if the interrupt level is APC then allocate some pool memory and hold the save area there, otherwise
the save area in question is grabbed from the current processor control region. If NPX is not loaded for the current thread then the FPU state is obtained from the NPX frame.

In our case we'll be doing something way simpler. Only do a FXSAVE/FNSAVE directly of the FPU state registers, in this way we are simplifying the code and the actual logic of Save/Restore mechanism.
2022-05-24 18:39:45 +02:00
Marcus Boillat fa52f2fae0
[NTOS:KE] Fix CPU extended family and model detection
Based on documentation from Geoff Chappell:
https://www.geoffchappell.com/studies/windows/km/cpu/cpuid/00000001h/eax.htm

CORE-17974
2022-05-09 21:50:24 +03:00
Marcus Boillat 00b3e4bc68
[NTOS:KE] Use bitfield structure for x86 CPU signature in EAX register
This makes code a lot more readable. CORE-17974
2022-05-09 21:50:24 +03:00
Stanislav Motylkov cc82bc14e2
[NTOS:KE] Move KiGet/SetProcessorType function below KiGetCpuVendor
CORE-17974
2022-05-09 21:50:19 +03:00
Hermès Bélusca-Maïto 9ea2b803c8
[NDK][HAL][NTOS] Add missing PRCB_MINOR_VERSION / PRCB_MAJOR_VERSION and use them. 2022-05-07 18:14:38 +02:00
Victor Perevertkin 99a6667bd9
[NTOS:KE] Remove all checks for x87 not being present 2022-01-25 02:12:33 +03:00
Victor Perevertkin 1aca6937ff
[NTOS:KE] Add a check for unsupported CPU features on i586
Currently, these features are vital for the kernel:
- CPUID instruction
- CMPXCHG8B instruction
- TSC aka Time Stamp Counter

All of that have to be present on i586
2022-01-25 02:12:33 +03:00
Victor Perevertkin 705e07ce31
[NTOS:KE] Move CPU features detection to a separate function on i586 2022-01-25 02:12:26 +03:00
Stanislav Motylkov 84cc81ee29
[NTOS:KE/x64] Detect CPU vendor properly and store value in PRCB
Also generate processor identifier properly based on this value
on the Configuration Manager machine-dependent initialization.

Update processor driver INF file accordingly.

CORE-17970 CORE-14922
2022-01-05 18:28:40 +03:00
Thomas Faber a4b2c80853
[NTOS:KE] Fix buffer overflow when displaying x64 bug checks 2022-01-03 13:25:09 -05:00
George Bișoc 3bc2d590a1
[NTOSKRNL] Regroup the pool allocation tags in one dedicated place
We have a special file, tag.h, which serves as a place to store whatever kernel pool allocation tag yet we still have some tags sparse over the kernel code... So just re-group them in one unique place.
2021-12-27 18:57:03 +01:00
Serge Gautherie 94b8095ba2 [NTOS:KE] KiTrap0EHandler(): Use MI_IS_WRITE_ACCESS() 2021-11-04 23:20:21 +03:00
Rafał Mikrut 54d5ad7533
[NTOS:KE] Fix copy paste bug in exception helper routine for ARM (#4005) 2021-10-07 23:04:19 +03:00
Hermès Bélusca-Maïto 6e9ff14e26
[NTOS:KD64,KE] IRQL is automatically adjusted during calls to KdEnterDebugger() and KdExitDebugger(). (#3942)
Addendum to 608032bd and 835c3023.

The IRQL is actually raised by KeFreezeExecution() and lowered by
KeThawExecution(), always to HIGH_IRQL on MP systems, or if necessary
on UP. These functions are called respectively by KdEnterDebugger()
and KdExitDebugger().
2021-09-12 18:20:32 +02:00
Victor Perevertkin 6ef6fabfc5
[FREELDR][NTOS][HALPPC][SDK] Remove PowerPC code
Remove PowerPC-related code from the kernel, HAL, SDK and
Freeloader.
2021-08-15 15:35:51 +03:00
James Tabor a81ad376a1 Check for PAE
Checking for PAE and set some logic later to support it.
2021-08-08 20:37:06 -05:00
Jérôme Gardou 42bec35f65 [NTOS:KE] Also rewrite KeZeroPages in assembly for amd64
Let's stick with "rep movsq" until we are able to have more precise benchmarks
2021-08-04 17:48:39 +02:00
Jérôme Gardou 51258295bd [NTOS:KE] Rewrite KeZeroPages in assembly
We spend a lot of time in this function, let's optimize it.
2021-08-04 17:48:39 +02:00
Timo Kreuzer a3763c61dc [PSDK][NDK] Use hex to define MIN/MAX constants like in native SDK
This fixes use of unary minus operator on unsigned type warning.
2021-07-23 22:03:48 +02:00
Jérôme Gardou 37d0a9c3f4 [NTOS:KE] Unconditionally check IRQL when acquiring & releasing spinlock at DISPATCH_LEVEL 2021-06-29 11:49:20 +02:00
Jérôme Gardou f30136bc79 [NTOS:KE] Test spinlock ownership on both UP & MP build
There is no reason not to, and this avoids introducing bugs stupidly.
2021-06-29 11:49:20 +02:00
Jérôme Gardou e312a40ae2 [NTOS:KE] Implement KeAcquireInStackQueuedSpinLockForDpc & KeReleaseInStackQueuedSpinLockForDpc 2021-06-29 11:49:20 +02:00
Jérôme Gardou c6e9fea844 [NTOSKRNL] Deduplicate some symbols 2021-06-24 18:48:31 +02:00
Jérôme Gardou 41de1bd724 [NTOS:KE] Do not allow waiting at IRQL >= DISPATCH_LEVEL when providing a timeout in KeWaitForMultipleObjects
CORE-6473
2021-06-21 11:42:01 +02:00
Timo Kreuzer f4d47faeb7 [NTOS:KE] Fix usage of KTHREAD::SwapBusy 2021-06-19 12:17:18 +02:00
Timo Kreuzer a011d19ed2 [NTOS:KE] Fix some locking issues 2021-06-19 12:17:18 +02:00
Timo Kreuzer 2ed56fa794 [NTOS] Fix build with CONFIG_SMP 2021-06-19 12:17:18 +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