Matt Turner <[email protected]> writes: > translator_use_goto_tb() refuses to chain unless the destination is on the > same page as the start of the TB. For guests whose text is much larger than > a page this is expensive: an emulated alpha gcc compiling a 255k line > translation unit takes the indirect dispatch path for 8.4 billion of its > 34.2 billion TB exits, and a large share of those are ordinary direct > branches that simply crossed an 8 KiB page boundary. > > The restriction was made unconditional by d3a2a1d803 ("accel/tcg: > Introduce translator_use_goto_tb"), whose rationale was: > > Various targets avoid the page crossing test for CONFIG_USER_ONLY, > but that is wrong: mmap and mprotect can change page permissions. > > That is true, but in user-only builds the invalidation path already covers > it. There are no page tables: every mmap, mprotect and munmap reaches > page_set_flags(), which calls tb_invalidate_phys_range() whenever the flags > actually change, and tb_phys_invalidate() calls tb_jmp_unlink() to reset > incoming jumps. A chained cross-page jump is therefore broken whenever the > destination page's permissions change. This is not true in system mode, > where TBs are keyed by physical address and a page table change invalidates > nothing, so the restriction is kept there. > tests/tcg/alpha/Makefile.target | 17 +++- > tests/tcg/alpha/gdbstub/xpage-bp.py | 34 +++++++ > tests/tcg/alpha/test-xpage-chain.c | 144 ++++++++++++++++++++++++++++ <snip>
Given alpha linux-user isn't widely built or used it would be better if we could make the xpage chaining tests multiarch so they are exercised on all *-user targets. -- Alex Bennée Virtualisation Tech Lead @ Linaro
