Skip to contentSkip to conversation

Extend "flags" to contain HW virtualization info

PATCH In review Sheng Yang 5 participants 13 messages Sep 9, 2008 – Sep 10, 2008

Subsystems (2)
lore
Share & tools
lore

Sheng Yang

author
#0 lore raw

cover Extend "flags" to contain HW virtualization info

Hi, All

Here is the update version of "virt flags" according to comments. Now I extend the "flags" instead of new "virt flags" line, this also result in NCAPINTS was extended to 9.

Still just implement Intel side. And I don't mean to tell apart from VMX and SVM features in cpufeatures.h.

Thanks!

--
regards
Yang, Sheng

author
#2 lore raw

PATCH 2/2 x86: Extended cpuinfo to show virtualization HW features

The hardware virtualization technology evolves very fast. But currently it's hard to tell if your CPU support a certain kind of HW technology without digging into the source code.

The patch add a new catagory in "flags" under /proc/cpuinfo. Now "flags" can indicate the (important) HW virtulization features the CPU supported as well.

Current implementation just cover Intel VMX side.

---
 arch/x86/kernel/cpu/common.c |   45 ++++++++++++++++++++++++++++++++++++++++++
 include/asm-x86/cpufeature.h |    9 +++++++-
 2 files changed, 53 insertions(+), 1 deletions(-)
arch/x86/kernel/cpu/common.c +45 -0
index f7c1964..01432e2 100644
@@ -581,6 +581,50 @@ static void __cpuinit detect_nopl(struct cpuinfo_x86 *c)
 	}
 }
 
+static void __cpuinit detect_vmx_virtcap(struct cpuinfo_x86 *c)
+{
+	/* Intel VMX MSR indicated features */
+#define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW	0x00200000
+#define X86_VMX_FEATURE_PROC_CTLS_VNMI		0x00400000
+#define X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS	0x80000000
+#define X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC	0x00000001
+#define X86_VMX_FEATURE_PROC_CTLS2_EPT		0x00000002
+#define X86_VMX_FEATURE_PROC_CTLS2_VPID		0x00000020
+
+	u32 vmx_msr_low, vmx_msr_high, msr_ctl, msr_ctl2;
+
+	clear_cpu_cap(c, X86_FEATURE_TPR_SHADOW);
+	clear_cpu_cap(c, X86_FEATURE_VNMI);
+	clear_cpu_cap(c, X86_FEATURE_FLEXPRIORITY);
+	clear_cpu_cap(c, X86_FEATURE_EPT);
+	clear_cpu_cap(c, X86_FEATURE_VPID);
+
+	rdmsr(MSR_IA32_VMX_PROCBASED_CTLS, vmx_msr_low, vmx_msr_high);
+	msr_ctl = vmx_msr_high | vmx_msr_low;
+	if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW)
+		set_cpu_cap(c, X86_FEATURE_TPR_SHADOW);
+	if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_VNMI)
+		set_cpu_cap(c, X86_FEATURE_VNMI);
+	if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS) {
+		rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2,
+		      vmx_msr_low, vmx_msr_high);
+		msr_ctl2 = vmx_msr_high | vmx_msr_low;
+		if ((msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC) &&
+		    (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW))
+			set_cpu_cap(c, X86_FEATURE_FLEXPRIORITY);
+		if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_EPT)
+			set_cpu_cap(c, X86_FEATURE_EPT);
+		if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VPID)
+			set_cpu_cap(c, X86_FEATURE_VPID);
+	}
+}
+
+static void __cpuinit detect_virtcap(struct cpuinfo_x86 *c)
+{
+	if (cpu_has(c, X86_FEATURE_VMX))
+		detect_vmx_virtcap(c);
+}
+
 static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
 {
 	if (!have_cpuid_p())
@@ -613,6 +657,7 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
 
 	init_scattered_cpuid_features(c);
 	detect_nopl(c);
+	detect_virtcap(c);
 }
 
 /*
include/asm-x86/cpufeature.h +8 -1
index 7ac4d93..8d45690 100644
@@ -6,7 +6,7 @@
 
 #include <asm/required-features.h>
 
-#define NCAPINTS	8	/* N 32-bit words worth of info */
+#define NCAPINTS	9	/* N 32-bit words worth of info */
 
 /*
  * Note: If the comment begins with a quoted string, that string is used
@@ -150,6 +150,13 @@
  */
 #define X86_FEATURE_IDA		(7*32+ 0) /* Intel Dynamic Acceleration */
 
