linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexander Shishkin <alexander.shishkin@linux.intel.com>
To: Sean Christopherson <seanjc@google.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Ingo Molnar <mingo@redhat.com>,
	linux-kernel@vger.kernel.org, Jiri Olsa <jolsa@kernel.org>,
	kvm@vger.kernel.org, Artem Kashkanov <artem.kashkanov@intel.com>,
	alexander.shishkin@linux.intel.com
Subject: Re: [PATCH] kvm/x86: Fix PT "host mode"
Date: Mon, 23 Aug 2021 20:11:47 +0300	[thread overview]
Message-ID: <87zgt8hyr0.fsf@ashishki-desk.ger.corp.intel.com> (raw)
In-Reply-To: <YSPJ8/PgcFRnp4N9@google.com>

Sean Christopherson <seanjc@google.com> writes:

> On Mon, Aug 23, 2021, Alexander Shishkin wrote:
>
>> Signed-off-by: Alexander Shishkin <alexander.shishkin@linux.intel.com>
>> Fixes: ff9d07a0e7ce7 ("KVM: Implement perf callbacks for guest sampling")
>
> This should be another clue that the fix isn't correct.
> That patch is from 2010,

Right, this should have been 8479e04e7d6b1 ("KVM: x86: Inject PMI for
KVM guest") instead.

> Intel PT was announced in 2013 and merged in 2019.

Technically, 2019 is when kvm started breaking host PT.

> This is not remotely correct.  vmx.c's "pt_mode", which is queried via this path,
> is modified by hardware_setup(), a.k.a. kvm_x86_ops.hardware_setup(), which runs
> _after_ this code.  And as alluded to above, these are generic perf callbacks,
> installing them if and only if Intel PT is enabled in a specific mode completely
> breaks "regular" perf.

I see your point, the callchain code will catch fire.

> I'll post a small series, there's a bit of code massage needed to fix this
> properly.  The PMI handler can also be optimized to avoid a retpoline when PT is
> not exposed to the guest.

The actual PMU handler also needs to know that kvm won't be needing it
so it can call the regular PT handler.

One could unset cbs->handle_intel_pt_intr() or one could have it return
different things depending on whether it was actually taken in kvm. But
both are rather disgusting.

Regards,
--
Alex

      reply	other threads:[~2021-08-23 17:11 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-23 13:42 [PATCH] kvm/x86: Fix PT "host mode" Alexander Shishkin
2021-08-23 16:16 ` Sean Christopherson
2021-08-23 17:11   ` Alexander Shishkin [this message]

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=87zgt8hyr0.fsf@ashishki-desk.ger.corp.intel.com \
    --to=alexander.shishkin@linux.intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=artem.kashkanov@intel.com \
    --cc=jolsa@kernel.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=seanjc@google.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;
as well as URLs for NNTP newsgroup(s).