]> git.proxmox.com Git - mirror_qemu.git/blame - bsd-user/signal.c
bsd-user/signal.c: implement abstract target / host signal translation
[mirror_qemu.git] / bsd-user / signal.c
CommitLineData
84778508
BS
1/*
2 * Emulation of BSD signals
3 *
4 * Copyright (c) 2003 - 2008 Fabrice Bellard
1366ef81 5 * Copyright (c) 2013 Stacey Son
84778508
BS
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
8167ee88 18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
84778508 19 */
84778508 20
5abfac27 21#include "qemu/osdep.h"
84778508 22#include "qemu.h"
0ef59989 23#include "signal-common.h"
fc9f9bdd 24#include "hw/core/tcg-cpu-ops.h"
84778508 25
835b04ed
WL
26/*
27 * Stubbed out routines until we merge signal support from bsd-user
28 * fork.
29 */
30
1366ef81
WL
31/*
32 * The BSD ABIs use the same singal numbers across all the CPU architectures, so
33 * (unlike Linux) these functions are just the identity mapping. This might not
34 * be true for XyzBSD running on AbcBSD, which doesn't currently work.
35 */
36int host_to_target_signal(int sig)
37{
38 return sig;
39}
40
41int target_to_host_signal(int sig)
42{
43 return sig;
44}
45
5abfac27
WL
46/*
47 * Queue a signal so that it will be send to the virtual CPU as soon as
48 * possible.
49 */
50void queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
51{
52 qemu_log_mask(LOG_UNIMP, "No signal queueing, dropping signal %d\n", sig);
53}
54
0ef59989
WL
55/*
56 * Force a synchronously taken QEMU_SI_FAULT signal. For QEMU the
57 * 'force' part is handled in process_pending_signals().
58 */
59void force_sig_fault(int sig, int code, abi_ulong addr)
60{
61 CPUState *cpu = thread_cpu;
62 CPUArchState *env = cpu->env_ptr;
63 target_siginfo_t info = {};
64
65 info.si_signo = sig;
66 info.si_errno = 0;
67 info.si_code = code;
68 info.si_addr = addr;
69 queue_signal(env, sig, &info);
70}
71
84778508
BS
72void signal_init(void)
73{
74}
75
9349b4f9 76void process_pending_signals(CPUArchState *cpu_env)
84778508
BS
77{
78}
835b04ed
WL
79
80void cpu_loop_exit_sigsegv(CPUState *cpu, target_ulong addr,
81 MMUAccessType access_type, bool maperr, uintptr_t ra)
82{
fc9f9bdd
WL
83 const struct TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops;
84
85 if (tcg_ops->record_sigsegv) {
86 tcg_ops->record_sigsegv(cpu, addr, access_type, maperr, ra);
87 }
88
89 force_sig_fault(TARGET_SIGSEGV,
90 maperr ? TARGET_SEGV_MAPERR : TARGET_SEGV_ACCERR,
91 addr);
92 cpu->exception_index = EXCP_INTERRUPT;
93 cpu_loop_exit_restore(cpu, ra);
835b04ed
WL
94}
95
96void cpu_loop_exit_sigbus(CPUState *cpu, target_ulong addr,
97 MMUAccessType access_type, uintptr_t ra)
98{
cfdee273
WL
99 const struct TCGCPUOps *tcg_ops = CPU_GET_CLASS(cpu)->tcg_ops;
100
101 if (tcg_ops->record_sigbus) {
102 tcg_ops->record_sigbus(cpu, addr, access_type, ra);
103 }
104
105 force_sig_fault(TARGET_SIGBUS, TARGET_BUS_ADRALN, addr);
106 cpu->exception_index = EXCP_INTERRUPT;
107 cpu_loop_exit_restore(cpu, ra);
835b04ed 108}