On Thu, Mar 29, 2007 at 11:58:33AM +0200, Michael Neubauer wrote: > "To avoid flushing the translated code each time the MMU mappings change, > QEMU uses a physically indexed translation cache. It means that each TB is > indexed with its physical address." > > Why does a cache like that prevent the translated code from being flushed? > If a translated code is relocated in physical memory (e. g. after a paging > swap operation) that would render the cache useless in my opinion.
My impression is that "each time the MMU mappings change" basically means "when there's a context switch" and not "when swapping occurs". If code is swapped out, then yes, it would have to be translated again. If you wanted to avoid that, you'd need a virtually indexed cache, and I believe that would require co-operation from the OS, as it would be very difficult for QEMU to keep track of processes/threads and paging itself. You'd also have to deal with cache aliases to avoid translating code for each process or thread that uses it. -- Stuart Brady