linux-mips.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Syncing CPU caches from userland on MIPS
@ 2009-11-24 18:28 Aurelien Jarno
  2009-11-24 21:04 ` David Daney
  2009-11-25 14:01 ` Florian Lohoff
  0 siblings, 2 replies; 10+ messages in thread
From: Aurelien Jarno @ 2009-11-24 18:28 UTC (permalink / raw)
  To: linux-mips; +Cc: Arnaud Patard

Hi all,

This question is not really kernel related, but still MIPS related, I
hope you don't mind.

Arnaud Patard and myself are trying to get qemu working on MIPS [1],
which includes translating TCG code (internal representation) into MIPS
instructions, that are then executed. Most of the code works, but we 
have some strange behaviors that seems related to CPU caches.

The code is written to a buffer, which is then executed. Before the
execution, the caches are synced using the cacheflush syscall:

| #include <sys/cachectl.h>
|  
| 
| static inline void flush_icache_range(unsigned long start, unsigned long stop)
| {
|     cacheflush ((void *)start, stop-start, ICACHE);
| }

It seems this is not enough, as sometimes, some executed code does not
correspond to the assembly dump of this memory region. This seems to be 
especially the case of memory regions that are written twice, due to
relocations:
1) a branch instruction is written with an offset of 0
2) the offset is patched
3) cacheflush is called

Sometimes the executed code correspond to the code written in 1), which
means the branch is skipped.

Does someone knows and/or has example code to correctly sync the CPU 
caches from userland on MIPS?

Thanks in advance,
Aurelien

[1] http://git.aurel32.net/?p=qemu.git;a=shortlog;h=refs/heads/tcg-mips

-- 
Aurelien Jarno	                        GPG: 1024D/F1BCDB73
aurelien@aurel32.net                 http://www.aurel32.net

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-11-25 15:18 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-24 18:28 Syncing CPU caches from userland on MIPS Aurelien Jarno
2009-11-24 21:04 ` David Daney
2009-11-24 21:35   ` Aurelien Jarno
2009-11-25 14:01 ` Florian Lohoff
2009-11-25 14:39   ` Arnaud Patard
2009-11-25 14:32     ` Florian Lohoff
2009-11-25 14:48       ` Arnaud Patard
2009-11-25 15:18         ` peter fuerst
2009-11-25 15:01     ` Ralf Baechle
2009-11-25 15:00   ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).