qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: TANG Tiancheng <lyndra@linux.alibaba.com>
To: qemu-devel@nongnu.org
Cc: Palmer Dabbelt <palmer@dabbelt.com>,
	 Alistair Francis <alistair.francis@wdc.com>,
	 Weiwei Li <liwei1518@gmail.com>,
	 Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
	 Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
	qemu-riscv@nongnu.org,  Peter Xu <peterx@redhat.com>,
	Fabiano Rosas <farosas@suse.de>,
	 TANG Tiancheng <lyndra@linux.alibaba.com>
Subject: [PATCH 0/3] Fix RISC-V timer migration issues
Date: Tue, 09 Sep 2025 17:46:43 +0800	[thread overview]
Message-ID: <20250909-timers-v1-0-7ee18a9d8f4b@linux.alibaba.com> (raw)

This patch set fixes several timer-related migration issues in QEMU's
RISC-V implementation that cause timer events to be lost or behave
incorrectly after snapshot save/restore or live migration.

The problems addressed are:

1. ACLINT mtimer time_delta not migrated: The time_delta field in
   RISCVAclintMTimerState was missing from vmstate, causing incorrect
   mtime values after snapshot restore. This resulted in guest time
   appearing "frozen" until enough virtual time elapsed to compensate
   for the offset error.

2. ACLINT mtimer timers array not migrated: Active timer events
   scheduled via riscv_aclint_mtimer_write_timecmp() were not being
   migrated, causing pending timer interrupts to be lost after restore.

3. CPU stimer/vstimer not migrated: The S-mode and VS-mode timer
   pointers in CPURISCVState were missing from vmstate_riscv_cpu,
   causing supervisor-level timer events to be lost.

The patch set introduces a new VMSTATE_TIMER_PTR_VARRAY macro to handle
migration of variable-length timer pointer arrays, and adds the missing
timer fields to the appropriate vmstate structures.

Signed-off-by: TANG Tiancheng <lyndra@linux.alibaba.com>
---
TANG Tiancheng (3):
      hw/intc: Save time_delta in RISC-V mtimer VMState
      hw/intc: Save timers array in RISC-V mtimer VMState
      target/riscv: Save stimer and vstimer in CPU vmstate

 hw/intc/riscv_aclint.c      |  7 +++++--
 include/migration/vmstate.h | 14 ++++++++++++++
 target/riscv/machine.c      | 25 +++++++++++++++++++++++++
 3 files changed, 44 insertions(+), 2 deletions(-)
---
base-commit: 6a9fa5ef3230a7d51e0d953a59ee9ef10af705b8
change-id: 20250909-timers-18c2c67b1a2a

Best regards,
-- 
TANG Tiancheng <lyndra@linux.alibaba.com>



             reply	other threads:[~2025-09-09 12:59 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-09  9:46 TANG Tiancheng [this message]
2025-09-09  9:46 ` [PATCH 1/3] hw/intc: Save time_delta in RISC-V mtimer VMState TANG Tiancheng
2025-09-09 12:36   ` Daniel Henrique Barboza
2025-09-09  9:46 ` [PATCH 2/3] hw/intc: Save timers array " TANG Tiancheng
2025-09-09 12:45   ` Daniel Henrique Barboza
2025-09-09 21:34     ` Peter Xu
2025-09-10  1:33       ` LIU Zhiwei
2025-09-09  9:46 ` [PATCH 3/3] target/riscv: Save stimer and vstimer in CPU vmstate TANG Tiancheng
2025-09-09 12:49   ` Daniel Henrique Barboza

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=20250909-timers-v1-0-7ee18a9d8f4b@linux.alibaba.com \
    --to=lyndra@linux.alibaba.com \
    --cc=alistair.francis@wdc.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=farosas@suse.de \
    --cc=liwei1518@gmail.com \
    --cc=palmer@dabbelt.com \
    --cc=peterx@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=zhiwei_liu@linux.alibaba.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).