From: Sean Christopherson <seanjc@google.com>
To: "Xu, Yanfei" <yanfei.xu@intel.com>
Cc: "pbonzini@redhat.com" <pbonzini@redhat.com>,
"vkuznets@redhat.com" <vkuznets@redhat.com>,
"wanpengli@tencent.com" <wanpengli@tencent.com>,
"jmattson@google.com" <jmattson@google.com>,
"joro@8bytes.org" <joro@8bytes.org>,
"tglx@linutronix.de" <tglx@linutronix.de>,
"mingo@redhat.com" <mingo@redhat.com>,
"bp@alien8.de" <bp@alien8.de>,
"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
"x86@kernel.org" <x86@kernel.org>,
"kvm@vger.kernel.org" <kvm@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"Wang, Wei W" <wei.w.wang@intel.com>,
"Liang, Kan" <kan.liang@intel.com>
Subject: Re: [PATCH] KVM: x86: Fix the intel_pt PMI handling wrongly considered from guest
Date: Fri, 20 May 2022 16:31:56 +0000 [thread overview]
Message-ID: <YofCfNsl6O45hYr0@google.com> (raw)
In-Reply-To: <DM6PR11MB41380A9DD32D6542CBC3A90BF0D39@DM6PR11MB4138.namprd11.prod.outlook.com>
Please don't top-post.
On Fri, May 20, 2022, Xu, Yanfei wrote:
> From: Sean Christopherson <seanjc@google.com>
> On Mon, May 16, 2022, Yanfei Xu wrote:
> > diff --git a/arch/x86/include/asm/kvm_host.h
> > b/arch/x86/include/asm/kvm_host.h index 4ff36610af6a..308cf19f123d
> > 100644
> > --- a/arch/x86/include/asm/kvm_host.h
> > +++ b/arch/x86/include/asm/kvm_host.h
> > @@ -1582,8 +1582,14 @@ static inline int kvm_arch_flush_remote_tlb(struct kvm *kvm)
> > return -ENOTSUPP;
> > }
> >
> > +enum kvm_intr_type {
> > + /* Values are arbitrary, but must be non-zero. */
> > + KVM_HANDLING_IRQ = 1,
> > + KVM_HANDLING_NMI,
> > +};
> > +
> > #define kvm_arch_pmi_in_guest(vcpu) \
> > - ((vcpu) && (vcpu)->arch.handling_intr_from_guest)
> > + ((vcpu) && (vcpu)->arch.handling_intr_from_guest ==
> > +KVM_HANDLING_NMI)
>
> My understanding is that this isn't correct as a general change, as perf
> events can use regular IRQs in some cases. See commit dd60d217062f4 ("KVM:
> x86: Fix perf timer mode IP reporting").
>
> I assume there's got to be a way to know which mode perf is using, e.g. we
> should be able to make this look something like:
>
> ((vcpu) && (vcpu)->arch.handling_intr_from_guest == kvm_pmi_vector)
> Hi Sean,
> You are right, the change of kvm_arch_pmi_in_guest is incorrect, because it should cover two cases of PMI.
> For the PMI of intel pt, it certainly is the NMI PMI. So how about fixing it like below?
Yep, that works. I did enough spelunking to figure out how we can fix the generic
issue, but it's per-event and requires a decent amount of plumbing in perf.
perf_guest_handle_intel_pt_intr() doesn't bother with perf_guest_state() since it's
such a specialized event, so fixing this in vmx_handle_intel_pt_intr() would likely
be the long-term solution even if/when the generic case is fixed.
next prev parent reply other threads:[~2022-05-20 16:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-15 17:16 [PATCH] KVM: x86: Fix the intel_pt PMI handling wrongly considered from guest Yanfei Xu
2022-05-16 13:58 ` Sean Christopherson
2022-05-18 10:01 ` Yanfei Xu
2022-05-20 9:54 ` Xu, Yanfei
2022-05-20 16:31 ` Sean Christopherson [this message]
2022-05-21 4:31 ` Xu, Yanfei
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=YofCfNsl6O45hYr0@google.com \
--to=seanjc@google.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kan.liang@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=wei.w.wang@intel.com \
--cc=x86@kernel.org \
--cc=yanfei.xu@intel.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