From: Sean Christopherson <seanjc@google.com>
To: Like Xu <like.xu.linux@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>,
Mark Rutland <mark.rutland@arm.com>, Jiri Olsa <jolsa@redhat.com>,
Namhyung Kim <namhyung@kernel.org>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, Artem Kashkanov <artem.kashkanov@intel.com>,
Arnaldo Carvalho de Melo <acme@kernel.org>,
Paolo Bonzini <pbonzini@redhat.com>,
Ingo Molnar <mingo@redhat.com>,
Peter Zijlstra <peterz@infradead.org>
Subject: Re: [PATCH 2/3] KVM: x86: Register Processor Trace interrupt hook iff PT enabled in guest
Date: Wed, 25 Aug 2021 14:59:57 +0000 [thread overview]
Message-ID: <YSZa7dkw6t7yN6vL@google.com> (raw)
In-Reply-To: <3021c1cc-a4eb-e3ab-d6b7-558cbaefd03b@gmail.com>
On Wed, Aug 25, 2021, Like Xu wrote:
> On 24/8/2021 3:37 am, Sean Christopherson wrote:
> > @@ -11061,6 +11061,8 @@ int kvm_arch_hardware_setup(void *opaque)
> > memcpy(&kvm_x86_ops, ops->runtime_ops, sizeof(kvm_x86_ops));
> > kvm_ops_static_call_update();
> > + if (ops->intel_pt_intr_in_guest && ops->intel_pt_intr_in_guest())
> > + kvm_guest_cbs.handle_intel_pt_intr = kvm_handle_intel_pt_intr;
>
> Emm, it's still buggy.
>
> The guest "unknown NMI" from the host Intel PT can still be reproduced
> after the following operation:
>
> rmmod kvm_intel
> modprobe kvm-intel pt_mode=1 ept=1
> rmmod kvm_intel
> modprobe kvm-intel pt_mode=1 ept=0
>
> Since the handle_intel_pt_intr is not reset to NULL in kvm_arch_hardware_unsetup(),
> and the previous function pointer still exists in the generic KVM data structure.
Ooof, good catch. Any preference between nullifying handle_intel_pt_intr in
setup() vs. unsetup()? I think I like the idea of "unwinding" during unsetup(),
even though it splits the logic a bit.
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index b5ade47dad9c..ffc6c2d73508 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -11093,6 +11093,7 @@ int kvm_arch_hardware_setup(void *opaque)
void kvm_arch_hardware_unsetup(void)
{
perf_unregister_guest_info_callbacks(&kvm_guest_cbs);
+ kvm_guest_cbs.handle_intel_pt_intr = NULL;
static_call(kvm_x86_hardware_unsetup)();
}
vs.
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index b5ade47dad9c..462aa7a360e9 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -11063,6 +11063,8 @@ int kvm_arch_hardware_setup(void *opaque)
if (ops->intel_pt_intr_in_guest && ops->intel_pt_intr_in_guest())
kvm_guest_cbs.handle_intel_pt_intr = kvm_handle_intel_pt_intr;
+ else
+ kvm_guest_cbs.handle_intel_pt_intr = NULL;
perf_register_guest_info_callbacks(&kvm_guest_cbs);
if (!kvm_cpu_cap_has(X86_FEATURE_XSAVES))
> But I have to say that this fix is much better than the one I proposed [1].
>
> [1] https://lore.kernel.org/lkml/20210514084436.848396-1-like.xu@linux.intel.com/
>
> > perf_register_guest_info_callbacks(&kvm_guest_cbs);
> > if (!kvm_cpu_cap_has(X86_FEATURE_XSAVES))
> >
next prev parent reply other threads:[~2021-08-25 15:00 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-23 19:37 [PATCH 0/3] perf/x86/intel: KVM: PT intr handler fix and cleanup Sean Christopherson
2021-08-23 19:37 ` [PATCH 1/3] KVM: x86: Register perf callbacks after calling vendor's hardware_setup() Sean Christopherson
2021-08-23 19:37 ` [PATCH 2/3] KVM: x86: Register Processor Trace interrupt hook iff PT enabled in guest Sean Christopherson
2021-08-24 7:28 ` Alexander Shishkin
2021-08-24 14:11 ` Sean Christopherson
2021-08-25 7:24 ` Like Xu
2021-08-25 14:59 ` Sean Christopherson [this message]
2021-08-25 20:09 ` Sean Christopherson
2021-08-23 19:37 ` [PATCH 3/3] perf/x86/intel: Fold current_vcpu check into KVM's PT intr handler Sean Christopherson
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=YSZa7dkw6t7yN6vL@google.com \
--to=seanjc@google.com \
--cc=acme@kernel.org \
--cc=alexander.shishkin@linux.intel.com \
--cc=artem.kashkanov@intel.com \
--cc=jmattson@google.com \
--cc=jolsa@redhat.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=like.xu.linux@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-perf-users@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=mingo@redhat.com \
--cc=namhyung@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peterz@infradead.org \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.