diff --git a/0C_virtual_memory/kernel8 b/0C_virtual_memory/kernel8 index f65f0bab..27b39c2d 100755 Binary files a/0C_virtual_memory/kernel8 and b/0C_virtual_memory/kernel8 differ diff --git a/0C_virtual_memory/src/mmu.rs b/0C_virtual_memory/src/mmu.rs index 13048dad..8acdaa14 100644 --- a/0C_virtual_memory/src/mmu.rs +++ b/0C_virtual_memory/src/mmu.rs @@ -178,8 +178,12 @@ pub unsafe fn init() { } const PAGESIZE: u64 = 4096; - let ro_start: u64 = &__ro_start as *const _ as u64 / PAGESIZE; - let ro_end: u64 = &__ro_end as *const _ as u64 / PAGESIZE; + let ro_first_page_index: u64 = &__ro_start as *const _ as u64 / PAGESIZE; + + // Notice the subtraction to calculate the last page index of the RO area + // and not the first page index after the RO area. + let ro_last_page_index: u64 = (&__ro_end as *const _ as u64 / PAGESIZE) - 1; + let common = STAGE1_DESCRIPTOR::VALID::True + STAGE1_DESCRIPTOR::TYPE::Table + STAGE1_DESCRIPTOR::AttrIndx.val(mair::NORMAL) @@ -189,7 +193,7 @@ pub unsafe fn init() { for (i, entry) in SINGLE_LVL3_TABLE.iter_mut().enumerate() { let j: u64 = i as u64; - let mem_attr = if j < ro_start || j > ro_end { + let mem_attr = if j < ro_first_page_index || j > ro_last_page_index { STAGE1_DESCRIPTOR::AP::RW_EL1 + STAGE1_DESCRIPTOR::XN::True } else { STAGE1_DESCRIPTOR::AP::RO_EL1 + STAGE1_DESCRIPTOR::XN::False diff --git a/0D_cache_performance/kernel8 b/0D_cache_performance/kernel8 index 6c23ac80..5d70db03 100755 Binary files a/0D_cache_performance/kernel8 and b/0D_cache_performance/kernel8 differ diff --git a/0D_cache_performance/src/mmu.rs b/0D_cache_performance/src/mmu.rs index df48d434..04eeb89e 100644 --- a/0D_cache_performance/src/mmu.rs +++ b/0D_cache_performance/src/mmu.rs @@ -170,8 +170,12 @@ pub unsafe fn init() { } const PAGESIZE: u64 = 4096; - let ro_start: u64 = &__ro_start as *const _ as u64 / PAGESIZE; - let ro_end: u64 = &__ro_end as *const _ as u64 / PAGESIZE; + let ro_first_page_index: u64 = &__ro_start as *const _ as u64 / PAGESIZE; + + // Notice the subtraction to calculate the last page index of the RO area + // and not the first page index after the RO area. + let ro_last_page_index: u64 = (&__ro_end as *const _ as u64 / PAGESIZE) - 1; + let common = STAGE1_DESCRIPTOR::VALID::True + STAGE1_DESCRIPTOR::TYPE::Table + STAGE1_DESCRIPTOR::AttrIndx.val(mair::NORMAL) @@ -181,7 +185,7 @@ pub unsafe fn init() { for (i, entry) in SINGLE_LVL3_TABLE.iter_mut().enumerate() { let j: u64 = i as u64; - let mem_attr = if j < ro_start || j > ro_end { + let mem_attr = if j < ro_first_page_index || j > ro_last_page_index { STAGE1_DESCRIPTOR::AP::RW_EL1 + STAGE1_DESCRIPTOR::XN::True } else { STAGE1_DESCRIPTOR::AP::RO_EL1 + STAGE1_DESCRIPTOR::XN::False