Skip to content

Commit 6eef08d

Browse files
committed
arch: Enable SMAP
Signed-off-by: Dennis Bonke <[email protected]>
1 parent 0be137d commit 6eef08d

File tree

1 file changed

+12
-0
lines changed
  • src/aero_kernel/src/arch/x86_64

1 file changed

+12
-0
lines changed

src/aero_kernel/src/arch/x86_64/mod.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,20 @@ pub fn init_cpu() {
256256
}
257257

258258
{
259+
// Check if SMAP is supported.
260+
let has_smap = CpuId::new()
261+
.get_extended_feature_info()
262+
.map_or(false, |i| i.has_smap());
263+
259264
let mut cr4 = controlregs::read_cr4();
260265

266+
if has_smap {
267+
log::info!("SMAP is supported, enabling SMAP.");
268+
cr4.insert(controlregs::Cr4Flags::SUPERVISOR_MODE_ACCESS_PREVENTION);
269+
} else {
270+
log::info!("SMAP is not supported.");
271+
}
272+
261273
cr4.insert(controlregs::Cr4Flags::OSFXSR);
262274
cr4.insert(controlregs::Cr4Flags::OSXMMEXCPT_ENABLE);
263275

0 commit comments

Comments
 (0)