+/* Virtualization flags: Linux defined */
+#define X86_FEATURE_TPR_SHADOW  (8*32+ 0) /* Intel TPR Shadow */
+#define X86_FEATURE_VNMI        (8*32+ 1) /* Intel Virtual NMI */
+#define X86_FEATURE_FLEXPRIORITY (8*32+ 2) /* Intel FlexPriority */
+#define X86_FEATURE_EPT         (8*32+ 3) /* Intel Extended Page Table */
+#define X86_FEATURE_VPID        (8*32+ 4) /* Intel Virtual Processor ID */
+
 #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
 
 #include <linux/bitops.h>
Signature · 1 line
1.5.4.5
author
#1 lore raw

PATCH 1/2 x86: Move VMX MSRs to msr-index.h

In reply to Sheng Yang

They are hardware specific MSRs, and we would use them in virtualization feature detection later.

---
 arch/x86/kvm/vmx.h          |   15 ---------------
 include/asm-x86/msr-index.h |   16 ++++++++++++++++
 2 files changed, 16 insertions(+), 15 deletions(-)
arch/x86/kvm/vmx.h +0 -15
index 425a134..b32d4e5 100644
@@ -331,21 +331,6 @@ enum vmcs_field {
 
 #define AR_RESERVD_MASK 0xfffe0f00
 
-#define MSR_IA32_VMX_BASIC                      0x480
-#define MSR_IA32_VMX_PINBASED_CTLS              0x481
-#define MSR_IA32_VMX_PROCBASED_CTLS             0x482
-#define MSR_IA32_VMX_EXIT_CTLS                  0x483
-#define MSR_IA32_VMX_ENTRY_CTLS                 0x484
-#define MSR_IA32_VMX_MISC                       0x485
-#define MSR_IA32_VMX_CR0_FIXED0                 0x486
-#define MSR_IA32_VMX_CR0_FIXED1                 0x487
-#define MSR_IA32_VMX_CR4_FIXED0                 0x488
-#define MSR_IA32_VMX_CR4_FIXED1                 0x489
-#define MSR_IA32_VMX_VMCS_ENUM                  0x48a
-#define MSR_IA32_VMX_PROCBASED_CTLS2            0x48b
-#define MSR_IA32_VMX_EPT_VPID_CAP               0x48c
-
-#define MSR_IA32_FEATURE_CONTROL                0x3a
 #define MSR_IA32_FEATURE_CONTROL_LOCKED         0x1
 #define MSR_IA32_FEATURE_CONTROL_VMXON_ENABLED  0x4
 
include/asm-x86/msr-index.h +16 -0
index 3052f05..0bb4330 100644
@@ -176,6 +176,7 @@
 #define MSR_IA32_TSC			0x00000010
 #define MSR_IA32_PLATFORM_ID		0x00000017
 #define MSR_IA32_EBL_CR_POWERON		0x0000002a
+#define MSR_IA32_FEATURE_CONTROL        0x0000003a
 
 #define MSR_IA32_APICBASE		0x0000001b
 #define MSR_IA32_APICBASE_BSP		(1<<8)
@@ -310,4 +311,19 @@
 /* Geode defined MSRs */
 #define MSR_GEODE_BUSCONT_CONF0		0x00001900
 
+/* Intel VT MSRs */
+#define MSR_IA32_VMX_BASIC              0x00000480
+#define MSR_IA32_VMX_PINBASED_CTLS      0x00000481
+#define MSR_IA32_VMX_PROCBASED_CTLS     0x00000482
+#define MSR_IA32_VMX_EXIT_CTLS          0x00000483
+#define MSR_IA32_VMX_ENTRY_CTLS         0x00000484
+#define MSR_IA32_VMX_MISC               0x00000485
+#define MSR_IA32_VMX_CR0_FIXED0         0x00000486
+#define MSR_IA32_VMX_CR0_FIXED1         0x00000487
+#define MSR_IA32_VMX_CR4_FIXED0         0x00000488
+#define MSR_IA32_VMX_CR4_FIXED1         0x00000489
+#define MSR_IA32_VMX_VMCS_ENUM          0x0000048a
+#define MSR_IA32_VMX_PROCBASED_CTLS2    0x0000048b
+#define MSR_IA32_VMX_EPT_VPID_CAP       0x0000048c
+
 #endif /* ASM_X86__MSR_INDEX_H */
Signature · 1 line
1.5.4.5
#3 lore raw

Re: [PATCH 2/2] x86: Extended cpuinfo to show virtualization HW features

In reply to Sheng Yang
Quoted 72 lines · Sheng Yang

The hardware virtualization technology evolves very fast. But currently it's hard to tell if your CPU support a certain kind of HW technology without digging into the source code.

The patch add a new catagory in "flags" under /proc/cpuinfo. Now "flags" can indicate the (important) HW virtulization features the CPU supported as well.

Current implementation just cover Intel VMX side.

---
 arch/x86/kernel/cpu/common.c |   45 ++++++++++++++++++++++++++++++++++++++++++
 include/asm-x86/cpufeature.h |    9 +++++++-
 2 files changed, 53 insertions(+), 1 deletions(-)
arch/x86/kernel/cpu/common.c +44 -0
index f7c1964..01432e2 100644
@@ -581,6 +581,50 @@ static void __cpuinit detect_nopl(struct cpuinfo_x86 *c)
       }
 }
 
