Re: [PATCH v2] arm64: tlbflush: Don't broadcast if mm was only active on local cpu
From: Will Deacon
Date: Wed Jun 17 2026 - 10:04:48 EST
On Tue, Jun 16, 2026 at 07:13:07AM +0100, Mark Rutland wrote:
> On Mon, Jun 15, 2026 at 03:44:20PM +0100, Will Deacon wrote:
> > On Mon, Jun 15, 2026 at 01:39:43PM +0100, Mark Rutland wrote:
> > > Regardless of the erratum, to correctly handle a vCPU being migrated
> > > from pCPU-x to pCPU-y, we rely on:
> > >
> > > * The host to set HCR_EL2.FB to ensure that TLB maintenance is
> > > broadcast to the ISH domain.
> > >
> > > * The host to set HCR_EL2.BSU to ensure the DSB is upgrade to ISH such
> > > that any guest-issued DSB NSH will it can complete any TLB maintenance
> > > that was upgraded to ISH.
> > >
> > > * The host to issue a DSB ISH on pCPU-x before the vCPU can run on
> > > pCPU-y, to complete any outstanding maintenance that was issued on
> > > pCPU-x. IIUC a DSB ISH on pCPU-y is not architecturally sufficient; it
> > > must be executed on the same CPU which issued the TLB maintenance.
> > >
> > > ... but as above, all of that should be independent of any of the errata
> > > that require the workaround.
> >
> > Yes, I understand all of the above but the case I'm struggling with is
> > where a vCPU runs on a system that needs the TLB invalidation to be
> > performed twice. For non-broadcast invalidation (from the guest
> > perspective), this patch will mean that it only performs the
> > invalidation once. So if the vCPU migrates to another physical CPU, can
> > that effectively undo the HCR_EL2.FB upgrade unless KVM issues TLB
> > invalidation as well as a DSB on migration?
> >
> > Maybe I'm missing something, as it looks like upstream already elides
> > the call to __tlbi_sync_s1ish() for the NOBROADCAST case.
>
> The key thing is that these errata only affect the completion of memory
> accesses, and only those accesses made by other (physical) PEs.
Thanks. That sort of detail isn't generally disclosed in the writeups,
but if you're certain that applies to all of the errata workarounds
selecting CONFIG_ARM64_WORKAROUND_REPEAT_TLBI, then let's rename
that config option and document this somewhere (in the Kconfig help?)
to make sure that anybody trying to use this workaround to e.g. resolve
problems on the broadcasting side, are aware that it won't necessarily
help.
> A single TLBI will correctly remove the actual TLB entries, and
> HCR_EL2.{FB,BSU} will still ensure that TLB entries are removed from the
> TLBs of other PEs.
>
> The errata only prevent completion of memory accesses made on other
> (physical) PEs, and:
>
> * For accesses made by the vCPU which is issuing the TLBI(s):
>
> - Regardless of the errata, the hypervisor has to ensure that when a
> vCPU is migrated from pCPU-x to pCPU-y, any prior CMOs or TLBIs are
> completed, which requires the host to execute a DSB ISH on pCPU-x
> before the vCPU can be run on pCPU-y.
>
> Maybe we have a latent bug here?
I think that should happen in the context switch path (see the
barrier in __switch_to()).
Will