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: Fri, 24 Mar 2023 07:31:55 -0700 [thread overview]
Message-ID: <ZB20W14VzVZZz+nI@google.com> (raw)
In-Reply-To: <655ac0f7-223b-9440-1bcb-e93af8915bfa@oracle.com>
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);
}
> > Any chance you (or anyone) would want to create a follow-up series to rename and/or
> > rework these flows to make it more obvious that the helpers handle updates as well
> > as transitions between "guest mode" and "host mode"? E.g. I can see KVM getting
> > clever and skipping the "activation" when KVM knows AVIC is already active (though
> > I can't tell for certain whether or not that would actually be problematic).
> >
>
> To be honest, I think the function naming is correct.
After looking more closely at the KVM code, I agree. I was thinking KVM invoked
the (de)activate helpers somewhat spuriously, but that's not actually the case,
KVM just has a few less-than-perfect names due to conflicting requirements.
Thanks!
next prev parent reply other threads:[~2023-03-24 14:31 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 [this message]
2023-03-28 10:42 ` Joao Martins
2023-03-28 15:20 ` Sean Christopherson
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=ZB20W14VzVZZz+nI@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 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.