Move PAT initialization to rmm

Rmm needs to know the exact PAT configuration to produce the correct
bits in the page table.
This commit is contained in:
bjorn3
2026-03-30 18:59:42 +02:00
parent c4b064ea44
commit 6e5c25b7a0
5 changed files with 44 additions and 54 deletions
+4 -38
View File
@@ -3,8 +3,6 @@
use core::fmt::Debug;
use x86::msr;
pub use super::CurrentRmmArch as RmmA;
pub use rmm::{Arch as RmmArch, PageFlags, PhysicalAddress, TableKind, VirtualAddress};
@@ -21,46 +19,14 @@ pub mod mapper;
pub const PAGE_SIZE: usize = RmmA::PAGE_SIZE;
pub const PAGE_MASK: usize = RmmA::PAGE_OFFSET_MASK;
/// Setup page attribute table
#[cold]
unsafe fn init_pat() {
unsafe {
let uncacheable = 0;
let write_combining = 1;
let write_through = 4;
//let write_protected = 5;
let write_back = 6;
let uncached = 7;
let pat0 = write_back;
let pat1 = write_through;
let pat2 = uncached;
let pat3 = uncacheable;
let pat4 = write_combining;
let pat5 = pat1;
let pat6 = pat2;
let pat7 = pat3;
msr::wrmsr(
msr::IA32_PAT,
(pat7 << 56)
| (pat6 << 48)
| (pat5 << 40)
| (pat4 << 32)
| (pat3 << 24)
| (pat2 << 16)
| (pat1 << 8)
| pat0,
);
}
}
/// Initialize PAT
#[cold]
pub unsafe fn init() {
unsafe {
init_pat();
#[cfg(target_arch = "x86")]
rmm::x86::init_pat();
#[cfg(target_arch = "x86_64")]
rmm::x86_64::init_pat();
}
}