How to detect if model specific register exist

425 views Asked by At

I am trying to check if a bit is clear in IA32_VMX_EPT_VPID_CAP (48CH) but in some cases I am working with hardware that dose not have that msr(q9300) itself and I get segfault. I was wondering if there was an instruction or a "nice" way to check if the msr exist in the first place. I know I could probably handle the segfault or check the CPU model and compare it to a prepared table that have what CPU have the msr, but those solutions seems a bit messy to me. I looked over the Intel Manuel but I havn`t found any references to a way to check it. Is there a convention or a more proper way then the ways mentioned above ?

1

There are 1 answers

0
prl On BEST ANSWER

From section A.10 of the Intel SDM:

The IA32_VMX_EPT_VPID_CAP MSR exists on processors that support EPT or VPID.

So you should check the following:

  • bit 63 of the IA32_VMX_PROCBASED_CTLS MSR is 1 (support for secondary controls)
  • and either bit 33 or bit 37 of the IA32_VMX_PROCBASED_CTLS2 MSR is 1 (support for EPT or VPID)