xref: /openbmc/qemu/accel/tcg/cpu-exec-common.c (revision 800af0aae1cfa456701c5fa1ef273ce47585179c)
1d9bb58e5SYang Zhong /*
2d9bb58e5SYang Zhong  *  emulator main execution loop
3d9bb58e5SYang Zhong  *
4d9bb58e5SYang Zhong  *  Copyright (c) 2003-2005 Fabrice Bellard
5d9bb58e5SYang Zhong  *
6d9bb58e5SYang Zhong  * This library is free software; you can redistribute it and/or
7d9bb58e5SYang Zhong  * modify it under the terms of the GNU Lesser General Public
8d9bb58e5SYang Zhong  * License as published by the Free Software Foundation; either
9fb0343d5SThomas Huth  * version 2.1 of the License, or (at your option) any later version.
10d9bb58e5SYang Zhong  *
11d9bb58e5SYang Zhong  * This library is distributed in the hope that it will be useful,
12d9bb58e5SYang Zhong  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13d9bb58e5SYang Zhong  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14d9bb58e5SYang Zhong  * Lesser General Public License for more details.
15d9bb58e5SYang Zhong  *
16d9bb58e5SYang Zhong  * You should have received a copy of the GNU Lesser General Public
17d9bb58e5SYang Zhong  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18d9bb58e5SYang Zhong  */
19d9bb58e5SYang Zhong 
20d9bb58e5SYang Zhong #include "qemu/osdep.h"
21d9bb58e5SYang Zhong #include "sysemu/cpus.h"
2214a48c1dSMarkus Armbruster #include "sysemu/tcg.h"
23720ace24SRichard Henderson #include "qemu/plugin.h"
24*43e7a2d3SPhilippe Mathieu-Daudé #include "internal-common.h"
25d9bb58e5SYang Zhong 
268e2b7299SYang Zhong bool tcg_allowed;
278e2b7299SYang Zhong 
28d9bb58e5SYang Zhong /* exit the current TB, but without causing any exception to be raised */
cpu_loop_exit_noexc(CPUState * cpu)29d9bb58e5SYang Zhong void cpu_loop_exit_noexc(CPUState *cpu)
30d9bb58e5SYang Zhong {
31d9bb58e5SYang Zhong     cpu->exception_index = -1;
32afd46fcaSPavel Dovgalyuk     cpu_loop_exit(cpu);
33d9bb58e5SYang Zhong }
34d9bb58e5SYang Zhong 
cpu_loop_exit(CPUState * cpu)35d9bb58e5SYang Zhong void cpu_loop_exit(CPUState *cpu)
36d9bb58e5SYang Zhong {
37afd46fcaSPavel Dovgalyuk     /* Undo the setting in cpu_tb_exec.  */
38464dacf6SRichard Henderson     cpu->neg.can_do_io = true;
39e04660afSRichard Henderson     /* Undo any setting in generated code.  */
40e04660afSRichard Henderson     qemu_plugin_disable_mem_helpers(cpu);
41d9bb58e5SYang Zhong     siglongjmp(cpu->jmp_env, 1);
42d9bb58e5SYang Zhong }
43d9bb58e5SYang Zhong 
cpu_loop_exit_restore(CPUState * cpu,uintptr_t pc)44d9bb58e5SYang Zhong void cpu_loop_exit_restore(CPUState *cpu, uintptr_t pc)
45d9bb58e5SYang Zhong {
46d9bb58e5SYang Zhong     if (pc) {
473d419a4dSRichard Henderson         cpu_restore_state(cpu, pc);
48d9bb58e5SYang Zhong     }
49afd46fcaSPavel Dovgalyuk     cpu_loop_exit(cpu);
50d9bb58e5SYang Zhong }
51d9bb58e5SYang Zhong 
cpu_loop_exit_atomic(CPUState * cpu,uintptr_t pc)52d9bb58e5SYang Zhong void cpu_loop_exit_atomic(CPUState *cpu, uintptr_t pc)
53d9bb58e5SYang Zhong {
549877ea05SRichard Henderson     /* Prevent looping if already executing in a serial context. */
559877ea05SRichard Henderson     g_assert(!cpu_in_serial_context(cpu));
56d9bb58e5SYang Zhong     cpu->exception_index = EXCP_ATOMIC;
57d9bb58e5SYang Zhong     cpu_loop_exit_restore(cpu, pc);
58d9bb58e5SYang Zhong }
59