[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen staging-4.17] xen/arm64: flushtlb: Implement the TLBI repeat workaround for TLB flush by VA



commit 95b9e5a188f6132711f47a24d05dc1816e189daf
Author:     Julien Grall <jgrall@xxxxxxxxxx>
AuthorDate: Tue Jan 24 19:25:50 2023 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Thu Jun 4 22:29:13 2026 +0100

    xen/arm64: flushtlb: Implement the TLBI repeat workaround for TLB flush by 
VA
    
    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 TLB flush by VA helpers are used in flush_xen_tlb_range_va_local()
    and flush_xen_tlb_range_va(). So if the range size is 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 
erratum #1286807")
    Signed-off-by: Julien Grall <jgrall@xxxxxxxxxx>
    Reviewed-by: Michal Orzel <michal.orzel@xxxxxxx>
    Tested-by: Henry Wang <Henry.Wang@xxxxxxx>
    (cherry picked from commit cbfaf6ccd2cb5d1b2bc6efe5c6f4ba5cccce5689)
    
    xen/arm: Remove stray semicolon at VREG_REG_HELPERS/TLB_HELPER* callers
    
    This is inconsistent with the rest of the code where macros are used
    to define functions, as it results in an empty declaration (i.e.
    semicolon with nothing before it) after function definition. This is also
    not allowed by C99.
    
    Take the opportunity to undefine TLB_HELPER* macros after last use.
    
    Signed-off-by: Michal Orzel <michal.orzel@xxxxxxx>
    Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
    (cherry picked from commit 6044b485ba5b0e4073a773402cedc2f2fae540ad)
---
 xen/arch/arm/include/asm/arm64/flushtlb.h | 32 +++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/xen/arch/arm/include/asm/arm64/flushtlb.h 
b/xen/arch/arm/include/asm/arm64/flushtlb.h
index fcc0788c30..56c6fc763b 100644
--- a/xen/arch/arm/include/asm/arm64/flushtlb.h
+++ b/xen/arch/arm/include/asm/arm64/flushtlb.h
@@ -45,6 +45,27 @@ static inline void name(void)                    \
         : : : "memory");                         \
 }
 
+/*
+ * 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)
 
@@ -61,18 +82,13 @@ TLB_HELPER(flush_all_guests_tlb, alle1is, ish)
 TLB_HELPER(flush_xen_tlb_local, alle2, nsh)
 
 /* 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)
 
 /* Flush TLB of all processors in the inner-shareable domain for address va. */
-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)
 
 #undef TLB_HELPER
+#undef TLB_HELPER_VA
 
 #endif /* __ASM_ARM_ARM64_FLUSHTLB_H__ */
 /*
--
generated by git-patchbot for /home/xen/git/xen.git#staging-4.17



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.