All of lore.kernel.org
 help / color / mirror / Atom feed
From: Xiaojuan Yang <yangxiaojuan@loongson.cn>
To: qemu-devel@nongnu.org
Cc: richard.henderson@linaro.org, gaosong@loongson.cn,
	maobibo@loongson.cn, mark.cave-ayland@ilande.co.uk,
	mst@redhat.com, imammedo@redhat.com, ani@anisinha.ca,
	f4bug@amsat.org, peter.maydell@linaro.org
Subject: [PATCH 09/11] target/loongarch: Add lock when writing timer clear reg
Date: Fri,  1 Jul 2022 17:34:05 +0800	[thread overview]
Message-ID: <20220701093407.2150607-10-yangxiaojuan@loongson.cn> (raw)
In-Reply-To: <20220701093407.2150607-1-yangxiaojuan@loongson.cn>

There is such error info when running linux kernel:
    tcg_handle_interrupt: assertion failed: (qemu_mutex_iothread_locked()).
    calling stack:
    #0 in raise () at /lib64/libc.so.6
    #1 in abort () at /lib64/libc.so.6
    #2 in g_assertion_message_expr.cold () at /lib64/libglib-2.0.so.0
    #3 in g_assertion_message_expr () at /lib64/libglib-2.0.so.0
    #4 in tcg_handle_interrupt (cpu=0x632000030800, mask=2) at ../accel/tcg/tcg-accel-ops.c:79
    #5 in cpu_interrupt (cpu=0x632000030800, mask=2) at ../softmmu/cpus.c:248
    #6 in loongarch_cpu_set_irq (opaque=0x632000030800, irq=11, level=0)
       at ../target/loongarch/cpu.c:100
    #7 in helper_csrwr_ticlr (env=0x632000039440, val=1) at ../target/loongarch/csr_helper.c:85
    #8 in code_gen_buffer ()
    #9 in cpu_tb_exec (cpu=0x632000030800, itb=0x7fff946ac280, tb_exit=0x7ffe4fcb6c30)
       at ../accel/tcg/cpu-exec.c:358

Add mutex iothread lock around loongarch_cpu_set_irq in csrwr_ticlr() to
fix the bug.

Signed-off-by: Xiaojuan Yang <yangxiaojuan@loongson.cn>
---
 target/loongarch/csr_helper.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/target/loongarch/csr_helper.c b/target/loongarch/csr_helper.c
index 24a9389364..7e02787895 100644
--- a/target/loongarch/csr_helper.c
+++ b/target/loongarch/csr_helper.c
@@ -81,7 +81,9 @@ target_ulong helper_csrwr_ticlr(CPULoongArchState *env, target_ulong val)
     int64_t old_v = 0;
 
     if (val & 0x1) {
+        qemu_mutex_lock_iothread();
         loongarch_cpu_set_irq(cpu, IRQ_TIMER, 0);
+        qemu_mutex_unlock_iothread();
     }
     return old_v;
 }
-- 
2.31.1



  parent reply	other threads:[~2022-07-01  9:49 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-01  9:33 [PATCH v2 00/11] Fix bugs for LoongArch virt machine Xiaojuan Yang
2022-07-01  9:33 ` [PATCH 01/11] hw/rtc/ls7a_rtc: Fix uninitialied bugs and toymatch writing function Xiaojuan Yang
2022-07-04  5:13   ` Richard Henderson
2022-07-01  9:33 ` [PATCH 02/11] hw/rtc/ls7a_rtc: Fix timer call back function Xiaojuan Yang
2022-07-04  5:13   ` Richard Henderson
2022-07-01  9:33 ` [PATCH 03/11] hw/rtc/ls7a_rtc: Remove unimplemented device in realized function Xiaojuan Yang
2022-07-04  5:13   ` Richard Henderson
2022-07-01  9:34 ` [PATCH 04/11] hw/rtc/ls7a_rtc: Add reset function Xiaojuan Yang
2022-07-01  9:34 ` [PATCH 05/11] hw/rtc/ls7a_rtc: Fix rtc enable and disable function Xiaojuan Yang
2022-07-04  5:14   ` Richard Henderson
2022-07-01  9:34 ` [PATCH 06/11] hw/rtc/ls7a_rtc: Use tm struct pointer as arguments in toy_time_to_val() Xiaojuan Yang
2022-07-04  5:15   ` Richard Henderson
2022-07-01  9:34 ` [PATCH 07/11] hw/rtc/ls7a_rtc: Fix 'calculate' spelling errors Xiaojuan Yang
2022-07-04  5:15   ` Richard Henderson
2022-07-01  9:34 ` [PATCH 08/11] target/loongarch: Fix the meaning of ECFG reg's VS field Xiaojuan Yang
2022-07-04  5:18   ` Richard Henderson
2022-07-04  6:04     ` gaosong
2022-07-01  9:34 ` Xiaojuan Yang [this message]
2022-07-04  5:19   ` [PATCH 09/11] target/loongarch: Add lock when writing timer clear reg Richard Henderson
2022-07-01  9:34 ` [PATCH 10/11] hw/intc/loongarch_ipi: Fix ipi device access of 64bits Xiaojuan Yang
2022-07-04  5:28   ` Richard Henderson
2022-07-04  9:09     ` gaosong
2022-07-01  9:34 ` [PATCH 11/11] hw/intc/loongarch_ipi: Fix mail send and any send function Xiaojuan Yang
2022-07-04  5:37   ` Richard Henderson
2022-07-04  9:10     ` gaosong
2022-07-04  9:26       ` Richard Henderson
2022-07-04  5:41 ` [PATCH v2 00/11] Fix bugs for LoongArch virt machine Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220701093407.2150607-10-yangxiaojuan@loongson.cn \
    --to=yangxiaojuan@loongson.cn \
    --cc=ani@anisinha.ca \
    --cc=f4bug@amsat.org \
    --cc=gaosong@loongson.cn \
    --cc=imammedo@redhat.com \
    --cc=maobibo@loongson.cn \
    --cc=mark.cave-ayland@ilande.co.uk \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.