mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
tcg: Prepare TB invalidation for lockless TB lookup
When invalidating a translation block, set an invalid flag into the TranslationBlock structure first. It is also necessary to check whether the target TB is still valid after acquiring 'tb_lock' but before calling tb_add_jump() since TB lookup is to be performed out of 'tb_lock' in future. Note that we don't have to check 'last_tb'; an already invalidated TB will not be executed anyway and it is thus safe to patch it. Suggested-by: Sergey Fedorov <serge.fdrv@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
118b07308a
commit
6d21e4208f
3 changed files with 8 additions and 2 deletions
|
@ -773,6 +773,7 @@ static TranslationBlock *tb_alloc(target_ulong pc)
|
|||
tb = &tcg_ctx.tb_ctx.tbs[tcg_ctx.tb_ctx.nb_tbs++];
|
||||
tb->pc = pc;
|
||||
tb->cflags = 0;
|
||||
tb->invalid = false;
|
||||
return tb;
|
||||
}
|
||||
|
||||
|
@ -994,6 +995,8 @@ void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr)
|
|||
uint32_t h;
|
||||
tb_page_addr_t phys_pc;
|
||||
|
||||
atomic_set(&tb->invalid, true);
|
||||
|
||||
/* remove the TB from the hash list */
|
||||
phys_pc = tb->page_addr[0] + (tb->pc & ~TARGET_PAGE_MASK);
|
||||
h = tb_hash_func(phys_pc, tb->pc, tb->flags);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue