From nobody Fri Dec 19 20:06:41 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1673604721; cv=none; d=zohomail.com; s=zohoarc; b=mhtbqM+aRKAr8qy5dZoe7Puowq4lW6PIdTsO+nRnmvnyBp/Khce1413biWgeNORyjV3sh4U3I89PHaT32NJSKfEfie9jxz42ttKmaEdY30c8EtlAxrShQ0Lk8zDVyz5EwhmM32mm2eadD5bzt2hrojwaXP6NXagaTcABwgsR3QQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1673604721; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vzfTzczjLXV/PEg7iDoDX2AUbfuIDhGYbEkSsXpjSeE=; b=Nxx+wD3evEdd3PGDCkjFAH1NOrL4Rk/zINrGDMooQuAZ4XPfdfuMz2qGAzb+4wX09znvfuK7IS/aJLyIggwDcbGspm853W9t+aVr9210Nvv5WFaKIaCPi61dMg+zX8Xhxv8tg5ebNgpzSusDTMZCmN6yxmP4Pidw7vrF5sc1lOg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16736047214751003.4597705300289; Fri, 13 Jan 2023 02:12:01 -0800 (PST) Received: from list by lists.xenproject.org with outflank-mailman.477048.739579 (Exim 4.92) (envelope-from ) id 1pGH2F-0004A7-Ts; Fri, 13 Jan 2023 10:11:43 +0000 Received: by outflank-mailman (output) from mailman id 477048.739579; Fri, 13 Jan 2023 10:11:43 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pGH2F-00049y-QW; Fri, 13 Jan 2023 10:11:43 +0000 Received: by outflank-mailman (input) for mailman id 477048; Fri, 13 Jan 2023 10:11:42 +0000 Received: from mail.xenproject.org ([104.130.215.37]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pGH2E-0003t1-Eo for xen-devel@lists.xenproject.org; Fri, 13 Jan 2023 10:11:42 +0000 Received: from xenbits.xenproject.org ([104.239.192.120]) by mail.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pGH2E-0006d1-3y; Fri, 13 Jan 2023 10:11:42 +0000 Received: from 54-240-197-224.amazon.com ([54.240.197.224] helo=dev-dsk-jgrall-1b-035652ec.eu-west-1.amazon.com) by xenbits.xenproject.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1pGH2D-0005Ty-Rv; Fri, 13 Jan 2023 10:11:42 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=xen.org; s=20200302mail; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From; bh=vzfTzczjLXV/PEg7iDoDX2AUbfuIDhGYbEkSsXpjSeE=; b=CTJBH7q+3tEciLNn32G6x2pXxh v7WFKd3NEiPWlcGbm5f5hXiAs+5kZBGlPmpt4OHD2dQ5i01kl1uVLr6RLXw2gNlSFpZV6vJvqON8B DEuBa1JY11p3Og8QqrJ90ogMAeJKUT9LkfpLCyqQgdad2QrArUn3iWit5t8QDS3DtDeM=; From: Julien Grall To: xen-devel@lists.xenproject.org Cc: Luca.Fancellu@arm.com, Julien Grall , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk , Michal Orzel Subject: [PATCH v4 02/14] xen/arm64: flushtlb: Implement the TLBI repeat workaround for TLB flush by VA Date: Fri, 13 Jan 2023 10:11:24 +0000 Message-Id: <20230113101136.479-3-julien@xen.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230113101136.479-1-julien@xen.org> References: <20230113101136.479-1-julien@xen.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @xen.org) X-ZM-MESSAGEID: 1673604722071100001 Content-Type: text/plain; charset="utf-8" From: Julien Grall Looking at the Neoverse N1 errata document, it is not clear to me why the TLBI repeat workaround is not applied for TLB flush by VA. The TBL flush by VA helpers are used in flush_xen_tlb_range_va_local() and flush_xen_tlb_range_va(). So if the range size if a fixed size smaller than a PAGE_SIZE, it would be possible that the compiler remove the loop and therefore replicate the sequence described in the erratum 1286807. So the TLBI repeat workaround should also be applied for the TLB flush by VA helpers. Fixes: 22e323d115d8 ("xen/arm: Add workaround for Cortex-A76/Neoverse-N1 er= ratum #1286807") Signed-off-by: Julien Grall Reviewed-by: Michal Orzel Tested-by: Henry Wang ---- This was spotted while looking at reducing the scope of the memory barriers. I don't have any HW affected. Changes in v4: - Add Michal's reviewed-by tag Changes in v3: - Patch added --- xen/arch/arm/include/asm/arm64/flushtlb.h | 31 +++++++++++++++++------ 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/xen/arch/arm/include/asm/arm64/flushtlb.h b/xen/arch/arm/inclu= de/asm/arm64/flushtlb.h index a40693b08dd3..7f81cbbb93f9 100644 --- a/xen/arch/arm/include/asm/arm64/flushtlb.h +++ b/xen/arch/arm/include/asm/arm64/flushtlb.h @@ -44,6 +44,27 @@ static inline void name(void) \ : : : "memory"); \ } =20 +/* + * FLush TLB by VA. This will likely be used in a loop, so the caller + * is responsible to use the appropriate memory barriers before/after + * the sequence. + * + * See above about the ARM64_WORKAROUND_REPEAT_TLBI sequence. + */ +#define TLB_HELPER_VA(name, tlbop) \ +static inline void name(vaddr_t va) \ +{ \ + asm volatile( \ + "tlbi " # tlbop ", %0;" \ + ALTERNATIVE( \ + "nop; nop;", \ + "dsb ish;" \ + "tlbi " # tlbop ", %0;", \ + ARM64_WORKAROUND_REPEAT_TLBI, \ + CONFIG_ARM64_WORKAROUND_REPEAT_TLBI) \ + : : "r" (va >> PAGE_SHIFT) : "memory"); \ +} + /* Flush local TLBs, current VMID only. */ TLB_HELPER(flush_guest_tlb_local, vmalls12e1, nsh); =20 @@ -60,16 +81,10 @@ TLB_HELPER(flush_all_guests_tlb, alle1is, ish); TLB_HELPER(flush_xen_tlb_local, alle2, nsh); =20 /* Flush TLB of local processor for address va. */ -static inline void __flush_xen_tlb_one_local(vaddr_t va) -{ - asm volatile("tlbi vae2, %0;" : : "r" (va>>PAGE_SHIFT) : "memory"); -} +TLB_HELPER_VA(__flush_xen_tlb_one_local, vae2); =20 /* Flush TLB of all processors in the inner-shareable domain for address v= a. */ -static inline void __flush_xen_tlb_one(vaddr_t va) -{ - asm volatile("tlbi vae2is, %0;" : : "r" (va>>PAGE_SHIFT) : "memory"); -} +TLB_HELPER_VA(__flush_xen_tlb_one, vae2is); =20 #endif /* __ASM_ARM_ARM64_FLUSHTLB_H__ */ /* --=20 2.38.1