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

Previous thread: Launching MyEverydayPage.com (Ver 2.0) by My Everyday Page on Tuesday, September 9, 2008 - 4:01 am. (1 message)

Next thread: [PATCH] seccomp: drop now bogus dependency on PROC_FS by Alexey Dobriyan on Tuesday, September 9, 2008 - 12:01 am. (2 messages)
From: Sheng Yang
Date: Monday, September 8, 2008 - 11:54 pm

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
--

From: Sheng Yang
Date: Monday, September 8, 2008 - 11:54 pm

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.

Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
 arch/x86/kernel/cpu/common.c |   45 ++++++++++++++++++++++++++++++++++++++++++
 include/asm-x86/cpufeature.h |    9 +++++++-
 2 files changed, 53 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index f7c1964..01432e2 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -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, ...
From: Yinghai Lu
Date: Tuesday, September 9, 2008 - 12:52 am

it should go into intel_64.c and intel.c

YH
--

From: Yang, Sheng
Date: Tuesday, September 9, 2008 - 1:05 am

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

Thanks!
-- 
regards
Yang, Sheng
--

From: Avi Kivity
Date: Tuesday, September 9, 2008 - 6:23 am

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

-- 
error compiling committee.c: too many arguments to function

--

From: Yinghai Lu
Date: Tuesday, September 9, 2008 - 10:45 am

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

YH
--

From: Ingo Molnar
Date: Wednesday, September 10, 2008 - 1:04 am

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
--

From: Yang, Sheng
Date: Wednesday, September 10, 2008 - 3:42 am

So quick.... 
Thanks Yinghai!

Would send the updated patch soon.
-- 
regards
Yang, Sheng
--

From: Ingo Molnar
Date: Wednesday, September 10, 2008 - 5:02 am

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
--

From: Sheng Yang
Date: Wednesday, September 10, 2008 - 3:53 am

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.

Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
 arch/x86/kernel/cpu/intel.c  |   41 +++++++++++++++++++++++++++++++++++++++++
 include/asm-x86/cpufeature.h |    9 ++++++++-
 2 files changed, 49 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index 5f76bf1..99468db 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -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, ...
From: Avi Kivity
Date: Tuesday, September 9, 2008 - 6:26 am

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

-- 
error compiling committee.c: too many arguments to function

--

From: H. Peter Anvin
Date: Tuesday, September 9, 2008 - 8:50 am

Those are autogenerated now.

	-hpa
--

From: Sheng Yang
Date: Monday, September 8, 2008 - 11:54 pm

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

Signed-off-by: Sheng Yang <sheng.yang@intel.com>
---
 arch/x86/kvm/vmx.h          |   15 ---------------
 include/asm-x86/msr-index.h |   16 ++++++++++++++++
 2 files changed, 16 insertions(+), 15 deletions(-)

diff --git a/arch/x86/kvm/vmx.h b/arch/x86/kvm/vmx.h
index 425a134..b32d4e5 100644
--- a/arch/x86/kvm/vmx.h
+++ b/arch/x86/kvm/vmx.h
@@ -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
 
diff --git a/include/asm-x86/msr-index.h b/include/asm-x86/msr-index.h
index 3052f05..0bb4330 100644
--- a/include/asm-x86/msr-index.h
+++ b/include/asm-x86/msr-index.h
@@ -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       ...
Previous thread: Launching MyEverydayPage.com (Ver 2.0) by My Everyday Page on Tuesday, September 9, 2008 - 4:01 am. (1 message)

Next thread: [PATCH] seccomp: drop now bogus dependency on PROC_FS by Alexey Dobriyan on Tuesday, September 9, 2008 - 12:01 am. (2 messages)