[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 31/74] cpu-exec: convert to cpu_halted
From: |
Robert Foley |
Subject: |
[PATCH v8 31/74] cpu-exec: convert to cpu_halted |
Date: |
Thu, 26 Mar 2020 15:31:13 -0400 |
From: "Emilio G. Cota" <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Reviewed-by: Alex Bennée <address@hidden>
Signed-off-by: Emilio G. Cota <address@hidden>
Signed-off-by: Robert Foley <address@hidden>
---
accel/tcg/cpu-exec.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c
index d95c4848a4..e296894ea1 100644
--- a/accel/tcg/cpu-exec.c
+++ b/accel/tcg/cpu-exec.c
@@ -425,14 +425,21 @@ static inline TranslationBlock *tb_find(CPUState *cpu,
return tb;
}
-static inline bool cpu_handle_halt(CPUState *cpu)
+static inline bool cpu_handle_halt_locked(CPUState *cpu)
{
- if (cpu->halted) {
+ g_assert(cpu_mutex_locked(cpu));
+
+ if (cpu_halted(cpu)) {
#if defined(TARGET_I386) && !defined(CONFIG_USER_ONLY)
if ((cpu->interrupt_request & CPU_INTERRUPT_POLL)
&& replay_interrupt()) {
X86CPU *x86_cpu = X86_CPU(cpu);
+
+ /* prevent deadlock; cpu_mutex must be acquired _after_ the BQL */
+ cpu_mutex_unlock(cpu);
qemu_mutex_lock_iothread();
+ cpu_mutex_lock(cpu);
+
apic_poll_irq(x86_cpu->apic_state);
cpu_reset_interrupt(cpu, CPU_INTERRUPT_POLL);
qemu_mutex_unlock_iothread();
@@ -442,12 +449,22 @@ static inline bool cpu_handle_halt(CPUState *cpu)
return true;
}
- cpu->halted = 0;
+ cpu_halted_set(cpu, 0);
}
return false;
}
+static inline bool cpu_handle_halt(CPUState *cpu)
+{
+ bool ret;
+
+ cpu_mutex_lock(cpu);
+ ret = cpu_handle_halt_locked(cpu);
+ cpu_mutex_unlock(cpu);
+ return ret;
+}
+
static inline void cpu_handle_debug_exception(CPUState *cpu)
{
CPUClass *cc = CPU_GET_CLASS(cpu);
@@ -546,7 +563,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu,
} else if (interrupt_request & CPU_INTERRUPT_HALT) {
replay_interrupt();
cpu->interrupt_request &= ~CPU_INTERRUPT_HALT;
- cpu->halted = 1;
+ cpu_halted_set(cpu, 1);
cpu->exception_index = EXCP_HLT;
qemu_mutex_unlock_iothread();
return true;
--
2.17.1
- [PATCH v8 24/74] mips: convert to cpu_halted, (continued)
- [PATCH v8 24/74] mips: convert to cpu_halted, Robert Foley, 2020/03/26
- [PATCH v8 25/74] riscv: convert to cpu_halted, Robert Foley, 2020/03/26
- [PATCH v8 28/74] xtensa: convert to cpu_halted, Robert Foley, 2020/03/26
- [PATCH v8 27/74] sparc: convert to cpu_halted, Robert Foley, 2020/03/26
- [PATCH v8 26/74] s390x: convert to cpu_halted, Robert Foley, 2020/03/26
- [PATCH v8 34/74] ppc: use cpu_reset_interrupt, Robert Foley, 2020/03/26
- [PATCH v8 36/74] i386: use cpu_reset_interrupt, Robert Foley, 2020/03/26
- [PATCH v8 39/74] arm: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 29/74] gdbstub: convert to cpu_halted, Robert Foley, 2020/03/26
- [PATCH v8 30/74] openrisc: convert to cpu_halted, Robert Foley, 2020/03/26
- [PATCH v8 31/74] cpu-exec: convert to cpu_halted,
Robert Foley <=
- [PATCH v8 32/74] cpu: convert to cpu_halted, Robert Foley, 2020/03/26
- [PATCH v8 33/74] cpu: define cpu_interrupt_request helpers, Robert Foley, 2020/03/26
- [PATCH v8 35/74] exec: use cpu_reset_interrupt, Robert Foley, 2020/03/26
- [PATCH v8 37/74] s390x: use cpu_reset_interrupt, Robert Foley, 2020/03/26
- [PATCH v8 38/74] openrisc: use cpu_reset_interrupt, Robert Foley, 2020/03/26
- [PATCH v8 43/74] i386/whpx-all: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 40/74] i386: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 46/74] sh4: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 41/74] i386/kvm: convert to cpu_interrupt_request, Robert Foley, 2020/03/26
- [PATCH v8 42/74] i386/hax-all: convert to cpu_interrupt_request, Robert Foley, 2020/03/26