[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250711115441.GV1599700@nvidia.com>
Date: Fri, 11 Jul 2025 08:54:41 -0300
From: Jason Gunthorpe <jgg@...dia.com>
To: Baolu Lu <baolu.lu@...ux.intel.com>
Cc: Peter Zijlstra <peterz@...radead.org>, Joerg Roedel <joro@...tes.org>,
Will Deacon <will@...nel.org>, Robin Murphy <robin.murphy@....com>,
Kevin Tian <kevin.tian@...el.com>, Jann Horn <jannh@...gle.com>,
Vasant Hegde <vasant.hegde@....com>,
Dave Hansen <dave.hansen@...el.com>,
Alistair Popple <apopple@...dia.com>,
Uladzislau Rezki <urezki@...il.com>,
Jean-Philippe Brucker <jean-philippe@...aro.org>,
Andy Lutomirski <luto@...nel.org>,
"Tested-by : Yi Lai" <yi1.lai@...el.com>, iommu@...ts.linux.dev,
security@...nel.org, linux-kernel@...r.kernel.org,
stable@...r.kernel.org
Subject: Re: [PATCH v2 1/1] iommu/sva: Invalidate KVA range on kernel TLB
flush
On Fri, Jul 11, 2025 at 11:00:06AM +0800, Baolu Lu wrote:
> > > +void iommu_sva_invalidate_kva_range(unsigned long start, unsigned long end)
> > > +{
> > > + struct iommu_mm_data *iommu_mm;
> > > +
> > > + if (!static_branch_unlikely(&iommu_sva_present))
> > > + return;
> > > +
> > > + guard(spinlock_irqsave)(&iommu_mms_lock);
> > > + list_for_each_entry(iommu_mm, &iommu_sva_mms, mm_list_elm)
> > > + mmu_notifier_arch_invalidate_secondary_tlbs(iommu_mm->mm, start, end);
> > > +}
> >
> > This is absolutely the wrong way to use static_branch. You want them in
> > inline functions guarding the function call, not inside the function
> > call.
>
> I don't think a static branch is desirable here, as we have no idea how
> often the condition will switch in real-world scenarios. I will remove
> it in the next version if there are no objections.
The point of the static branch was to make the 99% normal case where
SVA has never been used have no-cost in the core MM. I think we should
keep that idea
Jason
Powered by blists - more mailing lists