Skip to content
Snippets Groups Projects
Commit 84b0fe02 authored by iliya.saroukha's avatar iliya.saroukha :first_quarter_moon:
Browse files

feat: added function for checking MSR's flags

parent ce570953
No related branches found
No related tags found
No related merge requests found
......@@ -135,6 +135,26 @@ able to write to this MSR using __wrmsr. What's interesting about this is that
the tutorial tries to modify this MSR but if we assume that the **lock bit is set**
that branch **will be a no-op**.
```c
static bool ia32_feature_control_flags(void) {
int msr_value = __rdmsr(IA32_FEATURE_CONTROL_MSR);
if (!(msr_value & IA32_FEATURE_CONTROL_LOCK_BIT)) {
printk(KERN_INFO "Writing to the IA32_FEATURE_CONTROL MSR\n");
__wrmsr(IA32_FEATURE_CONTROL_MSR,
IA32_FEATURE_CONTROL_LOCK_BIT |
IA32_FEATURE_CONTROL_VMXON_OUTSIDE_SMX,
0);
}
if (!(msr_value & IA32_FEATURE_CONTROL_VMXON_OUTSIDE_SMX)) {
printk(KERN_INFO "Virtualization isn't available\n");
return false;
}
return true;
}
```
## References
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment