From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA2803F4830 for ; Mon, 15 Jun 2026 12:39:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781527195; cv=none; b=AKVWNrtwhXf6z15SkVAavJgBfsVHP4+rS2sznKK9kBBWPTp/imlu8uluI7WYNMNtcW3IJuRaSPRfprjC8YJfTE5OQO1p0i2VnVYCCs+TgIbli8+A2TupYHAsjO+3YbCub0XeKhuz2kOiIAS2D6HAYo5sJPZ2py4UR9KHCZY2NQ0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781527195; c=relaxed/simple; bh=kZSBouNcgnBKWX0ECo7+eUKRe/z+K7axYFcWodvnhBw=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EmYLXYPz4GrneMnJrPr1OK0s0Uhz1eFYta5ACWNeMU5PT4aTcGBJLFetxwHx3dpCD0//TTtOyu925Zd9xIqSKfocw9OsWu4uXupBko+D84/1izBIfrgsBPlOV3XChu258tWNVd0O0b///vBEO7JZd/cBW/mNdCyD6yEQB7P7aEk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=JRNf79MX; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="JRNf79MX" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 491F1328D; Mon, 15 Jun 2026 05:39:48 -0700 (PDT) Received: from J2N7QTR9R3.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 0CA0E3F905; Mon, 15 Jun 2026 05:39:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1781527193; bh=kZSBouNcgnBKWX0ECo7+eUKRe/z+K7axYFcWodvnhBw=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JRNf79MXpqjApZZXUVdA9wGEyQos1t68Tfoa2qQ7tD3B6+DCxRac7U3Tydcim2vGE Afoc0+WDGwe+5a2bHVuij3dPo35+QjA1Tdg82+2Y8IdSO0OfRSeSLuvRcmvcLzwuEx dXiy/HxHyW02zBa9i/kKSTshoBAkr1S4ErzsvkwQ= Date: Mon, 15 Jun 2026 13:39:43 +0100 From: Mark Rutland To: Will Deacon Cc: Linu Cherian , Catalin Marinas , Ryan Roberts , Kevin Brodsky , Anshuman Khandual , Yang Shi , Huang Ying , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] arm64: tlbflush: Don't broadcast if mm was only active on local cpu Message-ID: References: <20260523134710.3827956-1-linu.cherian@arm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Hi Will, On Sun, Jun 14, 2026 at 12:04:44PM +0100, Will Deacon wrote: > On Sat, May 23, 2026 at 07:17:10PM +0530, Linu Cherian wrote: > > static inline void flush_tlb_mm(struct mm_struct *mm) > > { > > unsigned long asid; > > + bool local; > > > > - dsb(ishst); > > + local = flush_tlb_user_pre(mm, TLBF_NONE); > > asid = __TLBI_VADDR(0, ASID(mm)); > > - __tlbi(aside1is, asid); > > - __tlbi_user(aside1is, asid); > > - __tlbi_sync_s1ish(mm); > > + if (local) { > > + __tlbi(aside1, asid); > > + __tlbi_user(aside1, asid); > > + dsb(nsh); > > + } else { > > + __tlbi(aside1is, asid); > > + __tlbi_user(aside1is, asid); > > + __tlbi_sync_s1ish(mm); > > + } > > + flush_tlb_user_post(local); > > I think you've changed this since Ryan's original patch, but why are you > only calling __tlbi_sync_s1ish() for the !local case? Doesn't that break > the erratum workaround when running as a VM if the vCPU is migrated? The errata mitigated by __tlbi_sync_s1ish() only affect broadcast maintenance (the 'ish' in the name was intended to convey that). No workaround is necessary for local TLB maintenance; aside from anything else, when some PE executes the DSB to complete the maintenance, that DSB alone is sufficient to complete memory accesses made by that PE. If it would make things clearer, we could add a __tlbi_sync_s1nsh() helper for the local case, which would boil down to a DSB NSH. 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. Mark.