[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20111004095726.GF30105@redhat.com>
Date: Tue, 4 Oct 2011 11:57:26 +0200
From: Gleb Natapov <gleb@...hat.com>
To: Avi Kivity <avi@...hat.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
joerg.roedel@....com, mingo@...e.hu, a.p.zijlstra@...llo.nl
Subject: Re: [PATCH 7/9] KVM, VMX: add support for switching of
PERF_GLOBAL_CTRL
On Tue, Oct 04, 2011 at 11:32:03AM +0200, Avi Kivity wrote:
> On 10/03/2011 03:49 PM, Gleb Natapov wrote:
> >Some cpus have special support for switching PERF_GLOBAL_CTRL msr.
> >Add logic to detect if such support exists and works properly and extend
> >msr switching code to use it if available. Also extend number of generic
> >msr switching entries to 8.
> >
> >
> > static DECLARE_BITMAP(vmx_vpid_bitmap, VMX_NR_VPIDS);
> > static DEFINE_SPINLOCK(vmx_vpid_lock);
> >@@ -1195,10 +1196,29 @@ static void clear_atomic_switch_msr(struct vcpu_vmx *vmx, unsigned msr)
> > {
> > unsigned i;
> > struct msr_autoload *m =&vmx->msr_autoload;
> >+ u32 entry_load, exit_load;
> >+ bool done = false;
> >
> >- if (msr == MSR_EFER&& cpu_has_load_ia32_efer) {
> >- vmcs_clear_bits(VM_ENTRY_CONTROLS, VM_ENTRY_LOAD_IA32_EFER);
> >- vmcs_clear_bits(VM_EXIT_CONTROLS, VM_EXIT_LOAD_IA32_EFER);
> >+ switch (msr) {
> >+ case MSR_EFER:
> >+ if (cpu_has_load_ia32_efer) {
> >+ entry_load = VM_ENTRY_LOAD_IA32_EFER;
> >+ exit_load = VM_EXIT_LOAD_IA32_EFER;
> >+ done = true;
> >+ }
> >+ break;
> >+ case MSR_CORE_PERF_GLOBAL_CTRL:
> >+ if (cpu_has_load_perf_global_ctrl) {
> >+ entry_load = VM_ENTRY_LOAD_IA32_PERF_GLOBAL_CTRL;
> >+ exit_load = VM_EXIT_LOAD_IA32_PERF_GLOBAL_CTRL;
> >+ done = true;
> >+ }
> >+ break;
> >+ }
> >+
> >+ if (done) {
> >+ vmcs_clear_bits(VM_ENTRY_CONTROLS, entry_load);
> >+ vmcs_clear_bits(VM_EXIT_CONTROLS, exit_load);
> > return;
> > }
> >
> >
>
> This is ugly. How about
>
> if (msr == MSR_EFER && cpu_has_load_ia32_efer) {
> clear_atomic_switch_msr_special(VM_ENTRY_LOAD_IA32_EFER,
> VM_EXIT_LOAD_IA32_EFER);
> return;
> }
>
> avoids the fake 'done' variable.
>
OK.
--
Gleb.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists