diff --git a/docs/re.md b/docs/re.md index 349b86243f5d79f39c02d76ce537bf3c3fc50b74..1fae61c466fa8f7e8de08bd7367cf0d1beb267c0 100644 --- a/docs/re.md +++ b/docs/re.md @@ -109,6 +109,33 @@ static void enable_vmx(void) { } ``` +VMXON is also controlled by the IA32_FEATURE_CONTROL MSR (Model-Specific +Register). MSRs are 64-bit wide. The address of IA32_FEATURE_CONTROL MSR is +**0x3a**. + +The relevant bits (in terms of VMX) of this MSR are: + +- Bit 0 (Lock bit) + - System BIOS can use this bit to provide a setup option for BIOS to disable + support for VMX. **If this bit is set, WRMSR to this MSR will cause a general- + protection exception**. To enable VMX support in a platform, BIOS must set bit + 1, bit 2, or both (see below), as well as the lock bit. +- Bit 1 (VMXON in SMX operation) +- Bit 2 (VMXON outside SMX operation) + +**In my case, after having activated VT-x through the BIOS, the value returned +by the IA32_FEATURE_CONTROL MSR is always equal to 5 (e.g. the lock bit and +VMXON outside SMX operation are always set).** + +**If I decide to deactivate VT-x, the MSR will return the value of 1 (e.g. lock +bit).** + +Due to the fact that the **lock bit** is always **set**, it means that I'm not +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**. + + ## References [^1]: [The Linux Kernel Module Programming Guide](https://sysprog21.github.io/lkmpg/)