[compiler-rt] r280877 - builtins: make sure that flags is setup properly for __clear_cache

Saleem Abdulrasool via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 7 15:59:54 PDT 2016


Author: compnerd
Date: Wed Sep  7 17:59:54 2016
New Revision: 280877

URL: http://llvm.org/viewvc/llvm-project?rev=280877&view=rev
Log:
builtins: make sure that flags is setup properly for __clear_cache

On Linux ARM, the syscall will take 3 arguments (start, end, flags).  Ensure
that we do not pass garbage to the flags, which can cause the cacheflush call to
fail, and therefore cause an abort at runtime.

Modified:
    compiler-rt/trunk/lib/builtins/clear_cache.c

Modified: compiler-rt/trunk/lib/builtins/clear_cache.c
URL: http://llvm.org/viewvc/llvm-project/compiler-rt/trunk/lib/builtins/clear_cache.c?rev=280877&r1=280876&r2=280877&view=diff
==============================================================================
--- compiler-rt/trunk/lib/builtins/clear_cache.c (original)
+++ compiler-rt/trunk/lib/builtins/clear_cache.c Wed Sep  7 17:59:54 2016
@@ -110,10 +110,12 @@ void __clear_cache(void *start, void *en
     #elif defined(__linux__)
          register int start_reg __asm("r0") = (int) (intptr_t) start;
          const register int end_reg __asm("r1") = (int) (intptr_t) end;
+         const register int flags __asm("r2") = 0;
          const register int syscall_nr __asm("r7") = __ARM_NR_cacheflush;
          __asm __volatile("svc 0x0"
                           : "=r"(start_reg)
-                          : "r"(syscall_nr), "r"(start_reg), "r"(end_reg));
+                          : "r"(syscall_nr), "r"(start_reg), "r"(end_reg),
+                            "r"(flags));
          if (start_reg != 0) {
              compilerrt_abort();
          }




More information about the llvm-commits mailing list