mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-28 15:34:33 +00:00
Added implementation of critical thread/process
This commit is contained in:
parent
954223cbf5
commit
3d947c2a03
@ -117,8 +117,13 @@ namespace CrashHandler
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
debug("Exception in user mode");
|
debug("Exception in user mode");
|
||||||
UserModeExceptionHandler(Frame);
|
if (!GetCurrentCPU()->CurrentThread->Security.IsCritical)
|
||||||
return;
|
{
|
||||||
|
UserModeExceptionHandler(Frame);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
EHPrint("\eFF0000Init process crashed!");
|
||||||
}
|
}
|
||||||
|
|
||||||
debug("Reading control registers...");
|
debug("Reading control registers...");
|
||||||
|
@ -81,6 +81,7 @@ void KernelMainThread()
|
|||||||
|
|
||||||
// TODO: Untested!
|
// TODO: Untested!
|
||||||
Execute::SpawnData ret = Execute::Spawn(Config.InitPath, argc, (uint64_t)argv.data());
|
Execute::SpawnData ret = Execute::Spawn(Config.InitPath, argc, (uint64_t)argv.data());
|
||||||
|
ret.Thread->SetCritical(true);
|
||||||
if (ret.Status != Execute::ExStatus::OK)
|
if (ret.Status != Execute::ExStatus::OK)
|
||||||
{
|
{
|
||||||
KPrint("\eE85230Failed to start %s! Code: %d", Config.InitPath, ret);
|
KPrint("\eE85230Failed to start %s! Code: %d", Config.InitPath, ret);
|
||||||
|
@ -624,12 +624,12 @@ namespace Tasking
|
|||||||
Thread->Registers.rsp = ((uint64_t)Thread->Stack + STACK_SIZE);
|
Thread->Registers.rsp = ((uint64_t)Thread->Stack + STACK_SIZE);
|
||||||
/* We need to leave the libc's crt to make a syscall when the Thread is exited or we are going to get GPF or PF exception. */
|
/* We need to leave the libc's crt to make a syscall when the Thread is exited or we are going to get GPF or PF exception. */
|
||||||
for (uint64_t i = 0; i < TO_PAGES(STACK_SIZE); i++)
|
for (uint64_t i = 0; i < TO_PAGES(STACK_SIZE); i++)
|
||||||
Memory::Virtual(Parent->PageTable).Map((void *)((uint64_t)Thread->Stack + (i * PAGE_SIZE)), (void *)((uint64_t)Thread->Stack + (i * PAGE_SIZE)), Memory::PTFlag::US);
|
Memory::Virtual(Parent->PageTable).Map((void *)((uint64_t)Thread->Stack + (i * PAGE_SIZE)), (void *)((uint64_t)Thread->Stack + (i * PAGE_SIZE)), Memory::PTFlag::RW | Memory::PTFlag::US);
|
||||||
|
|
||||||
if (!Memory::Virtual(Parent->PageTable).Check((void *)Offset, Memory::PTFlag::US))
|
if (!Memory::Virtual(Parent->PageTable).Check((void *)Offset, Memory::PTFlag::US))
|
||||||
{
|
{
|
||||||
error("Offset is not user accessible");
|
error("Offset is not user accessible");
|
||||||
Memory::Virtual(Parent->PageTable).Map((void *)Offset, (void *)Offset, Memory::PTFlag::RW | Memory::PTFlag::US);
|
Memory::Virtual(Parent->PageTable).Map((void *)Offset, (void *)Offset, Memory::PTFlag::RW | Memory::PTFlag::US); // We try one more time.
|
||||||
}
|
}
|
||||||
#elif defined(__i386__)
|
#elif defined(__i386__)
|
||||||
#elif defined(__aarch64__)
|
#elif defined(__aarch64__)
|
||||||
|
@ -60,6 +60,7 @@ namespace Tasking
|
|||||||
{
|
{
|
||||||
TaskTrustLevel TrustLevel;
|
TaskTrustLevel TrustLevel;
|
||||||
Token UniqueToken;
|
Token UniqueToken;
|
||||||
|
bool IsCritical;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct TaskInfo
|
struct TaskInfo
|
||||||
@ -117,6 +118,12 @@ namespace Tasking
|
|||||||
}
|
}
|
||||||
|
|
||||||
int GetExitCode() { return ExitCode; }
|
int GetExitCode() { return ExitCode; }
|
||||||
|
|
||||||
|
void SetCritical(bool critical)
|
||||||
|
{
|
||||||
|
trace("Setting criticality of thread %s to %s", Name, critical ? "true" : "false");
|
||||||
|
Security.IsCritical = critical;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PCB
|
struct PCB
|
||||||
|
Loading…
x
Reference in New Issue
Block a user