target/i386: raise FERR interrupt with iothread locked
PATCH 1/1 target/i386: raise FERR interrupt with iothread locked
Otherwise tcg_handle_interrupt() triggers an assertion failure:
#5 0x0000555555c97369 in tcg_handle_interrupt (cpu=0x555557434cb0, mask=2) at ../accel/tcg/tcg-accel-ops.c:83 #6 tcg_handle_interrupt (cpu=0x555557434cb0, mask=2) at ../accel/tcg/tcg-accel-ops.c:81 #7 0x0000555555b4d58b in pic_irq_request (opaque=<optimized out>, irq=<optimized out>, level=1) at ../hw/i386/x86.c:555 #8 0x0000555555b4f218 in gsi_handler (opaque=0x5555579423d0, n=13, level=1) at ../hw/i386/x86.c:611 #9 0x00007fffa42bde14 in code_gen_buffer ()
#10 0x0000555555c724bb in cpu_tb_exec (cpu=cpu@entry=0x555557434cb0, itb=<optimized out>, tb_exit=tb_exit@entry=0x7fffe9bfd658) at ../accel/tcg/cpu-exec.c:457
Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1808
--- target/i386/tcg/sysemu/fpu_helper.c | 2 ++ 1 file changed, 2 insertions(+)
target/i386/tcg/sysemu/fpu_helper.c +2 -0
@@ -31,7 +31,9 @@ void x86_register_ferr_irq(qemu_irq irq)void fpu_check_raise_ferr_irq (CPUX86State *env) {if (ferr_irq && !(env->hflags2 &HF2_IGNNE_MASK )) { +qemu_mutex_lock_iothread ();qemu_irq_raise (ferr_irq); +qemu_mutex_unlock_iothread ();return ; } }
Signature · 1 line
2.41.0
Quoted 22 lines · Paolo Bonzini
Otherwise
tcg_handle_interrupt()triggers an assertion failure:#5 0x0000555555c97369 in tcg_handle_interrupt (cpu=0x555557434cb0, mask=2) at ../accel/tcg/tcg-accel-ops.c:83 #6 tcg_handle_interrupt (cpu=0x555557434cb0, mask=2) at ../accel/tcg/tcg-accel-ops.c:81 #7 0x0000555555b4d58b in pic_irq_request (opaque=<optimized out>, irq=<optimized out>, level=1) at ../hw/i386/x86.c:555 #8 0x0000555555b4f218 in gsi_handler (opaque=0x5555579423d0, n=13, level=1) at ../hw/i386/x86.c:611 #9 0x00007fffa42bde14 in code_gen_buffer ()#10
0x0000555555c724bbincpu_tb_exec(cpu=cpu@entry=0x555557434cb0, itb=<optimized out>, tb_exit=tb_exit@entry=0x7fffe9bfd658) at../accel/tcg/cpu-exec.c:457Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1808Reported-by NyanCatTW1 <https://gitlab.com/a0939712328>Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/tcg/sysemu/fpu_helper.c | 2 ++ 1 file changed, 2 insertions(+)target/i386/tcg/sysemu/fpu_helper.c +0
-0
target/i386/tcg/sysemu/fpu_helper.c void x86_register_ferr_irq(qemu_irq irq) · line 39
Quoted 9 lines
target/i386/tcg/sysemu/fpu_helper.c +2
-0@@ -31,7 +31,9 @@ void x86_register_ferr_irq(qemu_irq irq)void fpu_check_raise_ferr_irq (CPUX86State *env) {if (ferr_irq && !(env->hflags2 &HF2_IGNNE_MASK )) { +qemu_mutex_lock_iothread ();qemu_irq_raise (ferr_irq); +qemu_mutex_unlock_iothread ();return ; } }
OK, so:
Maybe for completeness, squash this? :
-- >8 --
target/i386/tcg/sysemu/fpu_helper.c +2 -1
@@ -45,6 +45,8 @@ void cpu_clear_ignne(void)void cpu_set_ignne (void ) {CPUX86State *env = &X86_CPU (first_cpu)->env; + +g_assert (qemu_mutex_iothread_locked ()); env->hflags2 |=HF2_IGNNE_MASK ;/* ---
Somehow similar pattern so what about MIPS MTC0?:
mtc0_compare() ->
helper_mtc0_compare() ->
cpu_mips_store_compare() ->
qemu_irq_lower()Regards,
Phil.
Quoted 36 lines · Philippe Mathieu-Daudé
Quoted 22 lines · Paolo Bonzini
Otherwise
tcg_handle_interrupt()triggers an assertion failure:#5 0x0000555555c97369 in tcg_handle_interrupt (cpu=0x555557434cb0, mask=2) at ../accel/tcg/tcg-accel-ops.c:83 #6 tcg_handle_interrupt (cpu=0x555557434cb0, mask=2) at ../accel/tcg/tcg-accel-ops.c:81 #7 0x0000555555b4d58b in pic_irq_request (opaque=<optimized out>, irq=<optimized out>, level=1) at ../hw/i386/x86.c:555 #8 0x0000555555b4f218 in gsi_handler (opaque=0x5555579423d0, n=13, level=1) at ../hw/i386/x86.c:611 #9 0x00007fffa42bde14 in code_gen_buffer ()#10
0x0000555555c724bbincpu_tb_exec(cpu=cpu@entry=0x555557434cb0, itb=<optimized out>, tb_exit=tb_exit@entry=0x7fffe9bfd658) at../accel/tcg/cpu-exec.c:457Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1808Reported-by NyanCatTW1 <https://gitlab.com/a0939712328>Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/tcg/sysemu/fpu_helper.c | 2 ++ 1 file changed, 2 insertions(+)target/i386/tcg/sysemu/fpu_helper.c +0
-0target/i386/tcg/sysemu/fpu_helper.c void x86_register_ferr_irq(qemu_irq irq) · line 39
Quoted 9 lines
target/i386/tcg/sysemu/fpu_helper.c +2
-0@@ -31,7 +31,9 @@ void x86_register_ferr_irq(qemu_irq irq)void fpu_check_raise_ferr_irq (CPUX86State *env) {if (ferr_irq && !(env->hflags2 &HF2_IGNNE_MASK )) { +qemu_mutex_lock_iothread ();qemu_irq_raise (ferr_irq); +qemu_mutex_unlock_iothread ();return ; } }OK, so:
Quoted 1 line
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Actually Richard has a better (though also slightly incomplete) patch in the bug, so I'll send v2.
target/i386/tcg/sysemu/fpu_helper.c void cpu_clear_ignne(void) · line 49
Quoted 5 lines
void cpu_set_ignne(void) { CPUX86State *env = &X86_CPU(first_cpu)->env;target/i386/tcg/sysemu/fpu_helper.c +2
-0+ +g_assert (qemu_mutex_iothread_locked ());
qemu_irq_lower() is fine because it doesn't result in a call to tcg_handle_interrupt().
Paolo
Quoted 6 lines
Somehow similar pattern so what about MIPS MTC0?:
mtc0_compare()->
helper_mtc0_compare()->cpu_mips_store_compare() -> qemu_irq_lower()
Lower is a bit safer
Quoted 44 lines · Paolo Bonzini
Quoted 36 lines · Philippe Mathieu-Daudé
Quoted 22 lines · Paolo Bonzini
Otherwise
tcg_handle_interrupt()triggers an assertion failure:#5 0x0000555555c97369 in tcg_handle_interrupt (cpu=0x555557434cb0, mask=2) at ../accel/tcg/tcg-accel-ops.c:83 #6 tcg_handle_interrupt (cpu=0x555557434cb0, mask=2) at ../accel/tcg/tcg-accel-ops.c:81 #7 0x0000555555b4d58b in pic_irq_request (opaque=<optimized out>, irq=<optimized out>, level=1) at ../hw/i386/x86.c:555 #8 0x0000555555b4f218 in gsi_handler (opaque=0x5555579423d0, n=13, level=1) at ../hw/i386/x86.c:611 #9 0x00007fffa42bde14 in code_gen_buffer ()#10
0x0000555555c724bbincpu_tb_exec(cpu=cpu@entry=0x555557434cb0, itb=<optimized out>, tb_exit=tb_exit@entry=0x7fffe9bfd658) at../accel/tcg/cpu-exec.c:457Cc: [email protected]
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1808Reported-by NyanCatTW1 <https://gitlab.com/a0939712328>Signed-off-by Paolo Bonzini <[email protected]>--- target/i386/tcg/sysemu/fpu_helper.c | 2 ++ 1 file changed, 2 insertions(+)target/i386/tcg/sysemu/fpu_helper.c +0
-0target/i386/tcg/sysemu/fpu_helper.c void x86_register_ferr_irq(qemu_irq irq) · line 39
Quoted 9 lines
target/i386/tcg/sysemu/fpu_helper.c +2
-0@@ -31,7 +31,9 @@ void x86_register_ferr_irq(qemu_irq irq)void fpu_check_raise_ferr_irq (CPUX86State *env) {if (ferr_irq && !(env->hflags2 &HF2_IGNNE_MASK )) { +qemu_mutex_lock_iothread ();qemu_irq_raise (ferr_irq); +qemu_mutex_unlock_iothread ();return ; } }OK, so:
Quoted 1 line
Reviewed-by Philippe Mathieu-Daudé <[email protected]>Actually Richard has a better (though also slightly incomplete) patch in the bug, so I'll send v2.
Quoted 8 lines
target/i386/tcg/sysemu/fpu_helper.c void cpu_clear_ignne(void) · line 49
Quoted 5 lines
void cpu_set_ignne(void) { CPUX86State *env = &X86_CPU(first_cpu)->env;target/i386/tcg/sysemu/fpu_helper.c +2
-0+ +g_assert (qemu_mutex_iothread_locked ());
qemu_irq_lower()is fine because it doesn't result in a call totcg_handle_interrupt().
It does potentially result in calling code in a device model that assumes that it is protected by the iothread lock, though...
-- PMM