translate-all: exit cpu_restore_state early if translating

The translation code uses cpu_ld*_code which can trigger a tlb_fill
which if it fails will erroneously attempts a fault resolution. This
never works during translation as the TB being generated hasn't been
added yet. The target should have checked retaddr before calling
cpu_restore_state but for those that have yet to be fixed we do it
here to avoid a recursive tb_lock() under MTTCG's new locking regime

Backports commit d8b2239bcd8872a5c5f7534d1658fc2365caab2d from qemu
This commit is contained in:
Alex Bennée 2018-03-02 12:44:55 -05:00 committed by Lioncash
parent a01496e6d9
commit ad548f8110
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -319,6 +319,19 @@ bool cpu_restore_state(CPUState *cpu, uintptr_t retaddr)
TranslationBlock *tb;
CPUArchState *env = cpu->env_ptr;
/* A retaddr of zero is invalid so we really shouldn't have ended
* up here. The target code has likely forgotten to check retaddr
* != 0 before attempting to restore state. We return early to
* avoid blowing up on a recursive tb_lock(). The target must have
* previously survived a failed cpu_restore_state because
* tb_find_pc(0) would have failed anyway. It still should be
* fixed though.
*/
if (!retaddr) {
return false;
}
tb = tb_find_pc(env->uc, retaddr);
if (tb) {
cpu_restore_state_from_tb(cpu, tb, retaddr);