(It's an old intel i5-500whatever HP laptop)
I've so far tested on every single existing emulator (vmware, vbox, bochs, qemu) + a few other laptops and computers, and it worked great on all of them.
However, on this one laptop it triple faults because of what looks like BSS not getting zeroed properly (I have to also mention that I'm using my own bootloader + flat binary so i'm the one responsible for zeroing the BSS)
After hours of debugging I realized that it triple faults on a super early kernel main function, and after adding a few tests I've confirmed that. It hangs on this code:
Code: Select all
// logger initialization function
void Logger::initialize()
{
// This is a test line of code I've added and indeed it hangs here
// these are both static pointers members of the logger class and are supposed to be zeroed
if (s_sinks || s_write_lock) {
hang(); // hangs here
}
ASSERT(s_sinks == nullptr);
ASSERT(s_write_lock == nullptr);
s_sinks = new DynamicArray<LogSink*>(2);
if (E9LogSink::is_supported())
s_sinks->emplace(new E9LogSink());
s_sinks->emplace(new SerialSink());
s_write_lock = new InterruptSafeSpinLock;
}
on what looks like another static pointer that's supposed to be zero.
My linker script:
Code: Select all
ENTRY(start)
OUTPUT_FORMAT("binary")
SECTIONS
{
kernel_space_begin = 0xFFFFFFFF80000000; /* MAX - 2GB */
. = kernel_space_begin + 0x100000; /* 1MB into the address space */
.text ALIGN(4K) : AT (ADDR (.text) - kernel_space_begin)
{
*(.entry)
*(.text)
}
.rodata ALIGN(4K) : AT (ADDR (.rodata) - kernel_space_begin)
{
global_constructors_begin = .;
*(.ctors)
global_constructors_end = .;
*(.rodata)
}
.data ALIGN(4K) : AT (ADDR (.data) - kernel_space_begin)
{
*(.data)
}
.magic ALIGN(4K) : AT (ADDR (.magic) - kernel_space_begin)
{
*(.magic)
}
section_bss_begin = .;
.bss ALIGN(4K) : AT (ADDR (.bss) - kernel_space_begin)
{
*(COMMON)
*(.bss)
}
section_bss_end = .;
section_bss_size = section_bss_end - section_bss_begin;
}
Code: Select all
; zero section bss
mov rdi, section_bss_begin
mov rcx, section_bss_size
mov rbp, rax ; save the rax
mov rax, 0
rep stosb
mov rax, rbp
Anyways, if you have any ideas about what I'm doing wrong here I would really appreciate if you could tell me, I'm kind of out of ideas here.