From nobody Tue Feb 10 00:23:08 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1603713590; cv=none; d=zohomail.com; s=zohoarc; b=AG+ycjpL+yU2BmbrWcu29Dr6KQOHIJclgDiuPeqwkOL8V8iKXyxTEGVIen+0ImDVu92WANEJmN26uFkBr+DDG20kLlfDJfdkSbg0jFtsEcILUrAQ/qIDW2CFw+uypMPzbnYh3vQ38yP3HH1tGwhS/y+ETX1/3KpXBjQqNSMwvgE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1603713590; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZIq59XAi8MetBBGP2Ocrypeg5PZBjgO/owioZOuhiqY=; b=lyQ3+y0lxOJN7rdNWpnDWUixMQTYaAjYZY03j7oPPjBkhEIMS1vaK5RX1SaffPWHOrOKt+7Jo8F0kX3D4C3Fdk7p2EF4TjQ+jkHZKtV6x4u39GEz3wO6sDsZR/ZucINzG/72aYFwDGsA4g58EATxmQFmLSTgaWBFG1s6DkJVpsQ= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1603713590234460.70698442138826; Mon, 26 Oct 2020 04:59:50 -0700 (PDT) Received: from localhost ([::1]:55364 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kX1AD-0005sW-3G for importer@patchew.org; Mon, 26 Oct 2020 07:59:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38880) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX16X-0000hO-Bh; Mon, 26 Oct 2020 07:56:01 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2483) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kX16T-0000iN-Ol; Mon, 26 Oct 2020 07:56:01 -0400 Received: from DGGEMS402-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CKYFV1xC2zhb7b; Mon, 26 Oct 2020 19:55:58 +0800 (CST) Received: from huawei.com (10.174.186.209) by DGGEMS402-HUB.china.huawei.com (10.3.19.202) with Microsoft SMTP Server id 14.3.487.0; Mon, 26 Oct 2020 19:55:42 +0800 From: Yifei Jiang To: , Subject: [PATCH V4 6/6] target/riscv: Add sifive_plic vmstate Date: Mon, 26 Oct 2020 19:55:30 +0800 Message-ID: <20201026115530.304-7-jiangyifei@huawei.com> X-Mailer: git-send-email 2.26.2.windows.1 In-Reply-To: <20201026115530.304-1-jiangyifei@huawei.com> References: <20201026115530.304-1-jiangyifei@huawei.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Originating-IP: [10.174.186.209] X-CFilter-Loop: Reflected Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=45.249.212.191; envelope-from=jiangyifei@huawei.com; helo=szxga05-in.huawei.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/10/26 07:55:53 X-ACL-Warn: Detected OS = Linux 3.1-3.10 [fuzzy] X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: zhang.zhanghailiang@huawei.com, sagark@eecs.berkeley.edu, kbastian@mail.uni-paderborn.de, victor.zhangxiaofeng@huawei.com, richard.henderson@linaro.org, Yifei Jiang , Alistair Francis , yinyipeng1@huawei.com, palmer@dabbelt.com, wu.wubin@huawei.com, dengkai1@huawei.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add sifive_plic vmstate for supporting sifive_plic migration. Current vmstate framework only supports one structure parameter as num field to describe variable length arrays, so introduce num_enables. Signed-off-by: Yifei Jiang Signed-off-by: Yipeng Yin Reviewed-by: Alistair Francis --- hw/intc/sifive_plic.c | 26 +++++++++++++++++++++++++- hw/intc/sifive_plic.h | 1 + 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/hw/intc/sifive_plic.c b/hw/intc/sifive_plic.c index f42fd695d8..97a1a27a9a 100644 --- a/hw/intc/sifive_plic.c +++ b/hw/intc/sifive_plic.c @@ -30,6 +30,7 @@ #include "hw/intc/sifive_plic.h" #include "target/riscv/cpu.h" #include "sysemu/sysemu.h" +#include "migration/vmstate.h" =20 #define RISCV_DEBUG_PLIC 0 =20 @@ -448,11 +449,12 @@ static void sifive_plic_realize(DeviceState *dev, Err= or **errp) TYPE_SIFIVE_PLIC, plic->aperture_size); parse_hart_config(plic); plic->bitfield_words =3D (plic->num_sources + 31) >> 5; + plic->num_enables =3D plic->bitfield_words * plic->num_addrs; plic->source_priority =3D g_new0(uint32_t, plic->num_sources); plic->target_priority =3D g_new(uint32_t, plic->num_addrs); plic->pending =3D g_new0(uint32_t, plic->bitfield_words); plic->claimed =3D g_new0(uint32_t, plic->bitfield_words); - plic->enable =3D g_new0(uint32_t, plic->bitfield_words * plic->num_add= rs); + plic->enable =3D g_new0(uint32_t, plic->num_enables); sysbus_init_mmio(SYS_BUS_DEVICE(dev), &plic->mmio); qdev_init_gpio_in(dev, sifive_plic_irq_request, plic->num_sources); =20 @@ -472,12 +474,34 @@ static void sifive_plic_realize(DeviceState *dev, Err= or **errp) msi_nonbroken =3D true; } =20 +static const VMStateDescription vmstate_sifive_plic =3D { + .name =3D "riscv_sifive_plic", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_VARRAY_UINT32(source_priority, SiFivePLICState, + num_sources, 0, + vmstate_info_uint32, uint32_t), + VMSTATE_VARRAY_UINT32(target_priority, SiFivePLICState, + num_addrs, 0, + vmstate_info_uint32, uint32_t), + VMSTATE_VARRAY_UINT32(pending, SiFivePLICState, bitfield_words= , 0, + vmstate_info_uint32, uint32_t), + VMSTATE_VARRAY_UINT32(claimed, SiFivePLICState, bitfield_words= , 0, + vmstate_info_uint32, uint32_t), + VMSTATE_VARRAY_UINT32(enable, SiFivePLICState, num_enables, 0, + vmstate_info_uint32, uint32_t), + VMSTATE_END_OF_LIST() + } +}; + static void sifive_plic_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); =20 device_class_set_props(dc, sifive_plic_properties); dc->realize =3D sifive_plic_realize; + dc->vmsd =3D &vmstate_sifive_plic; } =20 static const TypeInfo sifive_plic_info =3D { diff --git a/hw/intc/sifive_plic.h b/hw/intc/sifive_plic.h index b75b1f145d..1e451a270c 100644 --- a/hw/intc/sifive_plic.h +++ b/hw/intc/sifive_plic.h @@ -52,6 +52,7 @@ struct SiFivePLICState { uint32_t num_addrs; uint32_t num_harts; uint32_t bitfield_words; + uint32_t num_enables; PLICAddr *addr_config; uint32_t *source_priority; uint32_t *target_priority; --=20 2.19.1