* [PATCH v2] vmxcap: Add tool to query vmx capabilities
@ 2009-09-01 16:18 Avi Kivity
2009-09-02 6:50 ` Amit Shah
2009-09-02 18:57 ` Marcelo Tosatti
0 siblings, 2 replies; 8+ messages in thread
From: Avi Kivity @ 2009-09-01 16:18 UTC (permalink / raw)
To: Marcelo Tosatti; +Cc: kvm
This should really be in the kernel, but there are too many of them.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
v2: try /dev/cpu/0/msr first
kvm/scripts/vmxcap | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 154 insertions(+), 0 deletions(-)
create mode 100755 kvm/scripts/vmxcap
diff --git a/kvm/scripts/vmxcap b/kvm/scripts/vmxcap
new file mode 100755
index 0000000..50f094b
--- /dev/null
+++ b/kvm/scripts/vmxcap
@@ -0,0 +1,154 @@
+#!/usr/bin/python
+
+MSR_IA32_VMX_BASIC = 0x480
+MSR_IA32_VMX_PINBASED_CTLS = 0x481
+MSR_IA32_VMX_PROCBASED_CTLS = 0x482
+MSR_IA32_VMX_EXIT_CTLS = 0x483
+MSR_IA32_VMX_ENTRY_CTLS = 0x484
+MSR_IA32_VMX_MISC_CTLS = 0x485
+MSR_IA32_VMX_PROCBASED_CTLS2 = 0x48B
+MSR_IA32_VMX_TRUE_PINBASED_CTLS = 0x48D
+MSR_IA32_VMX_TRUE_PROCBASED_CTLS = 0x48E
+MSR_IA32_VMX_TRUE_EXIT_CTLS = 0x48F
+MSR_IA32_VMX_TRUE_ENTRY_CTLS = 0x490
+
+class msr(object):
+ def __init__(self):
+ try:
+ self.f = file('/dev/cpu/0/msr')
+ except:
+ self.f = file('/dev/msr0')
+ def read(self, index, default = None):
+ import struct
+ self.f.seek(index)
+ try:
+ return struct.unpack('Q', self.f.read(8))[0]
+ except:
+ return default
+
+class Control(object):
+ def __init__(self, name, bits, cap_msr, true_cap_msr = None):
+ self.name = name
+ self.bits = bits
+ self.cap_msr = cap_msr
+ self.true_cap_msr = true_cap_msr
+ def read2(self, nr):
+ m = msr()
+ val = m.read(nr, 0)
+ return (val & 0xffffffff, val >> 32)
+ def show(self):
+ print self.name
+ mbz, mb1 = self.read2(self.cap_msr)
+ tmbz, tmb1 = 0, 0
+ if self.true_cap_msr:
+ tmbz, tmb1 = self.read2(self.true_cap_msr)
+ for bit in sorted(self.bits.keys()):
+ zero = not (mbz & (1 << bit))
+ one = mb1 & (1 << bit)
+ true_zero = not (tmbz & (1 << bit))
+ true_one = tmb1 & (1 << bit)
+ s= '?'
+ if (self.true_cap_msr and true_zero and true_one
+ and one and not zero):
+ s = 'default'
+ elif zero and not one:
+ s = 'no'
+ elif one and not zero:
+ s = 'forced'
+ elif one and zero:
+ s = 'yes'
+ print ' %-40s %s' % (self.bits[bit], s)
+
+controls = [
+ Control(
+ name = 'pin-based controls',
+ bits = {
+ 0: 'External interrupt exiting',
+ 3: 'NMI exiting',
+ 5: 'Virtual NMIs',
+ 6: 'Activate VMX-preemption timer',
+ 7: 'Unrestricted guest',
+ },
+ cap_msr = MSR_IA32_VMX_PINBASED_CTLS,
+ true_cap_msr = MSR_IA32_VMX_TRUE_PINBASED_CTLS,
+ ),
+
+ Control(
+ name = 'primary processor-based controls',
+ bits = {
+ 2: 'Interrupt window exiting',
+ 3: 'Use TSC offsetting',
+ 7: 'HLT exiting',
+ 9: 'INVLPG exiting',
+ 10: 'MWAIT exiting',
+ 11: 'RDPMC exiting',
+ 12: 'RDTSC exiting',
+ 15: 'CR3-load exiting',
+ 16: 'CR3-store exiting',
+ 19: 'CR8-load exiting',
+ 20: 'CR8-store exiting',
+ 21: 'Use TPR shadow',
+ 22: 'NMI-window exiting',
+ 23: 'MOV-DR exiting',
+ 24: 'Unconditional I/O exiting',
+ 25: 'Use I/O bitmaps',
+ 27: 'Monitor trap flag',
+ 28: 'Use MSR bitmaps',
+ 29: 'MONITOR exiting',
+ 30: 'PAUSE exiting',
+ 31: 'Activate secondary control',
+ },
+ cap_msr = MSR_IA32_VMX_PROCBASED_CTLS,
+ true_cap_msr = MSR_IA32_VMX_TRUE_PROCBASED_CTLS,
+ ),
+
+ Control(
+ name = 'secondary processor-based controls',
+ bits = {
+ 0: 'Virtualize APIC accesses',
+ 1: 'Enable EPT',
+ 2: 'Descriptor-table exiting',
+ 4: 'Virtualize x2APIC mode',
+ 5: 'Enable VPID',
+ 6: 'WBINVD exiting',
+ },
+ cap_msr = MSR_IA32_VMX_PROCBASED_CTLS2,
+ ),
+
+ Control(
+ name = 'VM-Exit controls',
+ bits = {
+ 2: 'Save debug controls',
+ 9: 'Host address-space size',
+ 12: 'Load IA32_PERF_GLOBAL_CTRL',
+ 15: 'Acknowledge interrupt on exit',
+ 18: 'Save IA32_PAT',
+ 19: 'Load IA32_PAT',
+ 20: 'Save IA32_EFER',
+ 21: 'Load IA32_EFER',
+ 22: 'Save VMX-preemption timer value',
+ },
+ cap_msr = MSR_IA32_VMX_EXIT_CTLS,
+ true_cap_msr = MSR_IA32_VMX_TRUE_EXIT_CTLS,
+ ),
+
+ Control(
+ name = 'VM-Entry controls',
+ bits = {
+ 2: 'Load debug controls',
+ 9: 'IA-64 mode guest',
+ 10: 'Entry to SMM',
+ 11: 'Deactivate dual-monitor treatment',
+ 13: 'Load IA32_PERF_GLOBAL_CTRL',
+ 14: 'Load IA32_PAT',
+ 15: 'Load IA32_EFER',
+ },
+ cap_msr = MSR_IA32_VMX_ENTRY_CTLS,
+ true_cap_msr = MSR_IA32_VMX_TRUE_ENTRY_CTLS,
+ ),
+ ]
+
+for c in controls:
+ c.show()
+
+
--
1.6.4.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH v2] vmxcap: Add tool to query vmx capabilities
2009-09-01 16:18 [PATCH v2] vmxcap: Add tool to query vmx capabilities Avi Kivity
@ 2009-09-02 6:50 ` Amit Shah
2009-09-02 7:54 ` Avi Kivity
2009-09-02 18:57 ` Marcelo Tosatti
1 sibling, 1 reply; 8+ messages in thread
From: Amit Shah @ 2009-09-02 6:50 UTC (permalink / raw)
To: Avi Kivity; +Cc: Marcelo Tosatti, kvm
On (Tue) Sep 01 2009 [19:18:05], Avi Kivity wrote:
> This should really be in the kernel, but there are too many of them.
>
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>
> v2: try /dev/cpu/0/msr first
>
> kvm/scripts/vmxcap | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++
Why not call it cpucap and add svm support later?
Amit
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] vmxcap: Add tool to query vmx capabilities
2009-09-02 6:50 ` Amit Shah
@ 2009-09-02 7:54 ` Avi Kivity
2009-09-02 8:02 ` Amit Shah
0 siblings, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2009-09-02 7:54 UTC (permalink / raw)
To: Amit Shah; +Cc: Marcelo Tosatti, kvm
On 09/02/2009 09:50 AM, Amit Shah wrote:
> On (Tue) Sep 01 2009 [19:18:05], Avi Kivity wrote:
>
>> This should really be in the kernel, but there are too many of them.
>>
>> Signed-off-by: Avi Kivity<avi@redhat.com>
>> ---
>>
>> v2: try /dev/cpu/0/msr first
>>
>> kvm/scripts/vmxcap | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>
> Why not call it cpucap and add svm support later?
>
It's just a hack.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] vmxcap: Add tool to query vmx capabilities
2009-09-02 7:54 ` Avi Kivity
@ 2009-09-02 8:02 ` Amit Shah
2009-09-02 8:18 ` Avi Kivity
0 siblings, 1 reply; 8+ messages in thread
From: Amit Shah @ 2009-09-02 8:02 UTC (permalink / raw)
To: Avi Kivity; +Cc: Marcelo Tosatti, kvm
On (Wed) Sep 02 2009 [10:54:05], Avi Kivity wrote:
> On 09/02/2009 09:50 AM, Amit Shah wrote:
>> On (Tue) Sep 01 2009 [19:18:05], Avi Kivity wrote:
>>
>>> This should really be in the kernel, but there are too many of them.
>>>
>>> Signed-off-by: Avi Kivity<avi@redhat.com>
>>> ---
>>>
>>> v2: try /dev/cpu/0/msr first
>>>
>>> kvm/scripts/vmxcap | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>>>
>> Why not call it cpucap and add svm support later?
>>
>
> It's just a hack.
In that case there's danger of this becoming a "stable interface"
- when eg libvirt picks up support for it. It is useful
functionality.
Amit
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] vmxcap: Add tool to query vmx capabilities
2009-09-02 8:02 ` Amit Shah
@ 2009-09-02 8:18 ` Avi Kivity
2009-09-02 10:24 ` Amit Shah
0 siblings, 1 reply; 8+ messages in thread
From: Avi Kivity @ 2009-09-02 8:18 UTC (permalink / raw)
To: Amit Shah; +Cc: Marcelo Tosatti, kvm
On 09/02/2009 11:02 AM, Amit Shah wrote:
>> It's just a hack.
>>
> In that case there's danger of this becoming a "stable interface"
> - when eg libvirt picks up support for it. It is useful
> functionality.
>
They'll learn when the first spelling fix comes in. Don't use text APIs.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] vmxcap: Add tool to query vmx capabilities
2009-09-02 8:18 ` Avi Kivity
@ 2009-09-02 10:24 ` Amit Shah
2009-09-02 11:21 ` Avi Kivity
0 siblings, 1 reply; 8+ messages in thread
From: Amit Shah @ 2009-09-02 10:24 UTC (permalink / raw)
To: Avi Kivity; +Cc: Marcelo Tosatti, kvm
On (Wed) Sep 02 2009 [11:18:10], Avi Kivity wrote:
> On 09/02/2009 11:02 AM, Amit Shah wrote:
>>> It's just a hack.
>>>
>> In that case there's danger of this becoming a "stable interface"
>> - when eg libvirt picks up support for it. It is useful
>> functionality.
>>
>
> They'll learn when the first spelling fix comes in. Don't use text APIs.
:-) Interesting.
So then is this just meant to be a debug or informational tool?
Amit
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] vmxcap: Add tool to query vmx capabilities
2009-09-02 10:24 ` Amit Shah
@ 2009-09-02 11:21 ` Avi Kivity
0 siblings, 0 replies; 8+ messages in thread
From: Avi Kivity @ 2009-09-02 11:21 UTC (permalink / raw)
To: Amit Shah; +Cc: Marcelo Tosatti, kvm
On 09/02/2009 01:24 PM, Amit Shah wrote:
> So then is this just meant to be a debug or informational tool?
>
It's a stopgap until we expose it via /proc/cpuinfo or something similar.
--
error compiling committee.c: too many arguments to function
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH v2] vmxcap: Add tool to query vmx capabilities
2009-09-01 16:18 [PATCH v2] vmxcap: Add tool to query vmx capabilities Avi Kivity
2009-09-02 6:50 ` Amit Shah
@ 2009-09-02 18:57 ` Marcelo Tosatti
1 sibling, 0 replies; 8+ messages in thread
From: Marcelo Tosatti @ 2009-09-02 18:57 UTC (permalink / raw)
To: Avi Kivity; +Cc: kvm
On Tue, Sep 01, 2009 at 07:18:05PM +0300, Avi Kivity wrote:
> This should really be in the kernel, but there are too many of them.
>
> Signed-off-by: Avi Kivity <avi@redhat.com>
> ---
>
> v2: try /dev/cpu/0/msr first
>
> kvm/scripts/vmxcap | 154 ++++++++++++++++++++++++++++++++++++++++++++++++++++
> 1 files changed, 154 insertions(+), 0 deletions(-)
> create mode 100755 kvm/scripts/vmxcap
Applied, thanks.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-09-02 18:57 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-01 16:18 [PATCH v2] vmxcap: Add tool to query vmx capabilities Avi Kivity
2009-09-02 6:50 ` Amit Shah
2009-09-02 7:54 ` Avi Kivity
2009-09-02 8:02 ` Amit Shah
2009-09-02 8:18 ` Avi Kivity
2009-09-02 10:24 ` Amit Shah
2009-09-02 11:21 ` Avi Kivity
2009-09-02 18:57 ` Marcelo Tosatti
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.