From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ingo Molnar Subject: Re: [PATCH] perf/x86/intel/pt: Don't die on VMXON Date: Wed, 13 Apr 2016 11:49:51 +0200 Message-ID: <20160413094951.GC6430@gmail.com> References: <1459527854-5899-1-git-send-email-alexander.shishkin@linux.intel.com> <20160406085227.GO3448@twins.programming.kicks-ass.net> <87vb3v56x2.fsf@ashishki-desk.ger.corp.intel.com> <20160406115215.GK2906@worktop> <871t6izv9z.fsf@ashishki-desk.ger.corp.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: Peter Zijlstra , Gleb Natapov , Paolo Bonzini , x86@kernel.org, kvm@vger.kernel.org, Ingo Molnar , linux-kernel@vger.kernel.org, tglx@linutronix.de, hpa@zytor.com, Arnaldo Carvalho de Melo , Borislav Petkov To: Alexander Shishkin Return-path: Received: from mail-wm0-f67.google.com ([74.125.82.67]:35030 "EHLO mail-wm0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030249AbcDMJt4 (ORCPT ); Wed, 13 Apr 2016 05:49:56 -0400 Content-Disposition: inline In-Reply-To: <871t6izv9z.fsf@ashishki-desk.ger.corp.intel.com> Sender: kvm-owner@vger.kernel.org List-ID: * Alexander Shishkin wrote: > Signed-off-by: Alexander Shishkin > --- > arch/x86/events/intel/pt.c | 75 +++++++++++++++++++++++++++++++++------ > arch/x86/events/intel/pt.h | 2 ++ > arch/x86/include/asm/perf_event.h | 4 +++ > arch/x86/kvm/vmx.c | 4 +++ > 4 files changed, 74 insertions(+), 11 deletions(-) > +void intel_pt_vmx(int on) > +{ > + struct pt *pt = this_cpu_ptr(&pt_ctx); > + struct perf_event *event; > + unsigned long flags; > + > + /* PT plays nice with VMX, do nothing */ > + if (pt_pmu.vmx) > + return; > + > + /* > + * VMXON will clear RTIT_CTL.TraceEn; we need to make > + * sure to not try to set it while VMX is on. Disable > + * interrupts to avoid racing with pmu callbacks; > + * concurrent PMI should be handled fine. > + */ > + local_irq_save(flags); > + WRITE_ONCE(pt->vmx_on, on); > + > + if (on) { > + /* prevent pt_config_stop() from writing RTIT_CTL */ > + event = pt->handle.event; > + if (event) > + event->hw.config = 0; > + } > + local_irq_restore(flags); > +} > +EXPORT_SYMBOL_GPL(intel_pt_vmx); > --- a/arch/x86/kvm/vmx.c > +++ b/arch/x86/kvm/vmx.c > @@ -3075,6 +3075,8 @@ static __init int vmx_disabled_by_bios(void) > > static void kvm_cpu_vmxon(u64 addr) > { > + intel_pt_vmx(1); > + > asm volatile (ASM_VMX_VMXON_RAX > : : "a"(&addr), "m"(addr) > : "memory", "cc"); > @@ -3144,6 +3146,8 @@ static void vmclear_local_loaded_vmcss(void) > static void kvm_cpu_vmxoff(void) > { > asm volatile (__ex(ASM_VMX_VMXOFF) : : : "cc"); > + > + intel_pt_vmx(0); > } Yeah so the name intel_pt_vmx() is pretty information-free because it has no verb, only nouns - please name new functions descriptively to after what they do! Something like intel_pt_set_vmx_state() or so? Thanks, Ingo