bootloader icon indicating copy to clipboard operation
bootloader copied to clipboard

Hang after loading first level 4 table on uefi

Open Colepng opened this issue 1 year ago • 1 comments

I tried my os on real hardware for the first time and found that the bootloader is hanging. I tracked the issue down to this line. I'm still a beginner in os development so any help is appreciated.

I am running it on my laptop which is a lenvo legion 7 which has a AMD Ryzen 7 5800H.

Colepng avatar Oct 24 '24 16:10 Colepng

Hmm, there's not much to go on. How did you track this hang down to this line? Can you share the log output?

Freax13 avatar Oct 24 '24 17:10 Freax13

I cloned the repo locally, linked my kernel to the local version and added debug statements. I put 1 statement after the line I linked to and 1 after. Only the first 1 ran. The best photo I can add would be from my phone.

Image

As you can see in the photo it no longer hang. Instead of only copying over the first entry of the old page table, I started copying over all entries and now it works. The panic you can see in the photo seems to be from the fact my system uses huge page table while the bootloader expects 4KiB tables. If you know, could you explain to me why copying over all the old entries would fix it.

Colepng avatar Oct 25 '24 13:10 Colepng

The frame buffer (0xfc_1000_0000) address is in the second pml4 entry, interesting. Currently, we only copy the first pml4 entry, but when the bootloader tries to access the frame buffer it needs the second pml4e. The assumption in this comment was incorrect. Your fix (copying more entries) seems reasonable unless maybe that's what's causing the panic below? Freel free to open at PR. I'll investigate some more later this evening.

Freax13 avatar Oct 25 '24 13:10 Freax13