From 9e08e9f55f0403e8d940ba581a625ed181f6d117 Mon Sep 17 00:00:00 2001 From: "iliya.saroukha" <iliya.saroukhanian@etu.hesge.ch> Date: Tue, 3 Dec 2024 15:40:09 +0100 Subject: [PATCH] feat: explained the relevant bits to VMX of the IA32_FEATURE_CONTROL Model-Specific Register --- docs/re.md | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/re.md b/docs/re.md index 349b862..1fae61c 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/) -- GitLab