+static void __cpuinit detect_vmx_virtcap(struct cpuinfo_x86 *c)
+{
+       /* Intel VMX MSR indicated features */
+#define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW   0x00200000
+#define X86_VMX_FEATURE_PROC_CTLS_VNMI         0x00400000
+#define X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS     0x80000000
+#define X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC   0x00000001
+#define X86_VMX_FEATURE_PROC_CTLS2_EPT         0x00000002
+#define X86_VMX_FEATURE_PROC_CTLS2_VPID                0x00000020
+
+       u32 vmx_msr_low, vmx_msr_high, msr_ctl, msr_ctl2;
+
+       clear_cpu_cap(c, X86_FEATURE_TPR_SHADOW);
+       clear_cpu_cap(c, X86_FEATURE_VNMI);
+       clear_cpu_cap(c, X86_FEATURE_FLEXPRIORITY);
+       clear_cpu_cap(c, X86_FEATURE_EPT);
+       clear_cpu_cap(c, X86_FEATURE_VPID);
+
+       rdmsr(MSR_IA32_VMX_PROCBASED_CTLS, vmx_msr_low, vmx_msr_high);
+       msr_ctl = vmx_msr_high | vmx_msr_low;
+       if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW)
+               set_cpu_cap(c, X86_FEATURE_TPR_SHADOW);
+       if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_VNMI)
+               set_cpu_cap(c, X86_FEATURE_VNMI);
+       if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS) {
+               rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2,
+                     vmx_msr_low, vmx_msr_high);
+               msr_ctl2 = vmx_msr_high | vmx_msr_low;
+               if ((msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC) &&
+                   (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW))
+                       set_cpu_cap(c, X86_FEATURE_FLEXPRIORITY);
+               if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_EPT)
+                       set_cpu_cap(c, X86_FEATURE_EPT);
+               if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VPID)
+                       set_cpu_cap(c, X86_FEATURE_VPID);
+       }
+}
+
+static void __cpuinit detect_virtcap(struct cpuinfo_x86 *c)
+{
+       if (cpu_has(c, X86_FEATURE_VMX))
+               detect_vmx_virtcap(c);
+}
+
 static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
 {
       if (!have_cpuid_p())

arch/x86/kernel/cpu/common.c static void __cpuinit generic_identify(struct cpuinfo_x86 *c) · line 660

Quoted 4 lines
arch/x86/kernel/cpu/common.c +1 -0
@@ -613,6 +657,7 @@ static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
 
       init_scattered_cpuid_features(c);
       detect_nopl(c);
+       detect_virtcap(c);

it should go into intel_64.c and intel.c

YH

#4 lore raw

Re: [PATCH 2/2] x86: Extended cpuinfo to show virtualization HW features

Quoted 76 lines · On Tuesday 09 September 2008 15:52:26 Yinghai Lu wrote:
Quoted 75 lines · Sheng Yang

The hardware virtualization technology evolves very fast. But currently it's hard to tell if your CPU support a certain kind of HW technology without digging into the source code.

The patch add a new catagory in "flags" under /proc/cpuinfo. Now "flags" can indicate the (important) HW virtulization features the CPU supported as well.

Current implementation just cover Intel VMX side.

---
 arch/x86/kernel/cpu/common.c |   45
++++++++++++++++++++++++++++++++++++++++++ include/asm-x86/cpufeature.h |
   9 +++++++-
 2 files changed, 53 insertions(+), 1 deletions(-)
arch/x86/kernel/cpu/common.c +44 -0
index f7c1964..01432e2 100644
@@ -581,6 +581,50 @@ static void __cpuinit detect_nopl(struct cpuinfo_x86
 *c) }
 }
 
