mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 00:57:45 +00:00
Kernel: Fix detecting in what ring a crash happened
The ring is determined based on the CS register. This fixes crashes being handled as ring 3 crashes even though EIP/CS clearly showed that the crash happened in the kernel.
This commit is contained in:
parent
0f9be82826
commit
19ffd9d677
1 changed files with 5 additions and 4 deletions
|
@ -122,8 +122,8 @@ static void dump(const RegisterState& regs)
|
||||||
{
|
{
|
||||||
u16 ss;
|
u16 ss;
|
||||||
u32 esp;
|
u32 esp;
|
||||||
auto process = Process::current();
|
|
||||||
if (!process || process->is_ring0()) {
|
if (!(regs.cs & 3)) {
|
||||||
ss = regs.ss;
|
ss = regs.ss;
|
||||||
esp = regs.esp;
|
esp = regs.esp;
|
||||||
} else {
|
} else {
|
||||||
|
@ -149,6 +149,7 @@ static void dump(const RegisterState& regs)
|
||||||
: "=a"(cr4));
|
: "=a"(cr4));
|
||||||
klog() << "cr0=" << String::format("%08x", cr0) << " cr2=" << String::format("%08x", cr2) << " cr3=" << String::format("%08x", cr3) << " cr4=" << String::format("%08x", cr4);
|
klog() << "cr0=" << String::format("%08x", cr0) << " cr2=" << String::format("%08x", cr2) << " cr3=" << String::format("%08x", cr3) << " cr4=" << String::format("%08x", cr4);
|
||||||
|
|
||||||
|
auto process = Process::current();
|
||||||
if (process && process->validate_read((void*)regs.eip, 8)) {
|
if (process && process->validate_read((void*)regs.eip, 8)) {
|
||||||
SmapDisabler disabler;
|
SmapDisabler disabler;
|
||||||
u8* codeptr = (u8*)regs.eip;
|
u8* codeptr = (u8*)regs.eip;
|
||||||
|
@ -168,10 +169,10 @@ void handle_crash(RegisterState& regs, const char* description, int signal, bool
|
||||||
// make sure we switch back to the right page tables.
|
// make sure we switch back to the right page tables.
|
||||||
MM.enter_process_paging_scope(*process);
|
MM.enter_process_paging_scope(*process);
|
||||||
|
|
||||||
klog() << "CRASH: CPU #" << Processor::current().id() << " " << description << ". Ring " << (process->is_ring0() ? 0 : 3) << ".";
|
klog() << "CRASH: CPU #" << Processor::current().id() << " " << description << ". Ring " << (regs.cs & 3) << ".";
|
||||||
dump(regs);
|
dump(regs);
|
||||||
|
|
||||||
if (process->is_ring0()) {
|
if (!(regs.cs & 3)) {
|
||||||
klog() << "Crash in ring 0 :(";
|
klog() << "Crash in ring 0 :(";
|
||||||
dump_backtrace();
|
dump_backtrace();
|
||||||
Processor::halt();
|
Processor::halt();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue