From: Oliver Upton <oliver.upton@linux.dev>
To: Sean Christopherson <seanjc@google.com>
Cc: Jason Gunthorpe <jgg@ziepe.ca>,
Shameer Kolothum <shameerali.kolothum.thodi@huawei.com>,
kvmarm@lists.linux.dev, iommu@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, linuxarm@huawei.com,
kevin.tian@intel.com, alex.williamson@redhat.com, maz@kernel.org,
will@kernel.org, robin.murphy@arm.com, jean-philippe@linaro.org,
jonathan.cameron@huawei.com
Subject: Re: [RFC PATCH v2 4/7] iommufd: Associate kvm pointer to iommufd ctx
Date: Mon, 24 Jun 2024 12:51:34 -0700 [thread overview]
Message-ID: <ZnnORmCHrEI0KkGz@linux.dev> (raw)
In-Reply-To: <ZnnJA3ueCXsDtyB7@google.com>
On Mon, Jun 24, 2024 at 12:29:07PM -0700, Sean Christopherson wrote:
> On Mon, Jun 24, 2024, Oliver Upton wrote:
> > On Mon, Jun 24, 2024 at 03:01:48PM -0300, Jason Gunthorpe wrote:
> > > If KVM can change VMID on the fly then that is a further complication
> > > :\
>
> Ya, as written today, KVM doesn't assign a VMID when the VM is created, and instead
> allocates VMIDs on-demand when a vCPU is run.
>
> The KVM changes in this series allow "pinning" the currently assigned VMID, i.e.
> tries to address that further complication. But because of the on-demand
> allocation, there might not be a currently assigned VMID for VM, or the VMID might
> be stale, i.e. re-assigned to a different VM.
>
> Thus, kvm_arm_pinned_vmid_get() can effectively trigger VMID allocations, and
> thus cgroup charging and failure.
>
> If I'm reading the ARM code correctly, the intent is to cycle through VMIDs as
> necessary so that it's possible for every actively running VM to have a VMID.
> And maybe also to also minimize the number of TLB + I$ invalidations?
The commentary about TLBIs + I$ invalidations is in relation to how
rollover is handled. The kernel's ASID allocator does some deferred
invalidation, the VMID allocator does some eager invalidation at rollover
because it is believed to be a rarer occurrence.
But generally speaking, it's what you expect, we have some structures in
hardware that use VMID to form a tag, and we wnat to avoid blasting them
if at all possible.
> > >
> > > > Hmm, kvm_arm_pinned_vmid_get() doesn't fail, it just falls back to VMID=0. Which
> > > > seems odd.
> >
> > This is bleeding a bit of implementation detail where VMID=0 is known to
> > be reserved (thus invalid), it'd probably be better if the
> > implementation actually just returned an error.
>
> Oof, I assumed using VMID=0 just caused a loss of performance, but this makes
> it sound like the IOMMU mappings will fault?
Bit worse than that :)
Having the SMMU participate in broadcast TLB maintenance means TLBI
instructions on the CPU invalidate translations in the SMMU, which is
useful for SVA usecases. However, if the host is using different VMIDs
for the CPU and SMMU, then guest TLBIs no longer match the guest's SMMU
context...
Pinning / sharing the VMID between CPU and SMMU is a hard requirement if
you advertise BTM support to the guest.
--
Thanks,
Oliver
next prev parent reply other threads:[~2024-06-24 19:52 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-08 15:18 [RFC PATCH v2 0/7] iommu/arm-smmu-v3: Use pinned KVM VMID for stage 2 Shameer Kolothum
2024-02-08 15:18 ` [RFC PATCH v2 1/7] KVM: Add generic infrastructure to support pinned VMIDs Shameer Kolothum
2024-06-24 15:48 ` Sean Christopherson
2024-02-08 15:18 ` [RFC PATCH v2 2/7] KVM: arm64: Introduce support to pin VMIDs Shameer Kolothum
2024-06-24 19:22 ` Oliver Upton
2024-06-24 19:34 ` Shameerali Kolothum Thodi
2024-06-24 19:52 ` Oliver Upton
2024-02-08 15:18 ` [RFC PATCH v2 3/7] KVM: arm64: Add interfaces for pinned VMID support Shameer Kolothum
2024-02-08 15:18 ` [RFC PATCH v2 4/7] iommufd: Associate kvm pointer to iommufd ctx Shameer Kolothum
2024-02-08 15:42 ` Jason Gunthorpe
2024-06-24 16:53 ` Sean Christopherson
2024-06-24 17:07 ` Jason Gunthorpe
2024-06-24 17:54 ` Sean Christopherson
2024-06-24 18:01 ` Jason Gunthorpe
2024-06-24 19:12 ` Oliver Upton
2024-06-24 19:29 ` Sean Christopherson
2024-06-24 19:51 ` Oliver Upton [this message]
2024-06-24 22:35 ` Jason Gunthorpe
2024-06-25 2:21 ` Tian, Kevin
2024-06-24 19:13 ` Shameerali Kolothum Thodi
2024-06-25 1:53 ` Tian, Kevin
2024-02-08 15:18 ` [RFC PATCH v2 5/7] iommu: Pass in kvm pointer to domain_alloc_user Shameer Kolothum
2024-02-08 15:43 ` Jason Gunthorpe
2024-02-08 15:18 ` [RFC PATCH v2 6/7] iommu/arm-smmu-v3: Use KVM VMID for s2 stage Shameer Kolothum
2024-02-08 15:59 ` Jason Gunthorpe
2024-02-08 16:14 ` Shameerali Kolothum Thodi
2024-02-08 16:26 ` Jason Gunthorpe
2024-02-08 16:36 ` Shameerali Kolothum Thodi
2024-02-08 15:18 ` [RFC PATCH v2 7/7] iommu/arm-smmu-v3: Enable broadcast TLB maintenance Shameer Kolothum
2024-02-08 15:35 ` [RFC PATCH v2 0/7] iommu/arm-smmu-v3: Use pinned KVM VMID for stage 2 Jason Gunthorpe
2024-02-08 15:49 ` Shameerali Kolothum Thodi
2024-02-08 16:07 ` Jason Gunthorpe
2024-02-09 11:58 ` Jean-Philippe Brucker
2024-02-09 12:48 ` Jason Gunthorpe
2024-02-09 13:54 ` Shameerali Kolothum Thodi
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=ZnnORmCHrEI0KkGz@linux.dev \
--to=oliver.upton@linux.dev \
--cc=alex.williamson@redhat.com \
--cc=iommu@lists.linux.dev \
--cc=jean-philippe@linaro.org \
--cc=jgg@ziepe.ca \
--cc=jonathan.cameron@huawei.com \
--cc=kevin.tian@intel.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linuxarm@huawei.com \
--cc=maz@kernel.org \
--cc=robin.murphy@arm.com \
--cc=seanjc@google.com \
--cc=shameerali.kolothum.thodi@huawei.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;
as well as URLs for NNTP newsgroup(s).