]> git.ipfire.org Git - thirdparty/qemu.git/commit
target/i386: Give IRQs a chance when resetting HF_INHIBIT_IRQ_MASK
authorRuihan Li <lrh2000@pku.edu.cn>
Mon, 15 Apr 2024 06:45:21 +0000 (14:45 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 3 May 2024 12:15:48 +0000 (14:15 +0200)
commit6a5a63f74ba5c5355b7a8468d3d814bfffe928fb
tree240a96626150b508257fc27fa2ffb6bab2f5ad3a
parent4977ce198d2390bff8c71ad5cb1a5f6aa24b56fb
target/i386: Give IRQs a chance when resetting HF_INHIBIT_IRQ_MASK

When emulated with QEMU, interrupts will never come in the following
loop. However, if the NOP instruction is uncommented, interrupts will
fire as normal.

loop:
cli
     call do_sti
jmp loop

do_sti:
sti
# nop
ret

This behavior is different from that of a real processor. For example,
if KVM is enabled, interrupts will always fire regardless of whether the
NOP instruction is commented or not. Also, the Intel Software Developer
Manual states that after the STI instruction is executed, the interrupt
inhibit should end as soon as the next instruction (e.g., the RET
instruction if the NOP instruction is commented) is executed.

This problem is caused because the previous code may choose not to end
the TB even if the HF_INHIBIT_IRQ_MASK has just been reset (e.g., in the
case where the STI instruction is immediately followed by the RET
instruction), so that IRQs may not have a change to trigger. This commit
fixes the problem by always terminating the current TB to give IRQs a
chance to trigger when HF_INHIBIT_IRQ_MASK is reset.

Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>
Message-ID: <20240415064518.4951-4-lrh2000@pku.edu.cn>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
target/i386/tcg/translate.c