qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Alistair Francis <alistair23@gmail.com>
To: liu.xuemei1@zte.com.cn
Cc: palmer@dabbelt.com, alistair.francis@wdc.com,
	liwei1518@gmail.com,  dbarboza@ventanamicro.com,
	zhiwei_liu@linux.alibaba.com, peterx@redhat.com,
	 farosas@suse.de, qemu-riscv@nongnu.org, qemu-devel@nongnu.org
Subject: Re: [PATCH v2] migration: Fix migration failure when aia is configured as 'aplic-imsic'
Date: Mon, 19 May 2025 10:32:54 +1000	[thread overview]
Message-ID: <CAKmqyKNX1bnO9ptoj5AHY+XwWcrwAD+nwV5pJPArBURf1PCmSA@mail.gmail.com> (raw)
In-Reply-To: <202505122007170451_WeaVnOMOCnJghLHZ5zH@zte.com.cn>

On Tue, May 13, 2025 at 2:33 AM <liu.xuemei1@zte.com.cn> wrote:
>
> From: Xuemei Liu <liu.xuemei1@zte.com.cn>
>
> Address an error in migration when aia is configured as 'aplic-imsic' in
> riscv kvm vm by adding riscv_aplic_state_needed() and
> riscv_imsic_state_needed() to determine whether the corresponding sates are
> needed.
>
> Previously, the fields in the vmsds of 'riscv_aplic' and 'riscv_imsic' can
> only be initialized under certain special conditions in commit 95a97b3fd2.
> However, the corresponding ses of these vmsds are inserted into the
> savevm_state.handlers unconditionally. This led to migration failure
> characterized by uninitialized fields when save vm state:
> qemu-system-riscv64: ../migration/vmstate.c:433: vmstate_save_state_v:
> Assertion 'first_elem || !n_elems || !size' failed.
>
> Fixes: 95a97b3fd2 ("target/riscv: update APLIC and IMSIC to support KVM AIA")
>
> Signed-off-by: Xuemei Liu <liu.xuemei1@zte.com.cn>
> ---
>
>  Changes in v2:
>
>  - Dropped the modifications in vmstate_register_with_alias_id()
>  - Added riscv_aplic_state_needed() and riscv_imsic_state_needed()
>
>  hw/intc/riscv_aplic.c | 8 ++++++++
>  hw/intc/riscv_imsic.c | 6 ++++++
>  2 files changed, 14 insertions(+)
>
> diff --git a/hw/intc/riscv_aplic.c b/hw/intc/riscv_aplic.c
> index 8bcd9f4697..c9abef2e0f 100644
> --- a/hw/intc/riscv_aplic.c
> +++ b/hw/intc/riscv_aplic.c
> @@ -962,10 +962,18 @@ static const Property riscv_aplic_properties[] = {
>      DEFINE_PROP_BOOL("mmode", RISCVAPLICState, mmode, 0),
>  };
>
> +static bool riscv_aplic_state_needed(void *opaque)
> +{
> +    RISCVAPLICState *aplic = opaque;
> +
> +    return riscv_use_emulated_aplic(aplic->msimode);
> +}
> +
>  static const VMStateDescription vmstate_riscv_aplic = {
>      .name = "riscv_aplic",
>      .version_id = 2,
>      .minimum_version_id = 2,

I think these should also be incremented

Alistair

> +    .needed = riscv_aplic_state_needed,
>      .fields = (const VMStateField[]) {
>              VMSTATE_UINT32(domaincfg, RISCVAPLICState),
>              VMSTATE_UINT32(mmsicfgaddr, RISCVAPLICState),
> diff --git a/hw/intc/riscv_imsic.c b/hw/intc/riscv_imsic.c
> index 2169988167..92a7254076 100644
> --- a/hw/intc/riscv_imsic.c
> +++ b/hw/intc/riscv_imsic.c
> @@ -398,10 +398,16 @@ static const Property riscv_imsic_properties[] = {
>      DEFINE_PROP_UINT32("num-irqs", RISCVIMSICState, num_irqs, 0),
>  };
>
> +static bool riscv_imsic_state_needed(void *opaque)
> +{
> +    return !kvm_irqchip_in_kernel();
> +}
> +
>  static const VMStateDescription vmstate_riscv_imsic = {
>      .name = "riscv_imsic",
>      .version_id = 1,
>      .minimum_version_id = 1,
> +    .needed = riscv_imsic_state_needed,
>      .fields = (const VMStateField[]) {
>              VMSTATE_VARRAY_UINT32(eidelivery, RISCVIMSICState,
>                                    num_pages, 0,
> --
> 2.27.0
>


  reply	other threads:[~2025-05-19  0:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-12 12:07 [PATCH v2] migration: Fix migration failure when aia is configured as 'aplic-imsic' liu.xuemei1
2025-05-19  0:32 ` Alistair Francis [this message]
2025-05-20  2:28   ` liu.xuemei1

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=CAKmqyKNX1bnO9ptoj5AHY+XwWcrwAD+nwV5pJPArBURf1PCmSA@mail.gmail.com \
    --to=alistair23@gmail.com \
    --cc=alistair.francis@wdc.com \
    --cc=dbarboza@ventanamicro.com \
    --cc=farosas@suse.de \
    --cc=liu.xuemei1@zte.com.cn \
    --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).