All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: qemu-devel@nongnu.org
Subject: [PULL 03/11] target/mips: save CP0 timer in vmstate
Date: Tue, 31 Mar 2026 15:15:05 +0200	[thread overview]
Message-ID: <20260331131514.21152-4-philmd@linaro.org> (raw)
In-Reply-To: <20260331131514.21152-1-philmd@linaro.org>

From: Trieu Huynh <vikingtc4@gmail.com>

The MIPS R4K CP0 timer (env->timer) is not included in vmstate_mips_cpu,
so after loadvm the QEMUTimer has no scheduled expiry. This causes
qemu_poll_ns() to block indefinitely and the guest to freeze until an
external I/O event (e.g. a keypress) wakes the main loop.

Fix by adding an optional vmstate subsection for the timer, following
the same pattern used by ARM (gt_timer), RISC-V (env.stimer), SPARC
(qtimer), and OpenRISC (timer).

The .needed callback returns false when env->timer is NULL (KVM mode),
keeping the subsection optional for backwards compatibility with
existing snapshots.

Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1987
Signed-off-by: Trieu Huynh <vikingtc4@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20260329113732.482619-1-vikingtc4@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 target/mips/system/machine.c | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/target/mips/system/machine.c b/target/mips/system/machine.c
index 8af11fd896b..473d3ab0363 100644
--- a/target/mips/system/machine.c
+++ b/target/mips/system/machine.c
@@ -3,6 +3,7 @@
 #include "internal.h"
 #include "migration/cpu.h"
 #include "fpu_helper.h"
+#include "qemu/timer.h"
 
 static int cpu_post_load(void *opaque, int version_id)
 {
@@ -219,6 +220,23 @@ static const VMStateDescription vmstate_tlb = {
 
 /* MIPS CPU state */
 
+static bool mips_timer_needed(void *opaque)
+{
+    MIPSCPU *cpu = opaque;
+    return cpu->env.timer != NULL;
+}
+
+static const VMStateDescription mips_vmstate_timer = {
+    .name = "cpu/timer",
+    .version_id = 1,
+    .minimum_version_id = 1,
+    .needed = mips_timer_needed,
+    .fields = (const VMStateField[]) {
+        VMSTATE_TIMER_PTR(env.timer, MIPSCPU),
+        VMSTATE_END_OF_LIST()
+    }
+};
+
 const VMStateDescription vmstate_mips_cpu = {
     .name = "cpu",
     .version_id = 21,
@@ -333,4 +351,8 @@ const VMStateDescription vmstate_mips_cpu = {
 
         VMSTATE_END_OF_LIST()
     },
+    .subsections = (const VMStateDescription * const []) {
+        &mips_vmstate_timer,
+        NULL
+    }
 };
-- 
2.53.0



  parent reply	other threads:[~2026-03-31 13:16 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-31 13:15 [PULL 00/11] Misc HW patches for 2026-03-31 Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 01/11] ppc/pnv: generate dtb after machine initialization is complete Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 02/11] MAINTAINERS: Separate QDev section from QOM one Philippe Mathieu-Daudé
2026-03-31 13:15 ` Philippe Mathieu-Daudé [this message]
2026-03-31 13:15 ` [PULL 04/11] backends/igvm: switch to PRIx64 Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 05/11] target/i386/cpu.c: Correct minor grammar error in warning Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 06/11] target/i386: Treat qtest like TCG for supported-features Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 07/11] ati-vga: Silence warning about operator precedence Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 08/11] ati-vga: Add upper limit to x-linear-aper-size property Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 09/11] hw/pci-host/astro: Update copyright and documentation link Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 10/11] hw/hppa: Disable Artist graphics card on 64-bit machines Philippe Mathieu-Daudé
2026-03-31 13:15 ` [PULL 11/11] MAINTAINERS: fix OSUOSL typo Philippe Mathieu-Daudé
2026-03-31 16:34 ` [PULL 00/11] Misc HW patches for 2026-03-31 Peter Maydell

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=20260331131514.21152-4-philmd@linaro.org \
    --to=philmd@linaro.org \
    --cc=qemu-devel@nongnu.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.