From nobody Sat Nov 15 16:09:06 2025 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 1749543500557540.5104608320682; Tue, 10 Jun 2025 01:18:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9u-0004oX-4n; Tue, 10 Jun 2025 04:16:38 -0400 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 1uOu9r-0004nC-VM; Tue, 10 Jun 2025 04:16:35 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9m-0000Sl-Ju; Tue, 10 Jun 2025 04:16:34 -0400 Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8AxGHHZ6Udoa30SAQ--.48285S3; Tue, 10 Jun 2025 16:16:25 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by front1 (Coremail) with SMTP id qMiowMBxb8fT6UdojgwUAQ--.58593S3; Tue, 10 Jun 2025 16:16:24 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Bibo Mao , qemu-stable@nongnu.org Subject: [PULL 1/7] hw/loongarch/virt: Fix big endian support with MCFG table Date: Tue, 10 Jun 2025 15:53:44 +0800 Message-Id: <20250610075350.865626-2-gaosong@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20250610075350.865626-1-gaosong@loongson.cn> References: <20250610075350.865626-1-gaosong@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowMBxb8fT6UdojgwUAQ--.58593S3 X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=gaosong@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.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: 1749543502311116600 Content-Type: text/plain; charset="utf-8" From: Bibo Mao With API build_mcfg(), it is not necessary with parameter structure AcpiMcfgInfo to convert to little endian since it is directly used with host native endian. Here remove endian conversion before calling function build_mcfg(). With this patch, bios-tables-test passes to run on big endian host machine S390. Fixes: 735143f10d3e ("hw/loongarch: Add acpi ged support") Cc: qemu-stable@nongnu.org Signed-off-by: Bibo Mao Reviewed-by: Song Gao Message-Id: <20250604065502.1114098-2-maobibo@loongson.cn> Signed-off-by: Song Gao --- hw/loongarch/virt-acpi-build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/loongarch/virt-acpi-build.c b/hw/loongarch/virt-acpi-build.c index 073b6de75c..2cd2d9d842 100644 --- a/hw/loongarch/virt-acpi-build.c +++ b/hw/loongarch/virt-acpi-build.c @@ -575,8 +575,8 @@ static void acpi_build(AcpiBuildTables *tables, Machine= State *machine) acpi_add_table(table_offsets, tables_blob); { AcpiMcfgInfo mcfg =3D { - .base =3D cpu_to_le64(VIRT_PCI_CFG_BASE), - .size =3D cpu_to_le64(VIRT_PCI_CFG_SIZE), + .base =3D VIRT_PCI_CFG_BASE, + .size =3D VIRT_PCI_CFG_SIZE, }; build_mcfg(tables_blob, tables->linker, &mcfg, lvms->oem_id, lvms->oem_table_id); --=20 2.34.1 From nobody Sat Nov 15 16:09:06 2025 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 1749543530107999.8665584582234; Tue, 10 Jun 2025 01:18:50 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9u-0004oy-Rp; Tue, 10 Jun 2025 04:16:38 -0400 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 1uOu9q-0004mr-2T for qemu-devel@nongnu.org; Tue, 10 Jun 2025 04:16:35 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9m-0000Sq-9x for qemu-devel@nongnu.org; Tue, 10 Jun 2025 04:16:33 -0400 Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8Bx63Ha6UdobH0SAQ--.46118S3; Tue, 10 Jun 2025 16:16:26 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by front1 (Coremail) with SMTP id qMiowMBxb8fT6UdojgwUAQ--.58593S4; Tue, 10 Jun 2025 16:16:25 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Bibo Mao Subject: [PULL 2/7] hw/intc/loongarch_pch: Convert to little endian with ID register Date: Tue, 10 Jun 2025 15:53:45 +0800 Message-Id: <20250610075350.865626-3-gaosong@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20250610075350.865626-1-gaosong@loongson.cn> References: <20250610075350.865626-1-gaosong@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowMBxb8fT6UdojgwUAQ--.58593S4 X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=gaosong@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.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: 1749543532475116600 Content-Type: text/plain; charset="utf-8" From: Bibo Mao With PCH ID register, it is defined as union type as follows: union LoongArchPIC_ID { struct { uint8_t _reserved_0[3]; uint8_t id; uint8_t version; uint8_t _reserved_1; uint8_t irq_num; uint8_t _reserved_2; } QEMU_PACKED desc; uint64_t data; } And with pch driver in virt machine irq_number is parsed with little endian method: vec_count =3D ((readq(priv->base) >> 48) & 0xff) + 1 So the value of ID register should be converted to little endian. With this patch, linux kernel passes to run on S390 big endian host machine with TCG method. Signed-off-by: Bibo Mao Reviewed-by: Song Gao Message-Id: <20250604065502.1114098-3-maobibo@loongson.cn> Signed-off-by: Song Gao --- hw/intc/loongarch_pch_pic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/intc/loongarch_pch_pic.c b/hw/intc/loongarch_pch_pic.c index cbba2fc284..ebb33ed0b0 100644 --- a/hw/intc/loongarch_pch_pic.c +++ b/hw/intc/loongarch_pch_pic.c @@ -82,7 +82,7 @@ static uint64_t pch_pic_read(void *opaque, hwaddr addr, u= int64_t field_mask) addr -=3D offset; switch (addr) { case PCH_PIC_INT_ID: - val =3D s->id.data; + val =3D cpu_to_le64(s->id.data); break; case PCH_PIC_INT_MASK: val =3D s->int_mask; --=20 2.34.1 From nobody Sat Nov 15 16:09:06 2025 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 174954350506415.495005517324557; Tue, 10 Jun 2025 01:18:25 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9v-0004oz-Ia; Tue, 10 Jun 2025 04:16:39 -0400 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 1uOu9q-0004ms-2d for qemu-devel@nongnu.org; Tue, 10 Jun 2025 04:16:35 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9m-0000Sr-AC for qemu-devel@nongnu.org; Tue, 10 Jun 2025 04:16:33 -0400 Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8CxPuPa6Udob30SAQ--.10787S3; Tue, 10 Jun 2025 16:16:26 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by front1 (Coremail) with SMTP id qMiowMBxb8fT6UdojgwUAQ--.58593S5; Tue, 10 Jun 2025 16:16:26 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Bibo Mao Subject: [PULL 3/7] hw/intc/loongarch_extioi: Fix typo issue about register EXTIOI_COREISR_END Date: Tue, 10 Jun 2025 15:53:46 +0800 Message-Id: <20250610075350.865626-4-gaosong@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20250610075350.865626-1-gaosong@loongson.cn> References: <20250610075350.865626-1-gaosong@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowMBxb8fT6UdojgwUAQ--.58593S5 X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=gaosong@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.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: 1749543506278116600 Content-Type: text/plain; charset="utf-8" From: Bibo Mao Interrupt controller extioi supports 256 vectors, register EXTIOI_COREISR records pending interrupt status with bitmap method. Size of EXTIOI_COREISR is 256 / 8 =3D 0x20 bytes, EXTIOI_COREISR_END should be EXTIOI_COREISR_START + 0x20 rather than 0xB20. Signed-off-by: Bibo Mao Reviewed-by: Song Gao Message-Id: <20250605092848.1550985-1-maobibo@loongson.cn> Signed-off-by: Song Gao --- include/hw/intc/loongarch_extioi_common.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/hw/intc/loongarch_extioi_common.h b/include/hw/intc/lo= ongarch_extioi_common.h index 735bfee80a..dca25ff893 100644 --- a/include/hw/intc/loongarch_extioi_common.h +++ b/include/hw/intc/loongarch_extioi_common.h @@ -35,7 +35,7 @@ #define EXTIOI_ISR_START (0x700 - APIC_OFFSET) #define EXTIOI_ISR_END (0x720 - APIC_OFFSET) #define EXTIOI_COREISR_START (0x800 - APIC_OFFSET) -#define EXTIOI_COREISR_END (0xB20 - APIC_OFFSET) +#define EXTIOI_COREISR_END (0x820 - APIC_OFFSET) #define EXTIOI_COREMAP_START (0xC00 - APIC_OFFSET) #define EXTIOI_COREMAP_END (0xD00 - APIC_OFFSET) #define EXTIOI_SIZE 0x800 --=20 2.34.1 From nobody Sat Nov 15 16:09:06 2025 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 1749543489588471.82689728582716; Tue, 10 Jun 2025 01:18:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9s-0004nW-S4; Tue, 10 Jun 2025 04:16:36 -0400 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 1uOu9o-0004mX-OT for qemu-devel@nongnu.org; Tue, 10 Jun 2025 04:16:32 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9m-0000Sw-35 for qemu-devel@nongnu.org; Tue, 10 Jun 2025 04:16:32 -0400 Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8Cxqmra6UdocH0SAQ--.4923S3; Tue, 10 Jun 2025 16:16:26 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by front1 (Coremail) with SMTP id qMiowMBxb8fT6UdojgwUAQ--.58593S6; Tue, 10 Jun 2025 16:16:26 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Qiang Ma , Bibo Mao Subject: [PULL 4/7] hw/loongarch/virt: inform guest of kvm Date: Tue, 10 Jun 2025 15:53:47 +0800 Message-Id: <20250610075350.865626-5-gaosong@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20250610075350.865626-1-gaosong@loongson.cn> References: <20250610075350.865626-1-gaosong@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowMBxb8fT6UdojgwUAQ--.58593S6 X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=gaosong@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.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: 1749543492050116600 Content-Type: text/plain; charset="utf-8" From: Qiang Ma Commit bab27ea2e3 ("hw/arm/virt: smbios: inform guest of kvm") fixes the same issue on arm. without this patch: [root@localhost ~]# virt-what qemu with this patch: [root@localhost ~]# virt-what kvm Signed-off-by: Qiang Ma Reviewed-by: Bibo Mao Reviewed-by: Song Gao Message-Id: <20250603031813.31794-1-maqianga@uniontech.com> Signed-off-by: Song Gao --- hw/loongarch/virt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 1b504047db..a3d449ca8b 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -136,6 +136,10 @@ static void virt_build_smbios(LoongArchVirtMachineStat= e *lvms) return; } =20 + if (kvm_enabled()) { + product =3D "KVM Virtual Machine"; + } + smbios_set_defaults("QEMU", product, mc->name); =20 smbios_get_tables(ms, SMBIOS_ENTRY_POINT_TYPE_64, --=20 2.34.1 From nobody Sat Nov 15 16:09:06 2025 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 1749543463485803.0566794334803; Tue, 10 Jun 2025 01:17:43 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9x-0004q4-MB; Tue, 10 Jun 2025 04:16:41 -0400 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 1uOu9r-0004nE-Vh for qemu-devel@nongnu.org; Tue, 10 Jun 2025 04:16:35 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9m-0000TJ-Dp for qemu-devel@nongnu.org; Tue, 10 Jun 2025 04:16:34 -0400 Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8BxJHDb6UdodH0SAQ--.5027S3; Tue, 10 Jun 2025 16:16:27 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by front1 (Coremail) with SMTP id qMiowMBxb8fT6UdojgwUAQ--.58593S7; Tue, 10 Jun 2025 16:16:26 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Richard Henderson Subject: [PULL 5/7] target/loongarch: add check for fcond Date: Tue, 10 Jun 2025 15:53:48 +0800 Message-Id: <20250610075350.865626-6-gaosong@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20250610075350.865626-1-gaosong@loongson.cn> References: <20250610075350.865626-1-gaosong@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowMBxb8fT6UdojgwUAQ--.58593S7 X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=gaosong@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.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: 1749543472948116600 Content-Type: text/plain; charset="utf-8" fcond only has 22 types, add a check for fcond. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2972 Signed-off-by: Song Gao Reviewed-by: Richard Henderson Message-Id: <20250603024810.350510-1-gaosong@loongson.cn> --- .../loongarch/tcg/insn_trans/trans_fcmp.c.inc | 25 +++++++++++++------ .../loongarch/tcg/insn_trans/trans_vec.c.inc | 16 +++++++++--- 2 files changed, 30 insertions(+), 11 deletions(-) diff --git a/target/loongarch/tcg/insn_trans/trans_fcmp.c.inc b/target/loon= garch/tcg/insn_trans/trans_fcmp.c.inc index 3babf69e4a..6a2c030a6b 100644 --- a/target/loongarch/tcg/insn_trans/trans_fcmp.c.inc +++ b/target/loongarch/tcg/insn_trans/trans_fcmp.c.inc @@ -4,10 +4,15 @@ */ =20 /* bit0(signaling/quiet) bit1(lt) bit2(eq) bit3(un) bit4(neq) */ -static uint32_t get_fcmp_flags(int cond) +static uint32_t get_fcmp_flags(DisasContext *ctx, int cond) { uint32_t flags =3D 0; =20 + /*check cond , cond =3D[0-8,10,12] */ + if ((cond > 8) &&(cond !=3D 10) && (cond !=3D 12)) { + return -1; + } + if (cond & 0x1) { flags |=3D FCMP_LT; } @@ -26,9 +31,14 @@ static uint32_t get_fcmp_flags(int cond) static bool trans_fcmp_cond_s(DisasContext *ctx, arg_fcmp_cond_s *a) { TCGv var, src1, src2; - uint32_t flags; + uint32_t flags =3D get_fcmp_flags(ctx, a->fcond >>1); void (*fn)(TCGv, TCGv_env, TCGv, TCGv, TCGv_i32); =20 + if (flags =3D=3D -1) { + generate_exception(ctx, EXCCODE_INE); + return true; + } + if (!avail_FP_SP(ctx)) { return false; } @@ -39,8 +49,6 @@ static bool trans_fcmp_cond_s(DisasContext *ctx, arg_fcmp= _cond_s *a) src1 =3D get_fpr(ctx, a->fj); src2 =3D get_fpr(ctx, a->fk); fn =3D (a->fcond & 1 ? gen_helper_fcmp_s_s : gen_helper_fcmp_c_s); - flags =3D get_fcmp_flags(a->fcond >> 1); - fn(var, tcg_env, src1, src2, tcg_constant_i32(flags)); =20 tcg_gen_st8_tl(var, tcg_env, offsetof(CPULoongArchState, cf[a->cd])); @@ -50,9 +58,14 @@ static bool trans_fcmp_cond_s(DisasContext *ctx, arg_fcm= p_cond_s *a) static bool trans_fcmp_cond_d(DisasContext *ctx, arg_fcmp_cond_d *a) { TCGv var, src1, src2; - uint32_t flags; + uint32_t flags =3D get_fcmp_flags(ctx, a->fcond >> 1); void (*fn)(TCGv, TCGv_env, TCGv, TCGv, TCGv_i32); =20 + if (flags =3D=3D -1) { + generate_exception(ctx, EXCCODE_INE); + return true; + } + if (!avail_FP_DP(ctx)) { return false; } @@ -63,8 +76,6 @@ static bool trans_fcmp_cond_d(DisasContext *ctx, arg_fcmp= _cond_d *a) src1 =3D get_fpr(ctx, a->fj); src2 =3D get_fpr(ctx, a->fk); fn =3D (a->fcond & 1 ? gen_helper_fcmp_s_d : gen_helper_fcmp_c_d); - flags =3D get_fcmp_flags(a->fcond >> 1); - fn(var, tcg_env, src1, src2, tcg_constant_i32(flags)); =20 tcg_gen_st8_tl(var, tcg_env, offsetof(CPULoongArchState, cf[a->cd])); diff --git a/target/loongarch/tcg/insn_trans/trans_vec.c.inc b/target/loong= arch/tcg/insn_trans/trans_vec.c.inc index dff92772ad..d6f0560349 100644 --- a/target/loongarch/tcg/insn_trans/trans_vec.c.inc +++ b/target/loongarch/tcg/insn_trans/trans_vec.c.inc @@ -4655,19 +4655,23 @@ TRANS(xvslti_du, LASX, do_xcmpi, MO_64, TCG_COND_LT= U) =20 static bool do_vfcmp_cond_s(DisasContext *ctx, arg_vvv_fcond *a, uint32_t = sz) { - uint32_t flags; + uint32_t flags =3D get_fcmp_flags(ctx, a->fcond >> 1); void (*fn)(TCGv_env, TCGv_i32, TCGv_i32, TCGv_i32, TCGv_i32, TCGv_i32); TCGv_i32 vd =3D tcg_constant_i32(a->vd); TCGv_i32 vj =3D tcg_constant_i32(a->vj); TCGv_i32 vk =3D tcg_constant_i32(a->vk); TCGv_i32 oprsz =3D tcg_constant_i32(sz); =20 + if(flags =3D=3D -1){ + generate_exception(ctx, EXCCODE_INE); + return true; + } + if (!check_vec(ctx, sz)) { return true; } =20 fn =3D (a->fcond & 1 ? gen_helper_vfcmp_s_s : gen_helper_vfcmp_c_s); - flags =3D get_fcmp_flags(a->fcond >> 1); fn(tcg_env, oprsz, vd, vj, vk, tcg_constant_i32(flags)); =20 return true; @@ -4675,19 +4679,23 @@ static bool do_vfcmp_cond_s(DisasContext *ctx, arg_= vvv_fcond *a, uint32_t sz) =20 static bool do_vfcmp_cond_d(DisasContext *ctx, arg_vvv_fcond *a, uint32_t = sz) { - uint32_t flags; + uint32_t flags =3D get_fcmp_flags(ctx, a->fcond >> 1); void (*fn)(TCGv_env, TCGv_i32, TCGv_i32, TCGv_i32, TCGv_i32, TCGv_i32); TCGv_i32 vd =3D tcg_constant_i32(a->vd); TCGv_i32 vj =3D tcg_constant_i32(a->vj); TCGv_i32 vk =3D tcg_constant_i32(a->vk); TCGv_i32 oprsz =3D tcg_constant_i32(sz); =20 + if (flags =3D=3D -1) { + generate_exception(ctx, EXCCODE_INE); + return true; + } + if (!check_vec(ctx, sz)) { return true; } =20 fn =3D (a->fcond & 1 ? gen_helper_vfcmp_s_d : gen_helper_vfcmp_c_d); - flags =3D get_fcmp_flags(a->fcond >> 1); fn(tcg_env, oprsz, vd, vj, vk, tcg_constant_i32(flags)); =20 return true; --=20 2.34.1 From nobody Sat Nov 15 16:09:06 2025 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 1749543489101211.11502235812736; Tue, 10 Jun 2025 01:18:09 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9w-0004pY-1T; Tue, 10 Jun 2025 04:16:40 -0400 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 1uOu9q-0004mt-3Q for qemu-devel@nongnu.org; Tue, 10 Jun 2025 04:16:35 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9m-0000TF-9t for qemu-devel@nongnu.org; Tue, 10 Jun 2025 04:16:33 -0400 Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8CxLGvb6Udod30SAQ--.45918S3; Tue, 10 Jun 2025 16:16:27 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by front1 (Coremail) with SMTP id qMiowMBxb8fT6UdojgwUAQ--.58593S8; Tue, 10 Jun 2025 16:16:27 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Bibo Mao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 6/7] hw/loongarch/virt: Remove global variables about initrd Date: Tue, 10 Jun 2025 15:53:49 +0800 Message-Id: <20250610075350.865626-7-gaosong@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20250610075350.865626-1-gaosong@loongson.cn> References: <20250610075350.865626-1-gaosong@loongson.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowMBxb8fT6UdojgwUAQ--.58593S8 X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=gaosong@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.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: 1749543490031116600 From: Bibo Mao Global variables initrd_offset and initrd_size records loading information about initrd, it can be moved to structure loongarch_boot_info. Signed-off-by: Bibo Mao Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-Id: <20250430094738.1556670-2-maobibo@loongson.cn> Signed-off-by: Song Gao --- hw/loongarch/boot.c | 21 ++++++++++----------- include/hw/loongarch/boot.h | 2 ++ 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c index 9b6292eaa1..a343547acd 100644 --- a/hw/loongarch/boot.c +++ b/hw/loongarch/boot.c @@ -38,9 +38,6 @@ struct loongarch_linux_hdr { struct memmap_entry *memmap_table; unsigned memmap_entries; =20 -ram_addr_t initrd_offset; -uint64_t initrd_size; - static const unsigned int slave_boot_code[] =3D { /* Configure reset ebase. */ 0x0400302c, /* csrwr $t0, LOONGARCH_CSR_EENTRY */ @@ -121,7 +118,8 @@ static void init_efi_boot_memmap(struct efi_system_tabl= e *systab, } } =20 -static void init_efi_initrd_table(struct efi_system_table *systab, +static void init_efi_initrd_table(struct loongarch_boot_info *info, + struct efi_system_table *systab, void *p, void *start) { efi_guid_t tbl_guid =3D LINUX_EFI_INITRD_MEDIA_GUID; @@ -132,8 +130,8 @@ static void init_efi_initrd_table(struct efi_system_tab= le *systab, systab->tables[1].table =3D (struct efi_configuration_table *)(p - sta= rt); systab->nr_tables =3D 2; =20 - initrd_table->base =3D initrd_offset; - initrd_table->size =3D initrd_size; + initrd_table->base =3D info->initrd_addr; + initrd_table->size =3D info->initrd_size; } =20 static void init_efi_fdt_table(struct efi_system_table *systab) @@ -169,7 +167,7 @@ static void init_systab(struct loongarch_boot_info *inf= o, void *p, void *start) init_efi_boot_memmap(systab, p, start); p +=3D ROUND_UP(sizeof(struct efi_boot_memmap) + sizeof(efi_memory_desc_t) * memmap_entries, 64 * KiB); - init_efi_initrd_table(systab, p, start); + init_efi_initrd_table(info, systab, p, start); p +=3D ROUND_UP(sizeof(struct efi_initrd), 64 * KiB); init_efi_fdt_table(systab); =20 @@ -276,8 +274,8 @@ static ram_addr_t alloc_initrd_memory(struct loongarch_= boot_info *info, =20 static int64_t load_kernel_info(struct loongarch_boot_info *info) { - uint64_t kernel_entry, kernel_low, kernel_high; - ssize_t kernel_size; + uint64_t kernel_entry, kernel_low, kernel_high, initrd_offset =3D 0; + ssize_t kernel_size, initrd_size; =20 kernel_size =3D load_elf(info->kernel_filename, NULL, cpu_loongarch_virt_to_phys, NULL, @@ -313,8 +311,9 @@ static int64_t load_kernel_info(struct loongarch_boot_i= nfo *info) info->initrd_filename); exit(1); } - } else { - initrd_size =3D 0; + + info->initrd_addr =3D initrd_offset; + info->initrd_size =3D initrd_size; } =20 return kernel_entry; diff --git a/include/hw/loongarch/boot.h b/include/hw/loongarch/boot.h index b3b870df1f..27399de99c 100644 --- a/include/hw/loongarch/boot.h +++ b/include/hw/loongarch/boot.h @@ -102,6 +102,8 @@ struct loongarch_boot_info { const char *kernel_cmdline; const char *initrd_filename; uint64_t a0, a1, a2; + uint64_t initrd_addr; + uint64_t initrd_size; }; =20 extern struct memmap_entry *memmap_table; --=20 2.34.1 From nobody Sat Nov 15 16:09:06 2025 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 1749543531278627.9857420235672; Tue, 10 Jun 2025 01:18:51 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9v-0004p4-Jr; Tue, 10 Jun 2025 04:16:39 -0400 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 1uOu9r-0004n9-VB for qemu-devel@nongnu.org; Tue, 10 Jun 2025 04:16:35 -0400 Received: from mail.loongson.cn ([114.242.206.163]) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uOu9n-0000Tc-Lh for qemu-devel@nongnu.org; Tue, 10 Jun 2025 04:16:35 -0400 Received: from loongson.cn (unknown [10.2.5.185]) by gateway (Coremail) with SMTP id _____8CxTOLc6UdoeX0SAQ--.4943S3; Tue, 10 Jun 2025 16:16:28 +0800 (CST) Received: from localhost.localdomain (unknown [10.2.5.185]) by front1 (Coremail) with SMTP id qMiowMBxb8fT6UdojgwUAQ--.58593S9; Tue, 10 Jun 2025 16:16:27 +0800 (CST) From: Song Gao To: qemu-devel@nongnu.org Cc: stefanha@gmail.com, Bibo Mao Subject: [PULL 7/7] hw/loongarch/virt: Remove global variables about memmap tables Date: Tue, 10 Jun 2025 15:53:50 +0800 Message-Id: <20250610075350.865626-8-gaosong@loongson.cn> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20250610075350.865626-1-gaosong@loongson.cn> References: <20250610075350.865626-1-gaosong@loongson.cn> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-CM-TRANSID: qMiowMBxb8fT6UdojgwUAQ--.58593S9 X-CM-SenderInfo: 5jdr20tqj6z05rqj20fqof0/ X-Coremail-Antispam: 1Uk129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7KY7 ZEXasCq-sGcSsGvfJ3UbIjqfuFe4nvWSU5nxnvy29KBjDU0xBIdaVrnUUvcSsGvfC2Kfnx nUUI43ZEXa7xR_UUUUUUUUU== 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=gaosong@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, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.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: 1749543532805116600 Content-Type: text/plain; charset="utf-8" From: Bibo Mao Global variables memmap_table and memmap_entries stores UEFI memory map table informations. It can be moved into structure LoongArchVirtMachineState. Signed-off-by: Bibo Mao Reviewed-by: Song Gao Message-Id: <20250430094738.1556670-3-maobibo@loongson.cn> Signed-off-by: Song Gao --- hw/loongarch/boot.c | 31 +++++++++++++++++++------------ hw/loongarch/virt.c | 23 ++++++++++++++++------- include/hw/loongarch/boot.h | 3 --- include/hw/loongarch/virt.h | 2 ++ 4 files changed, 37 insertions(+), 22 deletions(-) diff --git a/hw/loongarch/boot.c b/hw/loongarch/boot.c index a343547acd..14d6c52d4e 100644 --- a/hw/loongarch/boot.c +++ b/hw/loongarch/boot.c @@ -35,9 +35,6 @@ struct loongarch_linux_hdr { uint32_t pe_header_offset; } QEMU_PACKED; =20 -struct memmap_entry *memmap_table; -unsigned memmap_entries; - static const unsigned int slave_boot_code[] =3D { /* Configure reset ebase. */ 0x0400302c, /* csrwr $t0, LOONGARCH_CSR_EENTRY */ @@ -91,12 +88,16 @@ static inline void *guidcpy(void *dst, const void *src) return memcpy(dst, src, sizeof(efi_guid_t)); } =20 -static void init_efi_boot_memmap(struct efi_system_table *systab, +static void init_efi_boot_memmap(MachineState *ms, + struct efi_system_table *systab, void *p, void *start) { unsigned i; struct efi_boot_memmap *boot_memmap =3D p; efi_guid_t tbl_guid =3D LINUX_EFI_BOOT_MEMMAP_GUID; + LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(ms); + struct memmap_entry *memmap_table; + unsigned int memmap_entries; =20 /* efi_configuration_table 1 */ guidcpy(&systab->tables[0].guid, &tbl_guid); @@ -108,6 +109,8 @@ static void init_efi_boot_memmap(struct efi_system_tabl= e *systab, boot_memmap->map_size =3D 0; =20 efi_memory_desc_t *map =3D p + sizeof(struct efi_boot_memmap); + memmap_table =3D lvms->memmap_table; + memmap_entries =3D lvms->memmap_entries; for (i =3D 0; i < memmap_entries; i++) { map =3D (void *)boot_memmap + sizeof(*map); map[i].type =3D memmap_table[i].type; @@ -144,10 +147,12 @@ static void init_efi_fdt_table(struct efi_system_tabl= e *systab) systab->nr_tables =3D 3; } =20 -static void init_systab(struct loongarch_boot_info *info, void *p, void *s= tart) +static void init_systab(MachineState *ms, + struct loongarch_boot_info *info, void *p, void *s= tart) { void *bp_tables_start; struct efi_system_table *systab =3D p; + LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(ms); =20 info->a2 =3D p - start; =20 @@ -164,9 +169,9 @@ static void init_systab(struct loongarch_boot_info *inf= o, void *p, void *start) systab->tables =3D p; bp_tables_start =3D p; =20 - init_efi_boot_memmap(systab, p, start); + init_efi_boot_memmap(ms, systab, p, start); p +=3D ROUND_UP(sizeof(struct efi_boot_memmap) + - sizeof(efi_memory_desc_t) * memmap_entries, 64 * KiB); + sizeof(efi_memory_desc_t) * lvms->memmap_entries, 64 * K= iB); init_efi_initrd_table(info, systab, p, start); p +=3D ROUND_UP(sizeof(struct efi_initrd), 64 * KiB); init_efi_fdt_table(systab); @@ -368,17 +373,19 @@ static void loongarch_firmware_boot(LoongArchVirtMach= ineState *lvms, fw_cfg_add_kernel_info(info, lvms->fw_cfg); } =20 -static void init_boot_rom(struct loongarch_boot_info *info, void *p) +static void init_boot_rom(MachineState *ms, + struct loongarch_boot_info *info, void *p) { void *start =3D p; =20 init_cmdline(info, p, start); p +=3D COMMAND_LINE_SIZE; =20 - init_systab(info, p, start); + init_systab(ms, info, p, start); } =20 -static void loongarch_direct_kernel_boot(struct loongarch_boot_info *info) +static void loongarch_direct_kernel_boot(MachineState *ms, + struct loongarch_boot_info *info) { void *p, *bp; int64_t kernel_addr =3D VIRT_FLASH0_BASE; @@ -396,7 +403,7 @@ static void loongarch_direct_kernel_boot(struct loongar= ch_boot_info *info) /* Load cmdline and system tables at [0 - 1 MiB] */ p =3D g_malloc0(1 * MiB); bp =3D p; - init_boot_rom(info, p); + init_boot_rom(ms, info, p); rom_add_blob_fixed_as("boot_info", bp, 1 * MiB, 0, &address_space_memo= ry); =20 /* Load slave boot code at pflash0 . */ @@ -436,6 +443,6 @@ void loongarch_load_kernel(MachineState *ms, struct loo= ngarch_boot_info *info) if (lvms->bios_loaded) { loongarch_firmware_boot(lvms, info); } else { - loongarch_direct_kernel_boot(info); + loongarch_direct_kernel_boot(ms, info); } } diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index a3d449ca8b..34dfbd13e5 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -172,8 +172,15 @@ static void virt_powerdown_req(Notifier *notifier, voi= d *opaque) acpi_send_event(s->acpi_ged, ACPI_POWER_DOWN_STATUS); } =20 -static void memmap_add_entry(uint64_t address, uint64_t length, uint32_t t= ype) +static void memmap_add_entry(MachineState *ms, uint64_t address, + uint64_t length, uint32_t type) { + LoongArchVirtMachineState *lvms =3D LOONGARCH_VIRT_MACHINE(ms); + struct memmap_entry *memmap_table; + unsigned int memmap_entries; + + memmap_table =3D lvms->memmap_table; + memmap_entries =3D lvms->memmap_entries; /* Ensure there are no duplicate entries. */ for (unsigned i =3D 0; i < memmap_entries; i++) { assert(memmap_table[i].address !=3D address); @@ -186,6 +193,8 @@ static void memmap_add_entry(uint64_t address, uint64_t= length, uint32_t type) memmap_table[memmap_entries].type =3D cpu_to_le32(type); memmap_table[memmap_entries].reserved =3D 0; memmap_entries++; + lvms->memmap_table =3D memmap_table; + lvms->memmap_entries =3D memmap_entries; } =20 static DeviceState *create_acpi_ged(DeviceState *pch_pic, @@ -623,13 +632,13 @@ static void fw_cfg_add_memory(MachineState *ms) } =20 if (size >=3D gap) { - memmap_add_entry(base, gap, 1); + memmap_add_entry(ms, base, gap, 1); size -=3D gap; base =3D VIRT_HIGHMEM_BASE; } =20 if (size) { - memmap_add_entry(base, size, 1); + memmap_add_entry(ms, base, size, 1); base +=3D size; } =20 @@ -644,7 +653,7 @@ static void fw_cfg_add_memory(MachineState *ms) * lowram: [base, +(gap - numa_info[0].node_mem)) * highram: [VIRT_HIGHMEM_BASE, +(ram_size - gap)) */ - memmap_add_entry(base, gap - numa_info[0].node_mem, 1); + memmap_add_entry(ms, base, gap - numa_info[0].node_mem, 1); size =3D ram_size - gap; base =3D VIRT_HIGHMEM_BASE; } else { @@ -652,7 +661,7 @@ static void fw_cfg_add_memory(MachineState *ms) } =20 if (size) { - memmap_add_entry(base, size, 1); + memmap_add_entry(ms, base, size, 1); } } =20 @@ -738,8 +747,8 @@ static void virt_init(MachineState *machine) rom_set_fw(lvms->fw_cfg); if (lvms->fw_cfg !=3D NULL) { fw_cfg_add_file(lvms->fw_cfg, "etc/memmap", - memmap_table, - sizeof(struct memmap_entry) * (memmap_entries)); + lvms->memmap_table, + sizeof(struct memmap_entry) * lvms->memmap_entries= ); } =20 /* Initialize the IO interrupt subsystem */ diff --git a/include/hw/loongarch/boot.h b/include/hw/loongarch/boot.h index 27399de99c..9819f7fbe3 100644 --- a/include/hw/loongarch/boot.h +++ b/include/hw/loongarch/boot.h @@ -106,9 +106,6 @@ struct loongarch_boot_info { uint64_t initrd_size; }; =20 -extern struct memmap_entry *memmap_table; -extern unsigned memmap_entries; - struct memmap_entry { uint64_t address; uint64_t length; diff --git a/include/hw/loongarch/virt.h b/include/hw/loongarch/virt.h index 2b7d19953f..602feab0f0 100644 --- a/include/hw/loongarch/virt.h +++ b/include/hw/loongarch/virt.h @@ -63,6 +63,8 @@ struct LoongArchVirtMachineState { struct loongarch_boot_info bootinfo; DeviceState *ipi; DeviceState *extioi; + struct memmap_entry *memmap_table; + unsigned int memmap_entries; }; =20 #define TYPE_LOONGARCH_VIRT_MACHINE MACHINE_TYPE_NAME("virt") --=20 2.34.1