We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 0be137d commit 6eef08dCopy full SHA for 6eef08d
src/aero_kernel/src/arch/x86_64/mod.rs
@@ -256,8 +256,20 @@ pub fn init_cpu() {
256
}
257
258
{
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
+
264
let mut cr4 = controlregs::read_cr4();
265
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
273
cr4.insert(controlregs::Cr4Flags::OSFXSR);
274
cr4.insert(controlregs::Cr4Flags::OSXMMEXCPT_ENABLE);
275
0 commit comments