redo boot around an explicit system volume and fixed kernel/HAL images, redo volumes and filesystem paths around capabilities instead of drive numbers and kernel CWD state, add a capability/security model with derived and revocable handles and security contexts, add port IPC and rssrv to manage the userspace resource namespace and publish the system volume, move process, dll and path loading to userspace and add process builder syscalls, init now supervises rssrv and the session process, redo the syscall ABI around request structs and four arguments, add a volume manager and proper partition arrival/removal handling so FAT and NTFS mount dynamically, clean up the HAL/DDK boundary so drivers don't depend on HAL internals, save fpu state properly now, the serial driver doesn't hang on a missing port, fix AHCI startup races, fix timeout accounting, fix shared mmap writeback, more smoke tests
This commit is contained in:
1 parent
4add6789ba
commit
f882d339fb
232 files changed
+20934
-8898
No files matched your search
+20
-43
@@ -4,8 +4,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <ntlite/ddi/hal_api.h>
|
||||
#include <kernel/hal/hal_apic.h>
|
||||
#include <kernel/hal/hal_api.h>
|
||||
#include <kernel/ke_hal.h>
|
||||
#include <intrin.h>
|
||||
#include <kernel/ke_debug.h>
|
||||
#include <kernel/ke_exception.h>
|
||||
@@ -104,7 +104,7 @@ static volatile long gPanicStoppedCpuCount;
|
||||
// Permanently stops a secondary processor that entered an active panic.
|
||||
static _Noreturn void KiPanicSecondaryHalt(void) {
|
||||
_InterlockedIncrement(&gPanicStoppedCpuCount);
|
||||
HalStopProcessor();
|
||||
KeStopProcessor();
|
||||
}
|
||||
|
||||
// Returns a stable token for the current execution context.
|
||||
@@ -131,7 +131,7 @@ static int KiPanicCurrentCpuOwnsReport(void) {
|
||||
|
||||
// Claims fatal-report ownership and masks interrupts on this processor.
|
||||
static void KiBeginFatalReport(void) {
|
||||
(void)HalDisableInterrupts();
|
||||
(void)KeDisableInterrupts();
|
||||
uintptr_t token = KiPanicCurrentToken();
|
||||
if (_InterlockedCompareExchange((volatile long*)&gPanicInProgress, 1, 0) == 0) {
|
||||
gPanicOwnerToken = token;
|
||||
@@ -243,8 +243,8 @@ static KSTATUS KiDebugLogWriteAll(FILE_OBJECT* file,
|
||||
}
|
||||
|
||||
// Persists the in-memory debug ring and flushes it through the storage stack.
|
||||
__declspec(dllexport) KSTATUS KeFlushDebugLogToFile(SYS_STRING_VIEW path) {
|
||||
if (!gDebugLogBuffer || gDebugLogSize == 0 || !SysSvIsValid(path) || path.Length == 0)
|
||||
KSTATUS KeFlushDebugLogToSystemRoot(const char* relativePath) {
|
||||
if (!gDebugLogBuffer || gDebugLogSize == 0 || !relativePath || !relativePath[0])
|
||||
return NTLSTATUS_INVALID_PARAMETER;
|
||||
if (!KeCanWait())
|
||||
return NTLSTATUS_INVALID_IRQL;
|
||||
@@ -259,10 +259,10 @@ __declspec(dllexport) KSTATUS KeFlushDebugLogToFile(SYS_STRING_VIEW path) {
|
||||
start = (gDebugLogUsed == gDebugLogSize) ? gDebugLogWrite : 0;
|
||||
KeReleaseSpinlock(&gDebugPrintLock, flags);
|
||||
|
||||
(void)IoDeleteFile(path);
|
||||
(void)KeDeleteSystemRootFile(relativePath);
|
||||
|
||||
FILE_OBJECT* file = (FILE_OBJECT*)0;
|
||||
KSTATUS st = IoCreateFile(path, &file);
|
||||
KSTATUS st = KeCreateSystemRootFile(relativePath, &file);
|
||||
if (!KSUCCESS(st)) {
|
||||
_InterlockedExchange((volatile long*)&gDebugLogFlushing, 0);
|
||||
return st;
|
||||
@@ -303,13 +303,9 @@ static void KiTryFlushPanicDebugLog(void) {
|
||||
if (!KeCanWait() || !KeSystemRootReady())
|
||||
return;
|
||||
|
||||
char path[1024];
|
||||
if (!KeBuildSystemRootPath("kernel-panic.log", path, sizeof(path)))
|
||||
return;
|
||||
|
||||
KSTATUS st = KeFlushDebugLogToFile(SysSvFromCstr(path));
|
||||
KSTATUS st = KeFlushDebugLogToSystemRoot("kernel-panic.log");
|
||||
if (!KSUCCESS(st))
|
||||
DbgPrint("debuglog: panic flush to %s failed st=0x%x\n", path, st);
|
||||
DbgPrint("debuglog: panic flush failed st=0x%x\n", st);
|
||||
}
|
||||
|
||||
// Writes one formatted panic record through panic-safe endpoints.
|
||||
@@ -327,7 +323,7 @@ __declspec(dllexport) _Noreturn void KePanic(int code, const char* fmt, ...) {
|
||||
|
||||
// Stop every other CPU before writing the final report. Panic-safe endpoints
|
||||
// do not depend on scheduler locks held by processors stopped by this IPI.
|
||||
HalApicSendPanicIpi();
|
||||
KeBroadcastProcessorNmi();
|
||||
|
||||
static const char banner[] = "\n*** KERNEL PANIC ***\n";
|
||||
KiOutputWrite(HAL_OUTPUT_STREAM_PANIC, HAL_OUTPUT_WRITE_EMERGENCY,
|
||||
@@ -337,9 +333,9 @@ __declspec(dllexport) _Noreturn void KePanic(int code, const char* fmt, ...) {
|
||||
KCPU* cpu = KeGetCurrentCpu();
|
||||
THREAD* thread = KeGetCurrentThread();
|
||||
if (cpu) {
|
||||
KiPanicPrintf("Panic CPU: %u LAPIC=%u",
|
||||
KiPanicPrintf("Panic CPU: %u hardware=%u",
|
||||
(unsigned)cpu->CpuIndex,
|
||||
(unsigned)cpu->LapicId);
|
||||
(unsigned)cpu->HardwareId);
|
||||
if (thread) {
|
||||
KiPanicPrintf(" thread=0x%016llX tid=%llu",
|
||||
thread,
|
||||
@@ -355,7 +351,7 @@ __declspec(dllexport) _Noreturn void KePanic(int code, const char* fmt, ...) {
|
||||
va_end(args);
|
||||
|
||||
KiTryFlushPanicDebugLog();
|
||||
HalStopProcessor();
|
||||
KeStopProcessor();
|
||||
}
|
||||
|
||||
// Writes user-visible console text through subscribed output endpoints.
|
||||
@@ -377,9 +373,9 @@ static void KiFaultPrintf(const char* format, ...) {
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
// Walk the process module list to find which image owns an address.
|
||||
// Returns the module name string, or "unknown" if the address is outside all
|
||||
// known image ranges. Base/size are optional and are useful for offset dumps.
|
||||
// Resolves the main user image or a registered kernel image that owns an address.
|
||||
// User-mode DLL bookkeeping belongs to the user-mode loader and is intentionally
|
||||
// not duplicated in kernel diagnostics.
|
||||
static const char* KiResolveModuleEx(PROCESS* proc, uintptr_t addr,
|
||||
uintptr_t* baseOut, size_t* sizeOut) {
|
||||
if (baseOut) *baseOut = 0;
|
||||
@@ -394,16 +390,6 @@ static const char* KiResolveModuleEx(PROCESS* proc, uintptr_t addr,
|
||||
return proc->Name;
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < proc->ModuleCount; i++) {
|
||||
uintptr_t base = proc->Modules[i].Base;
|
||||
size_t size = proc->Modules[i].Size;
|
||||
if (base && size && addr >= base && addr < base + size) {
|
||||
if (baseOut) *baseOut = base;
|
||||
if (sizeOut) *sizeOut = size;
|
||||
return proc->Modules[i].Name;
|
||||
}
|
||||
}
|
||||
|
||||
uintptr_t kernelBase = 0;
|
||||
size_t kernelSize = 0;
|
||||
const char* kernelModule = LdrFindKernelModuleByAddress(addr, &kernelBase, &kernelSize);
|
||||
@@ -595,15 +581,6 @@ static void KiDumpModules(PROCESS* proc) {
|
||||
(unsigned long long)proc->ImageSize);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < proc->ModuleCount; i++) {
|
||||
uintptr_t base = proc->Modules[i].Base;
|
||||
size_t size = proc->Modules[i].Size;
|
||||
KiFaultPrintf(" %-31s %016llx-%016llx size=%llx\n",
|
||||
proc->Modules[i].Name,
|
||||
(unsigned long long)base,
|
||||
(unsigned long long)(base + size),
|
||||
(unsigned long long)size);
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
@@ -783,9 +760,9 @@ static _Noreturn void KiFinishFaultedProcess(PROCESS* proc, THREAD* thread, KSTA
|
||||
// dead thread to the scheduler with interrupts enabled so waiters such as
|
||||
// the foreground shell can observe the process exit event.
|
||||
while (true) {
|
||||
HalEnableInterrupts();
|
||||
KeEnableInterrupts();
|
||||
KeYield();
|
||||
HalWaitForInterrupt();
|
||||
KeWaitForInterrupt();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -931,5 +908,5 @@ __declspec(dllexport) _Noreturn void KeFaultDispatch(int vector, uintptr_t rip,
|
||||
frame.Rip = rip;
|
||||
frame.Cs = cs;
|
||||
(void)KeFaultDispatchFrame(&frame);
|
||||
HalStopProcessor();
|
||||
KeStopProcessor();
|
||||
}
|
||||
Reference in new issue
Block a user