[Closed]My kernel just unexpectedly stops when setting up paging on a real laptop computer
Posted: Mon Jan 13, 2025 9:05 pm
Before enabling paging in kernel, I need to set up memory paging first. In my design, I need to map about hundreds of MB. It's really a time-consuming task, especially on a real laptop computer. My kernel unexpectedly stops. This bug doesn't happen on Qemu. I have no idea how to solve it.
My laptop is quite old. I bought it in 2013. It has "Intel i5-3230M (4) @ 3.200GHz" CPU and 8GB RAM.
This block of code will execute hundreds of thousands times. There will be lots of outputs on screen. At first, output messages are flushed very fast. Just before the bug, output messages are flushed slowly, line by line. Then the bug comes, there is a message "step3.4.4". And nothing happens. "step3.5" is never printed to screen. The laptop doesn't restart. It just stops.
I have read the assembly code, can't find anything weird.
My code:
https://github.com/stskyblade/StarOS/tr ... ocess-soft
https://github.com/stskyblade/StarOS/bl ... g.cpp#L120
How to build:
git clone -b dev-process-soft https://github.com/stskyblade/StarOS.git
cd StarOS
mkdir build
cd build
cmake -DUSB_DEVICE:STRING=/dev/sda .. # be very careful. /dev/sda is the device where my code will burn the disk image into
cmake --build . --target burn # Burning image happends here
Then restart computer from the hard disk above in IDE mode. My kernel only supports IDE mode of SATA disk.
My laptop is quite old. I bought it in 2013. It has "Intel i5-3230M (4) @ 3.200GHz" CPU and 8GB RAM.
Code: Select all
trace("step3.1");
PTE &entry = page_table[entry_offset];
trace("step3.2");
entry.p = 1;
entry.rw = 1;
trace("step3.3");
entry.user_or_supervisor = user_level;
trace("step3.4");
entry.reserved1 = 0;
trace("step3.4.1");
entry.access = 0;
trace("step3.4.2");
entry.dirty = 0;
trace("step3.4.3");
entry.reserved2 = 0;
trace("step3.4.4");
entry.avail = 0;
trace("step3.5");
entry.address =
reinterpret_cast<uint32_t>(physical_address) >> 12; // save high 20bit
trace("step4");
}
I have read the assembly code, can't find anything weird.
Code: Select all
400069fe: 8b 45 d8 mov -0x28(%ebp),%eax
40006a01: 0f b6 50 01 movzbl 0x1(%eax),%edx
40006a05: 83 e2 f1 and $0xfffffff1,%edx
40006a08: 88 50 01 mov %dl,0x1(%eax)
https://github.com/stskyblade/StarOS/tr ... ocess-soft
https://github.com/stskyblade/StarOS/bl ... g.cpp#L120
How to build:
git clone -b dev-process-soft https://github.com/stskyblade/StarOS.git
cd StarOS
mkdir build
cd build
cmake -DUSB_DEVICE:STRING=/dev/sda .. # be very careful. /dev/sda is the device where my code will burn the disk image into
cmake --build . --target burn # Burning image happends here
Then restart computer from the hard disk above in IDE mode. My kernel only supports IDE mode of SATA disk.