| 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/vaddr.h" |
| 24 | #include "exec/mmu-access-type.h" |
| 25 | #include "accel/tcg/cpu-loop.h" |
| 26 | |
| 27 | /** |
| 28 | * adjust_signal_pc: |
| 29 | * @pc: raw pc from the host signal ucontext_t. |
| 30 | * @is_write: host memory operation was write, or read-modify-write. |
| 31 | * |
| 32 | * Alter @pc as required for unwinding. Return the type of the |
| 33 | * guest memory access -- host reads may be for guest execution. |
| 34 | */ |
| 35 | MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write); |
| 36 | |
| 37 | /** |
| 38 | * handle_sigsegv_accerr_write: |
| 39 | * @cpu: the cpu context |
| 40 | * @old_set: the sigset_t from the signal ucontext_t |
| 41 | * @host_pc: the host pc, adjusted for the signal |
| 42 | * @host_addr: the host address of the fault |
| 43 | * |
| 44 | * Return true if the write fault has been handled, and should be re-tried. |
| 45 | */ |
| 46 | bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set, |
| 47 | uintptr_t host_pc, vaddr guest_addr); |
| 48 | |
| 49 | /** |
| 50 | * cpu_loop_exit_sigsegv: |
| 51 | * @cpu: the cpu context |
| 52 | * @addr: the guest address of the fault |
| 53 | * @access_type: access was read/write/execute |
| 54 | * @maperr: true for invalid page, false for permission fault |
| 55 | * @ra: host pc for unwinding |
| 56 | * |
| 57 | * Use the TCGCPUOps hook to record cpu state, do guest operating system |
| 58 | * specific things to raise SIGSEGV, and jump to the main cpu loop. |
| 59 | */ |
| 60 | G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, vaddr addr, |
| 61 | MMUAccessType access_type, |
| 62 | bool maperr, uintptr_t ra); |
| 63 | |
| 64 | /** |
| 65 | * cpu_loop_exit_sigbus: |
| 66 | * @cpu: the cpu context |
| 67 | * @addr: the guest address of the alignment fault |
| 68 | * @access_type: access was read/write/execute |
| 69 | * @ra: host pc for unwinding |
| 70 | * |
| 71 | * Use the TCGCPUOps hook to record cpu state, do guest operating system |
| 72 | * specific things to raise SIGBUS, and jump to the main cpu loop. |
| 73 | */ |
| 74 | G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, vaddr addr, |
| 75 | MMUAccessType access_type, |
| 76 | uintptr_t ra); |
| 77 | |
| 78 | G_NORETURN void cpu_loop(CPUArchState *env); |
| 79 | |
| 80 | void target_exception_dump(CPUArchState *env, const char *fmt, int code); |
| 81 | #define EXCP_DUMP(env, fmt, code) \ |
| 82 | target_exception_dump(env, fmt, code) |
| 83 | |
| 84 | #endif |