Kernel: Add ubsan

My brain has been melting since I'm getting very random bugs.
I hope I can debug them better with ubsan :)
This commit is contained in:
Bananymous
2023-03-06 23:38:05 +02:00
parent e480f9c195
commit 06db890d49
8 changed files with 128 additions and 12 deletions

View File

@@ -47,9 +47,9 @@ MMU::MMU()
m_highest_paging_struct[i] = (uint64_t)page_directory | Flags::Present;
}
// create and identity map first 4 MiB
// create and identity map first 6 MiB
uint64_t* page_directory1 = (uint64_t*)(m_highest_paging_struct[0] & PAGE_MASK);
for (uint64_t i = 0; i < 2; i++)
for (uint64_t i = 0; i < 3; i++)
{
uint64_t* page_table = allocate_page_aligned_page();
for (uint64_t j = 0; j < 512; j++)

View File

@@ -118,9 +118,10 @@ enable_sse:
ret
initialize_paging:
# identity map first 4 MiB
# identity map first 6 MiB
movl $(0x00000000 + 0x83), boot_page_directory1 + 0
movl $(0x00200000 + 0x83), boot_page_directory1 + 8
movl $(0x00400000 + 0x83), boot_page_directory1 + 16
movl $(boot_page_directory1 + 0x01), boot_page_directory_pointer_table
# enable PAE

View File

@@ -35,7 +35,7 @@ static uint64_t* allocate_page_aligned_page()
MMU::MMU()
{
// Identity map from 4 KiB -> 4 MiB
// Identity map from 4 KiB -> 6 MiB
m_highest_paging_struct = allocate_page_aligned_page();
uint64_t* pdpt = allocate_page_aligned_page();
@@ -44,7 +44,7 @@ MMU::MMU()
uint64_t* pd = allocate_page_aligned_page();
pdpt[0] = (uint64_t)pd | Flags::ReadWrite | Flags::Present;
for (uint32_t i = 0; i < 2; i++)
for (uint32_t i = 0; i < 3; i++)
{
uint64_t* pt = allocate_page_aligned_page();
for (uint64_t j = 0; j < 512; j++)

View File

@@ -41,9 +41,9 @@
# we will identity map first 4 MiB
# 0 MiB -> 1 MiB: bootloader stuff
# 1 MiB -> 2 MiB: kernel
# 2 MiB -> 3 MiB: kmalloc
# 3 MiB -> 4 MiB: kmalloc_fixed
# 1 MiB -> 4 MiB: kernel
# 4 MiB -> 5 MiB: kmalloc
# 5 MiB -> 6 MiB: kmalloc_fixed
.align 4096
boot_pml4:
.skip 512 * 8
@@ -127,9 +127,10 @@ enable_sse:
ret
initialize_paging:
# identity map first 4 MiB
# identity map first 6 MiB
movl $(0x00000000 + PG_PAGE_SIZE + PG_READ_WRITE + PG_PRESENT), boot_pd1 + 0
movl $(0x00200000 + PG_PAGE_SIZE + PG_READ_WRITE + PG_PRESENT), boot_pd1 + 8
movl $(0x00400000 + PG_PAGE_SIZE + PG_READ_WRITE + PG_PRESENT), boot_pd1 + 16
# set pdpte1 and pml4e1
movl $(boot_pd1 + PG_READ_WRITE + PG_PRESENT), boot_pdpt1