]> Savannah Git Hosting - gnulib.git/commitdiff
jit/cache: Fix for ia64 CPUs.
authorBruno Haible <bruno@clisp.org>
Tue, 9 Jan 2024 21:55:26 +0000 (22:55 +0100)
committerBruno Haible <bruno@clisp.org>
Thu, 18 Jan 2024 08:29:21 +0000 (09:29 +0100)
* lib/jit/cache.h (clear_cache): On ia64 CPUs, use the 'fc', 'sync',
'srlz' instructions.

ChangeLog
lib/jit/cache.h

index 746b428d0d0eecb741a52bb92a348668e13aeffd..e31eefe3cdda3f43be31e1f3088438c09599b9c6 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2024-01-09  Bruno Haible  <bruno@clisp.org>
+
+       jit/cache: Fix for ia64 CPUs.
+       * lib/jit/cache.h (clear_cache): On ia64 CPUs, use the 'fc', 'sync',
+       'srlz' instructions.
+
 2024-01-09  Bruno Haible  <bruno@clisp.org>
 
        jit/cache: Fix for hppa CPUs.
index 2a3469e0c4f5558eaf5146a7da3dd6c621487394..f9da28125e41bed54799b5bf01f93a1b5915440b 100644 (file)
@@ -123,6 +123,26 @@ clear_cache (void *start, void *end)
          "\n\t" "nop"
          "\n\t" "nop"
          "\n\t" "nop");
+#elif (defined __GNUC__ || defined __clang__) && defined __ia64
+  /* Use inline assembly.  */
+  /* The Intel IA-64 Architecture Software Developer's Manual volume 3 says:
+     "The line size affected is at least 32 bytes."  */
+  intptr_t cache_line_size = 32;
+  uintptr_t addr = (uintptr_t) start & ~cache_line_size;
+  uintptr_t end_addr = (uintptr_t) end;
+  do
+    {
+      /* Flush a cache line.  */
+      asm volatile ("fc %0" : : "r" (addr));
+      addr += cache_line_size;
+    }
+  while (addr < end_addr);
+  /* Ensure the preceding 'fc' instructions become effective in the local
+     processor and all remote processors.  */
+  asm volatile ("sync.i");
+  /* Ensure the preceding 'sync.i' instruction becomes effective in the
+     local processor's instruction cache.  */
+  asm volatile ("srlz.i");
 #elif (defined __GNUC__ || defined __clang__) && defined __m68k__ && defined __linux__
   /* Use inline assembly to call the 'cacheflush' system call.
      sys_cacheflush (addr, scope, cache, len)