]>
Commit | Line | Data |
---|---|---|
a77dabc3 | 1 | /* |
45e077d7 CF |
2 | * QEMU TCG vCPU common functionality |
3 | * | |
4 | * Functionality common to all TCG vCPU variants: mttcg, rr and icount. | |
a77dabc3 CF |
5 | * |
6 | * Copyright (c) 2003-2008 Fabrice Bellard | |
7 | * Copyright (c) 2014 Red Hat Inc. | |
8 | * | |
9 | * Permission is hereby granted, free of charge, to any person obtaining a copy | |
10 | * of this software and associated documentation files (the "Software"), to deal | |
11 | * in the Software without restriction, including without limitation the rights | |
12 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | |
13 | * copies of the Software, and to permit persons to whom the Software is | |
14 | * furnished to do so, subject to the following conditions: | |
15 | * | |
16 | * The above copyright notice and this permission notice shall be included in | |
17 | * all copies or substantial portions of the Software. | |
18 | * | |
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | |
20 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | |
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | |
22 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | |
23 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | |
24 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | |
25 | * THE SOFTWARE. | |
26 | */ | |
27 | ||
28 | #include "qemu/osdep.h" | |
29 | #include "qemu-common.h" | |
30 | #include "sysemu/tcg.h" | |
31 | #include "sysemu/replay.h" | |
32 | #include "qemu/main-loop.h" | |
33 | #include "qemu/guest-random.h" | |
34 | #include "exec/exec-all.h" | |
35 | #include "hw/boards.h" | |
36 | ||
37 | #include "tcg-cpus.h" | |
38 | ||
45e077d7 | 39 | /* common functionality among all TCG variants */ |
a77dabc3 | 40 | |
45e077d7 | 41 | void qemu_tcg_destroy_vcpu(CPUState *cpu) |
a77dabc3 | 42 | { |
45e077d7 | 43 | cpu_thread_signal_destroyed(cpu); |
a77dabc3 CF |
44 | } |
45 | ||
45e077d7 | 46 | int tcg_cpu_exec(CPUState *cpu) |
a77dabc3 | 47 | { |
45e077d7 CF |
48 | int ret; |
49 | #ifdef CONFIG_PROFILER | |
50 | int64_t ti; | |
51 | #endif | |
52 | assert(tcg_enabled()); | |
53 | #ifdef CONFIG_PROFILER | |
54 | ti = profile_getclock(); | |
55 | #endif | |
56 | cpu_exec_start(cpu); | |
57 | ret = cpu_exec(cpu); | |
58 | cpu_exec_end(cpu); | |
59 | #ifdef CONFIG_PROFILER | |
60 | qatomic_set(&tcg_ctx->prof.cpu_exec_time, | |
61 | tcg_ctx->prof.cpu_exec_time + profile_getclock() - ti); | |
62 | #endif | |
63 | return ret; | |
a77dabc3 CF |
64 | } |
65 | ||
bb4776be | 66 | /* mask must never be zero, except for A20 change call */ |
45e077d7 | 67 | void tcg_handle_interrupt(CPUState *cpu, int mask) |
bb4776be | 68 | { |
bb4776be CF |
69 | g_assert(qemu_mutex_iothread_locked()); |
70 | ||
bb4776be CF |
71 | cpu->interrupt_request |= mask; |
72 | ||
73 | /* | |
74 | * If called from iothread context, wake the target cpu in | |
75 | * case its halted. | |
76 | */ | |
77 | if (!qemu_cpu_is_self(cpu)) { | |
78 | qemu_cpu_kick(cpu); | |
79 | } else { | |
80 | qatomic_set(&cpu_neg(cpu)->icount_decr.u16.high, -1); | |
bb4776be CF |
81 | } |
82 | } |