+static void __cpuinit detect_vmx_virtcap(struct cpuinfo_x86 *c)
+{
+       /* Intel VMX MSR indicated features */
+#define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW   0x00200000
+#define X86_VMX_FEATURE_PROC_CTLS_VNMI         0x00400000
+#define X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS     0x80000000
+#define X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC   0x00000001
+#define X86_VMX_FEATURE_PROC_CTLS2_EPT         0x00000002
+#define X86_VMX_FEATURE_PROC_CTLS2_VPID                0x00000020
+
+       u32 vmx_msr_low, vmx_msr_high, msr_ctl, msr_ctl2;
+
+       clear_cpu_cap(c, X86_FEATURE_TPR_SHADOW);
+       clear_cpu_cap(c, X86_FEATURE_VNMI);
+       clear_cpu_cap(c, X86_FEATURE_FLEXPRIORITY);
+       clear_cpu_cap(c, X86_FEATURE_EPT);
+       clear_cpu_cap(c, X86_FEATURE_VPID);
+
+       rdmsr(MSR_IA32_VMX_PROCBASED_CTLS, vmx_msr_low, vmx_msr_high);
+       msr_ctl = vmx_msr_high | vmx_msr_low;
+       if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW)
+               set_cpu_cap(c, X86_FEATURE_TPR_SHADOW);
+       if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_VNMI)
+               set_cpu_cap(c, X86_FEATURE_VNMI);
+       if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS) {
+               rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2,
+                     vmx_msr_low, vmx_msr_high);
+               msr_ctl2 = vmx_msr_high | vmx_msr_low;
+               if ((msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC) &&
+                   (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW))
+                       set_cpu_cap(c, X86_FEATURE_FLEXPRIORITY);
+               if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_EPT)
+                       set_cpu_cap(c, X86_FEATURE_EPT);
+               if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VPID)
+                       set_cpu_cap(c, X86_FEATURE_VPID);
+       }
+}
+
+static void __cpuinit detect_virtcap(struct cpuinfo_x86 *c)
+{
+       if (cpu_has(c, X86_FEATURE_VMX))
+               detect_vmx_virtcap(c);
+}
+
 static void __cpuinit generic_identify(struct cpuinfo_x86 *c)
 {
       if (!have_cpuid_p())
@@ -613,6 +657,7 @@ static void __cpuinit generic_identify(struct
 cpuinfo_x86 *c)
 
Quoted 7 lines

arch/x86/kernel/cpu/common.c static void __cpuinit generic_identify(struct cpuinfo_x86 *c) · line 660

Quoted 3 lines
arch/x86/kernel/cpu/common.c +1 -0
       init_scattered_cpuid_features(c);
       detect_nopl(c);
+       detect_virtcap(c);

it should go into intel_64.c and intel.c

YH

Yeah, I've considered that, but seems duplicate for both files? The feature detection code is the same. Any way to merge them?

Thanks!

Signature · 2 lines
regards
Yang, Sheng
#5 lore raw

Re: [PATCH 2/2] x86: Extended cpuinfo to show virtualization HW features

Quoted 7 lines · Sheng
Quoted 4 lines

it should go into intel_64.c and intel.c

YH

Yeah, I've considered that, but seems duplicate for both files? The feature detection code is the same. Any way to merge them?

You could add another file (intel-vt.c) and #include or link it from both intel.c and intel_64.c.

Signature · 1 line
error compiling committee.c: too many arguments to function
#11 lore raw

Re: [PATCH 2/2] x86: Extended cpuinfo to show virtualization HW features

In reply to Sheng Yang
Quoted 10 lines · Sheng Yang

The hardware virtualization technology evolves very fast. But currently it's hard to tell if your CPU support a certain kind of HW technology without digging into the source code.

The patch add a new catagory in "flags" under /proc/cpuinfo. Now "flags" can indicate the (important) HW virtulization features the CPU supported as well.

Current implementation just cover Intel VMX side.

I'm missing the strings that go into /proc/cpuinfo?

Signature · 1 line
error compiling committee.c: too many arguments to function
#12 lore raw

Re: [PATCH 2/2] x86: Extended cpuinfo to show virtualization HW features

Quoted 3 lines · Avi Kivity

I'm missing the strings that go into /proc/cpuinfo?

Those are autogenerated now.

-hpa

#6 lore raw

Re: [PATCH 2/2] x86: Extended cpuinfo to show virtualization HW features

In reply to Yang, Sheng
Quoted 4 lines · Sheng

Yeah, I've considered that, but seems duplicate for both files? The feature detection code is the same. Any way to merge them?

just merged intel_64.c into intel.c...

YH

#7 lore raw

Re: [PATCH 2/2] x86: Extended cpuinfo to show virtualization HW features

Quoted 6 lines · Yinghai Lu
Quoted 3 lines · Sheng

Yeah, I've considered that, but seems duplicate for both files? The feature detection code is the same. Any way to merge them?

just merged intel_64.c into intel.c...

it's all in tip/master:

http://people.redhat.com/mingo/tip.git/README

would it be possible to get a patchset ontop of that?

Ingo

#8 lore raw

Re: [PATCH 2/2] x86: Extended cpuinfo to show virtualization HW features

Quoted 7 lines · On Wednesday 10 September 2008 16:04:21 Ingo Molnar wrote:
Quoted 5 lines · Yinghai Lu
Quoted 2 lines · Sheng

Yeah, I've considered that, but seems duplicate for both files? The feature detection code is the same. Any way to merge them?

just merged intel_64.c into intel.c...

Quoted 7 lines

it's all in tip/master:

http://people.redhat.com/mingo/tip.git/README

would it be possible to get a patchset ontop of that?

Ingo

So quick....
Thanks Yinghai!

Would send the updated patch soon.

Signature · 2 lines
regards
Yang, Sheng
author
#10 lore raw

PATCH 2/2 x86: Extended "flags" to show virtualization HW feature in /proc/cpuinfo

In reply to Ingo Molnar

The hardware virtualization technology evolves very fast. But currently it's hard to tell if your CPU support a certain kind of HW technology without digging into the source code.

The patch add a new catagory in "flags" under /proc/cpuinfo. Now "flags" can indicate the (important) HW virtulization features the CPU supported as well.

Current implementation just cover Intel VMX side.

---
 arch/x86/kernel/cpu/intel.c  |   41 +++++++++++++++++++++++++++++++++++++++++
 include/asm-x86/cpufeature.h |    9 ++++++++-
 2 files changed, 49 insertions(+), 1 deletions(-)
arch/x86/kernel/cpu/intel.c +41 -0
index 5f76bf1..99468db 100644
@@ -196,6 +196,44 @@ static int __cpuinit intel_num_cpu_cores(struct cpuinfo_x86 *c)
 		return 1;
 }
 
