Skip to contentSkip to conversation

need help

Qemu-devel oussema ben khedher 2 participants 2 messages Mar 1, 2017 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

I am trying to understand the block chaining of QEMU. And I have a question about the branch direction of each executed TBs. Suppose the TB#1 has been executed now, and find the next_tb (TB#2). Then we know the direction is TB#1--->TB#2 and store the chain in code cache for speedup the execution next time. So, next time qemu find the next TB (which is TB#1), then TB#1--->TB#2 will be executed in code cache. But I think that there are two branch direction of a TB.(branch taken/not taken) My question is how qemu ensure the direction is TB#1--->TB#2 next time?
Thanks all.

#2 lore raw
Quoted 10 lines · oussema ben khedher

I am trying to understand the block chaining of QEMU. And I have a question about the branch direction of each executed TBs. Suppose the TB#1 has been executed now, and find the next_tb (TB#2). Then we know the direction is TB#1--->TB#2 and store the chain in code cache for speedup the execution next time. So, next time qemu find the next TB (which is TB#1), then TB#1--->TB#2 will be executed in code cache.
But I think that there are two branch direction of a TB.(branch taken/not taken) My question is how qemu ensure the direction is TB#1--->TB#2 next time?

Every TB has two outbound links (though one may be unused for an unconditional branch). When we chain a TB together we only chain the link that we took. So if we do a "branch taken" exit from TB1 and find that it goes to TB2, then we link TB1's branch-taken code path directly to TB2. But that doesn't affect the branch-not-taken codepath. Later if we do a branch-not-taken exit from TB1 we may be able to chain it to a different TB.

(In fact the outbound links are just numbered 0 and 1, and there's no requirement to use them for taken and not-taken in any particular order.)

thanks
-- PMM