From nobody Tue Nov 26 06:55:28 2024 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709001104279983.0200683221028; Mon, 26 Feb 2024 18:31:44 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1renF1-0002xv-I5; Mon, 26 Feb 2024 21:30:47 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1renEz-0002xU-BG for qemu-devel@nongnu.org; Mon, 26 Feb 2024 21:30:45 -0500 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1renEw-0002PV-LL for qemu-devel@nongnu.org; Mon, 26 Feb 2024 21:30:45 -0500 Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8BxTOlLSd1l+88RAA--.35368S3; Tue, 27 Feb 2024 10:30:35 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cxbs1HSd1lRvhGAA--.54308S3; Tue, 27 Feb 2024 10:30:33 +0800 (CST) From: Bibo Mao To: Song Gao , Peter Xu , Fabiano Rosas , Laurent Vivier , Thomas Huth Cc: qemu-devel@nongnu.org Subject: [PATCH v2 1/5] hw/loongarch: Rename LOONGARCH_MACHINE with VIRT_MACHINE. Date: Tue, 27 Feb 2024 10:30:27 +0800 Message-Id: <20240227023031.3299067-2-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240227023031.3299067-1-maobibo@loongson.cn> References: <20240227023031.3299067-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8Cxbs1HSd1lRvhGAA--.54308S3 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoWxuw4kZFW7WF18Zw4Dur47ZFc_yoWxKr1fpF WDZF1kZr18Xrna93s7G3s8uF10yr4xCa42van7tr40kayDuryUGrW8C390yF1DA34DJF10 vwn5Cw4xXF1fJrXCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUk0b4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUXVWUAwAv7VC2z280aVAF wI0_Jr0_Gr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1j6r1xMIIF0xvE2Ix0cI8IcVCY1x0267AKxVWUJVW8JwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVWUJVW8JbIYCTnIWIevJa73UjIFyTuYvjxU7XTmDUUUU 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=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1709001105090100001 Content-Type: text/plain; charset="utf-8" On LoongArch system, there is only virt machine type now, name LOONGARCH_MACHINE is confused, rename it with VIRT_MACHINE. Machine name about Other real hw boards can be added in future. Signed-off-by: Bibo Mao --- hw/loongarch/acpi-build.c | 8 ++++---- hw/loongarch/virt.c | 19 +++++++++---------- include/hw/loongarch/virt.h | 4 ++-- 3 files changed, 15 insertions(+), 16 deletions(-) diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c index e5ab1080af..72322cdb1e 100644 --- a/hw/loongarch/acpi-build.c +++ b/hw/loongarch/acpi-build.c @@ -167,7 +167,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, Mach= ineState *machine) int i, arch_id, node_id; uint64_t mem_len, mem_base; int nb_numa_nodes =3D machine->numa_state->num_nodes; - LoongArchMachineState *lams =3D LOONGARCH_MACHINE(machine); + LoongArchMachineState *lams =3D VIRT_MACHINE(machine); MachineClass *mc =3D MACHINE_GET_CLASS(lams); const CPUArchIdList *arch_ids =3D mc->possible_cpu_arch_ids(machine); AcpiTable table =3D { .sig =3D "SRAT", .rev =3D 1, .oem_id =3D lams->o= em_id, @@ -279,7 +279,7 @@ static void build_la_ged_aml(Aml *dsdt, MachineState *machine) { uint32_t event; - LoongArchMachineState *lams =3D LOONGARCH_MACHINE(machine); + LoongArchMachineState *lams =3D VIRT_MACHINE(machine); =20 build_ged_aml(dsdt, "\\_SB."GED_DEVICE, HOTPLUG_HANDLER(lams->acpi_ged), @@ -391,7 +391,7 @@ static void build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine) { Aml *dsdt, *scope, *pkg; - LoongArchMachineState *lams =3D LOONGARCH_MACHINE(machine); + LoongArchMachineState *lams =3D VIRT_MACHINE(machine); AcpiTable table =3D { .sig =3D "DSDT", .rev =3D 1, .oem_id =3D lams->o= em_id, .oem_table_id =3D lams->oem_table_id }; =20 @@ -421,7 +421,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Mach= ineState *machine) =20 static void acpi_build(AcpiBuildTables *tables, MachineState *machine) { - LoongArchMachineState *lams =3D LOONGARCH_MACHINE(machine); + LoongArchMachineState *lams =3D VIRT_MACHINE(machine); GArray *table_offsets; AcpiFadtData fadt_data; unsigned facs, rsdt, dsdt; diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 1e98d8bda5..0d4ea57e5b 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -823,7 +823,7 @@ static void loongarch_init(MachineState *machine) ram_addr_t ram_size =3D machine->ram_size; uint64_t highram_size =3D 0, phyAddr =3D 0; MemoryRegion *address_space_mem =3D get_system_memory(); - LoongArchMachineState *lams =3D LOONGARCH_MACHINE(machine); + LoongArchMachineState *lams =3D VIRT_MACHINE(machine); int nb_numa_nodes =3D machine->numa_state->num_nodes; NodeInfo *numa_info =3D machine->numa_state->nodes; int i; @@ -990,7 +990,7 @@ bool loongarch_is_acpi_enabled(LoongArchMachineState *l= ams) static void loongarch_get_acpi(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - LoongArchMachineState *lams =3D LOONGARCH_MACHINE(obj); + LoongArchMachineState *lams =3D VIRT_MACHINE(obj); OnOffAuto acpi =3D lams->acpi; =20 visit_type_OnOffAuto(v, name, &acpi, errp); @@ -999,14 +999,14 @@ static void loongarch_get_acpi(Object *obj, Visitor *= v, const char *name, static void loongarch_set_acpi(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - LoongArchMachineState *lams =3D LOONGARCH_MACHINE(obj); + LoongArchMachineState *lams =3D VIRT_MACHINE(obj); =20 visit_type_OnOffAuto(v, name, &lams->acpi, errp); } =20 static void loongarch_machine_initfn(Object *obj) { - LoongArchMachineState *lams =3D LOONGARCH_MACHINE(obj); + LoongArchMachineState *lams =3D VIRT_MACHINE(obj); =20 lams->acpi =3D ON_OFF_AUTO_AUTO; lams->oem_id =3D g_strndup(ACPI_BUILD_APPNAME6, 6); @@ -1038,7 +1038,7 @@ static void virt_machine_device_pre_plug(HotplugHandl= er *hotplug_dev, static void virt_mem_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - LoongArchMachineState *lams =3D LOONGARCH_MACHINE(hotplug_dev); + LoongArchMachineState *lams =3D VIRT_MACHINE(hotplug_dev); =20 /* the acpi ged is always exist */ hotplug_handler_unplug_request(HOTPLUG_HANDLER(lams->acpi_ged), dev, @@ -1056,7 +1056,7 @@ static void virt_machine_device_unplug_request(Hotplu= gHandler *hotplug_dev, static void virt_mem_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - LoongArchMachineState *lams =3D LOONGARCH_MACHINE(hotplug_dev); + LoongArchMachineState *lams =3D VIRT_MACHINE(hotplug_dev); =20 hotplug_handler_unplug(HOTPLUG_HANDLER(lams->acpi_ged), dev, errp); pc_dimm_unplug(PC_DIMM(dev), MACHINE(lams)); @@ -1074,7 +1074,7 @@ static void virt_machine_device_unplug(HotplugHandler= *hotplug_dev, static void virt_mem_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - LoongArchMachineState *lams =3D LOONGARCH_MACHINE(hotplug_dev); + LoongArchMachineState *lams =3D VIRT_MACHINE(hotplug_dev); =20 pc_dimm_plug(PC_DIMM(dev), MACHINE(lams)); hotplug_handler_plug(HOTPLUG_HANDLER(lams->acpi_ged), @@ -1084,7 +1084,7 @@ static void virt_mem_plug(HotplugHandler *hotplug_dev, static void loongarch_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - LoongArchMachineState *lams =3D LOONGARCH_MACHINE(hotplug_dev); + LoongArchMachineState *lams =3D VIRT_MACHINE(hotplug_dev); MachineClass *mc =3D MACHINE_GET_CLASS(lams); =20 if (device_is_dynamic_sysbus(mc, dev)) { @@ -1166,7 +1166,6 @@ static void loongarch_class_init(ObjectClass *oc, voi= d *data) MachineClass *mc =3D MACHINE_CLASS(oc); HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(oc); =20 - mc->desc =3D "Loongson-3A5000 LS7A1000 machine"; mc->init =3D loongarch_init; mc->default_ram_size =3D 1 * GiB; mc->default_cpu_type =3D LOONGARCH_CPU_TYPE_NAME("la464"); @@ -1203,7 +1202,7 @@ static void loongarch_class_init(ObjectClass *oc, voi= d *data) =20 static const TypeInfo loongarch_machine_types[] =3D { { - .name =3D TYPE_LOONGARCH_MACHINE, + .name =3D TYPE_VIRT_MACHINE, .parent =3D TYPE_MACHINE, .instance_size =3D sizeof(LoongArchMachineState), .class_init =3D loongarch_class_init, diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h index 252f7df7f4..d9c7050340 100644 --- a/include/hw/loongarch/virt.h +++ b/include/hw/loongarch/virt.h @@ -57,8 +57,8 @@ struct LoongArchMachineState { AddressSpace as_iocsr; }; =20 -#define TYPE_LOONGARCH_MACHINE MACHINE_TYPE_NAME("virt") -OBJECT_DECLARE_SIMPLE_TYPE(LoongArchMachineState, LOONGARCH_MACHINE) +#define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") +OBJECT_DECLARE_SIMPLE_TYPE(LoongArchMachineState, VIRT_MACHINE) bool loongarch_is_acpi_enabled(LoongArchMachineState *lams); void loongarch_acpi_setup(LoongArchMachineState *lams); #endif --=20 2.39.3 From nobody Tue Nov 26 06:55:28 2024 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709001092771495.44389518064395; Mon, 26 Feb 2024 18:31:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1renFF-00031Z-OT; Mon, 26 Feb 2024 21:31:01 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1renFD-00031D-SN for qemu-devel@nongnu.org; Mon, 26 Feb 2024 21:30:59 -0500 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1renEw-0002PR-MB for qemu-devel@nongnu.org; Mon, 26 Feb 2024 21:30:59 -0500 Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8DxWPBLSd1l_s8RAA--.45220S3; Tue, 27 Feb 2024 10:30:35 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cxbs1HSd1lRvhGAA--.54308S4; Tue, 27 Feb 2024 10:30:35 +0800 (CST) From: Bibo Mao To: Song Gao , Peter Xu , Fabiano Rosas , Laurent Vivier , Thomas Huth Cc: qemu-devel@nongnu.org Subject: [PATCH v2 2/5] hw/loongarch: Rename LoongArchMachineState with VirtMachineState Date: Tue, 27 Feb 2024 10:30:28 +0800 Message-Id: <20240227023031.3299067-3-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240227023031.3299067-1-maobibo@loongson.cn> References: <20240227023031.3299067-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8Cxbs1HSd1lRvhGAA--.54308S4 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj9fXoWfKF1DKF13KrykCr1kAF43Arc_yoWrWF13Ao WfGFW3Ka48XryI93yjkrs8XFW7WF10kanxXFWUCF40ganxt3yUJF4fKrs5X3W7tFn8Kry7 X347Kw1fAr9rCr1rl-sFpf9Il3svdjkaLaAFLSUrUUUUjb8apTn2vfkv8UJUUUU8wcxFpf 9Il3svdxBIdaVrn0xqx4xG64xvF2IEw4CE5I8CrVC2j2Jv73VFW2AGmfu7bjvjm3AaLaJ3 UjIYCTnIWjp_UUUYb7kC6x804xWl14x267AKxVWUJVW8JwAFc2x0x2IEx4CE42xK8VAvwI 8IcIk0rVWrJVCq3wAFIxvE14AKwVWUGVWUXwA2ocxC64kIII0Yj41l84x0c7CEw4AK67xG Y2AK021l84ACjcxK6xIIjxv20xvE14v26r4j6ryUM28EF7xvwVC0I7IYx2IY6xkF7I0E14 v26r4j6F4UM28EF7xvwVC2z280aVAFwI0_Cr0_Gr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8JVW8Jr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27w Aqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_JF0_Jw1lYx0Ex4A2jsIE 14v26r1j6r4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x 0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E 7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcV C0I7IYx2IY67AKxVWUCVW8JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF 04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r1j6r4UMIIF0xvEx4A2jsIEc7 CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07j1LvtUUUUU= 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=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1709001095111100003 Content-Type: text/plain; charset="utf-8" Rename LoongArchMachineState with VirtMachineState, and change variable name LoongArchMachineState *lams with VirtMachineState *vms, and rename function loongarch_xxx() with virt_xxx() also. Signed-off-by: Bibo Mao --- hw/loongarch/acpi-build.c | 80 +++++----- hw/loongarch/fw_cfg.c | 2 +- hw/loongarch/fw_cfg.h | 2 +- hw/loongarch/virt.c | 290 ++++++++++++++++++------------------ include/hw/loongarch/virt.h | 8 +- 5 files changed, 191 insertions(+), 191 deletions(-) diff --git a/hw/loongarch/acpi-build.c b/hw/loongarch/acpi-build.c index 72322cdb1e..b6741809ef 100644 --- a/hw/loongarch/acpi-build.c +++ b/hw/loongarch/acpi-build.c @@ -105,14 +105,14 @@ build_facs(GArray *table_data) =20 /* build MADT */ static void -build_madt(GArray *table_data, BIOSLinker *linker, LoongArchMachineState *= lams) +build_madt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) { - MachineState *ms =3D MACHINE(lams); + MachineState *ms =3D MACHINE(vms); MachineClass *mc =3D MACHINE_GET_CLASS(ms); const CPUArchIdList *arch_ids =3D mc->possible_cpu_arch_ids(ms); int i, arch_id; - AcpiTable table =3D { .sig =3D "APIC", .rev =3D 1, .oem_id =3D lams->o= em_id, - .oem_table_id =3D lams->oem_table_id }; + AcpiTable table =3D { .sig =3D "APIC", .rev =3D 1, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 acpi_table_begin(&table, table_data); =20 @@ -167,11 +167,11 @@ build_srat(GArray *table_data, BIOSLinker *linker, Ma= chineState *machine) int i, arch_id, node_id; uint64_t mem_len, mem_base; int nb_numa_nodes =3D machine->numa_state->num_nodes; - LoongArchMachineState *lams =3D VIRT_MACHINE(machine); - MachineClass *mc =3D MACHINE_GET_CLASS(lams); + VirtMachineState *vms =3D VIRT_MACHINE(machine); + MachineClass *mc =3D MACHINE_GET_CLASS(vms); const CPUArchIdList *arch_ids =3D mc->possible_cpu_arch_ids(machine); - AcpiTable table =3D { .sig =3D "SRAT", .rev =3D 1, .oem_id =3D lams->o= em_id, - .oem_table_id =3D lams->oem_table_id }; + AcpiTable table =3D { .sig =3D "SRAT", .rev =3D 1, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 acpi_table_begin(&table, table_data); build_append_int_noprefix(table_data, 1, 4); /* Reserved */ @@ -279,13 +279,13 @@ static void build_la_ged_aml(Aml *dsdt, MachineState *machine) { uint32_t event; - LoongArchMachineState *lams =3D VIRT_MACHINE(machine); + VirtMachineState *vms =3D VIRT_MACHINE(machine); =20 build_ged_aml(dsdt, "\\_SB."GED_DEVICE, - HOTPLUG_HANDLER(lams->acpi_ged), + HOTPLUG_HANDLER(vms->acpi_ged), VIRT_SCI_IRQ, AML_SYSTEM_MEMORY, VIRT_GED_EVT_ADDR); - event =3D object_property_get_uint(OBJECT(lams->acpi_ged), + event =3D object_property_get_uint(OBJECT(vms->acpi_ged), "ged-event", &error_abort); if (event & ACPI_GED_MEM_HOTPLUG_EVT) { build_memory_hotplug_aml(dsdt, machine->ram_slots, "\\_SB", NULL, @@ -295,7 +295,7 @@ build_la_ged_aml(Aml *dsdt, MachineState *machine) acpi_dsdt_add_power_button(dsdt); } =20 -static void build_pci_device_aml(Aml *scope, LoongArchMachineState *lams) +static void build_pci_device_aml(Aml *scope, VirtMachineState *vms) { struct GPEXConfig cfg =3D { .mmio64.base =3D VIRT_PCI_MEM_BASE, @@ -305,13 +305,13 @@ static void build_pci_device_aml(Aml *scope, LoongArc= hMachineState *lams) .ecam.base =3D VIRT_PCI_CFG_BASE, .ecam.size =3D VIRT_PCI_CFG_SIZE, .irq =3D VIRT_GSI_BASE + VIRT_DEVICE_IRQS, - .bus =3D lams->pci_bus, + .bus =3D vms->pci_bus, }; =20 acpi_dsdt_add_gpex(scope, &cfg); } =20 -static void build_flash_aml(Aml *scope, LoongArchMachineState *lams) +static void build_flash_aml(Aml *scope, VirtMachineState *vms) { Aml *dev, *crs; MemoryRegion *flash_mem; @@ -322,11 +322,11 @@ static void build_flash_aml(Aml *scope, LoongArchMach= ineState *lams) hwaddr flash1_base; hwaddr flash1_size; =20 - flash_mem =3D pflash_cfi01_get_memory(lams->flash[0]); + flash_mem =3D pflash_cfi01_get_memory(vms->flash[0]); flash0_base =3D flash_mem->addr; flash0_size =3D memory_region_size(flash_mem); =20 - flash_mem =3D pflash_cfi01_get_memory(lams->flash[1]); + flash_mem =3D pflash_cfi01_get_memory(vms->flash[1]); flash1_base =3D flash_mem->addr; flash1_size =3D memory_region_size(flash_mem); =20 @@ -352,7 +352,7 @@ static void build_flash_aml(Aml *scope, LoongArchMachin= eState *lams) } =20 #ifdef CONFIG_TPM -static void acpi_dsdt_add_tpm(Aml *scope, LoongArchMachineState *vms) +static void acpi_dsdt_add_tpm(Aml *scope, VirtMachineState *vms) { PlatformBusDevice *pbus =3D PLATFORM_BUS_DEVICE(vms->platform_bus_dev); hwaddr pbus_base =3D VIRT_PLATFORM_BUS_BASEADDRESS; @@ -391,18 +391,18 @@ static void build_dsdt(GArray *table_data, BIOSLinker *linker, MachineState *machine) { Aml *dsdt, *scope, *pkg; - LoongArchMachineState *lams =3D VIRT_MACHINE(machine); - AcpiTable table =3D { .sig =3D "DSDT", .rev =3D 1, .oem_id =3D lams->o= em_id, - .oem_table_id =3D lams->oem_table_id }; + VirtMachineState *vms =3D VIRT_MACHINE(machine); + AcpiTable table =3D { .sig =3D "DSDT", .rev =3D 1, .oem_id =3D vms->oe= m_id, + .oem_table_id =3D vms->oem_table_id }; =20 acpi_table_begin(&table, table_data); dsdt =3D init_aml_allocator(); build_uart_device_aml(dsdt); - build_pci_device_aml(dsdt, lams); + build_pci_device_aml(dsdt, vms); build_la_ged_aml(dsdt, machine); - build_flash_aml(dsdt, lams); + build_flash_aml(dsdt, vms); #ifdef CONFIG_TPM - acpi_dsdt_add_tpm(dsdt, lams); + acpi_dsdt_add_tpm(dsdt, vms); #endif /* System State Package */ scope =3D aml_scope("\\"); @@ -421,7 +421,7 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Mach= ineState *machine) =20 static void acpi_build(AcpiBuildTables *tables, MachineState *machine) { - LoongArchMachineState *lams =3D VIRT_MACHINE(machine); + VirtMachineState *vms =3D VIRT_MACHINE(machine); GArray *table_offsets; AcpiFadtData fadt_data; unsigned facs, rsdt, dsdt; @@ -455,14 +455,14 @@ static void acpi_build(AcpiBuildTables *tables, Machi= neState *machine) fadt_data.dsdt_tbl_offset =3D &dsdt; fadt_data.xdsdt_tbl_offset =3D &dsdt; build_fadt(tables_blob, tables->linker, &fadt_data, - lams->oem_id, lams->oem_table_id); + vms->oem_id, vms->oem_table_id); =20 acpi_add_table(table_offsets, tables_blob); - build_madt(tables_blob, tables->linker, lams); + build_madt(tables_blob, tables->linker, vms); =20 acpi_add_table(table_offsets, tables_blob); build_pptt(tables_blob, tables->linker, machine, - lams->oem_id, lams->oem_table_id); + vms->oem_id, vms->oem_table_id); =20 acpi_add_table(table_offsets, tables_blob); build_srat(tables_blob, tables->linker, machine); @@ -470,13 +470,13 @@ static void acpi_build(AcpiBuildTables *tables, Machi= neState *machine) if (machine->numa_state->num_nodes) { if (machine->numa_state->have_numa_distance) { acpi_add_table(table_offsets, tables_blob); - build_slit(tables_blob, tables->linker, machine, lams->oem_id, - lams->oem_table_id); + build_slit(tables_blob, tables->linker, machine, vms->oem_id, + vms->oem_table_id); } if (machine->numa_state->hmat_enabled) { acpi_add_table(table_offsets, tables_blob); build_hmat(tables_blob, tables->linker, machine->numa_state, - lams->oem_id, lams->oem_table_id); + vms->oem_id, vms->oem_table_id); } } =20 @@ -486,8 +486,8 @@ static void acpi_build(AcpiBuildTables *tables, Machine= State *machine) .base =3D cpu_to_le64(VIRT_PCI_CFG_BASE), .size =3D cpu_to_le64(VIRT_PCI_CFG_SIZE), }; - build_mcfg(tables_blob, tables->linker, &mcfg, lams->oem_id, - lams->oem_table_id); + build_mcfg(tables_blob, tables->linker, &mcfg, vms->oem_id, + vms->oem_table_id); } =20 #ifdef CONFIG_TPM @@ -495,8 +495,8 @@ static void acpi_build(AcpiBuildTables *tables, Machine= State *machine) if (tpm_get_version(tpm_find()) =3D=3D TPM_VERSION_2_0) { acpi_add_table(table_offsets, tables_blob); build_tpm2(tables_blob, tables->linker, - tables->tcpalog, lams->oem_id, - lams->oem_table_id); + tables->tcpalog, vms->oem_id, + vms->oem_table_id); } #endif /* Add tables supplied by user (if any) */ @@ -510,13 +510,13 @@ static void acpi_build(AcpiBuildTables *tables, Machi= neState *machine) /* RSDT is pointed to by RSDP */ rsdt =3D tables_blob->len; build_rsdt(tables_blob, tables->linker, table_offsets, - lams->oem_id, lams->oem_table_id); + vms->oem_id, vms->oem_table_id); =20 /* RSDP is in FSEG memory, so allocate it separately */ { AcpiRsdpData rsdp_data =3D { .revision =3D 0, - .oem_id =3D lams->oem_id, + .oem_id =3D vms->oem_id, .xsdt_tbl_offset =3D NULL, .rsdt_tbl_offset =3D &rsdt, }; @@ -593,17 +593,17 @@ static const VMStateDescription vmstate_acpi_build = =3D { }, }; =20 -void loongarch_acpi_setup(LoongArchMachineState *lams) +void virt_acpi_setup(VirtMachineState *vms) { AcpiBuildTables tables; AcpiBuildState *build_state; =20 - if (!lams->fw_cfg) { + if (!vms->fw_cfg) { ACPI_BUILD_DPRINTF("No fw cfg. Bailing out.\n"); return; } =20 - if (!loongarch_is_acpi_enabled(lams)) { + if (!virt_is_acpi_enabled(vms)) { ACPI_BUILD_DPRINTF("ACPI disabled. Bailing out.\n"); return; } @@ -611,7 +611,7 @@ void loongarch_acpi_setup(LoongArchMachineState *lams) build_state =3D g_malloc0(sizeof *build_state); =20 acpi_build_tables_init(&tables); - acpi_build(&tables, MACHINE(lams)); + acpi_build(&tables, MACHINE(vms)); =20 /* Now expose it all to Guest */ build_state->table_mr =3D acpi_add_rom_blob(acpi_build_update, diff --git a/hw/loongarch/fw_cfg.c b/hw/loongarch/fw_cfg.c index f15a17416c..35aeb2decb 100644 --- a/hw/loongarch/fw_cfg.c +++ b/hw/loongarch/fw_cfg.c @@ -17,7 +17,7 @@ static void fw_cfg_boot_set(void *opaque, const char *boo= t_device, fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]); } =20 -FWCfgState *loongarch_fw_cfg_init(ram_addr_t ram_size, MachineState *ms) +FWCfgState *virt_fw_cfg_init(ram_addr_t ram_size, MachineState *ms) { FWCfgState *fw_cfg; int max_cpus =3D ms->smp.max_cpus; diff --git a/hw/loongarch/fw_cfg.h b/hw/loongarch/fw_cfg.h index 7c0de4db4a..27ee68286e 100644 --- a/hw/loongarch/fw_cfg.h +++ b/hw/loongarch/fw_cfg.h @@ -11,5 +11,5 @@ #include "hw/boards.h" #include "hw/nvram/fw_cfg.h" =20 -FWCfgState *loongarch_fw_cfg_init(ram_addr_t ram_size, MachineState *ms); +FWCfgState *virt_fw_cfg_init(ram_addr_t ram_size, MachineState *ms); #endif diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 0d4ea57e5b..3bc35c58c9 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -54,7 +54,7 @@ struct loaderparams { const char *initrd_filename; }; =20 -static PFlashCFI01 *virt_flash_create1(LoongArchMachineState *lams, +static PFlashCFI01 *virt_flash_create1(VirtMachineState *vms, const char *name, const char *alias_prop_name) { @@ -69,16 +69,16 @@ static PFlashCFI01 *virt_flash_create1(LoongArchMachine= State *lams, qdev_prop_set_uint16(dev, "id2", 0x00); qdev_prop_set_uint16(dev, "id3", 0x00); qdev_prop_set_string(dev, "name", name); - object_property_add_child(OBJECT(lams), name, OBJECT(dev)); - object_property_add_alias(OBJECT(lams), alias_prop_name, + object_property_add_child(OBJECT(vms), name, OBJECT(dev)); + object_property_add_alias(OBJECT(vms), alias_prop_name, OBJECT(dev), "drive"); return PFLASH_CFI01(dev); } =20 -static void virt_flash_create(LoongArchMachineState *lams) +static void virt_flash_create(VirtMachineState *vms) { - lams->flash[0] =3D virt_flash_create1(lams, "virt.flash0", "pflash0"); - lams->flash[1] =3D virt_flash_create1(lams, "virt.flash1", "pflash1"); + vms->flash[0] =3D virt_flash_create1(vms, "virt.flash0", "pflash0"); + vms->flash[1] =3D virt_flash_create1(vms, "virt.flash1", "pflash1"); } =20 static void virt_flash_map1(PFlashCFI01 *flash, @@ -104,19 +104,19 @@ static void virt_flash_map1(PFlashCFI01 *flash, sysbus_mmio_get_region(SYS_BUS_DEVICE(dev)= , 0)); } =20 -static void virt_flash_map(LoongArchMachineState *lams, +static void virt_flash_map(VirtMachineState *vms, MemoryRegion *sysmem) { - PFlashCFI01 *flash0 =3D lams->flash[0]; - PFlashCFI01 *flash1 =3D lams->flash[1]; + PFlashCFI01 *flash0 =3D vms->flash[0]; + PFlashCFI01 *flash1 =3D vms->flash[1]; =20 virt_flash_map1(flash0, VIRT_FLASH0_BASE, VIRT_FLASH0_SIZE, sysmem); virt_flash_map1(flash1, VIRT_FLASH1_BASE, VIRT_FLASH1_SIZE, sysmem); } =20 -static void fdt_add_flash_node(LoongArchMachineState *lams) +static void fdt_add_flash_node(VirtMachineState *vms) { - MachineState *ms =3D MACHINE(lams); + MachineState *ms =3D MACHINE(vms); char *nodename; MemoryRegion *flash_mem; =20 @@ -126,11 +126,11 @@ static void fdt_add_flash_node(LoongArchMachineState = *lams) hwaddr flash1_base; hwaddr flash1_size; =20 - flash_mem =3D pflash_cfi01_get_memory(lams->flash[0]); + flash_mem =3D pflash_cfi01_get_memory(vms->flash[0]); flash0_base =3D flash_mem->addr; flash0_size =3D memory_region_size(flash_mem); =20 - flash_mem =3D pflash_cfi01_get_memory(lams->flash[1]); + flash_mem =3D pflash_cfi01_get_memory(vms->flash[1]); flash1_base =3D flash_mem->addr; flash1_size =3D memory_region_size(flash_mem); =20 @@ -144,12 +144,12 @@ static void fdt_add_flash_node(LoongArchMachineState = *lams) g_free(nodename); } =20 -static void fdt_add_rtc_node(LoongArchMachineState *lams) +static void fdt_add_rtc_node(VirtMachineState *vms) { char *nodename; hwaddr base =3D VIRT_RTC_REG_BASE; hwaddr size =3D VIRT_RTC_LEN; - MachineState *ms =3D MACHINE(lams); + MachineState *ms =3D MACHINE(vms); =20 nodename =3D g_strdup_printf("/rtc@%" PRIx64, base); qemu_fdt_add_subnode(ms->fdt, nodename); @@ -158,12 +158,12 @@ static void fdt_add_rtc_node(LoongArchMachineState *l= ams) g_free(nodename); } =20 -static void fdt_add_uart_node(LoongArchMachineState *lams) +static void fdt_add_uart_node(VirtMachineState *vms) { char *nodename; hwaddr base =3D VIRT_UART_BASE; hwaddr size =3D VIRT_UART_SIZE; - MachineState *ms =3D MACHINE(lams); + MachineState *ms =3D MACHINE(vms); =20 nodename =3D g_strdup_printf("/serial@%" PRIx64, base); qemu_fdt_add_subnode(ms->fdt, nodename); @@ -174,11 +174,11 @@ static void fdt_add_uart_node(LoongArchMachineState *= lams) g_free(nodename); } =20 -static void create_fdt(LoongArchMachineState *lams) +static void create_fdt(VirtMachineState *vms) { - MachineState *ms =3D MACHINE(lams); + MachineState *ms =3D MACHINE(vms); =20 - ms->fdt =3D create_device_tree(&lams->fdt_size); + ms->fdt =3D create_device_tree(&vms->fdt_size); if (!ms->fdt) { error_report("create_device_tree() failed"); exit(1); @@ -192,10 +192,10 @@ static void create_fdt(LoongArchMachineState *lams) qemu_fdt_add_subnode(ms->fdt, "/chosen"); } =20 -static void fdt_add_cpu_nodes(const LoongArchMachineState *lams) +static void fdt_add_cpu_nodes(const VirtMachineState *vms) { int num; - const MachineState *ms =3D MACHINE(lams); + const MachineState *ms =3D MACHINE(vms); int smp_cpus =3D ms->smp.cpus; =20 qemu_fdt_add_subnode(ms->fdt, "/cpus"); @@ -249,11 +249,11 @@ static void fdt_add_cpu_nodes(const LoongArchMachineS= tate *lams) } } =20 -static void fdt_add_fw_cfg_node(const LoongArchMachineState *lams) +static void fdt_add_fw_cfg_node(const VirtMachineState *vms) { char *nodename; hwaddr base =3D VIRT_FWCFG_BASE; - const MachineState *ms =3D MACHINE(lams); + const MachineState *ms =3D MACHINE(vms); =20 nodename =3D g_strdup_printf("/fw_cfg@%" PRIx64, base); qemu_fdt_add_subnode(ms->fdt, nodename); @@ -265,7 +265,7 @@ static void fdt_add_fw_cfg_node(const LoongArchMachineS= tate *lams) g_free(nodename); } =20 -static void fdt_add_pcie_node(const LoongArchMachineState *lams) +static void fdt_add_pcie_node(const VirtMachineState *vms) { char *nodename; hwaddr base_mmio =3D VIRT_PCI_MEM_BASE; @@ -276,7 +276,7 @@ static void fdt_add_pcie_node(const LoongArchMachineSta= te *lams) hwaddr size_pcie =3D VIRT_PCI_CFG_SIZE; hwaddr base =3D base_pcie; =20 - const MachineState *ms =3D MACHINE(lams); + const MachineState *ms =3D MACHINE(vms); =20 nodename =3D g_strdup_printf("/pcie@%" PRIx64, base); qemu_fdt_add_subnode(ms->fdt, nodename); @@ -299,9 +299,9 @@ static void fdt_add_pcie_node(const LoongArchMachineSta= te *lams) g_free(nodename); } =20 -static void fdt_add_irqchip_node(LoongArchMachineState *lams) +static void fdt_add_irqchip_node(VirtMachineState *vms) { - MachineState *ms =3D MACHINE(lams); + MachineState *ms =3D MACHINE(vms); char *nodename; uint32_t irqchip_phandle; =20 @@ -343,15 +343,15 @@ static void fdt_add_memory_node(MachineState *ms, g_free(nodename); } =20 -static void virt_build_smbios(LoongArchMachineState *lams) +static void virt_build_smbios(VirtMachineState *vms) { - MachineState *ms =3D MACHINE(lams); - MachineClass *mc =3D MACHINE_GET_CLASS(lams); + MachineState *ms =3D MACHINE(vms); + MachineClass *mc =3D MACHINE_GET_CLASS(vms); uint8_t *smbios_tables, *smbios_anchor; size_t smbios_tables_len, smbios_anchor_len; const char *product =3D "QEMU Virtual Machine"; =20 - if (!lams->fw_cfg) { + if (!vms->fw_cfg) { return; } =20 @@ -362,25 +362,25 @@ static void virt_build_smbios(LoongArchMachineState *= lams) &smbios_anchor, &smbios_anchor_len, &error_fatal); =20 if (smbios_anchor) { - fw_cfg_add_file(lams->fw_cfg, "etc/smbios/smbios-tables", + fw_cfg_add_file(vms->fw_cfg, "etc/smbios/smbios-tables", smbios_tables, smbios_tables_len); - fw_cfg_add_file(lams->fw_cfg, "etc/smbios/smbios-anchor", + fw_cfg_add_file(vms->fw_cfg, "etc/smbios/smbios-anchor", smbios_anchor, smbios_anchor_len); } } =20 static void virt_machine_done(Notifier *notifier, void *data) { - LoongArchMachineState *lams =3D container_of(notifier, - LoongArchMachineState, machine_don= e); - virt_build_smbios(lams); - loongarch_acpi_setup(lams); + VirtMachineState *vms =3D container_of(notifier, + VirtMachineState, machine_done); + virt_build_smbios(vms); + virt_acpi_setup(vms); } =20 static void virt_powerdown_req(Notifier *notifier, void *opaque) { - LoongArchMachineState *s =3D container_of(notifier, - LoongArchMachineState, powerdown_notifi= er); + VirtMachineState *s =3D container_of(notifier, + VirtMachineState, powerdown_notifier); =20 acpi_send_event(s->acpi_ged, ACPI_POWER_DOWN_STATUS); } @@ -411,7 +411,7 @@ static void memmap_add_entry(uint64_t address, uint64_t= length, uint32_t type) memmap_entries++; } =20 -static uint64_t cpu_loongarch_virt_to_phys(void *opaque, uint64_t addr) +static uint64_t cpu_virt_to_phys(void *opaque, uint64_t addr) { return addr & MAKE_64BIT_MASK(0, TARGET_PHYS_ADDR_SPACE_BITS); } @@ -422,7 +422,7 @@ static int64_t load_kernel_info(const struct loaderpara= ms *loaderparams) ssize_t kernel_size; =20 kernel_size =3D load_elf(loaderparams->kernel_filename, NULL, - cpu_loongarch_virt_to_phys, NULL, + cpu_virt_to_phys, NULL, &kernel_entry, &kernel_low, &kernel_high, NULL, 0, EM_LOONGARCH, 1, 0); @@ -436,10 +436,10 @@ static int64_t load_kernel_info(const struct loaderpa= rams *loaderparams) return kernel_entry; } =20 -static DeviceState *create_acpi_ged(DeviceState *pch_pic, LoongArchMachine= State *lams) +static DeviceState *create_acpi_ged(DeviceState *pch_pic, VirtMachineState= *vms) { DeviceState *dev; - MachineState *ms =3D MACHINE(lams); + MachineState *ms =3D MACHINE(vms); uint32_t event =3D ACPI_GED_PWR_DOWN_EVT; =20 if (ms->ram_slots) { @@ -486,9 +486,9 @@ static DeviceState *create_platform_bus(DeviceState *pc= h_pic) return dev; } =20 -static void loongarch_devices_init(DeviceState *pch_pic, LoongArchMachineS= tate *lams) +static void virt_devices_init(DeviceState *pch_pic, VirtMachineState *vms) { - MachineClass *mc =3D MACHINE_GET_CLASS(lams); + MachineClass *mc =3D MACHINE_GET_CLASS(vms); DeviceState *gpex_dev; SysBusDevice *d; PCIBus *pci_bus; @@ -500,7 +500,7 @@ static void loongarch_devices_init(DeviceState *pch_pic= , LoongArchMachineState * d =3D SYS_BUS_DEVICE(gpex_dev); sysbus_realize_and_unref(d, &error_fatal); pci_bus =3D PCI_HOST_BRIDGE(gpex_dev)->bus; - lams->pci_bus =3D pci_bus; + vms->pci_bus =3D pci_bus; =20 /* Map only part size_ecam bytes of ECAM space */ ecam_alias =3D g_new0(MemoryRegion, 1); @@ -536,7 +536,7 @@ static void loongarch_devices_init(DeviceState *pch_pic= , LoongArchMachineState * qdev_get_gpio_in(pch_pic, VIRT_UART_IRQ - VIRT_GSI_BASE), 115200, serial_hd(0), DEVICE_LITTLE_ENDIAN); - fdt_add_uart_node(lams); + fdt_add_uart_node(vms); =20 /* Network init */ pci_init_nic_devices(pci_bus, mc->default_nic); @@ -549,17 +549,17 @@ static void loongarch_devices_init(DeviceState *pch_p= ic, LoongArchMachineState * sysbus_create_simple("ls7a_rtc", VIRT_RTC_REG_BASE, qdev_get_gpio_in(pch_pic, VIRT_RTC_IRQ - VIRT_GSI_BASE)); - fdt_add_rtc_node(lams); + fdt_add_rtc_node(vms); =20 /* acpi ged */ - lams->acpi_ged =3D create_acpi_ged(pch_pic, lams); + vms->acpi_ged =3D create_acpi_ged(pch_pic, vms); /* platform bus */ - lams->platform_bus_dev =3D create_platform_bus(pch_pic); + vms->platform_bus_dev =3D create_platform_bus(pch_pic); } =20 -static void loongarch_irq_init(LoongArchMachineState *lams) +static void virt_irq_init(VirtMachineState *vms) { - MachineState *ms =3D MACHINE(lams); + MachineState *ms =3D MACHINE(vms); DeviceState *pch_pic, *pch_msi, *cpudev; DeviceState *ipi, *extioi; SysBusDevice *d; @@ -596,9 +596,9 @@ static void loongarch_irq_init(LoongArchMachineState *l= ams) sysbus_realize_and_unref(SYS_BUS_DEVICE(ipi), &error_fatal); =20 /* IPI iocsr memory region */ - memory_region_add_subregion(&lams->system_iocsr, SMP_IPI_MAILBOX, + memory_region_add_subregion(&vms->system_iocsr, SMP_IPI_MAILBOX, sysbus_mmio_get_region(SYS_BUS_DEVICE(ipi), 0)); - memory_region_add_subregion(&lams->system_iocsr, MAIL_SEND_ADDR, + memory_region_add_subregion(&vms->system_iocsr, MAIL_SEND_ADDR, sysbus_mmio_get_region(SYS_BUS_DEVICE(ipi), 1)); =20 for (cpu =3D 0; cpu < ms->smp.cpus; cpu++) { @@ -606,7 +606,7 @@ static void loongarch_irq_init(LoongArchMachineState *l= ams) cpudev =3D DEVICE(cpu_state); lacpu =3D LOONGARCH_CPU(cpu_state); env =3D &(lacpu->env); - env->address_space_iocsr =3D &lams->as_iocsr; + env->address_space_iocsr =3D &vms->as_iocsr; =20 /* connect ipi irq to cpu irq */ qdev_connect_gpio_out(ipi, cpu, qdev_get_gpio_in(cpudev, IRQ_IPI)); @@ -617,7 +617,7 @@ static void loongarch_irq_init(LoongArchMachineState *l= ams) extioi =3D qdev_new(TYPE_LOONGARCH_EXTIOI); qdev_prop_set_uint32(extioi, "num-cpu", ms->smp.cpus); sysbus_realize_and_unref(SYS_BUS_DEVICE(extioi), &error_fatal); - memory_region_add_subregion(&lams->system_iocsr, APIC_BASE, + memory_region_add_subregion(&vms->system_iocsr, APIC_BASE, sysbus_mmio_get_region(SYS_BUS_DEVICE(extioi), 0)); =20 /* @@ -665,28 +665,28 @@ static void loongarch_irq_init(LoongArchMachineState = *lams) qdev_get_gpio_in(extioi, i + start)); } =20 - loongarch_devices_init(pch_pic, lams); + virt_devices_init(pch_pic, vms); } =20 -static void loongarch_firmware_init(LoongArchMachineState *lams) +static void virt_firmware_init(VirtMachineState *vms) { - char *filename =3D MACHINE(lams)->firmware; + char *filename =3D MACHINE(vms)->firmware; char *bios_name =3D NULL; int bios_size, i; BlockBackend *pflash_blk0; MemoryRegion *mr; =20 - lams->bios_loaded =3D false; + vms->bios_loaded =3D false; =20 /* Map legacy -drive if=3Dpflash to machine properties */ - for (i =3D 0; i < ARRAY_SIZE(lams->flash); i++) { - pflash_cfi01_legacy_drive(lams->flash[i], + for (i =3D 0; i < ARRAY_SIZE(vms->flash); i++) { + pflash_cfi01_legacy_drive(vms->flash[i], drive_get(IF_PFLASH, 0, i)); } =20 - virt_flash_map(lams, get_system_memory()); + virt_flash_map(vms, get_system_memory()); =20 - pflash_blk0 =3D pflash_cfi01_get_blk(lams->flash[0]); + pflash_blk0 =3D pflash_cfi01_get_blk(vms->flash[0]); =20 if (pflash_blk0) { if (filename) { @@ -694,7 +694,7 @@ static void loongarch_firmware_init(LoongArchMachineSta= te *lams) "options at once"); exit(1); } - lams->bios_loaded =3D true; + vms->bios_loaded =3D true; return; } =20 @@ -705,14 +705,14 @@ static void loongarch_firmware_init(LoongArchMachineS= tate *lams) exit(1); } =20 - mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(lams->flash[0]), 0); + mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(vms->flash[0]), 0); bios_size =3D load_image_mr(bios_name, mr); if (bios_size < 0) { error_report("Could not load ROM image '%s'", bios_name); exit(1); } g_free(bios_name); - lams->bios_loaded =3D true; + vms->bios_loaded =3D true; } } =20 @@ -754,16 +754,16 @@ static void fw_cfg_add_kernel_info(const struct loade= rparams *loaderparams, } } =20 -static void loongarch_firmware_boot(LoongArchMachineState *lams, +static void virt_firmware_boot(VirtMachineState *vms, const struct loaderparams *loaderparam= s) { - fw_cfg_add_kernel_info(loaderparams, lams->fw_cfg); + fw_cfg_add_kernel_info(loaderparams, vms->fw_cfg); } =20 -static void loongarch_direct_kernel_boot(LoongArchMachineState *lams, +static void virt_direct_kernel_boot(VirtMachineState *vms, const struct loaderparams *loader= params) { - MachineState *machine =3D MACHINE(lams); + MachineState *machine =3D MACHINE(vms); int64_t kernel_addr =3D 0; LoongArchCPU *lacpu; int i; @@ -778,12 +778,12 @@ static void loongarch_direct_kernel_boot(LoongArchMac= hineState *lams, } } =20 -static void loongarch_qemu_write(void *opaque, hwaddr addr, +static void virt_qemu_write(void *opaque, hwaddr addr, uint64_t val, unsigned size) { } =20 -static uint64_t loongarch_qemu_read(void *opaque, hwaddr addr, unsigned si= ze) +static uint64_t virt_qemu_read(void *opaque, hwaddr addr, unsigned size) { switch (addr) { case VERSION_REG: @@ -801,9 +801,9 @@ static uint64_t loongarch_qemu_read(void *opaque, hwadd= r addr, unsigned size) return 0ULL; } =20 -static const MemoryRegionOps loongarch_qemu_ops =3D { - .read =3D loongarch_qemu_read, - .write =3D loongarch_qemu_write, +static const MemoryRegionOps virt_qemu_ops =3D { + .read =3D virt_qemu_read, + .write =3D virt_qemu_write, .endianness =3D DEVICE_LITTLE_ENDIAN, .valid =3D { .min_access_size =3D 4, @@ -815,7 +815,7 @@ static const MemoryRegionOps loongarch_qemu_ops =3D { }, }; =20 -static void loongarch_init(MachineState *machine) +static void virt_init(MachineState *machine) { LoongArchCPU *lacpu; const char *cpu_model =3D machine->cpu_type; @@ -823,7 +823,7 @@ static void loongarch_init(MachineState *machine) ram_addr_t ram_size =3D machine->ram_size; uint64_t highram_size =3D 0, phyAddr =3D 0; MemoryRegion *address_space_mem =3D get_system_memory(); - LoongArchMachineState *lams =3D VIRT_MACHINE(machine); + VirtMachineState *vms =3D VIRT_MACHINE(machine); int nb_numa_nodes =3D machine->numa_state->num_nodes; NodeInfo *numa_info =3D machine->numa_state->nodes; int i; @@ -842,16 +842,16 @@ static void loongarch_init(MachineState *machine) error_report("ram_size must be greater than 1G."); exit(1); } - create_fdt(lams); + create_fdt(vms); =20 /* Create IOCSR space */ - memory_region_init_io(&lams->system_iocsr, OBJECT(machine), NULL, + memory_region_init_io(&vms->system_iocsr, OBJECT(machine), NULL, machine, "iocsr", UINT64_MAX); - address_space_init(&lams->as_iocsr, &lams->system_iocsr, "IOCSR"); - memory_region_init_io(&lams->iocsr_mem, OBJECT(machine), - &loongarch_qemu_ops, + address_space_init(&vms->as_iocsr, &vms->system_iocsr, "IOCSR"); + memory_region_init_io(&vms->iocsr_mem, OBJECT(machine), + &virt_qemu_ops, machine, "iocsr_misc", 0x428); - memory_region_add_subregion(&lams->system_iocsr, 0, &lams->iocsr_mem); + memory_region_add_subregion(&vms->system_iocsr, 0, &vms->iocsr_mem); =20 /* Init CPUs */ possible_cpus =3D mc->possible_cpu_arch_ids(machine); @@ -862,14 +862,14 @@ static void loongarch_init(MachineState *machine) lacpu =3D LOONGARCH_CPU(cpu); lacpu->phy_id =3D machine->possible_cpus->cpus[i].arch_id; } - fdt_add_cpu_nodes(lams); + fdt_add_cpu_nodes(vms); =20 /* Node0 memory */ memmap_add_entry(VIRT_LOWMEM_BASE, VIRT_LOWMEM_SIZE, 1); fdt_add_memory_node(machine, VIRT_LOWMEM_BASE, VIRT_LOWMEM_SIZE, 0); - memory_region_init_alias(&lams->lowmem, NULL, "loongarch.node0.lowram", + memory_region_init_alias(&vms->lowmem, NULL, "loongarch.node0.lowram", machine->ram, offset, VIRT_LOWMEM_SIZE); - memory_region_add_subregion(address_space_mem, phyAddr, &lams->lowmem); + memory_region_add_subregion(address_space_mem, phyAddr, &vms->lowmem); =20 offset +=3D VIRT_LOWMEM_SIZE; if (nb_numa_nodes > 0) { @@ -881,9 +881,9 @@ static void loongarch_init(MachineState *machine) phyAddr =3D VIRT_HIGHMEM_BASE; memmap_add_entry(phyAddr, highram_size, 1); fdt_add_memory_node(machine, phyAddr, highram_size, 0); - memory_region_init_alias(&lams->highmem, NULL, "loongarch.node0.highra= m", + memory_region_init_alias(&vms->highmem, NULL, "loongarch.node0.highram= ", machine->ram, offset, highram_size); - memory_region_add_subregion(address_space_mem, phyAddr, &lams->highmem= ); + memory_region_add_subregion(address_space_mem, phyAddr, &vms->highmem); =20 /* Node1 - Nodemax memory */ offset +=3D highram_size; @@ -924,49 +924,49 @@ static void loongarch_init(MachineState *machine) } =20 /* load the BIOS image. */ - loongarch_firmware_init(lams); + virt_firmware_init(vms); =20 /* fw_cfg init */ - lams->fw_cfg =3D loongarch_fw_cfg_init(ram_size, machine); - rom_set_fw(lams->fw_cfg); - if (lams->fw_cfg !=3D NULL) { - fw_cfg_add_file(lams->fw_cfg, "etc/memmap", + vms->fw_cfg =3D virt_fw_cfg_init(ram_size, machine); + rom_set_fw(vms->fw_cfg); + if (vms->fw_cfg !=3D NULL) { + fw_cfg_add_file(vms->fw_cfg, "etc/memmap", memmap_table, sizeof(struct memmap_entry) * (memmap_entries)); } - fdt_add_fw_cfg_node(lams); + fdt_add_fw_cfg_node(vms); loaderparams.ram_size =3D ram_size; loaderparams.kernel_filename =3D machine->kernel_filename; loaderparams.kernel_cmdline =3D machine->kernel_cmdline; loaderparams.initrd_filename =3D machine->initrd_filename; /* load the kernel. */ if (loaderparams.kernel_filename) { - if (lams->bios_loaded) { - loongarch_firmware_boot(lams, &loaderparams); + if (vms->bios_loaded) { + virt_firmware_boot(vms, &loaderparams); } else { - loongarch_direct_kernel_boot(lams, &loaderparams); + virt_direct_kernel_boot(vms, &loaderparams); } } - fdt_add_flash_node(lams); + fdt_add_flash_node(vms); /* register reset function */ for (i =3D 0; i < machine->smp.cpus; i++) { lacpu =3D LOONGARCH_CPU(qemu_get_cpu(i)); qemu_register_reset(reset_load_elf, lacpu); } /* Initialize the IO interrupt subsystem */ - loongarch_irq_init(lams); - fdt_add_irqchip_node(lams); + virt_irq_init(vms); + fdt_add_irqchip_node(vms); platform_bus_add_all_fdt_nodes(machine->fdt, "/intc", VIRT_PLATFORM_BUS_BASEADDRESS, VIRT_PLATFORM_BUS_SIZE, VIRT_PLATFORM_BUS_IRQ); - lams->machine_done.notify =3D virt_machine_done; - qemu_add_machine_init_done_notifier(&lams->machine_done); + vms->machine_done.notify =3D virt_machine_done; + qemu_add_machine_init_done_notifier(&vms->machine_done); /* connect powerdown request */ - lams->powerdown_notifier.notify =3D virt_powerdown_req; - qemu_register_powerdown_notifier(&lams->powerdown_notifier); + vms->powerdown_notifier.notify =3D virt_powerdown_req; + qemu_register_powerdown_notifier(&vms->powerdown_notifier); =20 - fdt_add_pcie_node(lams); + fdt_add_pcie_node(vms); /* * Since lowmem region starts from 0 and Linux kernel legacy start add= ress * at 2 MiB, FDT base address is located at 1 MiB to avoid NULL pointer @@ -975,43 +975,43 @@ static void loongarch_init(MachineState *machine) * the FDT is copied again upon reset, even if addr points into RAM. */ fdt_base =3D 1 * MiB; - qemu_fdt_dumpdtb(machine->fdt, lams->fdt_size); - rom_add_blob_fixed("fdt", machine->fdt, lams->fdt_size, fdt_base); + qemu_fdt_dumpdtb(machine->fdt, vms->fdt_size); + rom_add_blob_fixed("fdt", machine->fdt, vms->fdt_size, fdt_base); } =20 -bool loongarch_is_acpi_enabled(LoongArchMachineState *lams) +bool virt_is_acpi_enabled(VirtMachineState *vms) { - if (lams->acpi =3D=3D ON_OFF_AUTO_OFF) { + if (vms->acpi =3D=3D ON_OFF_AUTO_OFF) { return false; } return true; } =20 -static void loongarch_get_acpi(Object *obj, Visitor *v, const char *name, +static void virt_get_acpi(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - LoongArchMachineState *lams =3D VIRT_MACHINE(obj); - OnOffAuto acpi =3D lams->acpi; + VirtMachineState *vms =3D VIRT_MACHINE(obj); + OnOffAuto acpi =3D vms->acpi; =20 visit_type_OnOffAuto(v, name, &acpi, errp); } =20 -static void loongarch_set_acpi(Object *obj, Visitor *v, const char *name, +static void virt_set_acpi(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp) { - LoongArchMachineState *lams =3D VIRT_MACHINE(obj); + VirtMachineState *vms =3D VIRT_MACHINE(obj); =20 - visit_type_OnOffAuto(v, name, &lams->acpi, errp); + visit_type_OnOffAuto(v, name, &vms->acpi, errp); } =20 -static void loongarch_machine_initfn(Object *obj) +static void virt_machine_initfn(Object *obj) { - LoongArchMachineState *lams =3D VIRT_MACHINE(obj); + VirtMachineState *vms =3D VIRT_MACHINE(obj); =20 - lams->acpi =3D ON_OFF_AUTO_AUTO; - lams->oem_id =3D g_strndup(ACPI_BUILD_APPNAME6, 6); - lams->oem_table_id =3D g_strndup(ACPI_BUILD_APPNAME8, 8); - virt_flash_create(lams); + vms->acpi =3D ON_OFF_AUTO_AUTO; + vms->oem_id =3D g_strndup(ACPI_BUILD_APPNAME6, 6); + vms->oem_table_id =3D g_strndup(ACPI_BUILD_APPNAME8, 8); + virt_flash_create(vms); } =20 static bool memhp_type_supported(DeviceState *dev) @@ -1038,10 +1038,10 @@ static void virt_machine_device_pre_plug(HotplugHan= dler *hotplug_dev, static void virt_mem_unplug_request(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - LoongArchMachineState *lams =3D VIRT_MACHINE(hotplug_dev); + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); =20 /* the acpi ged is always exist */ - hotplug_handler_unplug_request(HOTPLUG_HANDLER(lams->acpi_ged), dev, + hotplug_handler_unplug_request(HOTPLUG_HANDLER(vms->acpi_ged), dev, errp); } =20 @@ -1056,10 +1056,10 @@ static void virt_machine_device_unplug_request(Hotp= lugHandler *hotplug_dev, static void virt_mem_unplug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - LoongArchMachineState *lams =3D VIRT_MACHINE(hotplug_dev); + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); =20 - hotplug_handler_unplug(HOTPLUG_HANDLER(lams->acpi_ged), dev, errp); - pc_dimm_unplug(PC_DIMM(dev), MACHINE(lams)); + hotplug_handler_unplug(HOTPLUG_HANDLER(vms->acpi_ged), dev, errp); + pc_dimm_unplug(PC_DIMM(dev), MACHINE(vms)); qdev_unrealize(dev); } =20 @@ -1074,22 +1074,22 @@ static void virt_machine_device_unplug(HotplugHandl= er *hotplug_dev, static void virt_mem_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - LoongArchMachineState *lams =3D VIRT_MACHINE(hotplug_dev); + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); =20 - pc_dimm_plug(PC_DIMM(dev), MACHINE(lams)); - hotplug_handler_plug(HOTPLUG_HANDLER(lams->acpi_ged), + pc_dimm_plug(PC_DIMM(dev), MACHINE(vms)); + hotplug_handler_plug(HOTPLUG_HANDLER(vms->acpi_ged), dev, &error_abort); } =20 -static void loongarch_machine_device_plug_cb(HotplugHandler *hotplug_dev, +static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - LoongArchMachineState *lams =3D VIRT_MACHINE(hotplug_dev); - MachineClass *mc =3D MACHINE_GET_CLASS(lams); + VirtMachineState *vms =3D VIRT_MACHINE(hotplug_dev); + MachineClass *mc =3D MACHINE_GET_CLASS(vms); =20 if (device_is_dynamic_sysbus(mc, dev)) { - if (lams->platform_bus_dev) { - platform_bus_link_device(PLATFORM_BUS_DEVICE(lams->platform_bu= s_dev), + if (vms->platform_bus_dev) { + platform_bus_link_device(PLATFORM_BUS_DEVICE(vms->platform_bus= _dev), SYS_BUS_DEVICE(dev)); } } else if (memhp_type_supported(dev)) { @@ -1161,12 +1161,12 @@ static int64_t virt_get_default_cpu_node_id(const M= achineState *ms, int idx) return nidx; } =20 -static void loongarch_class_init(ObjectClass *oc, void *data) +static void virt_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); HotplugHandlerClass *hc =3D HOTPLUG_HANDLER_CLASS(oc); =20 - mc->init =3D loongarch_init; + mc->init =3D virt_init; mc->default_ram_size =3D 1 * GiB; mc->default_cpu_type =3D LOONGARCH_CPU_TYPE_NAME("la464"); mc->default_ram_id =3D "loongarch.ram"; @@ -1184,13 +1184,13 @@ static void loongarch_class_init(ObjectClass *oc, v= oid *data) mc->auto_enable_numa_with_memdev =3D true; mc->get_hotplug_handler =3D virt_machine_get_hotplug_handler; mc->default_nic =3D "virtio-net-pci"; - hc->plug =3D loongarch_machine_device_plug_cb; + hc->plug =3D virt_machine_device_plug_cb; hc->pre_plug =3D virt_machine_device_pre_plug; hc->unplug_request =3D virt_machine_device_unplug_request; hc->unplug =3D virt_machine_device_unplug; =20 object_class_property_add(oc, "acpi", "OnOffAuto", - loongarch_get_acpi, loongarch_set_acpi, + virt_get_acpi, virt_set_acpi, NULL, NULL); object_class_property_set_description(oc, "acpi", "Enable ACPI"); @@ -1200,13 +1200,13 @@ static void loongarch_class_init(ObjectClass *oc, v= oid *data) #endif } =20 -static const TypeInfo loongarch_machine_types[] =3D { +static const TypeInfo virt_machine_types[] =3D { { .name =3D TYPE_VIRT_MACHINE, .parent =3D TYPE_MACHINE, - .instance_size =3D sizeof(LoongArchMachineState), - .class_init =3D loongarch_class_init, - .instance_init =3D loongarch_machine_initfn, + .instance_size =3D sizeof(VirtMachineState), + .class_init =3D virt_class_init, + .instance_init =3D virt_machine_initfn, .interfaces =3D (InterfaceInfo[]) { { TYPE_HOTPLUG_HANDLER }, { } @@ -1214,4 +1214,4 @@ static const TypeInfo loongarch_machine_types[] =3D { } }; =20 -DEFINE_TYPES(loongarch_machine_types) +DEFINE_TYPES(virt_machine_types) diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h index d9c7050340..130fe21125 100644 --- a/include/hw/loongarch/virt.h +++ b/include/hw/loongarch/virt.h @@ -32,7 +32,7 @@ #define VIRT_GED_MEM_ADDR (VIRT_GED_EVT_ADDR + ACPI_GED_EVT_SEL_LEN) #define VIRT_GED_REG_ADDR (VIRT_GED_MEM_ADDR + MEMORY_HOTPLUG_IO_LEN) =20 -struct LoongArchMachineState { +struct VirtMachineState { /*< private >*/ MachineState parent_obj; =20 @@ -58,7 +58,7 @@ struct LoongArchMachineState { }; =20 #define TYPE_VIRT_MACHINE MACHINE_TYPE_NAME("virt") -OBJECT_DECLARE_SIMPLE_TYPE(LoongArchMachineState, VIRT_MACHINE) -bool loongarch_is_acpi_enabled(LoongArchMachineState *lams); -void loongarch_acpi_setup(LoongArchMachineState *lams); +OBJECT_DECLARE_SIMPLE_TYPE(VirtMachineState, VIRT_MACHINE) +bool virt_is_acpi_enabled(VirtMachineState *vms); +void virt_acpi_setup(VirtMachineState *vms); #endif --=20 2.39.3 From nobody Tue Nov 26 06:55:28 2024 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709001142280334.2733926745009; Mon, 26 Feb 2024 18:32:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1renF3-0002zK-Pq; Mon, 26 Feb 2024 21:30:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1renF3-0002yr-1I for qemu-devel@nongnu.org; Mon, 26 Feb 2024 21:30:49 -0500 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1renEw-0002PS-Md for qemu-devel@nongnu.org; Mon, 26 Feb 2024 21:30:48 -0500 Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8DxqehMSd1lAdARAA--.25864S3; Tue, 27 Feb 2024 10:30:36 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cxbs1HSd1lRvhGAA--.54308S5; Tue, 27 Feb 2024 10:30:35 +0800 (CST) From: Bibo Mao To: Song Gao , Peter Xu , Fabiano Rosas , Laurent Vivier , Thomas Huth Cc: qemu-devel@nongnu.org Subject: [PATCH v2 3/5] hw/loongarch: Add compat machine for 9.0 Date: Tue, 27 Feb 2024 10:30:29 +0800 Message-Id: <20240227023031.3299067-4-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240227023031.3299067-1-maobibo@loongson.cn> References: <20240227023031.3299067-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8Cxbs1HSd1lRvhGAA--.54308S5 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoWxZF1rWF4UGF4kXr4UXF4DKFX_yoW5Xr1DpF 9xZrs8Cw4DWFsxurWfJan8ZF45Krs7Ga42qFs7Zw4vyasrCryjvr18G34q9ay7ArWkJF45 ZF4kCa47W3W5ZwcCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkYb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r126r13M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4j6r4UJwAS0I0E0xvYzxvE52x082IY62kv0487Mc804VCY07AIYIkI8VC2zVCFFI0UMc 02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0I7IYx2IY67AKxVWUtVWrXwAv7VC2z280aVAF wI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r4UM4x0Y48IcxkI7VAKI48JMxAIw28IcxkI7V AKI48JMxC20s026xCaFVCjc4AY6r1j6r4UMI8I3I0E5I8CrVAFwI0_Jr0_Jr4lx2IqxVCj r7xvwVAFwI0_JrI_JrWlx4CE17CEb7AF67AKxVWUAVWUtwCIc40Y0x0EwIxGrwCI42IY6x IIjxv20xvE14v26r1I6r4UMIIF0xvE2Ix0cI8IcVCY1x0267AKxVW8JVWxJwCI42IY6xAI w20EY4v20xvaj40_Jr0_JF4lIxAIcVC2z280aVAFwI0_Jr0_Gr1lIxAIcVC2z280aVCY1x 0267AKxVW8JVW8JrUvcSsGvfC2KfnxnUUI43ZEXa7IU8gAw7UUUUU== 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=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_HELO_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1709001143075100004 Content-Type: text/plain; charset="utf-8" Since migration test case requires compat machine type support, compat machine is added for qemu 9.0 here. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- hw/loongarch/virt.c | 60 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 47 insertions(+), 13 deletions(-) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 3bc35c58c9..f37f642ede 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -46,6 +46,32 @@ #include "hw/block/flash.h" #include "qemu/error-report.h" =20 +#define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ + static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ + void *data) \ + { \ + MachineClass *mc =3D MACHINE_CLASS(oc); \ + virt_machine_##major##_##minor##_options(mc); \ + mc->desc =3D "QEMU " # major "." # minor " ARM Virtual Machine"; \ + if (latest) { \ + mc->alias =3D "virt"; \ + } \ + } \ + static const TypeInfo machvirt_##major##_##minor##_info =3D { \ + .name =3D MACHINE_TYPE_NAME("virt-" # major "." # minor), \ + .parent =3D TYPE_VIRT_MACHINE, \ + .class_init =3D virt_##major##_##minor##_class_init, \ + }; \ + static void machvirt_machine_##major##_##minor##_init(void) \ + { \ + type_register_static(&machvirt_##major##_##minor##_info); \ + } \ + type_init(machvirt_machine_##major##_##minor##_init); + +#define DEFINE_VIRT_MACHINE_AS_LATEST(major, minor) \ + DEFINE_VIRT_MACHINE_LATEST(major, minor, true) +#define DEFINE_VIRT_MACHINE(major, minor) \ + DEFINE_VIRT_MACHINE_LATEST(major, minor, false) =20 struct loaderparams { uint64_t ram_size; @@ -1200,18 +1226,26 @@ static void virt_class_init(ObjectClass *oc, void *= data) #endif } =20 -static const TypeInfo virt_machine_types[] =3D { - { - .name =3D TYPE_VIRT_MACHINE, - .parent =3D TYPE_MACHINE, - .instance_size =3D sizeof(VirtMachineState), - .class_init =3D virt_class_init, - .instance_init =3D virt_machine_initfn, - .interfaces =3D (InterfaceInfo[]) { - { TYPE_HOTPLUG_HANDLER }, - { } - }, - } +static const TypeInfo virt_machine_info =3D { + .name =3D TYPE_VIRT_MACHINE, + .parent =3D TYPE_MACHINE, + .abstract =3D true, + .instance_size =3D sizeof(VirtMachineState), + .class_init =3D virt_class_init, + .instance_init =3D virt_machine_initfn, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_HOTPLUG_HANDLER }, + { } + }, }; =20 -DEFINE_TYPES(virt_machine_types) +static void machvirt_machine_init(void) +{ + type_register_static(&virt_machine_info); +} +type_init(machvirt_machine_init); + +static void virt_machine_9_0_options(MachineClass *mc) +{ +} +DEFINE_VIRT_MACHINE_AS_LATEST(9, 0) --=20 2.39.3 From nobody Tue Nov 26 06:55:28 2024 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1709001092672757.2028063691935; Mon, 26 Feb 2024 18:31:32 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1renF2-0002yc-5I; Mon, 26 Feb 2024 21:30:48 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1renEz-0002xi-Ta for qemu-devel@nongnu.org; Mon, 26 Feb 2024 21:30:45 -0500 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1renEw-0002PX-L2 for qemu-devel@nongnu.org; Mon, 26 Feb 2024 21:30:44 -0500 Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8AxPOlMSd1lBNARAA--.35232S3; Tue, 27 Feb 2024 10:30:36 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cxbs1HSd1lRvhGAA--.54308S6; Tue, 27 Feb 2024 10:30:36 +0800 (CST) From: Bibo Mao To: Song Gao , Peter Xu , Fabiano Rosas , Laurent Vivier , Thomas Huth Cc: qemu-devel@nongnu.org Subject: [PATCH v2 4/5] hw/loongarch: Set minimium memory size as 256M Date: Tue, 27 Feb 2024 10:30:30 +0800 Message-Id: <20240227023031.3299067-5-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240227023031.3299067-1-maobibo@loongson.cn> References: <20240227023031.3299067-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8Cxbs1HSd1lRvhGAA--.54308S6 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj9xXoW7JFyDZr17urWDWry5GFy8Zwc_yoWfArb_WF yxGw1xCr1DW3Wj9w47Xw1rJw4DWa10yFn5Za47Ga4kG343JrsxGFs2gwn3ur129w45uws3 Jw4ktryYyr9xWosvyTuYvTs0mTUanT9S1TB71UUUUUDqnTZGkaVYY2UrUUUUj1kv1TuYvT s0mT0YCTnIWjqI5I8CrVACY4xI64kE6c02F40Ex7xfYxn0WfASr-VFAUDa7-sFnT9fnUUI cSsGvfJTRUUUb7kYFVCjjxCrM7AC8VAFwI0_Jr0_Gr1l1xkIjI8I6I8E6xAIw20EY4v20x vaj40_Wr0E3s1l1IIY67AEw4v_Jrv_JF1l8cAvFVAK0II2c7xJM28CjxkF64kEwVA0rcxS w2x7M28EF7xvwVC0I7IYx2IY67AKxVW8JVW5JwA2z4x0Y4vE2Ix0cI8IcVCY1x0267AKxV W8JVWxJwA2z4x0Y4vEx4A2jsIE14v26F4j6r4UJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1q6rW5McIj6I8E87Iv67AK xVW8JVWxJwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_Gr0_Xr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVW8JVWxJwCI42IY6I8E87Iv6xkF7I 0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjxUcCD7UUUUU 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=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1709001095025100001 Content-Type: text/plain; charset="utf-8" The minimum memory size for LoongArch UEFI bios is 256M, also some test cases such as migration and qos use 256M memory by default. Here set minimum memory size for Loongarch VirtMachine with 256M rather than 1G, so that test cases with 256M memory can pass to run. Signed-off-by: Bibo Mao Reviewed-by: Song Gao --- hw/loongarch/virt.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index f37f642ede..1dadb8e299 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -864,8 +864,8 @@ static void virt_init(MachineState *machine) cpu_model =3D LOONGARCH_CPU_TYPE_NAME("la464"); } =20 - if (ram_size < 1 * GiB) { - error_report("ram_size must be greater than 1G."); + if (ram_size < 256 * MiB) { + error_report("ram_size must be greater than 256M."); exit(1); } create_fdt(vms); --=20 2.39.3 From nobody Tue Nov 26 06:55:28 2024 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 Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 170900112487034.897926777218004; Mon, 26 Feb 2024 18:32:04 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1renF3-0002ys-4M; Mon, 26 Feb 2024 21:30:49 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1renF1-0002yJ-MK for qemu-devel@nongnu.org; Mon, 26 Feb 2024 21:30:47 -0500 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1renEz-0002QQ-Fh for qemu-devel@nongnu.org; Mon, 26 Feb 2024 21:30:47 -0500 Received: from loongson.cn (unknown [10.2.5.213]) by gateway (Coremail) with SMTP id _____8DxWPBRSd1lEtARAA--.45223S3; Tue, 27 Feb 2024 10:30:41 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.213]) by localhost.localdomain (Coremail) with SMTP id AQAAf8Cxbs1HSd1lRvhGAA--.54308S7; Tue, 27 Feb 2024 10:30:39 +0800 (CST) From: Bibo Mao To: Song Gao , Peter Xu , Fabiano Rosas , Laurent Vivier , Thomas Huth Cc: qemu-devel@nongnu.org Subject: [PATCH v2 5/5] tests: Add migration test for loongarch64 Date: Tue, 27 Feb 2024 10:30:31 +0800 Message-Id: <20240227023031.3299067-6-maobibo@loongson.cn> X-Mailer: git-send-email 2.39.3 In-Reply-To: <20240227023031.3299067-1-maobibo@loongson.cn> References: <20240227023031.3299067-1-maobibo@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: AQAAf8Cxbs1HSd1lRvhGAA--.54308S7 X-CM-SenderInfo: xpdruxter6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBj93XoW3Ar1DKw4kGFy8ZryUur1ruFX_yoWxKr1xpw 1rCw1Ikan7GF17t3WfWryj9r1fZw1xGr1aga97Jr40yrZYyFy8Aw1Ygry2qFn3X3yjgF4F vwn5tr17K3WDArcCm3ZEXasCq-sJn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVWxJVW8Jr1l84ACjcxK6I8E87Iv6xkF7I0E14v2 6r4UJVWxJr1le2I262IYc4CY6c8Ij28IcVAaY2xG8wAqjxCEc2xF0cIa020Ex4CE44I27w Aqx4xG64xvF2IEw4CE5I8CrVC2j2WlYx0E2Ix0cI8IcVAFwI0_Jw0_WrylYx0Ex4A2jsIE 14v26r4j6F4UMcvjeVCFs4IE7xkEbVWUJVW8JwACjcxG0xvY0x0EwIxGrwCF04k20xvY0x 0EwIxGrwCFx2IqxVCFs4IE7xkEbVWUJVW8JwC20s026c02F40E14v26r1j6r18MI8I3I0E 7480Y4vE14v26r106r1rMI8E67AF67kF1VAFwI0_JF0_Jw1lIxkGc2Ij64vIr41lIxAIcV C0I7IYx2IY67AKxVW8JVW5JwCI42IY6xIIjxv20xvEc7CjxVAFwI0_Gr0_Cr1lIxAIcVCF 04k26cxKx2IYs7xG6r1j6r1xMIIF0xvEx4A2jsIE14v26r4j6F4UMIIF0xvEx4A2jsIEc7 CjxVAFwI0_Gr0_Gr1UYxBIdaVFxhVjvjDU0xZFpf9x07jOdb8UUUUU= 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=114.242.206.163; envelope-from=maobibo@loongson.cn; helo=mail.loongson.cn X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1709001125246100001 Content-Type: text/plain; charset="utf-8" This patch adds migration test support for loongarch64. The test code comes from aarch64 mostly, only that it booted as bios in qemu since kernel requires elf format and bios uses binary format. In addition to providing the binary, this patch also includes the source code and the build script in tests/migration/loongarch64. So users can change the source and/or re-compile the binary as they wish. Signed-off-by: Bibo Mao Reviewed-by: Fabiano Rosas Acked-by: Thomas Huth Acked-by: Peter Xu --- tests/migration/Makefile | 2 +- tests/migration/loongarch64/Makefile | 18 +++++++++ tests/migration/loongarch64/a-b-kernel.S | 49 ++++++++++++++++++++++++ tests/migration/loongarch64/a-b-kernel.h | 16 ++++++++ tests/migration/migration-test.h | 3 ++ tests/qtest/meson.build | 4 ++ tests/qtest/migration-test.c | 10 +++++ 7 files changed, 101 insertions(+), 1 deletion(-) create mode 100644 tests/migration/loongarch64/Makefile create mode 100644 tests/migration/loongarch64/a-b-kernel.S create mode 100644 tests/migration/loongarch64/a-b-kernel.h diff --git a/tests/migration/Makefile b/tests/migration/Makefile index 13e99b1692..cfebfe23f8 100644 --- a/tests/migration/Makefile +++ b/tests/migration/Makefile @@ -5,7 +5,7 @@ # See the COPYING file in the top-level directory. # =20 -TARGET_LIST =3D i386 aarch64 s390x +TARGET_LIST =3D i386 aarch64 s390x loongarch64 =20 SRC_PATH =3D ../.. =20 diff --git a/tests/migration/loongarch64/Makefile b/tests/migration/loongar= ch64/Makefile new file mode 100644 index 0000000000..5d8719205f --- /dev/null +++ b/tests/migration/loongarch64/Makefile @@ -0,0 +1,18 @@ +# To specify cross compiler prefix, use CROSS_PREFIX=3D +# $ make CROSS_PREFIX=3Dloongarch64-linux-gnu- + +.PHONY: all clean +all: a-b-kernel.h + +a-b-kernel.h: loongarch64.kernel + echo "$$__note" > $@ + xxd -i $< | sed -e 's/.*int.*//' >> $@ + +loongarch64.kernel: loongarch64.elf + $(CROSS_PREFIX)objcopy -j .text -O binary $< $@ + +loongarch64.elf: a-b-kernel.S + $(CROSS_PREFIX)gcc -o $@ -nostdlib -Wl,--build-id=3Dnone $< + +clean: + $(RM) *.kernel *.elf diff --git a/tests/migration/loongarch64/a-b-kernel.S b/tests/migration/loo= ngarch64/a-b-kernel.S new file mode 100644 index 0000000000..cd543345fe --- /dev/null +++ b/tests/migration/loongarch64/a-b-kernel.S @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (c) 2024 Loongson Technology Corporation Limited + */ +#include "../migration-test.h" + +#define LOONGARCH_CSR_CRMD 0 +#define LOONGARCH_VIRT_UART 0x1FE001E0 +.section .text + + .globl _start +_start: + /* output char 'A' to UART16550 */ + li.d $t0, LOONGARCH_VIRT_UART + li.w $t1, 'A' + st.b $t1, $t0, 0 + + /* traverse test memory region */ + li.d $t0, LOONGARCH_TEST_MEM_START + li.d $t1, LOONGARCH_TEST_MEM_END + li.d $t2, TEST_MEM_PAGE_SIZE + li.d $t4, LOONGARCH_VIRT_UART + li.w $t5, 'B' + +clean: + st.b $zero, $t0, 0 + add.d $t0, $t0, $t2 + bne $t0, $t1, clean + /* keeps a counter so we can limit the output speed */ + addi.d $t6, $zero, 0 + +mainloop: + li.d $t0, LOONGARCH_TEST_MEM_START + +innerloop: + ld.bu $t3, $t0, 0 + addi.w $t3, $t3, 1 + ext.w.b $t3, $t3 + st.b $t3, $t0, 0 + add.d $t0, $t0, $t2 + bne $t0, $t1, innerloop + + addi.d $t6, $t6, 1 + andi $t6, $t6, 31 + bnez $t6, mainloop + + st.b $t5, $t4, 0 + b mainloop + nop diff --git a/tests/migration/loongarch64/a-b-kernel.h b/tests/migration/loo= ngarch64/a-b-kernel.h new file mode 100644 index 0000000000..b3fe466754 --- /dev/null +++ b/tests/migration/loongarch64/a-b-kernel.h @@ -0,0 +1,16 @@ +/* This file is automatically generated from the assembly file in +* tests/migration/loongarch64. Edit that file and then run "make all" +* inside tests/migration to update, and then remember to send both +* the header and the assembler differences in your patch submission. +*/ +unsigned char loongarch64_kernel[] =3D { + 0x0c, 0xc0, 0x3f, 0x14, 0x8c, 0x81, 0x87, 0x03, 0x0d, 0x04, 0x81, 0x03, + 0x8d, 0x01, 0x00, 0x29, 0x0c, 0x00, 0x04, 0x14, 0x0d, 0x80, 0x0c, 0x14, + 0x2e, 0x00, 0x00, 0x14, 0x10, 0xc0, 0x3f, 0x14, 0x10, 0x82, 0x87, 0x03, + 0x11, 0x08, 0x81, 0x03, 0x80, 0x01, 0x00, 0x29, 0x8c, 0xb9, 0x10, 0x00, + 0x8d, 0xf9, 0xff, 0x5f, 0x12, 0x00, 0xc0, 0x02, 0x0c, 0x00, 0x04, 0x14, + 0x8f, 0x01, 0x00, 0x2a, 0xef, 0x05, 0x80, 0x02, 0xef, 0x5d, 0x00, 0x00, + 0x8f, 0x01, 0x00, 0x29, 0x8c, 0xb9, 0x10, 0x00, 0x8d, 0xed, 0xff, 0x5f, + 0x52, 0x06, 0xc0, 0x02, 0x52, 0x7e, 0x40, 0x03, 0x5f, 0xde, 0xff, 0x47, + 0x11, 0x02, 0x00, 0x29, 0xff, 0xd7, 0xff, 0x53, 0x00, 0x00, 0x40, 0x03 +}; diff --git a/tests/migration/migration-test.h b/tests/migration/migration-t= est.h index 68512c0b1b..f402e48349 100644 --- a/tests/migration/migration-test.h +++ b/tests/migration/migration-test.h @@ -32,4 +32,7 @@ */ #define ARM_TEST_MAX_KERNEL_SIZE (512 * 1024) =20 +/* LoongArch64 */ +#define LOONGARCH_TEST_MEM_START (32 * 1024 * 1024) +#define LOONGARCH_TEST_MEM_END (100 * 1024 * 1024) #endif /* MIGRATION_TEST_H */ diff --git a/tests/qtest/meson.build b/tests/qtest/meson.build index 6ea77893f5..88b9d7550a 100644 --- a/tests/qtest/meson.build +++ b/tests/qtest/meson.build @@ -250,6 +250,10 @@ qtests_s390x =3D \ qtests_riscv32 =3D \ (config_all_devices.has_key('CONFIG_SIFIVE_E_AON') ? ['sifive-e-aon-watc= hdog-test'] : []) =20 +qtests_loongarch64 =3D \ + qtests_filter + \ + ['migration-test'] + qos_test_ss =3D ss.source_set() qos_test_ss.add( 'ac97-test.c', diff --git a/tests/qtest/migration-test.c b/tests/qtest/migration-test.c index 8a5bb1752e..8a25edfa77 100644 --- a/tests/qtest/migration-test.c +++ b/tests/qtest/migration-test.c @@ -132,6 +132,7 @@ static char *bootpath; #include "tests/migration/i386/a-b-bootblock.h" #include "tests/migration/aarch64/a-b-kernel.h" #include "tests/migration/s390x/a-b-bios.h" +#include "tests/migration/loongarch64/a-b-kernel.h" =20 static void bootfile_create(char *dir, bool suspend_me) { @@ -158,6 +159,9 @@ static void bootfile_create(char *dir, bool suspend_me) content =3D aarch64_kernel; len =3D sizeof(aarch64_kernel); g_assert(sizeof(aarch64_kernel) <=3D ARM_TEST_MAX_KERNEL_SIZE); + } else if (strcmp(arch, "loongarch64") =3D=3D 0) { + content =3D loongarch64_kernel; + len =3D sizeof(loongarch64_kernel); } else { g_assert_not_reached(); } @@ -823,6 +827,12 @@ static int test_migrate_start(QTestState **from, QTest= State **to, arch_opts =3D g_strdup_printf("-cpu max -kernel %s", bootpath); start_address =3D ARM_TEST_MEM_START; end_address =3D ARM_TEST_MEM_END; + } else if (strcmp(arch, "loongarch64") =3D=3D 0) { + memory_size =3D "256M"; + machine_alias =3D "virt"; + arch_opts =3D g_strdup_printf("-cpu max -bios %s", bootpath); + start_address =3D LOONGARCH_TEST_MEM_START; + end_address =3D LOONGARCH_TEST_MEM_END; } else { g_assert_not_reached(); } --=20 2.39.3