1cd71c089SLaurent Vivier /* 2cd71c089SLaurent Vivier * qemu user cpu loop 3cd71c089SLaurent Vivier * 4cd71c089SLaurent Vivier * Copyright (c) 2003-2008 Fabrice Bellard 5cd71c089SLaurent Vivier * 6cd71c089SLaurent Vivier * This program is free software; you can redistribute it and/or modify 7cd71c089SLaurent Vivier * it under the terms of the GNU General Public License as published by 8cd71c089SLaurent Vivier * the Free Software Foundation; either version 2 of the License, or 9cd71c089SLaurent Vivier * (at your option) any later version. 10cd71c089SLaurent Vivier * 11cd71c089SLaurent Vivier * This program is distributed in the hope that it will be useful, 12cd71c089SLaurent Vivier * but WITHOUT ANY WARRANTY; without even the implied warranty of 13cd71c089SLaurent Vivier * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14cd71c089SLaurent Vivier * GNU General Public License for more details. 15cd71c089SLaurent Vivier * 16cd71c089SLaurent Vivier * You should have received a copy of the GNU General Public License 17cd71c089SLaurent Vivier * along with this program; if not, see <http://www.gnu.org/licenses/>. 18cd71c089SLaurent Vivier */ 19cd71c089SLaurent Vivier 20b74c8981SPhilippe Mathieu-Daudé #ifndef USER_CPU_LOOP_H 21b74c8981SPhilippe Mathieu-Daudé #define USER_CPU_LOOP_H 22cd71c089SLaurent Vivier 23*d551b822SRichard Henderson #include "exec/vaddr.h" 241bf0d6e4SPhilippe Mathieu-Daudé #include "exec/mmu-access-type.h" 25*d551b822SRichard Henderson 26cd71c089SLaurent Vivier 271bf0d6e4SPhilippe Mathieu-Daudé /** 281bf0d6e4SPhilippe Mathieu-Daudé * adjust_signal_pc: 291bf0d6e4SPhilippe Mathieu-Daudé * @pc: raw pc from the host signal ucontext_t. 301bf0d6e4SPhilippe Mathieu-Daudé * @is_write: host memory operation was write, or read-modify-write. 311bf0d6e4SPhilippe Mathieu-Daudé * 321bf0d6e4SPhilippe Mathieu-Daudé * Alter @pc as required for unwinding. Return the type of the 331bf0d6e4SPhilippe Mathieu-Daudé * guest memory access -- host reads may be for guest execution. 341bf0d6e4SPhilippe Mathieu-Daudé */ 351bf0d6e4SPhilippe Mathieu-Daudé MMUAccessType adjust_signal_pc(uintptr_t *pc, bool is_write); 361bf0d6e4SPhilippe Mathieu-Daudé 371bf0d6e4SPhilippe Mathieu-Daudé /** 381bf0d6e4SPhilippe Mathieu-Daudé * handle_sigsegv_accerr_write: 391bf0d6e4SPhilippe Mathieu-Daudé * @cpu: the cpu context 401bf0d6e4SPhilippe Mathieu-Daudé * @old_set: the sigset_t from the signal ucontext_t 411bf0d6e4SPhilippe Mathieu-Daudé * @host_pc: the host pc, adjusted for the signal 421bf0d6e4SPhilippe Mathieu-Daudé * @host_addr: the host address of the fault 431bf0d6e4SPhilippe Mathieu-Daudé * 441bf0d6e4SPhilippe Mathieu-Daudé * Return true if the write fault has been handled, and should be re-tried. 451bf0d6e4SPhilippe Mathieu-Daudé */ 461bf0d6e4SPhilippe Mathieu-Daudé bool handle_sigsegv_accerr_write(CPUState *cpu, sigset_t *old_set, 47*d551b822SRichard Henderson uintptr_t host_pc, vaddr guest_addr); 481bf0d6e4SPhilippe Mathieu-Daudé 491bf0d6e4SPhilippe Mathieu-Daudé /** 501bf0d6e4SPhilippe Mathieu-Daudé * cpu_loop_exit_sigsegv: 511bf0d6e4SPhilippe Mathieu-Daudé * @cpu: the cpu context 521bf0d6e4SPhilippe Mathieu-Daudé * @addr: the guest address of the fault 531bf0d6e4SPhilippe Mathieu-Daudé * @access_type: access was read/write/execute 541bf0d6e4SPhilippe Mathieu-Daudé * @maperr: true for invalid page, false for permission fault 551bf0d6e4SPhilippe Mathieu-Daudé * @ra: host pc for unwinding 561bf0d6e4SPhilippe Mathieu-Daudé * 571bf0d6e4SPhilippe Mathieu-Daudé * Use the TCGCPUOps hook to record cpu state, do guest operating system 581bf0d6e4SPhilippe Mathieu-Daudé * specific things to raise SIGSEGV, and jump to the main cpu loop. 591bf0d6e4SPhilippe Mathieu-Daudé */ 60*d551b822SRichard Henderson G_NORETURN void cpu_loop_exit_sigsegv(CPUState *cpu, vaddr addr, 611bf0d6e4SPhilippe Mathieu-Daudé MMUAccessType access_type, 621bf0d6e4SPhilippe Mathieu-Daudé bool maperr, uintptr_t ra); 631bf0d6e4SPhilippe Mathieu-Daudé 641bf0d6e4SPhilippe Mathieu-Daudé /** 651bf0d6e4SPhilippe Mathieu-Daudé * cpu_loop_exit_sigbus: 661bf0d6e4SPhilippe Mathieu-Daudé * @cpu: the cpu context 671bf0d6e4SPhilippe Mathieu-Daudé * @addr: the guest address of the alignment fault 681bf0d6e4SPhilippe Mathieu-Daudé * @access_type: access was read/write/execute 691bf0d6e4SPhilippe Mathieu-Daudé * @ra: host pc for unwinding 701bf0d6e4SPhilippe Mathieu-Daudé * 711bf0d6e4SPhilippe Mathieu-Daudé * Use the TCGCPUOps hook to record cpu state, do guest operating system 721bf0d6e4SPhilippe Mathieu-Daudé * specific things to raise SIGBUS, and jump to the main cpu loop. 731bf0d6e4SPhilippe Mathieu-Daudé */ 74*d551b822SRichard Henderson G_NORETURN void cpu_loop_exit_sigbus(CPUState *cpu, vaddr addr, 751bf0d6e4SPhilippe Mathieu-Daudé MMUAccessType access_type, 761bf0d6e4SPhilippe Mathieu-Daudé uintptr_t ra); 771bf0d6e4SPhilippe Mathieu-Daudé 78166a4b6eSPhilippe Mathieu-Daudé G_NORETURN void cpu_loop(CPUArchState *env); 79166a4b6eSPhilippe Mathieu-Daudé 80bd5ccd61SHelge Deller void target_exception_dump(CPUArchState *env, const char *fmt, int code); 81bd5ccd61SHelge Deller #define EXCP_DUMP(env, fmt, code) \ 82bd5ccd61SHelge Deller target_exception_dump(env, fmt, code) 83cd71c089SLaurent Vivier 84fb5c28e1SPhilippe Mathieu-Daudé typedef struct target_pt_regs target_pt_regs; 85fb5c28e1SPhilippe Mathieu-Daudé 86fb5c28e1SPhilippe Mathieu-Daudé void target_cpu_copy_regs(CPUArchState *env, target_pt_regs *regs); 87fb5c28e1SPhilippe Mathieu-Daudé 88cd71c089SLaurent Vivier #endif 89