LKML Archive on
help / color / mirror / Atom feed
From: Alexander Shishkin <>
To: Sean Christopherson <>
Cc: Paolo Bonzini <>,
	Peter Zijlstra <>,
	Arnaldo Carvalho de Melo <>,
	Ingo Molnar <>,, Jiri Olsa <>,, Artem Kashkanov <>,
Subject: Re: [PATCH] kvm/x86: Fix PT "host mode"
Date: Mon, 23 Aug 2021 20:11:47 +0300	[thread overview]
Message-ID: <> (raw)
In-Reply-To: <YSPJ8/>

Sean Christopherson <> writes:

> On Mon, Aug 23, 2021, Alexander Shishkin wrote:
>> Signed-off-by: Alexander Shishkin <>
>> 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.


      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 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \
    --subject='Re: [PATCH] kvm/x86: Fix PT "host mode"' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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).