From d14c2c01392ded46ae2bc16aa6f08ab2594cc65c Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Wed, 7 Sep 2016 22:59:54 +0000 Subject: [PATCH] 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. llvm-svn: 280877 --- compiler-rt/lib/builtins/clear_cache.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/compiler-rt/lib/builtins/clear_cache.c b/compiler-rt/lib/builtins/clear_cache.c index 55bbdd375891..4c2ac3b1eb05 100644 --- a/compiler-rt/lib/builtins/clear_cache.c +++ b/compiler-rt/lib/builtins/clear_cache.c @@ -110,10 +110,12 @@ void __clear_cache(void *start, void *end) { #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(); }