From: Sean Christopherson <seanjc@google.com>
To: Joao Martins <joao.m.martins@oracle.com>
Cc: iommu@lists.linux.dev, Joerg Roedel <joro@8bytes.org>,
Suravee Suthikulpanit <suravee.suthikulpanit@amd.com>,
Vasant Hegde <vasant.hegde@amd.com>,
Will Deacon <will@kernel.org>,
Robin Murphy <robin.murphy@arm.com>,
Maxim Levitsky <mlevitsk@redhat.com>,
Alejandro Jimenez <alejandro.j.jimenez@oracle.com>,
kvm@vger.kernel.org
Subject: Re: [PATCH v2 1/2] iommu/amd: Don't block updates to GATag if guest mode is on
Date: Tue, 28 Mar 2023 08:20:49 -0700 [thread overview]
Message-ID: <ZCMF0ReWqG0Q7Zna@google.com> (raw)
In-Reply-To: <cde77b1f-e612-2a9e-e437-8892f7f1fde9@oracle.com>
On Tue, Mar 28, 2023, Joao Martins wrote:
> [I was out sick, hence the delay]
>
> On 24/03/2023 14:31, Sean Christopherson wrote:
> > On Thu, Mar 16, 2023, Joao Martins wrote:
> >> On 16/03/2023 21:01, Sean Christopherson wrote:
> >>> Is there any harm in giving deactivate the same treatement? If the worst case
> >>> scenario is a few wasted cycles, having symmetric flows and eliminating benign
> >>> bugs seems like a worthwhile tradeoff (assuming this is indeed a relatively slow
> >>> path like I think it is).
> >>>
> >>
> >> I wanna say there's no harm, but initially I had such a patch, and on testing it
> >> broke the classic interrupt remapping case but I didn't investigate further --
> >> my suspicion is that the only case that should care is the updates (not the
> >> actual deactivation of guest-mode).
> >
> > Ugh, I bet this is due to KVM invoking irq_set_vcpu_affinity() with garbage when
> > AVIC is enabled, but KVM can't use a posted interrupt due to the how the IRQ is
> > configured. I vaguely recall a bug report about uninitialized data in "pi" being
> > consumed, but I can't find it at the moment.
> >
> > if (!get_pi_vcpu_info(kvm, e, &vcpu_info, &svm) && set &&
> > kvm_vcpu_apicv_active(&svm->vcpu)) {
> >
> > ...
> >
> > } else {
> > /* Use legacy mode in IRTE */
> > struct amd_iommu_pi_data pi;
> >
> > /**
> > * Here, pi is used to:
> > * - Tell IOMMU to use legacy mode for this interrupt.
> > * - Retrieve ga_tag of prior interrupt remapping data.
> > */
> > pi.prev_ga_tag = 0;
> > pi.is_guest_mode = false;
> > ret = irq_set_vcpu_affinity(host_irq, &pi);
> > }
> >
> >
>
> I recall one instance of the 'garbage pi data' issue but this was due to
> prev_ga_tag not being initialized (see commit f6426ab9c957).
Yep, that's the one I was trying to recall.
> As far as I understand, AMD implementation on irq_vcpu_set_affinity will
> write back to caller the following fields of pi:
>
> - prev_ga_tag
> - ir_data
> - guest_mode (sometimes when it is unsupported or disabled by the host via cmdline)
>
> On legacy interrupt remap path (no iommu avic) the IRQ update just uses irq data
> mostly. It's the avic path that uses more things (vcpu_data, ga_tag, base,
> ga_root_ptr, ga_vector), but all of which are initialized by KVM properly already.
Ya, on my Nth read through, I don't see any issues with KVM's behavior. I was
thinking that KVM's "pi" could bleed into amd_iommu_deactivate_guest_mode(), but
I had just gotten turned around by the many "data" variables. Bummer.
next prev parent reply other threads:[~2023-03-28 15:23 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-16 20:02 [PATCH v2 0/2] iommu/amd: Fix GAM IRTEs affinity and GALog restart Joao Martins
2023-03-16 20:02 ` [PATCH v2 1/2] iommu/amd: Don't block updates to GATag if guest mode is on Joao Martins
2023-03-16 21:01 ` Sean Christopherson
2023-03-16 21:25 ` Joao Martins
2023-03-24 14:31 ` Sean Christopherson
2023-03-28 10:42 ` Joao Martins
2023-03-28 15:20 ` Sean Christopherson [this message]
2023-03-28 9:07 ` Alexey Kardashevskiy
2023-03-28 10:19 ` Joao Martins
2023-03-16 20:02 ` [PATCH v2 2/2] iommu/amd: Handle GALog overflows Joao Martins
2023-04-13 10:24 ` Suthikulpanit, Suravee
2023-04-13 10:30 ` Joao Martins
2023-04-13 10:41 ` Suthikulpanit, Suravee
2023-04-17 5:04 ` Vasant Hegde
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=ZCMF0ReWqG0Q7Zna@google.com \
--to=seanjc@google.com \
--cc=alejandro.j.jimenez@oracle.com \
--cc=iommu@lists.linux.dev \
--cc=joao.m.martins@oracle.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=mlevitsk@redhat.com \
--cc=robin.murphy@arm.com \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@amd.com \
--cc=will@kernel.org \
/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