Skip to content

Commit 77912b4

Browse files
committed
Enable the functionality for the global flag in page tables
Signed-off-by: SlyMarbo <[email protected]>
1 parent 6d2fec5 commit 77912b4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

kernel/src/memory/vmm/mod.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ use crate::memory::vmm::mapping::PagePurpose;
1313
use crate::memory::KERNEL_HEAP;
1414
use crate::{println, Locked};
1515
use fixed_size_block::FixedSizeBlockAllocator;
16+
use x86_64::registers::control::{Cr4, Cr4Flags};
1617
use x86_64::structures::paging::mapper::{MapToError, MapperFlushAll};
1718
use x86_64::structures::paging::{
1819
FrameAllocator, Mapper, OffsetPageTable, Page, PageTable, PageTableFlags, Size4KiB,
@@ -55,6 +56,12 @@ pub fn init(
5556
);
5657
}
5758

59+
// Set the CR4 fields, so we can then use the global
60+
// page flag when we remap the kernel.
61+
let mut flags = Cr4::read();
62+
flags |= Cr4Flags::PAGE_GLOBAL; // Enable the global flag in page tables.
63+
unsafe { Cr4::write(flags) };
64+
5865
// Remap the kernel, now that the heap is set up.
5966
unsafe { remap_kernel(mapper) };
6067

0 commit comments

Comments
 (0)