Fix stack overruns

This commit is contained in:
Justin C. Miller
2019-04-16 23:39:52 -07:00
parent 6302e8b73a
commit 910b5116f4
5 changed files with 22 additions and 20 deletions

View File

@@ -48,7 +48,7 @@ interrupts_disable:
section .bss
align 0x100
idle_stack_begin:
resb 0x1000 ; 4KiB stack space
resb 0x4000 ; 16KiB stack space
global idle_stack_end
idle_stack_end:

View File

@@ -184,22 +184,24 @@ isr_handler(cpu_state *regs)
uintptr_t cr2 = 0;
__asm__ __volatile__ ("mov %%cr2, %0" : "=r"(cr2));
if (!page_manager::get()->fault_handler(cr2)) {
cons->set_color(11);
cons->puts("\nPage Fault:\n");
cons->set_color();
if ((regs->errorcode & 0x9) == 0 &&
page_manager::get()->fault_handler(cr2))
break;
cons->puts(" flags:");
if (regs->errorcode & 0x01) cons->puts(" present");
if (regs->errorcode & 0x02) cons->puts(" write");
if (regs->errorcode & 0x04) cons->puts(" user");
if (regs->errorcode & 0x08) cons->puts(" reserved");
if (regs->errorcode & 0x10) cons->puts(" ip");
cons->puts("\n");
print_regs(*regs);
print_stacktrace(2);
_halt();
}
cons->set_color(11);
cons->puts("\nPage Fault:\n");
cons->set_color();
cons->puts(" flags:");
if (regs->errorcode & 0x01) cons->puts(" present");
if (regs->errorcode & 0x02) cons->puts(" write");
if (regs->errorcode & 0x04) cons->puts(" user");
if (regs->errorcode & 0x08) cons->puts(" reserved");
if (regs->errorcode & 0x10) cons->puts(" ip");
cons->puts("\n");
print_regs(*regs);
print_stacktrace(2);
_halt();
}
break;

View File

@@ -110,7 +110,7 @@ void fatal(area_t area, const char *fmt, ...);
} // namespace log
namespace logs {
#define LOG(name, lvl) extern log::area_t name;
#define LOG(name, lvl) extern const log::area_t name;
#include "log_areas.inc"
#undef LOG
} // namespace logs

View File

@@ -29,7 +29,7 @@ public:
/// \returns An allocated element
inline item_type * pop()
{
if (this->empty()) allocate();
if (this->empty()) this->allocate();
kassert(!this->empty(), "Slab allocator is empty after allocate()");
item_type *item = this->pop_front();
kutil::memset(item, 0, sizeof(item_type));

View File

@@ -7,7 +7,7 @@
namespace kutil {
namespace logs {
#define LOG(name, lvl) \
log::area_t name = #name ## _h; \
const log::area_t name = #name ## _h; \
const char * name ## _name = #name;
#include "log_areas.inc"
#undef LOG
@@ -19,7 +19,7 @@ using kutil::memset;
using kutil::memcpy;
logger *logger::s_log = nullptr;
const char *logger::s_level_names[] = {"", "debug", " info", " warn", "error", "fatal"};
const char *logger::s_level_names[] = {"", "debug", "info", "warn", "error", "fatal"};
logger::logger() :
m_buffer(nullptr, 0),