Having problems with the MSR bitmaps.
I read the IA32_VMX_PROCBASED_CTLS MSR, set bit 28 and stored it into the vmcs's Primary proc-based VM-execution controls field.
I then have the following structure in the vmcs header file:

u64 MSR_READ_LO[128];
u64 MSR_READ_HI[128];
u64 MSR_WRITE_LO[128];
u64 MSR_WRITE_HI[128];
} __attribute__ (( aligned (4096) ));

and in the vmcs.cI have the following code that should clear all bits in the MSR bitmap pointed to by the MSR_BITMAP address of the vmcs field so that no MSR read or write will cause a VM exit:


unsigned long MSR_BITMAP_ADDR = (unsigned long) &MSR_BITMAP1;
memset(&MSR_BITMAP1, 0, sizeof(MSR_BITMAP1)); //this should clear all bits in the bitmap forcing no MSRs to cause a VM exit
__vmwrite (MSR_BITMAP_LO, (u32)MSR_BITMAP_ADDR);
__vmwrite (MSR_BITMAP_HI, (u32)(MSR_BITMAP_ADDR >> 32));

In the VM i have the following code trying to read a MSR:

rdmsrl(MSR_IA32_APIC_BASE_BSE, apic_base);

However when the VM tries to read the MSR I still get a VM-exit due to a MSR exception. How do I correctly setup the MSR bitmap of the VMCS so that I do not get a VM-exit caused by a MSR exception when I try to read a MSR in the VM. (Trying to write to an MSR in the VM causes a triple fault, hopefully solving this will fix that problem as well.)
Any suggestions?

3 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione

Hello,so if you have correctly set the use of MSR bitmaps in the execution control field maybe your RCX value is not correctly in his range.What I mean is: if theMSR_READ_LO is in the range [0, 0x1FFF] so RCX (or ECX) value should be in the same range, the same for other kind of bitmaps. This happens because if you execute __rdmsr without a correct value (ie. in the range) in RCX a VM exit occurs.EITHER if the bit in the "selected (low/high, read/write)" MSR bitmaps corresponding to the RCX value is 1. So the n_bit (with n = rcx_value) should not be 1.Tell me what about this check, thanksirp

Problem was with the privilege level of my CS segment. Was not able to view the MSRs because my privilege level was 3 not 0.

Accedere per lasciare un commento.