From: "Yang, Sheng" <sheng.yang@intel.com>
To: "Yinghai Lu" <yhlu.kernel@gmail.com>
Cc: "Ingo Molnar" <mingo@elte.hu>,
linux-kernel@vger.kernel.org, "Avi Kivity" <avi@qumranet.com>,
"Andi Kleen" <ak@linux.intel.com>,
"H. Peter Anvin" <hpa@zytor.com>,
"Thomas Gleixner" <tglx@linutronix.de>
Subject: Re: [PATCH 2/2] x86: Extended cpuinfo to show virtualization HW features
Date: Tue, 9 Sep 2008 16:05:41 +0800 [thread overview]
Message-ID: <200809091605.42121.sheng.yang@intel.com> (raw)
In-Reply-To: <86802c440809090052t2e626ce8h4fda865b8cbce00b@mail.gmail.com>
On Tuesday 09 September 2008 15:52:26 Yinghai Lu wrote:
> On Mon, Sep 8, 2008 at 11:54 PM, Sheng Yang <sheng.yang@intel.com> wrote:
> > 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, 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);
>
> 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!
--
regards
Yang, Sheng
next prev parent reply other threads:[~2008-09-09 8:02 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-09 6:54 [PATCH 0/2] Extend "flags" to contain HW virtualization info Sheng Yang
2008-09-09 6:54 ` [PATCH 1/2] x86: Move VMX MSRs to msr-index.h Sheng Yang
2008-09-09 6:54 ` [PATCH 2/2] x86: Extended cpuinfo to show virtualization HW features Sheng Yang
2008-09-09 7:52 ` Yinghai Lu
2008-09-09 8:05 ` Yang, Sheng [this message]
2008-09-09 13:23 ` Avi Kivity
2008-09-09 17:45 ` Yinghai Lu
2008-09-10 8:04 ` Ingo Molnar
2008-09-10 10:42 ` Yang, Sheng
2008-09-10 12:02 ` Ingo Molnar
2008-09-10 10:53 ` [PATCH 2/2] x86: Extended "flags" to show virtualization HW feature in /proc/cpuinfo Sheng Yang
2008-09-09 13:26 ` [PATCH 2/2] x86: Extended cpuinfo to show virtualization HW features Avi Kivity
2008-09-09 15:50 ` H. Peter Anvin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200809091605.42121.sheng.yang@intel.com \
--to=sheng.yang@intel.com \
--cc=ak@linux.intel.com \
--cc=avi@qumranet.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=tglx@linutronix.de \
--cc=yhlu.kernel@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox