From nobody Wed Oct 29 20:34:59 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1524606706085240.1878503840294; Tue, 24 Apr 2018 14:51:46 -0700 (PDT) Received: from localhost ([::1]:60968 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5qj-0006YS-An for importer@patchew.org; Tue, 24 Apr 2018 17:51:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32872) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fB5lK-0002lI-4p for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fB5lH-00072Z-VN for qemu-devel@nongnu.org; Tue, 24 Apr 2018 17:46:10 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:47104 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fB5lH-00072Q-RK; Tue, 24 Apr 2018 17:46:07 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4CCA3406C79C; Tue, 24 Apr 2018 21:46:06 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-120-175.rdu2.redhat.com [10.10.120.175]) by smtp.corp.redhat.com (Postfix) with ESMTP id 46C4F2166BC6; Tue, 24 Apr 2018 21:46:04 +0000 (UTC) From: Laszlo Ersek To: qemu-devel@nongnu.org Date: Tue, 24 Apr 2018 23:45:46 +0200 Message-Id: <20180424214550.32549-3-lersek@redhat.com> In-Reply-To: <20180424214550.32549-1-lersek@redhat.com> References: <20180424214550.32549-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 24 Apr 2018 21:46:07 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.5]); Tue, 24 Apr 2018 21:46:07 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'lersek@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH 2/6] qapi: handle the riscv CpuInfoArch in query-cpus-fast X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Riku Voipio , Sagar Karandikar , Peter Crosthwaite , Bastian Koppelmann , qemu-stable@nongnu.org, Palmer Dabbelt , Laurent Vivier , Markus Armbruster , Michael Clark , Paolo Bonzini , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Commit 25fa194b7b11 added the @riscv enum constant to @CpuInfoArch (used in both @CpuInfo and @CpuInfoFast -- the return types of the @query-cpus and @query-cpus-fast commands, respectively), and assigned, in both return structures, the @CpuInfoRISCV sub-structure to the new enum value. However, qmp_query_cpus_fast() would not populate either the @arch field or the @CpuInfoRISCV sub-structure, when TARGET_RISCV was defined; only qmp_query_cpus() would. In theory, there are two ways to fix this: (a) Fill in both the @arch field and the @CpuInfoRISCV sub-structure in qmp_query_cpus_fast(), by copying the logic from qmp_query_cpus(). (b) Assign @CpuInfoOther to the @riscv enum constant in @CpuInfoFast, and populate only the @arch field in qmp_query_cpus_fast(). Approach (b) seems more robust, because: - clearly there has never been an attempt to get actual RISV CPU state from qmp_query_cpus_fast(), so its lack of RISCV support is not actually a problem, - getting CPU state without interrupting KVM looks like an exceptional thing to do (only S390X does it currently). Cc: Bastian Koppelmann Cc: Eric Blake Cc: Laurent Vivier Cc: Markus Armbruster Cc: Michael Clark Cc: Palmer Dabbelt Cc: Paolo Bonzini Cc: Peter Crosthwaite Cc: Richard Henderson Cc: Riku Voipio Cc: Sagar Karandikar Cc: qemu-stable@nongnu.org Fixes: 25fa194b7b11901561532e435beb83d046899f7a Signed-off-by: Laszlo Ersek Reviewed-by: Eric Blake --- Notes: PATCHv1: =20 - new patch qapi/misc.json | 2 +- cpus.c | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/qapi/misc.json b/qapi/misc.json index 5636f4a14997..104d013adba6 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -565,23 +565,23 @@ { 'union': 'CpuInfoFast', 'base': {'cpu-index': 'int', 'qom-path': 'str', 'thread-id': 'int', '*props': 'CpuInstanceProperties', 'arch': 'CpuInfoArch' }, 'discriminator': 'arch', 'data': { 'x86': 'CpuInfoOther', 'sparc': 'CpuInfoOther', 'ppc': 'CpuInfoOther', 'mips': 'CpuInfoOther', 'tricore': 'CpuInfoOther', 's390': 'CpuInfoS390', - 'riscv': 'CpuInfoRISCV', + 'riscv': 'CpuInfoOther', 'other': 'CpuInfoOther' } } =20 ## # @query-cpus-fast: # # Returns information about all virtual CPUs. This command does not # incur a performance penalty and should be used in production # instead of query-cpus. # # Returns: list of @CpuInfoFast # diff --git a/cpus.c b/cpus.c index 1a9a2edee1f2..60563a6d54ec 100644 --- a/cpus.c +++ b/cpus.c @@ -2225,22 +2225,24 @@ CpuInfoFastList *qmp_query_cpus_fast(Error **errp) #elif defined(TARGET_SPARC) info->value->arch =3D CPU_INFO_ARCH_SPARC; #elif defined(TARGET_MIPS) info->value->arch =3D CPU_INFO_ARCH_MIPS; #elif defined(TARGET_TRICORE) info->value->arch =3D CPU_INFO_ARCH_TRICORE; #elif defined(TARGET_S390X) s390_cpu =3D S390_CPU(cpu); env =3D &s390_cpu->env; info->value->arch =3D CPU_INFO_ARCH_S390; info->value->u.s390.cpu_state =3D env->cpu_state; +#elif defined(TARGET_RISCV) + info->value->arch =3D CPU_INFO_ARCH_RISCV; #else info->value->arch =3D CPU_INFO_ARCH_OTHER; #endif if (!cur_item) { head =3D cur_item =3D info; } else { cur_item->next =3D info; cur_item =3D info; } } =20 --=20 2.14.1.3.gb7cf6e02401b