1 /* 2 * qemu user cpu loop 3 * 4 * Copyright (c) 2003-2008 Fabrice Bellard 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef USER_CPU_LOOP_H 21 #define USER_CPU_LOOP_H 22 23 #include "exec/abi_ptr.h" 24 #include "exec/mmu-access-type.h" 25 #include "exec/log.h" 26 #include "exec/target_long.h" 27 #include "special-errno.h" 28 29 /** 30 * adjust_signal_pc: 31 * @pc: raw pc from the host signal ucontext_t. 32 * @is_write: host memory operation was write, or read-modify-write. 33 * 34 * Alter @pc as required for unwinding. Return the type of the 35 * guest memory access -- host reads may be for guest execution. 36 */ 37 MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write); 38 39 /** 40 * handle_sigsegv_accerr_write: 41 * @cpu: the cpu context 42 * @old_set: the sigset_t from the signal ucontext_t 43 * @host_pc: the host pc, adjusted for the signal 44 * @host_addr: the host address of the fault 45 * 46 * Return true if the write fault has been handled, and should be re-tried. 47 */ 48 bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set, 49 uintptr_t host_pc, abi_ptr guest_addr); 50 51 /** 52 * cpu_loop_exit_sigsegv: 53 * @cpu: the cpu context 54 * @addr: the guest address of the fault 55 * @access_type: access was read/write/execute 56 * @maperr: true for invalid page, false for permission fault 57 * @ra: host pc for unwinding 58 * 59 * Use the TCGCPUOps hook to record cpu state, do guest operating system 60 * specific things to raise SIGSEGV, and jump to the main cpu loop. 61 */ 62 G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr, 63 MMUAccessType access_type, 64 bool maperr, uintptr_t ra); 65 66 /** 67 * cpu_loop_exit_sigbus: 68 * @cpu: the cpu context 69 * @addr: the guest address of the alignment fault 70 * @access_type: access was read/write/execute 71 * @ra: host pc for unwinding 72 * 73 * Use the TCGCPUOps hook to record cpu state, do guest operating system 74 * specific things to raise SIGBUS, and jump to the main cpu loop. 75 */ 76 G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr, 77 MMUAccessType access_type, 78 uintptr_t ra); 79 80 G_NORETURN void cpu_loop(CPUArchState *env); 81 82 void target_exception_dump(CPUArchState *env, const char *fmt, int code); 83 #define EXCP_DUMP(env, fmt, code) \ 84 target_exception_dump(env, fmt, code) 85 86 typedef struct target_pt_regs target_pt_regs; 87 88 void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs); 89 90 #endif 91