Commit 3233f0d463d299be89e2672928fc215dc99c2c71

Authored by balrog
1 parent 80fe30ed

Use libgcc __clear_cache to clean icache, when available.

Calling the clear cache syscall directly generates an illegal instruction 
on some (armv4) kernels.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5843 c046a42c-6fe2-441c-8c8c-71466251a162
exec-all.h
... ... @@ -205,18 +205,26 @@ static inline void tb_set_jmp_target1(unsigned long jmp_addr, unsigned long addr
205 205 #elif defined(__arm__)
206 206 static inline void tb_set_jmp_target1(unsigned long jmp_addr, unsigned long addr)
207 207 {
  208 +#if QEMU_GNUC_PREREQ(4, 1)
  209 + void __clear_cache(char *beg, char *end);
  210 +#else
208 211 register unsigned long _beg __asm ("a1");
209 212 register unsigned long _end __asm ("a2");
210 213 register unsigned long _flg __asm ("a3");
  214 +#endif
211 215  
212 216 /* we could use a ldr pc, [pc, #-4] kind of branch and avoid the flush */
213 217 *(uint32_t *)jmp_addr |= ((addr - (jmp_addr + 8)) >> 2) & 0xffffff;
214 218  
  219 +#if QEMU_GNUC_PREREQ(4, 1)
  220 + __clear_cache((char *) jmp_addr, (char *) jmp_addr + 4);
  221 +#else
215 222 /* flush icache */
216 223 _beg = jmp_addr;
217 224 _end = jmp_addr + 4;
218 225 _flg = 0;
219 226 __asm __volatile__ ("swi 0x9f0002" : : "r" (_beg), "r" (_end), "r" (_flg));
  227 +#endif
220 228 }
221 229 #endif
222 230  
... ...
tcg/arm/tcg-target.h
... ... @@ -69,8 +69,13 @@ enum {
69 69  
70 70 static inline void flush_icache_range(unsigned long start, unsigned long stop)
71 71 {
  72 +#if QEMU_GNUC_PREREQ(4, 1)
  73 + void __clear_cache(char *beg, char *end);
  74 + __clear_cache((char *) start, (char *) stop);
  75 +#else
72 76 register unsigned long _beg __asm ("a1") = start;
73 77 register unsigned long _end __asm ("a2") = stop;
74 78 register unsigned long _flg __asm ("a3") = 0;
75 79 __asm __volatile__ ("swi 0x9f0002" : : "r" (_beg), "r" (_end), "r" (_flg));
  80 +#endif
76 81 }
... ...