+static void __cpuinit detect_vmx_virtcap(struct cpuinfo_x86 *c)
+{
+	/* Intel VMX MSR indicated features */
+#define X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW	0x00200000
+#define X86_VMX_FEATURE_PROC_CTLS_VNMI		0x00400000
+#define X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS	0x80000000
+#define X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC	0x00000001
+#define X86_VMX_FEATURE_PROC_CTLS2_EPT		0x00000002
+#define X86_VMX_FEATURE_PROC_CTLS2_VPID		0x00000020
+
+	u32 vmx_msr_low, vmx_msr_high, msr_ctl, msr_ctl2;
+
+	clear_cpu_cap(c, X86_FEATURE_TPR_SHADOW);
+	clear_cpu_cap(c, X86_FEATURE_VNMI);
+	clear_cpu_cap(c, X86_FEATURE_FLEXPRIORITY);
+	clear_cpu_cap(c, X86_FEATURE_EPT);
+	clear_cpu_cap(c, X86_FEATURE_VPID);
+
+	rdmsr(MSR_IA32_VMX_PROCBASED_CTLS, vmx_msr_low, vmx_msr_high);
+	msr_ctl = vmx_msr_high | vmx_msr_low;
+	if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW)
+		set_cpu_cap(c, X86_FEATURE_TPR_SHADOW);
+	if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_VNMI)
+		set_cpu_cap(c, X86_FEATURE_VNMI);
+	if (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_2ND_CTLS) {
+		rdmsr(MSR_IA32_VMX_PROCBASED_CTLS2,
+		      vmx_msr_low, vmx_msr_high);
+		msr_ctl2 = vmx_msr_high | vmx_msr_low;
+		if ((msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VIRT_APIC) &&
+		    (msr_ctl & X86_VMX_FEATURE_PROC_CTLS_TPR_SHADOW))
+			set_cpu_cap(c, X86_FEATURE_FLEXPRIORITY);
+		if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_EPT)
+			set_cpu_cap(c, X86_FEATURE_EPT);
+		if (msr_ctl2 & X86_VMX_FEATURE_PROC_CTLS2_VPID)
+			set_cpu_cap(c, X86_FEATURE_VPID);
+	}
+}
+
 static void __cpuinit init_intel(struct cpuinfo_x86 *c)
 {
 	unsigned int l2 = 0;
@@ -289,6 +327,9 @@ static void __cpuinit init_intel(struct cpuinfo_x86 *c)
 
 	/* Work around errata */
 	srat_detect_node();
+
+	if (cpu_has(c, X86_FEATURE_VMX))
+		detect_vmx_virtcap(c);
 }
 
 #ifdef CONFIG_X86_32
