3 # tool for querying VMX capabilities
5 # Copyright 2009-2010 Red Hat, Inc.
8 # Avi Kivity <avi@redhat.com>
10 # This work is licensed under the terms of the GNU GPL, version 2. See
11 # the COPYING file in the top-level directory.
13 from __future__
import print_function
14 MSR_IA32_VMX_BASIC
= 0x480
15 MSR_IA32_VMX_PINBASED_CTLS
= 0x481
16 MSR_IA32_VMX_PROCBASED_CTLS
= 0x482
17 MSR_IA32_VMX_EXIT_CTLS
= 0x483
18 MSR_IA32_VMX_ENTRY_CTLS
= 0x484
19 MSR_IA32_VMX_MISC_CTLS
= 0x485
20 MSR_IA32_VMX_PROCBASED_CTLS2
= 0x48B
21 MSR_IA32_VMX_EPT_VPID_CAP
= 0x48C
22 MSR_IA32_VMX_TRUE_PINBASED_CTLS
= 0x48D
23 MSR_IA32_VMX_TRUE_PROCBASED_CTLS
= 0x48E
24 MSR_IA32_VMX_TRUE_EXIT_CTLS
= 0x48F
25 MSR_IA32_VMX_TRUE_ENTRY_CTLS
= 0x490
26 MSR_IA32_VMX_VMFUNC
= 0x491
31 self
.f
= open('/dev/cpu/0/msr', 'rb', 0)
33 self
.f
= open('/dev/msr0', 'rb', 0)
34 def read(self
, index
, default
= None):
38 return struct
.unpack('Q', self
.f
.read(8))[0]
42 class Control(object):
43 def __init__(self
, name
, bits
, cap_msr
, true_cap_msr
= None):
46 self
.cap_msr
= cap_msr
47 self
.true_cap_msr
= true_cap_msr
51 return (val
& 0xffffffff, val
>> 32)
54 mbz
, mb1
= self
.read2(self
.cap_msr
)
57 tmbz
, tmb1
= self
.read2(self
.true_cap_msr
)
58 for bit
in sorted(self
.bits
.keys()):
59 zero
= not (mbz
& (1 << bit
))
60 one
= mb1
& (1 << bit
)
61 true_zero
= not (tmbz
& (1 << bit
))
62 true_one
= tmb1
& (1 << bit
)
64 if (self
.true_cap_msr
and true_zero
and true_one
65 and one
and not zero
):
67 elif zero
and not one
:
69 elif one
and not zero
:
73 print(' %-40s %s' % (self
.bits
[bit
], s
))
76 def __init__(self
, name
, bits
, msr
):
82 value
= msr().read(self
.msr
, 0)
83 print(' Hex: 0x%x' % (value
))
85 if type(key
) is tuple:
89 for bits
in sorted(self
.bits
.keys(), key
= first_bit
):
90 if type(bits
) is tuple:
96 return { True: 'yes', False: 'no' }[x
]
97 v
= (value
>> lo
) & ((1 << (hi
- lo
+ 1)) - 1)
98 print(' %-40s %s' % (self
.bits
[bits
], fmt(v
)))
102 name
= 'Basic VMX Information',
105 (32,44): 'VMCS size',
106 48: 'VMCS restricted to 32 bit addresses',
107 49: 'Dual-monitor support',
108 (50, 53): 'VMCS memory type',
109 54: 'INS/OUTS instruction information',
110 55: 'IA32_VMX_TRUE_*_CTLS support',
112 msr
= MSR_IA32_VMX_BASIC
,
115 name
= 'pin-based controls',
117 0: 'External interrupt exiting',
120 6: 'Activate VMX-preemption timer',
121 7: 'Process posted interrupts',
123 cap_msr
= MSR_IA32_VMX_PINBASED_CTLS
,
124 true_cap_msr
= MSR_IA32_VMX_TRUE_PINBASED_CTLS
,
128 name
= 'primary processor-based controls',
130 2: 'Interrupt window exiting',
131 3: 'Use TSC offsetting',
137 15: 'CR3-load exiting',
138 16: 'CR3-store exiting',
139 19: 'CR8-load exiting',
140 20: 'CR8-store exiting',
141 21: 'Use TPR shadow',
142 22: 'NMI-window exiting',
143 23: 'MOV-DR exiting',
144 24: 'Unconditional I/O exiting',
145 25: 'Use I/O bitmaps',
146 27: 'Monitor trap flag',
147 28: 'Use MSR bitmaps',
148 29: 'MONITOR exiting',
150 31: 'Activate secondary control',
152 cap_msr
= MSR_IA32_VMX_PROCBASED_CTLS
,
153 true_cap_msr
= MSR_IA32_VMX_TRUE_PROCBASED_CTLS
,
157 name
= 'secondary processor-based controls',
159 0: 'Virtualize APIC accesses',
161 2: 'Descriptor-table exiting',
163 4: 'Virtualize x2APIC mode',
166 7: 'Unrestricted guest',
167 8: 'APIC register emulation',
168 9: 'Virtual interrupt delivery',
169 10: 'PAUSE-loop exiting',
170 11: 'RDRAND exiting',
171 12: 'Enable INVPCID',
172 13: 'Enable VM functions',
173 14: 'VMCS shadowing',
174 15: 'Enable ENCLS exiting',
175 16: 'RDSEED exiting',
177 18: 'EPT-violation #VE',
178 19: 'Conceal non-root operation from PT',
179 20: 'Enable XSAVES/XRSTORS',
180 22: 'Mode-based execute control (XS/XU)',
183 cap_msr
= MSR_IA32_VMX_PROCBASED_CTLS2
,
187 name
= 'VM-Exit controls',
189 2: 'Save debug controls',
190 9: 'Host address-space size',
191 12: 'Load IA32_PERF_GLOBAL_CTRL',
192 15: 'Acknowledge interrupt on exit',
195 20: 'Save IA32_EFER',
196 21: 'Load IA32_EFER',
197 22: 'Save VMX-preemption timer value',
198 23: 'Clear IA32_BNDCFGS',
199 24: 'Conceal VM exits from PT',
201 cap_msr
= MSR_IA32_VMX_EXIT_CTLS
,
202 true_cap_msr
= MSR_IA32_VMX_TRUE_EXIT_CTLS
,
206 name
= 'VM-Entry controls',
208 2: 'Load debug controls',
209 9: 'IA-32e mode guest',
211 11: 'Deactivate dual-monitor treatment',
212 13: 'Load IA32_PERF_GLOBAL_CTRL',
214 15: 'Load IA32_EFER',
215 16: 'Load IA32_BNDCFGS',
216 17: 'Conceal VM entries from PT',
218 cap_msr
= MSR_IA32_VMX_ENTRY_CTLS
,
219 true_cap_msr
= MSR_IA32_VMX_TRUE_ENTRY_CTLS
,
223 name
= 'Miscellaneous data',
225 (0,4): 'VMX-preemption timer scale (log2)',
226 5: 'Store EFER.LMA into IA-32e mode guest control',
227 6: 'HLT activity state',
228 7: 'Shutdown activity state',
229 8: 'Wait-for-SIPI activity state',
230 15: 'IA32_SMBASE support',
231 (16,24): 'Number of CR3-target values',
232 (25,27): 'MSR-load/store count recommendation',
233 28: 'IA32_SMM_MONITOR_CTL[2] can be set to 1',
234 29: 'VMWRITE to VM-exit information fields',
235 30: 'Inject event with insn length=0',
236 (32,63): 'MSEG revision identifier',
238 msr
= MSR_IA32_VMX_MISC_CTLS
,
242 name
= 'VPID and EPT capabilities',
244 0: 'Execute-only EPT translations',
245 6: 'Page-walk length 4',
246 8: 'Paging-structure memory type UC',
247 14: 'Paging-structure memory type WB',
250 20: 'INVEPT supported',
251 21: 'EPT accessed and dirty flags',
252 25: 'Single-context INVEPT',
253 26: 'All-context INVEPT',
254 32: 'INVVPID supported',
255 40: 'Individual-address INVVPID',
256 41: 'Single-context INVVPID',
257 42: 'All-context INVVPID',
258 43: 'Single-context-retaining-globals INVVPID',
260 msr
= MSR_IA32_VMX_EPT_VPID_CAP
,
263 name
= 'VM Functions',
267 msr
= MSR_IA32_VMX_VMFUNC
,