From nobody Wed May 1 19:57:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1660489052; cv=none; d=zohomail.com; s=zohoarc; b=hGTatFYGNSGY9JNpLgNgOyuM0bCbhEcGvHpOvXcE6cf/IIIvXccUAFroPcIunf1iBu5XSxmSr/fjO+kDtoxGFsA5ENlof7Y0uXlLsQ54/8o5/QkHtmPj38vy8IZFOR19fRl8J06Id9Tp2XJYJQInaV01/bppKC+0F8X2+wdFXdY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660489052; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+MkQRSg/7a2G9nbRNVwQyN40puZB48Xkvl5oRSP1Yrg=; b=TPzJHhQ/MvnEvlt1bhRxybMSlFeS5E77h6ke9kAp5LjfLtNbzlT3kcGpoI4x7ez7uFN/TJceFtQqMTJ38H0/je5v1BynSofcSxuBCGt72BJjajLDCj3+t/RNyqgMZsi2gFEiR6YOmmvPTMa4RtI6GFkx8ov7Hfch26hm1eiOM98= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1660489052688799.1830976669969; Sun, 14 Aug 2022 07:57:32 -0700 (PDT) Received: from localhost ([::1]:41040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNF3T-0004cu-8F for importer@patchew.org; Sun, 14 Aug 2022 10:57:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48070) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNF26-0002Eo-TV for qemu-devel@nongnu.org; Sun, 14 Aug 2022 10:56:06 -0400 Received: from mail.xen0n.name ([115.28.160.31]:54606 helo=mailbox.box.xen0n.name) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNF22-0007Oc-Bs for qemu-devel@nongnu.org; Sun, 14 Aug 2022 10:56:06 -0400 Received: from ld50.lan (unknown [101.88.24.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 6225A6061B; Sun, 14 Aug 2022 22:55:47 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1660488948; bh=7fqqbxSiwMiSghRpfLHiYPLKCY1CYMyCDHuauIcZAKw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qBS+KBezxDdienosyuSGib6/t2haoeLR7NcUUm3t0rtkPpzvodfG6X22PjsHJbwIt Zf/CcFs+HwUwSbcaalJNwf9v0vul80LffZFGQmqAWnFYXW1Y0iEpp1G+F4TmlHJQCe zPTCligQPabNZiLnc0iwhxDz3EOn6ypcTdas7hik= From: WANG Xuerui To: qemu-devel@nongnu.org Cc: WANG Xuerui , Richard Henderson , Song Gao , Xiaojuan Yang , WANG Xuerui Subject: [PATCH for-7.1 1/4] target/loongarch: Only allow short -cpu arguments without type name suffix Date: Sun, 14 Aug 2022 22:55:19 +0800 Message-Id: <20220814145522.1474927-2-i.qemu@xen0n.name> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220814145351.1474753-1-git@xen0n.name> References: <20220814145351.1474753-1-git@xen0n.name> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.28.160.31; envelope-from=i.qemu@xen0n.name; helo=mailbox.box.xen0n.name X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @xen0n.name) X-ZM-MESSAGEID: 1660489055119100001 Content-Type: text/plain; charset="utf-8" From: WANG Xuerui Previously both "foo" and "foo-loongarch-cpu" are accepted for the -cpu command-line option, the latter of which being excessively long and redundant, hence unwanted. Remove support for consistency with other targets and simpler code. Signed-off-by: WANG Xuerui --- target/loongarch/cpu.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 941e2772bc..dc233ee209 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -573,14 +573,11 @@ static ObjectClass *loongarch_cpu_class_by_name(const= char *cpu_model) { ObjectClass *oc; =20 - oc =3D object_class_by_name(cpu_model); + g_autofree char *typename =3D g_strdup_printf(LOONGARCH_CPU_TYPE_NAME(= "%s"), + cpu_model); + oc =3D object_class_by_name(typename); if (!oc) { - g_autofree char *typename=20 - =3D g_strdup_printf(LOONGARCH_CPU_TYPE_NAME("%s"), cpu_model); - oc =3D object_class_by_name(typename); - if (!oc) { - return NULL; - } + return NULL; } =20 if (object_class_dynamic_cast(oc, TYPE_LOONGARCH_CPU) --=20 2.35.1 From nobody Wed May 1 19:57:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1660489179; cv=none; d=zohomail.com; s=zohoarc; b=U/YfYFIgUgGkwAY0tBFZOuhI+IP+5G2JmcVMvO6UyO38zJT7lpVCEeCbWxM6FSBJlYDxELCFq7W7sxJaICqXdig47Jq5vZ46x6IFan/Pzkd3efSs8e720NHYgX7hxypXGevShO8vKDy4vnoLhZwJ0Kn646GhNdie7cti/J4F3Kc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660489179; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+irHgRZ910ALYJa0v1y5KAFcS/NhidwOnJxM2OVULUg=; b=gi+FODdCbWjR4OBWaKovQJeLd+DcRPyrTM3M1mSHiT24zl0G1WrgHpoOp6s1W6OMSepAHptN2WiTI0tfy1OTPGbX9rAGZAeIaILNDSJsNmW730Z061tZ49BvFI1KsDcmxlUtGzF/6kil/LMTGRQ24XJBP55I+k1LylfX/QEhQc4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1660489179963996.5496357627684; Sun, 14 Aug 2022 07:59:39 -0700 (PDT) Received: from localhost ([::1]:45478 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNF5X-0007Zz-03 for importer@patchew.org; Sun, 14 Aug 2022 10:59:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48094) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNF29-0002Gs-Av for qemu-devel@nongnu.org; Sun, 14 Aug 2022 10:56:09 -0400 Received: from mail.xen0n.name ([115.28.160.31]:54608 helo=mailbox.box.xen0n.name) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNF23-0007Ok-GM for qemu-devel@nongnu.org; Sun, 14 Aug 2022 10:56:08 -0400 Received: from ld50.lan (unknown [101.88.24.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id C843660685; Sun, 14 Aug 2022 22:55:51 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1660488952; bh=QjsDyZnb+B3PuXXr3jo/IJYwPW9wT9MymKbqCh7O60g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LsZBvcZydOu1NqAHGtCxe/ukzm0FebBzskZ9oyLfBtxEEkdP9HloPjyOC5Q6FnfNN atZoj/xfRkzy/3OBkaK3pbT74wVvPh/jNgFdp1cRtnKyoDBvbKVGu3Z5FRZmDvv/bN hJDlnThY8TvsN/jY43OG9hX6jdgDrfCxeYv2/AGY= From: WANG Xuerui To: qemu-devel@nongnu.org Cc: WANG Xuerui , Richard Henderson , Song Gao , Xiaojuan Yang , WANG Xuerui Subject: [PATCH for-7.1 2/4] target/loongarch: Trim type name suffix in -cpu help output Date: Sun, 14 Aug 2022 22:55:20 +0800 Message-Id: <20220814145522.1474927-3-i.qemu@xen0n.name> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220814145351.1474753-1-git@xen0n.name> References: <20220814145351.1474753-1-git@xen0n.name> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.28.160.31; envelope-from=i.qemu@xen0n.name; helo=mailbox.box.xen0n.name X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @xen0n.name) X-ZM-MESSAGEID: 1660489181138100001 Content-Type: text/plain; charset="utf-8" From: WANG Xuerui Also add a header and indentation for each entry, while at it. Signed-off-by: WANG Xuerui --- target/loongarch/cpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index dc233ee209..4663539443 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -416,13 +416,15 @@ static void loongarch_la464_initfn(Object *obj) static void loongarch_cpu_list_entry(gpointer data, gpointer user_data) { const char *typename =3D object_class_get_name(OBJECT_CLASS(data)); + int len =3D strlen(typename) - strlen(LOONGARCH_CPU_TYPE_SUFFIX); =20 - qemu_printf("%s\n", typename); + qemu_printf(" %.*s\n", len, typename); } =20 void loongarch_cpu_list(void) { GSList *list; + qemu_printf("Available CPUs:\n"); list =3D object_class_get_list_sorted(TYPE_LOONGARCH_CPU, false); g_slist_foreach(list, loongarch_cpu_list_entry, NULL); g_slist_free(list); --=20 2.35.1 From nobody Wed May 1 19:57:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1660489054; cv=none; d=zohomail.com; s=zohoarc; b=HsP8UAlrfc9mN9q818m0h+jRniT+mT6GmL7orU6gMzONrncns50cS9O3S4lZ3jOxTh3aU5UwlfxyHdUh71E8oEjEyF/rnvDg1A4t8eMqt9APnRbJp3itMkov2ANZZa+7+lB2WjfjmDVAqIGnSNCsnJcRfyruok0wCmJ6BFH7MLE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660489054; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RhSL+xaM1lZ8FE/qtAWxQUrbgiUtBbbyJUGkDkaxj/c=; b=Nh0nx7galvl13u6K+V3RxZ+XHnxTT9AB/3CQMrTIMnP9x7xS+FV3hDKlOtt9YBq6StF4MCnX9TRaDawKk9tDNXcEi6jxdOREnoXzI9MiOINQMYQgIE2oFVcE0Ijxyx3KUb3E06zF7rX+Ib/WwHsQlbefn3Ahqs+PXgySMfLEElg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 166048905495975.43888686665468; Sun, 14 Aug 2022 07:57:34 -0700 (PDT) Received: from localhost ([::1]:41154 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNF3V-0004hK-Uw for importer@patchew.org; Sun, 14 Aug 2022 10:57:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48060) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNF26-0002EG-Io for qemu-devel@nongnu.org; Sun, 14 Aug 2022 10:56:06 -0400 Received: from mail.xen0n.name ([115.28.160.31]:54610 helo=mailbox.box.xen0n.name) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNF22-0007Ov-Bp for qemu-devel@nongnu.org; Sun, 14 Aug 2022 10:56:06 -0400 Received: from ld50.lan (unknown [101.88.24.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id DEB8560689; Sun, 14 Aug 2022 22:55:52 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1660488953; bh=zWrIL0lZGhOH7n7egt4bN5g9dwIoAJ4aiT0lHuWmZIo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H23lnpAinse//L01CqBG21iykm+hxwA8bnWkdG8vtairn0Qfy1fECGZGtXkADqDSj KkUhP1sSMO8Aa1d7u6IPH56hcf2LxzM39jwDWnqa0pWgA2WkSDVYbVHZwDtEEzwMgJ rs1n+9qj0/D+xzsHJxMqNF6SQyVSRGmE1EdNKWRA= From: WANG Xuerui To: qemu-devel@nongnu.org Cc: WANG Xuerui , Richard Henderson , Song Gao , Xiaojuan Yang , WANG Xuerui Subject: [PATCH for-7.1 3/4] target/loongarch: rename the TCG CPU "la464" to "qemu64-v1.00" Date: Sun, 14 Aug 2022 22:55:21 +0800 Message-Id: <20220814145522.1474927-4-i.qemu@xen0n.name> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220814145351.1474753-1-git@xen0n.name> References: <20220814145351.1474753-1-git@xen0n.name> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.28.160.31; envelope-from=i.qemu@xen0n.name; helo=mailbox.box.xen0n.name X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @xen0n.name) X-ZM-MESSAGEID: 1660489056458100005 Content-Type: text/plain; charset="utf-8" From: WANG Xuerui The only LoongArch CPU implemented is modeled after the Loongson 3A5000, but it is not the real thing, and at least one feature [1] is missing that actually made the model incompatible with the real 3A5000. What's more, the model is currently named "la464", while none of the micro-architecture-specific things are currently present, further making things needlessly complex. In general, high-fidelity models can and should be named after the real hardware model, while generic emulation-oriented models should be named after ISA levels. For now, the best reference for LoongArch ISA levels is the revision number of the LoongArch ISA Manual, of which v1.00 is still the latest. (v1.01 and v1.02 are minor revisions without substantive change.) As defined by various specs, the vendor and model names are also reflected in respective CSRs, and are 8 bytes long. So, rename "la464" to "qemu64-v1.00", with "QEMU64" as vendor name and "v1.00" as model name. As the QEMU 7.1 hasn't been officially released, no downstream is expected to depend on the old name, so this change should be safe for 7.1. [1]: https://lore.kernel.org/loongarch/20220726094049.7200-2-maobibo@loongs= on.cn/ Signed-off-by: WANG Xuerui --- hw/loongarch/virt.c | 14 ++------------ target/loongarch/cpu.c | 6 +++--- 2 files changed, 5 insertions(+), 15 deletions(-) diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 5cc0b05538..35e2174a17 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -626,7 +626,6 @@ static void loongarch_direct_kernel_boot(LoongArchMachi= neState *lams) static void loongarch_init(MachineState *machine) { LoongArchCPU *lacpu; - const char *cpu_model =3D machine->cpu_type; ram_addr_t offset =3D 0; ram_addr_t ram_size =3D machine->ram_size; uint64_t highram_size =3D 0; @@ -634,15 +633,6 @@ static void loongarch_init(MachineState *machine) LoongArchMachineState *lams =3D LOONGARCH_MACHINE(machine); int i; =20 - if (!cpu_model) { - cpu_model =3D LOONGARCH_CPU_TYPE_NAME("la464"); - } - - if (!strstr(cpu_model, "la464")) { - error_report("LoongArch/TCG needs cpu type la464"); - exit(1); - } - if (ram_size < 1 * GiB) { error_report("ram_size must be greater than 1G."); exit(1); @@ -749,10 +739,10 @@ static void loongarch_class_init(ObjectClass *oc, voi= d *data) { MachineClass *mc =3D MACHINE_CLASS(oc); =20 - mc->desc =3D "Loongson-3A5000 LS7A1000 machine"; + mc->desc =3D "LoongArch64 v1.00-compatible LS7A1000 machine"; mc->init =3D loongarch_init; mc->default_ram_size =3D 1 * GiB; - mc->default_cpu_type =3D LOONGARCH_CPU_TYPE_NAME("la464"); + mc->default_cpu_type =3D LOONGARCH_CPU_TYPE_NAME("qemu64-v1.00"); mc->default_ram_id =3D "loongarch.ram"; mc->max_cpus =3D LOONGARCH_MAX_VCPUS; mc->is_default =3D 1; diff --git a/target/loongarch/cpu.c b/target/loongarch/cpu.c index 4663539443..0a41509a0c 100644 --- a/target/loongarch/cpu.c +++ b/target/loongarch/cpu.c @@ -527,9 +527,9 @@ static uint64_t loongarch_qemu_read(void *opaque, hwadd= r addr, unsigned size) return 1ULL << IOCSRF_MSI | 1ULL << IOCSRF_EXTIOI | 1ULL << IOCSRF_CSRIPI; case VENDOR_REG: - return 0x6e6f73676e6f6f4cULL; /* "Loongson" */ + return 0x3436554d4551ULL; /* "QEMU64" */ case CPUNAME_REG: - return 0x303030354133ULL; /* "3A5000" */ + return 0x30302e3176ULL; /* "v1.00" */ case MISC_FUNC_REG: return 1ULL << IOCSRM_EXTIOI_EN; } @@ -715,7 +715,7 @@ static const TypeInfo loongarch_cpu_type_infos[] =3D { .class_size =3D sizeof(LoongArchCPUClass), .class_init =3D loongarch_cpu_class_init, }, - DEFINE_LOONGARCH_CPU_TYPE("la464", loongarch_la464_initfn), + DEFINE_LOONGARCH_CPU_TYPE("qemu64-v1.00", loongarch_la464_initfn), }; =20 DEFINE_TYPES(loongarch_cpu_type_infos) --=20 2.35.1 From nobody Wed May 1 19:57:07 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1660489053; cv=none; d=zohomail.com; s=zohoarc; b=Vwjonqit9/9mS4zN2K17Si6P8gvqIChOJxcfkr9b11W4bBD3DigwCxZ8lKdQMrU73h1TbihIhYfVsCMBwJeKfMCGTzpqutl96xJ2TybprjI/p8x63deHVuqvZajxb1TnA6GtquXwsUoF3ShlB3IAW3CbmxIf/iUJq8VEeIjrI2U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1660489053; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=my84f3jf6DaMvBjeuvIM3SbU+eiNMvWBxzJGqyhHIV4=; b=coLB6HWR9NlHZ976A25SZki5UeCbjXxx4zp1OM4vXetHP/iupGWpTwz5R37UC+gRVjAU/2rffi1k672x12/pYemqxAXSwfjviYE409FMA2PySmaRCe2+jYkxJe3gDjSrvUXWyJMFmhdoom6sZyGs3pZ7IXuVCHqGu/Ku4k2aeik= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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 1660489053838266.1327850458497; Sun, 14 Aug 2022 07:57:33 -0700 (PDT) Received: from localhost ([::1]:41036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oNF3U-0004cp-M6 for importer@patchew.org; Sun, 14 Aug 2022 10:57:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48096) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNF28-0002HI-Rq for qemu-devel@nongnu.org; Sun, 14 Aug 2022 10:56:08 -0400 Received: from mail.xen0n.name ([115.28.160.31]:54612 helo=mailbox.box.xen0n.name) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oNF25-0007P8-U5 for qemu-devel@nongnu.org; Sun, 14 Aug 2022 10:56:08 -0400 Received: from ld50.lan (unknown [101.88.24.16]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mailbox.box.xen0n.name (Postfix) with ESMTPSA id F02266068A; Sun, 14 Aug 2022 22:55:53 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail; t=1660488955; bh=xtOi84D7gwtPt2qpdJhKaRrxyW1/rWu6BSRb/i6isgs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eYVPUZnnunLOumcu1kWPpyTPRuLrB7ItLB8L942cxJdEHjE/TPL9gPzMG9xecEknM y6gVSjmWRZc9dC7X+CEc/fW88DbM/32EZ/nSygofSf1x5iczKb+k7SOXKQlWQZRV+j j69uytOND0V1O0t6Ve7dQCefEQFQjSQ7b00pPH34= From: WANG Xuerui To: qemu-devel@nongnu.org Cc: WANG Xuerui , Richard Henderson , Song Gao , Xiaojuan Yang , WANG Xuerui Subject: [PATCH for-7.1 4/4] docs, target/loongarch: Rewrite the LoongArch docs Date: Sun, 14 Aug 2022 22:55:22 +0800 Message-Id: <20220814145522.1474927-5-i.qemu@xen0n.name> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220814145351.1474753-1-git@xen0n.name> References: <20220814145351.1474753-1-git@xen0n.name> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=115.28.160.31; envelope-from=i.qemu@xen0n.name; helo=mailbox.box.xen0n.name X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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" X-ZohoMail-DKIM: pass (identity @xen0n.name) X-ZM-MESSAGEID: 1660489055144100002 Content-Type: text/plain; charset="utf-8" From: WANG Xuerui Much information is already outdated in its current form, not to mention the hard-to-understand Chinglish. Rewrite to hopefully de-duplicate and re-organize things, and reflect the latest status of LoongArch at upstream. Signed-off-by: WANG Xuerui --- docs/system/loongarch/loongson3.rst | 41 ------------ docs/system/loongarch/virt.rst | 41 ++++++++++++ target/loongarch/README | 99 ----------------------------- target/loongarch/README.md | 75 ++++++++++++++++++++++ 4 files changed, 116 insertions(+), 140 deletions(-) delete mode 100644 docs/system/loongarch/loongson3.rst create mode 100644 docs/system/loongarch/virt.rst delete mode 100644 target/loongarch/README create mode 100644 target/loongarch/README.md diff --git a/docs/system/loongarch/loongson3.rst b/docs/system/loongarch/lo= ongson3.rst deleted file mode 100644 index fa3acd01c0..0000000000 --- a/docs/system/loongarch/loongson3.rst +++ /dev/null @@ -1,41 +0,0 @@ -:orphan: - -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D -loongson3 virt generic platform (``virt``) -=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D - -The ``virt`` machine use gpex host bridge, and there are some -emulated devices on virt board, such as loongson7a RTC device, -IOAPIC device, ACPI device and so on. - -Supported devices ------------------ - -The ``virt`` machine supports: -- Gpex host bridge -- Ls7a RTC device -- Ls7a IOAPIC device -- Ls7a ACPI device -- Fw_cfg device -- PCI/PCIe devices -- Memory device -- CPU device. Type: Loongson-3A5000. - -CPU and machine Type --------------------- - -The ``qemu-system-loongarch64`` provides emulation for virt -machine. You can specify the machine type ``virt`` and -cpu type ``Loongson-3A5000``. - -Boot options ------------- - -Now the ``virt`` machine can run test program in ELF format and the -method of compiling is in target/loongarch/README. - -.. code-block:: bash - - $ qemu-system-loongarch64 -machine virt -m 4G -cpu Loongson-3A5000 \ - -smp 1 -kernel hello -monitor none -display none \ - -chardev file,path=3Dhello.out,id=3Doutput -serial chardev:output diff --git a/docs/system/loongarch/virt.rst b/docs/system/loongarch/virt.rst new file mode 100644 index 0000000000..2d8f7e1db5 --- /dev/null +++ b/docs/system/loongarch/virt.rst @@ -0,0 +1,41 @@ +:orphan: + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +LoongArch generic virtualized platform (``virt``) +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The ``virt`` machine has a GPEX host bridge, and some more emulated devices +such as the LS7A RTC, IOAPIC, ACPI device and so on. + +Being a machine type designed for virtualized use cases, the machine resem= bles +a Loongson 3A5000 + LS7A1000 board, but is not an exact emulation. +For example, only cascading of the EXTIOI interrupt is implemented. +Also, only the RTC block of the LS7A1000 is emulated; for the other devices +the QEMU models are used. +Normally you do not need to care about any of these. + +Supported devices +----------------- + +The ``virt`` machine supports: + +- GPEX host bridge +- LS7A RTC device +- LS7A IOAPIC device +- LS7A ACPI device +- fw_cfg device +- PCI/PCIe devices +- Memory device +- CPU device. Defaults to ``qemu64-v1.00``. + +Boot options +------------ + +Some more information could be found in the QEMU sources at +``target/loongarch/README.md``. A simple example being: + +.. code-block:: bash + + $ qemu-system-loongarch64 -machine virt -m 4G -smp 1 -kernel hello \ + -monitor none -display none \ + -chardev file,path=3Dhello.out,id=3Doutput -serial chardev:output diff --git a/target/loongarch/README b/target/loongarch/README deleted file mode 100644 index 1823375d04..0000000000 --- a/target/loongarch/README +++ /dev/null @@ -1,99 +0,0 @@ -- Introduction - - LoongArch is the general processor architecture of Loongson. - - The following versions of the LoongArch core are supported - core: 3A5000 - https://github.com/loongson/LoongArch-Documentation/releases/download/= 2021.08.17/LoongArch-Vol1-v1.00-EN.pdf - - We can get the latest loongarch documents at https://github.com/loongson= /LoongArch-Documentation/tags. - - -- System emulation - - Mainly emulate a virt 3A5000 board and ls7a bridge that is not exactly t= he same as the host. - 3A5000 support multiple interrupt cascading while here we just emulate t= he extioi interrupt - cascading. LS7A1000 host bridge support multiple devices, such as sata, = gmac, uart, rtc - and so on. But we just realize the rtc. Others use the qemu common devic= es. It does not affect - the general use. We also introduced the emulation of devices at docs/sys= tem/loongarch/virt.rst. - - This version only supports running binary files in ELF format, and does = not depend on BIOS and kernel file. - You can compile the test program with 'make & make check-tcg' and run th= e test case with the following command: - - 1. Install LoongArch cross-tools on X86 machines. - - Download cross-tools. - - wget https://github.com/loongson/build-tools/releases/download/2022.= 05.29/loongarch64-clfs-5.0-cross-tools-gcc-full.tar.xz - - tar -vxf loongarch64-clfs-5.0-cross-tools-gcc-full.tar.xz -C /opt - - Config cross-tools env. - - . setenv.sh - - setenv.sh: - - #!/bin/sh - set -x - CC_PREFIX=3D/opt/cross-tools - - export PATH=3D$CC_PREFIX/bin:$PATH - export LD_LIBRARY_PATH=3D$CC_PREFIX/lib:$LD_LIBRARY_PATH - export LD_LIBRARY_PATH=3D$CC_PREFIX/loongarch64-unknown-linux-gn= u/lib/:$LD_LIBRARY_PATH - set +x - - 2. Test tests/tcg/multiarch. - - ./configure --disable-rdma --disable-pvrdma --prefix=3D/usr \ - --target-list=3D"loongarch64-softmmu" \ - --disable-libiscsi --disable-libnfs --disable-libpmem \ - --disable-glusterfs --enable-libusb --enable-usb-redir \ - --disable-opengl --disable-xen --enable-spice --disable-werror= \ - --enable-debug --disable-capstone --disable-kvm --enable-profi= ler - - cd build/ - - make && make check-tcg - - or - - ./build/qemu-system-loongarch64 -machine virt -m 4G -cpu Loongson-3A50= 00 -smp 1 -kernel build/tests/tcg/loongarch64-softmmu/hello -monitor none -= display none -chardev file,path=3Dhello.out,id=3Doutput -serial chardev:out= put - -- Linux-user emulation - - We already support Linux user emulation. We can use LoongArch cross-tool= s to build LoongArch executables on X86 machines, - and We can also use qemu-loongarch64 to run LoongArch executables. - - 1. Config cross-tools env. - - see System emulation. - - 2. Test tests/tcg/multiarch. - - ./configure --static --prefix=3D/usr --disable-werror --target-lis= t=3D"loongarch64-linux-user" --enable-debug - - cd build - - make && make check-tcg - - 3. Run LoongArch system basic command with loongarch-clfs-system. - - - Config clfs env. - - wget https://github.com/loongson/build-tools/releases/download/2022= .05.29/loongarch64-clfs-system-5.0.tar.bz2 - - tar -vxf loongarch64-clfs-system-5.0.tar.bz2 -C /opt/clfs - - cp /opt/clfs/lib64/ld-linux-loongarch-lp64d.so.1 /lib64 - - export LD_LIBRARY_PATH=3D"/opt/clfs/lib64" - - - Run LoongArch system basic command. - - ./qemu-loongarch64 /opt/clfs/usr/bin/bash - ./qemu-loongarch64 /opt/clfs/usr/bin/ls - ./qemu-loongarch64 /opt/clfs/usr/bin/pwd - -- Note. - We can get the latest LoongArch documents or LoongArch tools at https://= github.com/loongson/ diff --git a/target/loongarch/README.md b/target/loongarch/README.md new file mode 100644 index 0000000000..6a5ff8acd5 --- /dev/null +++ b/target/loongarch/README.md @@ -0,0 +1,75 @@ +# QEMU LoongArch target + +## Introduction + +LoongArch is the general-purpose instruction set architecture developed by +Loongson. Documentation can be found at [the LoongArch Documentation repos= itory][docs-repo]. + +[docs-repo]: https://github.com/loongson/LoongArch-Documentation + +Currently the following CPU models are supported: + +|`-cpu name`|Description| +|:----------|:----------| +|`qemu64-v1.00`|Virtual model similar to the Loongson 3A5000, compatible w= ith LoongArch64 v1.00.| + +## Trying out + +For some of the steps or development/debug purposes, you may have to set up +cross toolchains if you are not running on native LoongArch hardware. + +Now that LoongArch support has been merged in the GNU toolchain packages a= nd +Linux, you may make your own toolchains like with any other architectures; +Loongson also has made available [their pre-compiled toolchain binaries fo= r x86][build-tools]. +You may follow the respective instructions to set up your development +environment. + +[build-tools]: https://github.com/loongson/build-tools + +### System emulation + +Both raw ELF images and EFI stub kernels together with UEFI firmware image= are +supported. + +For running raw ELF images with system emulation: + +```sh +# In the build directory: +./qemu-system-loongarch64 -m 4G -smp 1 \ + -kernel build/tests/tcg/loongarch64-softmmu/hello \ + -monitor none -display none \ + -chardev file,path=3Dhello.out,id=3Doutput -serial chardev:output +``` + +For a more complete emulation with UEFI firmware, currently there is no +pre-compiled firmware blob yet, but in the meantime you may compile your o= wn +firmware image with Loongson's forked [EDK II][edk2] and +[corresponding platform code][edk2-plat]. + +[edk2]: https://github.com/loongson/edk2-LoongarchVirt +[edk2-plat]: https://github.com/loongson/edk2-platforms + +Once you have the firmware image in place, you could boot EFI images with = it. +For example: + +```sh +./qemu-system-loongarch64 -m 4G smp 4 \ + -bios path/to/your/QEMU_EFI.fd \ + -kernel path/to/your/vmlinux \ + -initrd path/to/your/initramfs/if/you/have/one \ + -append 'root=3D/dev/ram rdinit=3D/sbin/init console=3DttyS0,115200' + -nographic +``` + +### Linux-user emulation + +Linux-user emulation is fully supported, and there are already several Lin= ux +distributions available with ready-to-use sysroot tarballs, for example +[CLFS][clfs] and [Gentoo][gentoo]. + +You may compile static qemu-user binaries then follow suitable instructions +for your distribution (set up binfmt\_misc, etc.) to make yourself a Loong= Arch +chroot for experimentation. + +[clfs]: https://github.com/sunhaiyong1978/CLFS-for-LoongArch +[gentoo]: https://wiki.gentoo.org/wiki/Project:LoongArch --=20 2.35.1