We are changing the critical section from being around the majority of the cpu_handle_interrupt to instead be around just the call to ->cpu_exec_interrupt.
This is in preparation for pushing down the BQL into the per arch implementation. We should mention that we discussed these changes as well as some open questions here: https://lists.gnu.org/archive/html/qemu-devel/2020-08/msg01189.html With the main open question being: BQL is clearly needed to protect the critical section around the call to ->cpu_exec_interrupt. What else is the BQL protecting in cpu_handle_interrupt that we need to consider? Are we missing anything here? Signed-off-by: Robert Foley <robert.fo...@linaro.org> --- accel/tcg/cpu-exec.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index e661635f06..499a8bdc5e 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -556,7 +556,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, if (unlikely(cpu_interrupt_request(cpu))) { int interrupt_request; - qemu_mutex_lock_iothread(); interrupt_request = cpu_interrupt_request(cpu); if (unlikely(cpu->singlestep_enabled & SSTEP_NOIRQ)) { /* Mask out external interrupts for this step. */ @@ -565,7 +564,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, if (interrupt_request & CPU_INTERRUPT_DEBUG) { cpu_reset_interrupt(cpu, CPU_INTERRUPT_DEBUG); cpu->exception_index = EXCP_DEBUG; - qemu_mutex_unlock_iothread(); return true; } if (replay_mode == REPLAY_MODE_PLAY && !replay_has_interrupt()) { @@ -575,13 +573,13 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, cpu_reset_interrupt(cpu, CPU_INTERRUPT_HALT); cpu_halted_set(cpu, 1); cpu->exception_index = EXCP_HLT; - qemu_mutex_unlock_iothread(); return true; } #if defined(TARGET_I386) else if (interrupt_request & CPU_INTERRUPT_INIT) { X86CPU *x86_cpu = X86_CPU(cpu); CPUArchState *env = &x86_cpu->env; + qemu_mutex_lock_iothread(); replay_interrupt(); cpu_svm_check_intercept_param(env, SVM_EXIT_INIT, 0, 0); do_cpu_init(x86_cpu); @@ -593,7 +591,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, else if (interrupt_request & CPU_INTERRUPT_RESET) { replay_interrupt(); cpu_reset(cpu); - qemu_mutex_unlock_iothread(); return true; } #endif @@ -602,6 +599,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, True when it is, and we should restart on a new TB, and via longjmp via cpu_loop_exit. */ else { + qemu_mutex_lock_iothread(); if (cc->cpu_exec_interrupt(cpu, interrupt_request)) { replay_interrupt(); /* @@ -616,6 +614,7 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, /* The target hook may have updated the 'cpu->interrupt_request'; * reload the 'interrupt_request' value */ interrupt_request = cpu_interrupt_request(cpu); + qemu_mutex_unlock_iothread(); } if (interrupt_request & CPU_INTERRUPT_EXITTB) { cpu_reset_interrupt(cpu, CPU_INTERRUPT_EXITTB); @@ -625,7 +624,6 @@ static inline bool cpu_handle_interrupt(CPUState *cpu, } /* If we exit via cpu_loop_exit/longjmp it is reset in cpu_exec */ - qemu_mutex_unlock_iothread(); } /* Finally, check if we need to exit to the main loop. */ -- 2.17.1