Skip to contentSkip to conversation

Qemu memory management

Qemu-devel Michael Neubauer 2 participants 2 messages Mar 29, 2007

lore
Share & tools
lore
#0 lore raw

Hello,

I'm trying to learn a bit more about the Qemu SoftMMU. The following quotation is taken from section 2.10 of the "Qemu Internals" documentation.

"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. Maybe I'm just mixing too many things up here since I don't really have a lot of experience in the whole operating systems stuff. I would really appreciate it if someone could give me a hint.

I'm sorry if that's the wrong place to ask questions like the one above. Please let me know if there's any other comprehensive resource of information available.

-- Michael

#1 lore raw
Quoted 7 lines · Michael Neubauer

"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.

Signature · 1 line
Stuart Brady