include/asm-x86/cpufeature.h +8 -1
index 7ac4d93..8d45690 100644
@@ -6,7 +6,7 @@
 
 #include <asm/required-features.h>
 
-#define NCAPINTS	8	/* N 32-bit words worth of info */
+#define NCAPINTS	9	/* N 32-bit words worth of info */
 
 /*
  * Note: If the comment begins with a quoted string, that string is used
@@ -150,6 +150,13 @@
  */
 #define X86_FEATURE_IDA		(7*32+ 0) /* Intel Dynamic Acceleration */
 
+/* Virtualization flags: Linux defined */
+#define X86_FEATURE_TPR_SHADOW  (8*32+ 0) /* Intel TPR Shadow */
+#define X86_FEATURE_VNMI        (8*32+ 1) /* Intel Virtual NMI */
+#define X86_FEATURE_FLEXPRIORITY (8*32+ 2) /* Intel FlexPriority */
+#define X86_FEATURE_EPT         (8*32+ 3) /* Intel Extended Page Table */
+#define X86_FEATURE_VPID        (8*32+ 4) /* Intel Virtual Processor ID */
+
 #if defined(__KERNEL__) && !defined(__ASSEMBLY__)
 
 #include <linux/bitops.h>
Signature · 1 line
1.5.4.5
#9 lore raw

Re: [PATCH 2/2] x86: Extended cpuinfo to show virtualization HW features

In reply to Yang, Sheng
Quoted 10 lines · Yang, Sheng
Quoted 9 lines · On Wednesday 10 September 2008 16:04:21 Ingo Molnar wrote:
Quoted 5 lines · Yinghai Lu
Quoted 2 lines · Sheng

Yeah, I've considered that, but seems duplicate for both files? The feature detection code is the same. Any way to merge them?

just merged intel_64.c into intel.c...

it's all in tip/master:

Quoted 7 lines
Quoted 5 lines

http://people.redhat.com/mingo/tip.git/README

would it be possible to get a patchset ontop of that?

Ingo

So quick....

hey, wasting time is something we really suck at ;-)

Quoted 3 lines

Thanks Yinghai!

Would send the updated patch soon.

got it, thanks. I've applied patch #1 and updated patch #2 to the tip/x86/unify-cpu-detect topic tree:

e38e05a: x86: extended "flags" to show virtualization HW feature in /proc/cpuinfo 315a655: x86: move VMX MSRs to msr-index.h

Ingo