From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631629447060386.0128326064828; Tue, 14 Sep 2021 07:24:07 -0700 (PDT) Received: from localhost ([::1]:44854 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9Ly-0003cL-0b for importer@patchew.org; Tue, 14 Sep 2021 10:24:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34052) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Jt-0000c9-CC for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:21:57 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37348) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Jr-0003dz-Q7 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:21:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-465-0ANmDWgANhWaZU5mbBWQ9w-1; Tue, 14 Sep 2021 10:21:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 17498835DE0; Tue, 14 Sep 2021 14:21:49 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id A48F35D9CA; Tue, 14 Sep 2021 14:21:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629315; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jqg+KbdjEyUa8qwGSIprn8VTfs1RlVUX+DOblupWdX8=; b=W8/6Fo1XBSR9oEHYrGMIwhjnhcfyVtYx6yv4BZARIfodwkNmiPupOUkwSo8Tb4QJjvE8DE fwGlji4eXX6R0PbiH/3UtaE32YQlCu48UKdDaBI+7jJS2Vrw3Gd/gHGLcNBnw5Y1VkADZy 3jDUM64mhMFt3SF48kzVfa6soM2djT4= X-MC-Unique: 0ANmDWgANhWaZU5mbBWQ9w-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 01/53] docs/devel: rename file for writing monitor commands Date: Tue, 14 Sep 2021 15:19:50 +0100 Message-Id: <20210914142042.1655100-2-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631629448201100001 The file already covers writing new style HMP commands, in addition to the QMP commands, so it deserves a more general name. Signed-off-by: Daniel P. Berrang=C3=A9 --- docs/devel/index.rst | 2 +- ...riting-qmp-commands.rst =3D> writing-monitor-commands.rst} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename docs/devel/{writing-qmp-commands.rst =3D> writing-monitor-commands.= rst} (99%) diff --git a/docs/devel/index.rst b/docs/devel/index.rst index f95df10b3e..7c25177c5d 100644 --- a/docs/devel/index.rst +++ b/docs/devel/index.rst @@ -44,4 +44,4 @@ modifying QEMU's source code. ebpf_rss vfio-migration qapi-code-gen - writing-qmp-commands + writing-monitor-commands diff --git a/docs/devel/writing-qmp-commands.rst b/docs/devel/writing-monit= or-commands.rst similarity index 99% rename from docs/devel/writing-qmp-commands.rst rename to docs/devel/writing-monitor-commands.rst index 6a10a06c48..497c9ce0d5 100644 --- a/docs/devel/writing-qmp-commands.rst +++ b/docs/devel/writing-monitor-commands.rst @@ -1,8 +1,8 @@ -How to write QMP commands using the QAPI framework -=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= =3D +How to write monitor commands +=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 =20 This document is a step-by-step guide on how to write new QMP commands usi= ng -the QAPI framework. It also shows how to implement new style HMP commands. +the QAPI framework and new style HMP commands. =20 This document doesn't discuss QMP protocol level details, nor does it dive into the QAPI framework implementation. --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163162977506933.63940042074239; Tue, 14 Sep 2021 07:29:35 -0700 (PDT) Received: from localhost ([::1]:55662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9RF-0002y6-Hy for importer@patchew.org; Tue, 14 Sep 2021 10:29:33 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34214) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9KC-0000r2-4C for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:22:16 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:27524) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9K9-0003qX-Jv for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:22:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-369-NNEgaP0pPJWT2ZgG2q1f7A-1; Tue, 14 Sep 2021 10:22:11 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 19763180831A; Tue, 14 Sep 2021 14:22:08 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 728C65D9DC; Tue, 14 Sep 2021 14:21:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629333; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=S4mcFixgI8QWYygoX/mbTsK3lsPq8Q1IHo4rS1KMgFE=; b=WA8+DuDjrl2WwplG/PLUF5oi3JDh9hxliYiGrf0KqWhB4c3CLcY8QnX6RgW8+1SFdqH95s ZKAE5KOxC3yuqeFmw1f8naHzCD4EXYYkfb4Fwtl6cGnhdt1jz5DMoQwDEwSTSVIJRcp3x8 KsdTp3EWaktFeJP4UDg7i9XH/LKZI54= X-MC-Unique: NNEgaP0pPJWT2ZgG2q1f7A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 02/53] docs/devel: tweak headings in monitor command docs Date: Tue, 14 Sep 2021 15:19:51 +0100 Message-Id: <20210914142042.1655100-3-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631629777740100001 The new headings reflect the intended structure of the document and will better suit additions that follow. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Markus Armbruster --- docs/devel/writing-monitor-commands.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/devel/writing-monitor-commands.rst b/docs/devel/writing-m= onitor-commands.rst index 497c9ce0d5..cddb36fb74 100644 --- a/docs/devel/writing-monitor-commands.rst +++ b/docs/devel/writing-monitor-commands.rst @@ -85,8 +85,8 @@ any data". Now you're ready to enter the QMP example comm= ands as explained in the following sections. =20 =20 -Writing a command that doesn't return data ------------------------------------------- +Writing a simple command: hello-world +------------------------------------- =20 That's the most simple QMP command that can be written. Usually, this kind= of command carries some meaningful action in QEMU but here it will just print @@ -340,8 +340,8 @@ Please, check the "-monitor" command-line option to kno= w how to open a user monitor. =20 =20 -Writing a command that returns data ------------------------------------ +Writing more complex commands +----------------------------- =20 A QMP command is capable of returning any data the QAPI supports like inte= gers, strings, booleans, enumerations and user defined types. --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631630077450205.0183195860659; Tue, 14 Sep 2021 07:34:37 -0700 (PDT) Received: from localhost ([::1]:37784 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9W7-00021Q-TE for importer@patchew.org; Tue, 14 Sep 2021 10:34:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34310) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9KK-0000xL-M8 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:22:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:32164) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9KH-0003vh-6L for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:22:24 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-225-RMCR6vBXPDCSX-Pz2hmpwA-1; Tue, 14 Sep 2021 10:22:19 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BBBC4801E72; Tue, 14 Sep 2021 14:22:15 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 612D35D9CA; Tue, 14 Sep 2021 14:22:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629340; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u06VPRO3ZTpziCI9V80Mt31DearKqRpMuaMoaazZMng=; b=gPRKiAlMvO5LmshAFLi31sVbXc1/aet0HsgU5lyAEQceQgp86pR0dMbQDxGbjGwiIBc9L6 lX02IMFIeEoGt/ORvC+3AOHlZVQJM4Oe6jThGV4bE0XgsCdro1YWj7s1PO63XbBw7FICMl Ab3jF5PsoHTDzz+UApzd+cOnt2i3hMg= X-MC-Unique: RMCR6vBXPDCSX-Pz2hmpwA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 03/53] docs/devel: document expectations for QAPI data modelling for QMP Date: Tue, 14 Sep 2021 15:19:52 +0100 Message-Id: <20210914142042.1655100-4-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631630079928100001 Traditionally we have required that newly added QMP commands will model any returned data using fine grained QAPI types. This is good for commands that are intended to be consumed by machines, where clear data representation is very important. Commands that don't satisfy this have generally been added to HMP only. In effect the decision of whether to add a new command to QMP vs HMP has been used as a proxy for the decision of whether the cost of designing a fine grained QAPI type is justified by the potential benefits. As a result the commands present in QMP and HMP are non-overlapping sets, although HMP comamnds can be accessed indirectly via the QMP command 'human-monitor-command'. One of the downsides of 'human-monitor-command' is that the QEMU monitor APIs remain tied into various internal parts of the QEMU code. For example any exclusively HMP command will need to use 'monitor_printf' to get data out. It would be desirable to be able to fully isolate the monitor implementation from QEMU internals, however, this is only possible if all commands are exclusively based on QAPI with direct QMP exposure. The way to achieve this desired end goal is to finese the requirements for QMP command design. For cases where the output of a command is only intended for human consumption, it is reasonable to want to simplify the implementation by returning a plain string containing formatted data instead of designing a fine grained QAPI data type. This can be permitted if-and-only-if the command is exposed under the 'x-' name prefix. This indicates that the command data format is liable to future change and that it is not following QAPI design best practice. The poster child example for this would be the 'info registers' HMP command which returns printf formatted data representing CPU state. This information varies enourmously across target architectures and changes relatively frequently as new CPU features are implemented. It is there as debugging data for human operators, and any machine usage would treat it as an opaque blob. It is thus reasonable to expose this in QMP as 'x-query-registers' returning a 'str' field. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Markus Armbruster --- docs/devel/writing-monitor-commands.rst | 27 +++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/docs/devel/writing-monitor-commands.rst b/docs/devel/writing-m= onitor-commands.rst index cddb36fb74..d68c552fdd 100644 --- a/docs/devel/writing-monitor-commands.rst +++ b/docs/devel/writing-monitor-commands.rst @@ -350,6 +350,33 @@ In this section we will focus on user defined types. P= lease, check the QAPI documentation for information about the other types. =20 =20 +Modelling data in QAPI +~~~~~~~~~~~~~~~~~~~~~~ + +For a QMP command that to be considered stable and supported long term, +there is a requirement returned data should be explicitly modelled +using fine-grained QAPI types. As a general guide, a caller of the QMP +command should never need to parse individual returned data fields. If +a field appears to need parsing, then it should be split into separate +fields corresponding to each distinct data item. This should be the +common case for any new QMP command that is intended to be used by +machines, as opposed to exclusively human operators. + +Some QMP commands, however, are only intended as ad hoc debugging aids +for human operators. While they may return large amounts of formatted +data, it is not expected that machines will need to parse the result. +The overhead of defining a fine grained QAPI type for the data may not +be justified by the potential benefit. In such cases, it is permitted +to have a command return a simple string that contains formatted data, +however, it is mandatory for the command to use the 'x-' name prefix. +This indicates that the command is not guaranteed to be long term +stable / liable to change in future and is not following QAPI design +best practices. An example where this approach is taken is the QMP +command "x-query-registers". This returns a formatted dump of the +architecture specific CPU state. The way the data is formatted varies +across QEMU targets, is liable to change over time, and is only +intended to be consumed as an opaque string by machines. + User Defined Types ~~~~~~~~~~~~~~~~~~ =20 --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163162979037627.894357173517278; Tue, 14 Sep 2021 07:29:50 -0700 (PDT) Received: from localhost ([::1]:57094 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9RU-0003wu-BM for importer@patchew.org; Tue, 14 Sep 2021 10:29:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Kd-0001dx-LQ for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:22:43 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:30752) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Ka-00049F-Fc for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:22:42 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-451-3kvnxxzgOzWlZw_UBtYRjQ-1; Tue, 14 Sep 2021 10:22:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1E49B1084681; Tue, 14 Sep 2021 14:22:34 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0E5B55D9CA; Tue, 14 Sep 2021 14:22:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629359; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AKQ5Y6mKD8eeLMm/8Vj1U//cSS0HbEG9luA/4D8pINQ=; b=F1X8741Gv376tfj200L2vmhX2xs/UeoRrR6bX57kDAut85Jx4UA4ylku2dxcD3Dijki9FU BLBKwawbiX7bzfLDwIzaz2FWJOFgMOLtcpFWPjf32C942dzGjvanagR5uShZeOCBlQrouW RwGIv3AiNuHrytQqFejoFL+ezunkMac= X-MC-Unique: 3kvnxxzgOzWlZw_UBtYRjQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 04/53] docs/devel: add example of command returning unstructured text Date: Tue, 14 Sep 2021 15:19:53 +0100 Message-Id: <20210914142042.1655100-5-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631629794429100001 This illustrates how to add a QMP command returning unstructured text, following the guidelines added in the previous patch. The example uses a simplified version of 'info roms'. Signed-off-by: Daniel P. Berrang=C3=A9 --- docs/devel/writing-monitor-commands.rst | 85 +++++++++++++++++++++++++ 1 file changed, 85 insertions(+) diff --git a/docs/devel/writing-monitor-commands.rst b/docs/devel/writing-m= onitor-commands.rst index d68c552fdd..4cf51ab557 100644 --- a/docs/devel/writing-monitor-commands.rst +++ b/docs/devel/writing-monitor-commands.rst @@ -647,3 +647,88 @@ has to traverse the list, it's shown below for referen= ce:: =20 qapi_free_TimerAlarmMethodList(method_list); } + +Writing a debugging aid returning unstructured text +--------------------------------------------------- + +As discussed at the start of the previous example, it is required that +commands expecting machine usage be using fine-grained QAPI data types. +The exception to this rule applies when the command is solely intended +as a debugging aid and allows for returning unstructured text. This is +commonly needed for query commands that report aspects of QEMU's +internal state that are useful to human operators. + +In this example we will consider a simplified variant of the HMP +command ``info roms``. Following the earlier rules, this command will +need to live under the ``x-`` name prefix, so its QMP implementation +will be called ``x-query-roms``. It will have no parameters and will +return a single text string:: + + { 'struct': 'HumanReadableText', + 'data': { 'human-readable-text': 'str' } } + + { 'command': 'x-query-roms', + 'returns': 'HumanReadableText' } + +The ``HumanReadableText`` struct is intended to be used for all +commands, under the ``x-`` name prefix that are returning unstructured +text targetted at humans. It should never be used for commands outside +the ``x-`` name prefix, as those should be using structured QAPI types. + +Implementing the QMP command +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +The QMP implementation will typically involve creating a ``GString`` +object and printing formatted data into it:: + + HumanReadableText *qmp_x_query_roms(Error **errp) + { + GString buf =3D g_string_new(""); + HumanReadableText ret =3D g_new0(HumanReadableText, 1); + Rom *rom; + + QTAILQ_FOREACH(rom, &roms, next) { + g_string_append_printf("%s size=3D0x%06zx name=3D\"%s\"\n", + memory_region_name(rom->mr), + rom->romsize, + rom->name); + } + + ret->human_readable_text =3D g_string_free(buf, FALSE); + + return ret; + } + + +Implementing the HMP command +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Now that the QMP command is in place, we can also make it available in +the human monitor (HMP) as shown in previous examples. The HMP +implementations will all look fairly similar, as all they need do is +invoke the QMP command and then print the resulting text or error +message. Here's the implementation of the "info roms" HMP command:: + + void hmp_info_roms(Monitor *mon, const QDict *qdict) + { + Error err =3D NULL; + g_autoptr(HumanReadableText) info =3D qmp_x_query_roms(&err); + if (err) { + error_report_err(err); + return; + } + monitor_printf(mon, "%s\n", info->human_readable_text); + } + +Also, you have to add the function's prototype to the hmp.h file. + +There's one last step to actually make the command available to +monitor users, we should add it to the hmp-commands-info.hx file:: + + { + .name =3D "roms", + .args_type =3D "", + .params =3D "", + .help =3D "show roms", + .cmd =3D hmp_info_roms, + }, --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631630280995923.6013857276743; Tue, 14 Sep 2021 07:38:00 -0700 (PDT) Received: from localhost ([::1]:46342 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9ZP-0008L7-UC for importer@patchew.org; Tue, 14 Sep 2021 10:37:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34592) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Km-0001wQ-7c for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:22:52 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53293) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Ki-0004Fu-O3 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:22:52 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-16-CmXhOXUDPVO6dPAWyAYScw-1; Tue, 14 Sep 2021 10:22:45 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A83A1006AA5; Tue, 14 Sep 2021 14:22:42 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6A7495D9CA; Tue, 14 Sep 2021 14:22:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629367; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=hnAoCdun/m6178yZjeWVfAYiK2xccClT/ddcqgE1vOc=; b=FGOP64Fvs/nl8G9/dB995ESfDBN5MIczfs2NBRZ/CDniTE7JtO0oWD+rjJLJaTLcqm833S S/hS1P8akCpkb6SJDdJB/HjkL9XCflEV4VxKV2By4MIz4blsfgtXUnRk7c6ekqrWuAEy3c RlNs/sAHIa7+kg+eKwINkxR0DdpRoQc= X-MC-Unique: CmXhOXUDPVO6dPAWyAYScw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 05/53] docs/devel: document expectations for HMP commands in the future Date: Tue, 14 Sep 2021 15:19:54 +0100 Message-Id: <20210914142042.1655100-6-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631630282103100001 We no longer wish to have commands implemented in HMP only. All commands should start with a QMP implementation and the HMP merely be a shim around this. To reduce the burden of implementing QMP commands where there is low expectation of machine usage, requirements for QAPI modelling are relaxed provided the command is under the "x-" name prefix. Signed-off-by: Daniel P. Berrang=C3=A9 --- docs/devel/writing-monitor-commands.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/docs/devel/writing-monitor-commands.rst b/docs/devel/writing-m= onitor-commands.rst index 4cf51ab557..983130a793 100644 --- a/docs/devel/writing-monitor-commands.rst +++ b/docs/devel/writing-monitor-commands.rst @@ -11,6 +11,16 @@ For an in-depth introduction to the QAPI framework, plea= se refer to docs/devel/qapi-code-gen.txt. For documentation about the QMP protocol, start with docs/interop/qmp-intro.txt. =20 +Historically QEMU has permitted new monitor commands to be implemented in = HMP +only, QMP only, or both, depending on whether they needed to be accessible= to +human operators, machines, or both. When both QMP and HMP are implemented = it +is expected the HMP implementation is a shim around the QMP implementation. +Going forward, the expectation is that new commands are implemented in QMP +only, or both QMP and HMP. No further commands are to be added to HMP only. +The long term goal is that all HMP commands will be implemented in terms of +their QMP equivalent, enabling internals of QEMU to be fully isolated from +the HMP implementation. Refer to the later topic on modelling data in QAPI +for further guidance on commands that would have traditionally been HMP on= ly. =20 Overview -------- --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631629514092497.7667441807894; Tue, 14 Sep 2021 07:25:14 -0700 (PDT) Received: from localhost ([::1]:47736 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9N3-0005XV-0k for importer@patchew.org; Tue, 14 Sep 2021 10:25:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9L3-0002DZ-O6 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:23:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:60283) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9L1-0004T2-1C for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:23:09 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-265-XoKLPxexNHmDkTmH1a4ktg-1; Tue, 14 Sep 2021 10:23:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BB3DF1084683; Tue, 14 Sep 2021 14:23:00 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 588BE5D9CA; Tue, 14 Sep 2021 14:22:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629385; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rKnaBwFCCJX9ZX6cv7A4ifx+XIL+7QBX+qDEATc0WKY=; b=FvwScpkw/c6lo782uppwpfvt1NIaou0TFbcQy/Pz0tLvq1nJDIYTXO7iVULMr2tcj/yD5X RV4BnH1utCBW4+Ex8rIKZtI9NLsbTmYFNDKlX7SzGUwQt+iBdju4AR5dvLhQJbJSVrjO0A nfyAsasS/WqQJAahFLzjV5Z6DohObmQ= X-MC-Unique: XoKLPxexNHmDkTmH1a4ktg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 06/53] hw/core: introduce 'format_state' callback to replace 'dump_state' Date: Tue, 14 Sep 2021 15:19:55 +0100 Message-Id: <20210914142042.1655100-7-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631629515455100001 The 'dump_state' callback assumes it will be outputting to a FILE object. This is fine for HMP, but not so useful for QMP. Introduce a new 'format_state' callback that returns a formatted GString instead. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/cpu-common.c | 15 +++++++++++++++ include/hw/core/cpu.h | 13 ++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index e2f5a64604..c2cd33a817 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -106,6 +106,21 @@ void cpu_dump_state(CPUState *cpu, FILE *f, int flags) if (cc->dump_state) { cpu_synchronize_state(cpu); cc->dump_state(cpu, f, flags); + } else if (cc->format_state) { + g_autoptr(GString) buf =3D g_string_new(""); + cpu_synchronize_state(cpu); + cc->format_state(cpu, buf, flags); + qemu_fprintf(f, "%s", buf->str); + } +} + +void cpu_format_state(CPUState *cpu, GString *buf, int flags) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + if (cc->format_state) { + cpu_synchronize_state(cpu); + cc->format_state(cpu, buf, flags); } } =20 diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index bc864564ce..1599ef9df3 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -91,7 +91,8 @@ struct SysemuCPUOps; * @reset_dump_flags: #CPUDumpFlags to use for reset logging. * @has_work: Callback for checking if there is work to do. * @memory_rw_debug: Callback for GDB memory access. - * @dump_state: Callback for dumping state. + * @dump_state: Callback for dumping state. Deprecated, use @format_state. + * @format_state: Callback for formatting state. * @get_arch_id: Callback for getting architecture-dependent CPU ID. * @set_pc: Callback for setting the Program Counter register. This * should have the semantics used by the target architecture when @@ -136,6 +137,7 @@ struct CPUClass { int (*memory_rw_debug)(CPUState *cpu, vaddr addr, uint8_t *buf, int len, bool is_write); void (*dump_state)(CPUState *cpu, FILE *, int flags); + void (*format_state)(CPUState *cpu, GString *buf, int flags); int64_t (*get_arch_id)(CPUState *cpu); void (*set_pc)(CPUState *cpu, vaddr value); int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); @@ -537,6 +539,15 @@ enum CPUDumpFlags { */ void cpu_dump_state(CPUState *cpu, FILE *f, int flags); =20 +/** + * cpu_format_state: + * @cpu: The CPU whose state is to be formatted. + * @buf: buffer to format state into + * + * Formats the CPU state. + */ +void cpu_format_state(CPUState *cpu, GString *buf, int flags); + #ifndef CONFIG_USER_ONLY /** * cpu_get_phys_page_attrs_debug: --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631630091890995.507947653981; Tue, 14 Sep 2021 07:34:51 -0700 (PDT) Received: from localhost ([::1]:38528 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9WM-0002aU-Jg for importer@patchew.org; Tue, 14 Sep 2021 10:34:50 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34860) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9LA-0002J7-Uh for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:23:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9L7-0004YU-RU for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:23:16 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-397-A9bwwun7PU-maqSTdeQ_xw-1; Tue, 14 Sep 2021 10:23:12 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4729784A5E0; Tue, 14 Sep 2021 14:23:08 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F14E5D9CA; Tue, 14 Sep 2021 14:23:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629393; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tog67gS4drGXdUxWrkIWCLaJgHomsSxvNugMDYrI6tI=; b=EXDDFyZd10jx19s/zrVhVfNW7h1AkU6fzvn+7VHV8Vg0+Cf4FWlha0TaZ3gtzZbro4Ho7g szNXI3QS9K1GTuFsOeTUH0SRgMkg724xN1Y9GE1YzcsYkWWlgeuIRP2XNRsWDjN5tuOCMs hDtfeMxXAX8FcuaoEITLsI/SKRTzKYI= X-MC-Unique: A9bwwun7PU-maqSTdeQ_xw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 07/53] target/alpha: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:19:56 +0100 Message-Id: <20210914142042.1655100-8-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631630093258100001 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/alpha/cpu.c | 2 +- target/alpha/cpu.h | 2 +- target/alpha/helper.c | 28 ++++++++++++++++------------ 3 files changed, 18 insertions(+), 14 deletions(-) diff --git a/target/alpha/cpu.c b/target/alpha/cpu.c index 4871ad0c0a..d0cdda9554 100644 --- a/target/alpha/cpu.c +++ b/target/alpha/cpu.c @@ -239,7 +239,7 @@ static void alpha_cpu_class_init(ObjectClass *oc, void = *data) =20 cc->class_by_name =3D alpha_cpu_class_by_name; cc->has_work =3D alpha_cpu_has_work; - cc->dump_state =3D alpha_cpu_dump_state; + cc->format_state =3D alpha_cpu_format_state; cc->set_pc =3D alpha_cpu_set_pc; cc->gdb_read_register =3D alpha_cpu_gdb_read_register; cc->gdb_write_register =3D alpha_cpu_gdb_write_register; diff --git a/target/alpha/cpu.h b/target/alpha/cpu.h index 82df108967..9e3c80ebcc 100644 --- a/target/alpha/cpu.h +++ b/target/alpha/cpu.h @@ -278,7 +278,7 @@ extern const VMStateDescription vmstate_alpha_cpu; =20 void alpha_cpu_do_interrupt(CPUState *cpu); bool alpha_cpu_exec_interrupt(CPUState *cpu, int int_req); -void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags); +void alpha_cpu_format_state(CPUState *cs, GString *buf, int flags); hwaddr alpha_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int alpha_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int alpha_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/alpha/helper.c b/target/alpha/helper.c index 4f56fe4d23..6ed80e8a27 100644 --- a/target/alpha/helper.c +++ b/target/alpha/helper.c @@ -451,7 +451,7 @@ bool alpha_cpu_exec_interrupt(CPUState *cs, int interru= pt_request) return false; } =20 -void alpha_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void alpha_cpu_format_state(CPUState *cs, GString *buf, int flags) { static const char linux_reg_names[31][4] =3D { "v0", "t0", "t1", "t2", "t3", "t4", "t5", "t6", @@ -463,25 +463,29 @@ void alpha_cpu_dump_state(CPUState *cs, FILE *f, int = flags) CPUAlphaState *env =3D &cpu->env; int i; =20 - qemu_fprintf(f, "PC " TARGET_FMT_lx " PS %02x\n", - env->pc, extract32(env->flags, ENV_FLAG_PS_SHIFT, 8)); + g_string_append_printf(buf, + "PC " TARGET_FMT_lx " PS %02x\n", + env->pc, + extract32(env->flags, ENV_FLAG_PS_SHIFT, 8)); for (i =3D 0; i < 31; i++) { - qemu_fprintf(f, "%-8s" TARGET_FMT_lx "%c", - linux_reg_names[i], cpu_alpha_load_gr(env, i), - (i % 3) =3D=3D 2 ? '\n' : ' '); + g_string_append_printf(buf, "%-8s" TARGET_FMT_lx "%c", + linux_reg_names[i], cpu_alpha_load_gr(env, = i), + (i % 3) =3D=3D 2 ? '\n' : ' '); } =20 - qemu_fprintf(f, "lock_a " TARGET_FMT_lx " lock_v " TARGET_FMT_lx "\n= ", - env->lock_addr, env->lock_value); + g_string_append_printf(buf, "lock_a " TARGET_FMT_lx + " lock_v " TARGET_FMT_lx "\n", + env->lock_addr, env->lock_value); =20 if (flags & CPU_DUMP_FPU) { for (i =3D 0; i < 31; i++) { - qemu_fprintf(f, "f%-7d%016" PRIx64 "%c", i, env->fir[i], - (i % 3) =3D=3D 2 ? '\n' : ' '); + g_string_append_printf(buf, "f%-7d%016" PRIx64 "%c", i, env->f= ir[i], + (i % 3) =3D=3D 2 ? '\n' : ' '); } - qemu_fprintf(f, "fpcr %016" PRIx64 "\n", cpu_alpha_load_fpcr(en= v)); + g_string_append_printf(buf, "fpcr %016" PRIx64 "\n", + cpu_alpha_load_fpcr(env)); } - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } =20 /* This should only be called from translate, via gen_excp. --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631630507709884.886155122284; Tue, 14 Sep 2021 07:41:47 -0700 (PDT) Received: from localhost ([::1]:57970 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9d4-00085D-Gs for importer@patchew.org; Tue, 14 Sep 2021 10:41:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34994) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9LU-00037C-8n for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:23:36 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:27278) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9LR-0004m1-3v for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:23:36 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-230-4gJOaScQPj2SUv-rd9PB3Q-1; Tue, 14 Sep 2021 10:23:30 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0D70318414A5; Tue, 14 Sep 2021 14:23:27 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 90E945D9CA; Tue, 14 Sep 2021 14:23:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629412; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KGkGVwRmSHO8zOwMvdSsq1teOA4ZO2QBEQn2l0HSxc0=; b=Zr06pwlMxRFC+vbq1H7ZZWZdBJ7gq6CkORquG+Wb2oTi5NV404WncvU6Klp+21tV9LhTBy RVCxAStqbH8uTyfb7nc6ckGssa6NBum3Lfg5VSrja1CHFKIsK0U1RREpQdOoE4TbSXUcf2 ACmzvp0vCOQl8OLpBmb3jl68ouhSN8M= X-MC-Unique: 4gJOaScQPj2SUv-rd9PB3Q-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 08/53] target/arm: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:19:57 +0100 Message-Id: <20210914142042.1655100-9-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631630509814100001 Signed-off-by: Daniel P. Berrang=C3=A9 --- target/arm/cpu.c | 152 +++++++++++++++++++++++++---------------------- 1 file changed, 81 insertions(+), 71 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index d631c4683c..5999277e67 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -798,7 +798,7 @@ static void arm_disas_set_info(CPUState *cpu, disassemb= le_info *info) =20 #ifdef TARGET_AARCH64 =20 -static void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) +static void aarch64_cpu_format_state(CPUState *cs, GString *buf, int flags) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; @@ -807,13 +807,14 @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE= *f, int flags) int el =3D arm_current_el(env); const char *ns_status; =20 - qemu_fprintf(f, " PC=3D%016" PRIx64 " ", env->pc); + g_string_append_printf(buf, " PC=3D%016" PRIx64 " ", env->pc); for (i =3D 0; i < 32; i++) { if (i =3D=3D 31) { - qemu_fprintf(f, " SP=3D%016" PRIx64 "\n", env->xregs[i]); + g_string_append_printf(buf, " SP=3D%016" PRIx64 "\n", env->xre= gs[i]); } else { - qemu_fprintf(f, "X%02d=3D%016" PRIx64 "%s", i, env->xregs[i], - (i + 2) % 3 ? " " : "\n"); + g_string_append_printf(buf, "X%02d=3D%016" PRIx64 "%s", + i, env->xregs[i], + (i + 2) % 3 ? " " : "\n"); } } =20 @@ -822,29 +823,29 @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE= *f, int flags) } else { ns_status =3D ""; } - qemu_fprintf(f, "PSTATE=3D%08x %c%c%c%c %sEL%d%c", - psr, - psr & PSTATE_N ? 'N' : '-', - psr & PSTATE_Z ? 'Z' : '-', - psr & PSTATE_C ? 'C' : '-', - psr & PSTATE_V ? 'V' : '-', - ns_status, - el, - psr & PSTATE_SP ? 'h' : 't'); + g_string_append_printf(buf, "PSTATE=3D%08x %c%c%c%c %sEL%d%c", + psr, + psr & PSTATE_N ? 'N' : '-', + psr & PSTATE_Z ? 'Z' : '-', + psr & PSTATE_C ? 'C' : '-', + psr & PSTATE_V ? 'V' : '-', + ns_status, + el, + psr & PSTATE_SP ? 'h' : 't'); =20 if (cpu_isar_feature(aa64_bti, cpu)) { - qemu_fprintf(f, " BTYPE=3D%d", (psr & PSTATE_BTYPE) >> 10); + g_string_append_printf(buf, " BTYPE=3D%d", (psr & PSTATE_BTYPE) >= > 10); } if (!(flags & CPU_DUMP_FPU)) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); return; } if (fp_exception_el(env, el) !=3D 0) { - qemu_fprintf(f, " FPU disabled\n"); + g_string_append_printf(buf, " FPU disabled\n"); return; } - qemu_fprintf(f, " FPCR=3D%08x FPSR=3D%08x\n", - vfp_get_fpcr(env), vfp_get_fpsr(env)); + g_string_append_printf(buf, " FPCR=3D%08x FPSR=3D%08x\n", + vfp_get_fpcr(env), vfp_get_fpsr(env)); =20 if (cpu_isar_feature(aa64_sve, cpu) && sve_exception_el(env, el) =3D= =3D 0) { int j, zcr_len =3D sve_zcr_len_for_el(env, el); @@ -852,11 +853,11 @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE= *f, int flags) for (i =3D 0; i <=3D FFR_PRED_NUM; i++) { bool eol; if (i =3D=3D FFR_PRED_NUM) { - qemu_fprintf(f, "FFR=3D"); + g_string_append_printf(buf, "FFR=3D"); /* It's last, so end the line. */ eol =3D true; } else { - qemu_fprintf(f, "P%02d=3D", i); + g_string_append_printf(buf, "P%02d=3D", i); switch (zcr_len) { case 0: eol =3D i % 8 =3D=3D 7; @@ -881,76 +882,84 @@ static void aarch64_cpu_dump_state(CPUState *cs, FILE= *f, int flags) } else { digits =3D (zcr_len % 4 + 1) * 4; } - qemu_fprintf(f, "%0*" PRIx64 "%s", digits, - env->vfp.pregs[i].p[j], - j ? ":" : eol ? "\n" : " "); + g_string_append_printf(buf, "%0*" PRIx64 "%s", digits, + env->vfp.pregs[i].p[j], + j ? ":" : eol ? "\n" : " "); } } =20 for (i =3D 0; i < 32; i++) { if (zcr_len =3D=3D 0) { - qemu_fprintf(f, "Z%02d=3D%016" PRIx64 ":%016" PRIx64 "%s", - i, env->vfp.zregs[i].d[1], - env->vfp.zregs[i].d[0], i & 1 ? "\n" : " "); + g_string_append_printf(buf, "Z%02d=3D%016" PRIx64 + ":%016" PRIx64 "%s", + i, env->vfp.zregs[i].d[1], + env->vfp.zregs[i].d[0], + i & 1 ? "\n" : " "); } else if (zcr_len =3D=3D 1) { - qemu_fprintf(f, "Z%02d=3D%016" PRIx64 ":%016" PRIx64 - ":%016" PRIx64 ":%016" PRIx64 "\n", - i, env->vfp.zregs[i].d[3], env->vfp.zregs[i].= d[2], - env->vfp.zregs[i].d[1], env->vfp.zregs[i].d[0= ]); + g_string_append_printf(buf, "Z%02d=3D%016" PRIx64 ":%016" = PRIx64 + ":%016" PRIx64 ":%016" PRIx64 "\n", + i, env->vfp.zregs[i].d[3], + env->vfp.zregs[i].d[2], + env->vfp.zregs[i].d[1], + env->vfp.zregs[i].d[0]); } else { for (j =3D zcr_len; j >=3D 0; j--) { bool odd =3D (zcr_len - j) % 2 !=3D 0; if (j =3D=3D zcr_len) { - qemu_fprintf(f, "Z%02d[%x-%x]=3D", i, j, j - 1); + g_string_append_printf(buf, "Z%02d[%x-%x]=3D", + i, j, j - 1); } else if (!odd) { if (j > 0) { - qemu_fprintf(f, " [%x-%x]=3D", j, j - 1); + g_string_append_printf(buf, " [%x-%x]=3D", + j, j - 1); } else { - qemu_fprintf(f, " [%x]=3D", j); + g_string_append_printf(buf, " [%x]=3D", j); } } - qemu_fprintf(f, "%016" PRIx64 ":%016" PRIx64 "%s", - env->vfp.zregs[i].d[j * 2 + 1], - env->vfp.zregs[i].d[j * 2], - odd || j =3D=3D 0 ? "\n" : ":"); + g_string_append_printf(buf, + "%016" PRIx64 ":%016" PRIx64 "%= s", + env->vfp.zregs[i].d[j * 2 + 1], + env->vfp.zregs[i].d[j * 2], + odd || j =3D=3D 0 ? "\n" : ":"); } } } } else { for (i =3D 0; i < 32; i++) { uint64_t *q =3D aa64_vfp_qreg(env, i); - qemu_fprintf(f, "Q%02d=3D%016" PRIx64 ":%016" PRIx64 "%s", - i, q[1], q[0], (i & 1 ? "\n" : " ")); + g_string_append_printf(buf, "Q%02d=3D%016" PRIx64 ":%016" PRIx= 64 "%s", + i, q[1], q[0], (i & 1 ? "\n" : " ")); } } } =20 #else =20 -static inline void aarch64_cpu_dump_state(CPUState *cs, FILE *f, int flags) +static inline void +aarch64_cpu_format_state(CPUState *cs, GString *buf, int flags) { g_assert_not_reached(); } =20 #endif =20 -static void arm_cpu_dump_state(CPUState *cs, FILE *f, int flags) +static void arm_cpu_format_state(CPUState *cs, GString *buf, int flags) { ARMCPU *cpu =3D ARM_CPU(cs); CPUARMState *env =3D &cpu->env; int i; =20 if (is_a64(env)) { - aarch64_cpu_dump_state(cs, f, flags); + aarch64_cpu_format_state(cs, buf, flags); return; } =20 for (i =3D 0; i < 16; i++) { - qemu_fprintf(f, "R%02d=3D%08x", i, env->regs[i]); + g_string_append_printf(buf, "R%02d=3D%08x", i, env->regs[i]); if ((i % 4) =3D=3D 3) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } else { - qemu_fprintf(f, " "); + g_string_append_printf(buf, " "); } } =20 @@ -973,15 +982,15 @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f,= int flags) } } =20 - qemu_fprintf(f, "XPSR=3D%08x %c%c%c%c %c %s%s\n", - xpsr, - xpsr & XPSR_N ? 'N' : '-', - xpsr & XPSR_Z ? 'Z' : '-', - xpsr & XPSR_C ? 'C' : '-', - xpsr & XPSR_V ? 'V' : '-', - xpsr & XPSR_T ? 'T' : 'A', - ns_status, - mode); + g_string_append_printf(buf, "XPSR=3D%08x %c%c%c%c %c %s%s\n", + xpsr, + xpsr & XPSR_N ? 'N' : '-', + xpsr & XPSR_Z ? 'Z' : '-', + xpsr & XPSR_C ? 'C' : '-', + xpsr & XPSR_V ? 'V' : '-', + xpsr & XPSR_T ? 'T' : 'A', + ns_status, + mode); } else { uint32_t psr =3D cpsr_read(env); const char *ns_status =3D ""; @@ -991,15 +1000,15 @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f= , int flags) ns_status =3D env->cp15.scr_el3 & SCR_NS ? "NS " : "S "; } =20 - qemu_fprintf(f, "PSR=3D%08x %c%c%c%c %c %s%s%d\n", - psr, - psr & CPSR_N ? 'N' : '-', - psr & CPSR_Z ? 'Z' : '-', - psr & CPSR_C ? 'C' : '-', - psr & CPSR_V ? 'V' : '-', - psr & CPSR_T ? 'T' : 'A', - ns_status, - aarch32_mode_name(psr), (psr & 0x10) ? 32 : 26); + g_string_append_printf(buf, "PSR=3D%08x %c%c%c%c %c %s%s%d\n", + psr, + psr & CPSR_N ? 'N' : '-', + psr & CPSR_Z ? 'Z' : '-', + psr & CPSR_C ? 'C' : '-', + psr & CPSR_V ? 'V' : '-', + psr & CPSR_T ? 'T' : 'A', + ns_status, + aarch32_mode_name(psr), (psr & 0x10) ? 32 := 26); } =20 if (flags & CPU_DUMP_FPU) { @@ -1011,14 +1020,15 @@ static void arm_cpu_dump_state(CPUState *cs, FILE *= f, int flags) } for (i =3D 0; i < numvfpregs; i++) { uint64_t v =3D *aa32_vfp_dreg(env, i); - qemu_fprintf(f, "s%02d=3D%08x s%02d=3D%08x d%02d=3D%016" PRIx6= 4 "\n", - i * 2, (uint32_t)v, - i * 2 + 1, (uint32_t)(v >> 32), - i, v); + g_string_append_printf(buf, "s%02d=3D%08x s%02d=3D%08x d%02d= =3D%016" + PRIx64 "\n", + i * 2, (uint32_t)v, + i * 2 + 1, (uint32_t)(v >> 32), + i, v); } - qemu_fprintf(f, "FPSCR: %08x\n", vfp_get_fpscr(env)); + g_string_append_printf(buf, "FPSCR: %08x\n", vfp_get_fpscr(env)); if (cpu_isar_feature(aa32_mve, cpu)) { - qemu_fprintf(f, "VPR: %08x\n", env->v7m.vpr); + g_string_append_printf(buf, "VPR: %08x\n", env->v7m.vpr); } } } @@ -2039,7 +2049,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) =20 cc->class_by_name =3D arm_cpu_class_by_name; cc->has_work =3D arm_cpu_has_work; - cc->dump_state =3D arm_cpu_dump_state; + cc->format_state =3D arm_cpu_format_state; cc->set_pc =3D arm_cpu_set_pc; cc->gdb_read_register =3D arm_cpu_gdb_read_register; cc->gdb_write_register =3D arm_cpu_gdb_write_register; --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631630625056577.3556010952504; Tue, 14 Sep 2021 07:43:45 -0700 (PDT) Received: from localhost ([::1]:38214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9ex-0005SL-RP for importer@patchew.org; Tue, 14 Sep 2021 10:43:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35128) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9La-0003SR-MM for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:23:42 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:33698) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9LY-0004qu-9n for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:23:42 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-305-6RGKKmbnPumDTWSfTJDAMA-1; Tue, 14 Sep 2021 10:23:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9BEE81084685; Tue, 14 Sep 2021 14:23:34 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 535C05D9CA; Tue, 14 Sep 2021 14:23:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629419; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=HvKtDY8hvhL+Mhb7T4tthhDY0w2UGu81fBbKj8Ukk/M=; b=hbAL62AgzNnhVRYWC7yZrmVtLMTSYmgXTuNIJXm9oNp74Mo0kDQgHQ0R5CPDMtbOxNqd3k 3rpxUHC5FOAAqU3bVt6I1z03bVrNaIzBZHieK8P0hEHDkeEDJ8k6peLYgNQqeWWwZHputQ 2vUAXQFtJHwjkoelOYjKCrO8molzss4= X-MC-Unique: 6RGKKmbnPumDTWSfTJDAMA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 09/53] target/avr: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:19:58 +0100 Message-Id: <20210914142042.1655100-10-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631630626784100003 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/avr/cpu.c | 57 ++++++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/target/avr/cpu.c b/target/avr/cpu.c index ea14175ca5..17ff21f8be 100644 --- a/target/avr/cpu.c +++ b/target/avr/cpu.c @@ -145,43 +145,44 @@ static ObjectClass *avr_cpu_class_by_name(const char = *cpu_model) return oc; } =20 -static void avr_cpu_dump_state(CPUState *cs, FILE *f, int flags) +static void avr_cpu_format_state(CPUState *cs, GString *buf, int flags) { AVRCPU *cpu =3D AVR_CPU(cs); CPUAVRState *env =3D &cpu->env; int i; =20 - qemu_fprintf(f, "\n"); - qemu_fprintf(f, "PC: %06x\n", env->pc_w * 2); /* PC points to words= */ - qemu_fprintf(f, "SP: %04x\n", env->sp); - qemu_fprintf(f, "rampD: %02x\n", env->rampD >> 16); - qemu_fprintf(f, "rampX: %02x\n", env->rampX >> 16); - qemu_fprintf(f, "rampY: %02x\n", env->rampY >> 16); - qemu_fprintf(f, "rampZ: %02x\n", env->rampZ >> 16); - qemu_fprintf(f, "EIND: %02x\n", env->eind >> 16); - qemu_fprintf(f, "X: %02x%02x\n", env->r[27], env->r[26]); - qemu_fprintf(f, "Y: %02x%02x\n", env->r[29], env->r[28]); - qemu_fprintf(f, "Z: %02x%02x\n", env->r[31], env->r[30]); - qemu_fprintf(f, "SREG: [ %c %c %c %c %c %c %c %c ]\n", - env->sregI ? 'I' : '-', - env->sregT ? 'T' : '-', - env->sregH ? 'H' : '-', - env->sregS ? 'S' : '-', - env->sregV ? 'V' : '-', - env->sregN ? '-' : 'N', /* Zf has negative logic */ - env->sregZ ? 'Z' : '-', - env->sregC ? 'I' : '-'); - qemu_fprintf(f, "SKIP: %02x\n", env->skip); - - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); + /* PC points to words */ + g_string_append_printf(buf, "PC: %06x\n", env->pc_w * 2); + g_string_append_printf(buf, "SP: %04x\n", env->sp); + g_string_append_printf(buf, "rampD: %02x\n", env->rampD >> 16); + g_string_append_printf(buf, "rampX: %02x\n", env->rampX >> 16); + g_string_append_printf(buf, "rampY: %02x\n", env->rampY >> 16); + g_string_append_printf(buf, "rampZ: %02x\n", env->rampZ >> 16); + g_string_append_printf(buf, "EIND: %02x\n", env->eind >> 16); + g_string_append_printf(buf, "X: %02x%02x\n", env->r[27], env->r[= 26]); + g_string_append_printf(buf, "Y: %02x%02x\n", env->r[29], env->r[= 28]); + g_string_append_printf(buf, "Z: %02x%02x\n", env->r[31], env->r[= 30]); + g_string_append_printf(buf, "SREG: [ %c %c %c %c %c %c %c %c ]\n", + env->sregI ? 'I' : '-', + env->sregT ? 'T' : '-', + env->sregH ? 'H' : '-', + env->sregS ? 'S' : '-', + env->sregV ? 'V' : '-', + env->sregN ? '-' : 'N', /* Zf has negative logi= c */ + env->sregZ ? 'Z' : '-', + env->sregC ? 'I' : '-'); + g_string_append_printf(buf, "SKIP: %02x\n", env->skip); + + g_string_append_printf(buf, "\n"); for (i =3D 0; i < ARRAY_SIZE(env->r); i++) { - qemu_fprintf(f, "R[%02d]: %02x ", i, env->r[i]); + g_string_append_printf(buf, "R[%02d]: %02x ", i, env->r[i]); =20 if ((i % 8) =3D=3D 7) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } =20 #include "hw/core/sysemu-cpu-ops.h" @@ -215,7 +216,7 @@ static void avr_cpu_class_init(ObjectClass *oc, void *d= ata) cc->class_by_name =3D avr_cpu_class_by_name; =20 cc->has_work =3D avr_cpu_has_work; - cc->dump_state =3D avr_cpu_dump_state; + cc->format_state =3D avr_cpu_format_state; cc->set_pc =3D avr_cpu_set_pc; cc->memory_rw_debug =3D avr_cpu_memory_rw_debug; dc->vmsd =3D &vms_avr_cpu; --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163163081000620.091709908708253; Tue, 14 Sep 2021 07:46:50 -0700 (PDT) Received: from localhost ([::1]:46552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9hw-0002o0-Sp for importer@patchew.org; Tue, 14 Sep 2021 10:46:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35268) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Ls-0004Yr-TP for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:24:00 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:54604) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Lr-00054M-1l for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:24:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-339-nOwsKEuIPtGuGn2e9YWnZw-1; Tue, 14 Sep 2021 10:23:57 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5172C801E72; Tue, 14 Sep 2021 14:23:53 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id F20AA5D9CA; Tue, 14 Sep 2021 14:23:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629438; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/ocCcBzbBdzil9FXe57cZVezF7Lyvm73oMJaNhuDio4=; b=R92HV/U91UpDUlCNLY3QmzjreDN9362QM9TuGDz2ewkNwgSwfHje7ZUah6rkDUfYGTtsdI Y5XoJlPYts93i93pzp9kPHop2Gi5evmJFPZ2s+TKY0D1/RFRaC/Q+YoVRyIrZCE0y0gvVB trp2/Ve5BZHzHabkZM/k8jdpEfwGi6I= X-MC-Unique: nOwsKEuIPtGuGn2e9YWnZw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 10/53] target/cris: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:19:59 +0100 Message-Id: <20210914142042.1655100-11-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631630811966100003 Signed-off-by: Daniel P. Berrang=C3=A9 --- target/cris/cpu.c | 2 +- target/cris/cpu.h | 2 +- target/cris/translate.c | 33 +++++++++++++++++---------------- 3 files changed, 19 insertions(+), 18 deletions(-) diff --git a/target/cris/cpu.c b/target/cris/cpu.c index 70932b1f8c..5159cf6528 100644 --- a/target/cris/cpu.c +++ b/target/cris/cpu.c @@ -295,7 +295,7 @@ static void cris_cpu_class_init(ObjectClass *oc, void *= data) =20 cc->class_by_name =3D cris_cpu_class_by_name; cc->has_work =3D cris_cpu_has_work; - cc->dump_state =3D cris_cpu_dump_state; + cc->format_state =3D cris_cpu_format_state; cc->set_pc =3D cris_cpu_set_pc; cc->gdb_read_register =3D cris_cpu_gdb_read_register; cc->gdb_write_register =3D cris_cpu_gdb_write_register; diff --git a/target/cris/cpu.h b/target/cris/cpu.h index d3b6492909..908cb051da 100644 --- a/target/cris/cpu.h +++ b/target/cris/cpu.h @@ -191,7 +191,7 @@ void cris_cpu_do_interrupt(CPUState *cpu); void crisv10_cpu_do_interrupt(CPUState *cpu); bool cris_cpu_exec_interrupt(CPUState *cpu, int int_req); =20 -void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags); +void cris_cpu_format_state(CPUState *cs, GString *buf, int flags); =20 hwaddr cris_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); =20 diff --git a/target/cris/translate.c b/target/cris/translate.c index a84b753349..6098693186 100644 --- a/target/cris/translate.c +++ b/target/cris/translate.c @@ -3307,7 +3307,7 @@ void gen_intermediate_code(CPUState *cs, TranslationB= lock *tb, int max_insns) translator_loop(&cris_tr_ops, &dc.base, cs, tb, max_insns); } =20 -void cris_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void cris_cpu_format_state(CPUState *cs, GString *buf, int flags) { CRISCPU *cpu =3D CRIS_CPU(cs); CPUCRISState *env =3D &cpu->env; @@ -3326,40 +3326,41 @@ void cris_cpu_dump_state(CPUState *cs, FILE *f, int= flags) regnames =3D regnames_v32; } =20 - qemu_fprintf(f, "PC=3D%x CCS=3D%x btaken=3D%d btarget=3D%x\n" - "cc_op=3D%d cc_src=3D%d cc_dest=3D%d cc_result=3D%x cc_ma= sk=3D%x\n", - env->pc, env->pregs[PR_CCS], env->btaken, env->btarget, - env->cc_op, - env->cc_src, env->cc_dest, env->cc_result, env->cc_mask); + g_string_append_printf(buf, "PC=3D%x CCS=3D%x btaken=3D%d btarget=3D%x= \n" + "cc_op=3D%d cc_src=3D%d cc_dest=3D%d cc_result= =3D%x " + "cc_mask=3D%x\n", + env->pc, env->pregs[PR_CCS], env->btaken, + env->btarget, env->cc_op, env->cc_src, + env->cc_dest, env->cc_result, env->cc_mask); =20 =20 for (i =3D 0; i < 16; i++) { - qemu_fprintf(f, "%s=3D%8.8x ", regnames[i], env->regs[i]); + g_string_append_printf(buf, "%s=3D%8.8x ", regnames[i], env->regs[= i]); if ((i + 1) % 4 =3D=3D 0) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } - qemu_fprintf(f, "\nspecial regs:\n"); + g_string_append_printf(buf, "\nspecial regs:\n"); for (i =3D 0; i < 16; i++) { - qemu_fprintf(f, "%s=3D%8.8x ", pregnames[i], env->pregs[i]); + g_string_append_printf(buf, "%s=3D%8.8x ", pregnames[i], env->preg= s[i]); if ((i + 1) % 4 =3D=3D 0) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } if (env->pregs[PR_VR] >=3D 32) { uint32_t srs =3D env->pregs[PR_SRS]; - qemu_fprintf(f, "\nsupport function regs bank %x:\n", srs); + g_string_append_printf(buf, "\nsupport function regs bank %x:\n", = srs); if (srs < ARRAY_SIZE(env->sregs)) { for (i =3D 0; i < 16; i++) { - qemu_fprintf(f, "s%2.2d=3D%8.8x ", - i, env->sregs[srs][i]); + g_string_append_printf(buf, "s%2.2d=3D%8.8x ", + i, env->sregs[srs][i]); if ((i + 1) % 4 =3D=3D 0) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } } } - qemu_fprintf(f, "\n\n"); + g_string_append_printf(buf, "\n\n"); =20 } =20 --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631630327052582.4084512296953; Tue, 14 Sep 2021 07:38:47 -0700 (PDT) Received: from localhost ([::1]:49040 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9a9-0001pK-UB for importer@patchew.org; Tue, 14 Sep 2021 10:38:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35536) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9MF-0005oM-AD for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:24:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22297) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9MC-0005IM-9M for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:24:23 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-424-T1Wd6paBM5W9Ez1ipBntEg-1; Tue, 14 Sep 2021 10:24:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A67BB1006AA4; Tue, 14 Sep 2021 14:24:14 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 992D55D9DC; Tue, 14 Sep 2021 14:23:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629459; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=m2c50X1HcjOI8LxDAAuTPtCdgQQQ4EI3QbjaNt6yV6Y=; b=J1FIAMq9P3vH6YogNozqUjKmnvpwBptIySdBJFRihBZH4YofpM42FPAT+AVBQDrqphG8Yq PA7Hp5MNNflO+zNPYqQ5zL63i979dFe9dt/3kWnrJSXIhTiUNB2T8h908gpKVP45Mj9842 FnlFhOtjA1tSIlc4o/x7LBNBpwfzmrI= X-MC-Unique: T1Wd6paBM5W9Ez1ipBntEg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 11/53] target/hexagon: delete unused hexagon_debug() method Date: Tue, 14 Sep 2021 15:20:00 +0100 Message-Id: <20210914142042.1655100-12-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631630328382100003 This method isn't used in any code and its functionality is already available via the 'info registers' HMP command. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Taylor Simpson --- target/hexagon/cpu.c | 5 ----- target/hexagon/internal.h | 1 - 2 files changed, 6 deletions(-) diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 3338365c16..14c628db7a 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -169,11 +169,6 @@ static void hexagon_dump_state(CPUState *cs, FILE *f, = int flags) hexagon_dump(env, f); } =20 -void hexagon_debug(CPUHexagonState *env) -{ - hexagon_dump(env, stdout); -} - static void hexagon_cpu_set_pc(CPUState *cs, vaddr value) { HexagonCPU *cpu =3D HEXAGON_CPU(cs); diff --git a/target/hexagon/internal.h b/target/hexagon/internal.h index 6b20affdfa..167e91026a 100644 --- a/target/hexagon/internal.h +++ b/target/hexagon/internal.h @@ -31,7 +31,6 @@ =20 int hexagon_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int hexagon_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); -void hexagon_debug(CPUHexagonState *env); =20 extern const char * const hexagon_regnames[TOTAL_PER_THREAD_REGS]; =20 --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631083911165.1814422734675; Tue, 14 Sep 2021 07:51:23 -0700 (PDT) Received: from localhost ([::1]:57144 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9mM-0001rc-SG for importer@patchew.org; Tue, 14 Sep 2021 10:51:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9MV-0006FE-La for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:24:44 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50400) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9ML-0005Qo-9q for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:24:39 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-434-ovBrFADYMLKm8tduxgsr8g-1; Tue, 14 Sep 2021 10:24:26 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9365D1084684; Tue, 14 Sep 2021 14:24:22 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B4F25D9CA; Tue, 14 Sep 2021 14:24:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=3YLRVW0oFoZglAlAy4KiGneoC45YXK+pcucpdSfC/k8=; b=PklRqdncCwLD4PMp13tUP1SLtoCG0zzmDQQYWXtAo7T4OGS1tapuGH1/7Cl+STMEAgxFyw LM0b/whF0rhTk+u657RzusUF42biDytTOEy7LTBI7z5A3hF8pSsfcp7OyR3hD5dEXLmG+j 3xYidYy3rjciN2jur/LIUiVbYtjF6+0= X-MC-Unique: ovBrFADYMLKm8tduxgsr8g-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 12/53] target/hexagon: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:01 +0100 Message-Id: <20210914142042.1655100-13-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631084670100003 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/hexagon/cpu.c | 65 ++++++++++++++++++++------------------------ 1 file changed, 29 insertions(+), 36 deletions(-) diff --git a/target/hexagon/cpu.c b/target/hexagon/cpu.c index 14c628db7a..7802186ad7 100644 --- a/target/hexagon/cpu.c +++ b/target/hexagon/cpu.c @@ -98,7 +98,7 @@ static target_ulong read_p3_0(CPUHexagonState *env) return control_reg; } =20 -static void print_reg(FILE *f, CPUHexagonState *env, int regnum) +static void format_reg(GString *buf, CPUHexagonState *env, int regnum) { target_ulong value; =20 @@ -109,13 +109,14 @@ static void print_reg(FILE *f, CPUHexagonState *env, = int regnum) : env->gpr[regnum]; } =20 - qemu_fprintf(f, " %s =3D 0x" TARGET_FMT_lx "\n", - hexagon_regnames[regnum], value); + g_string_append_printf(buf, " %s =3D 0x" TARGET_FMT_lx "\n", + hexagon_regnames[regnum], value); } =20 -static void hexagon_dump(CPUHexagonState *env, FILE *f) +static void hexagon_format_state(CPUState *cs, GString *buf, int flags) { - HexagonCPU *cpu =3D env_archcpu(env); + HexagonCPU *cpu =3D HEXAGON_CPU(cs); + CPUHexagonState *env =3D &cpu->env; =20 if (cpu->lldb_compat) { /* @@ -128,45 +129,37 @@ static void hexagon_dump(CPUHexagonState *env, FILE *= f) env->last_pc_dumped =3D env->gpr[HEX_REG_PC]; } =20 - qemu_fprintf(f, "General Purpose Registers =3D {\n"); + g_string_append_printf(buf, "General Purpose Registers =3D {\n"); for (int i =3D 0; i < 32; i++) { - print_reg(f, env, i); + format_reg(buf, env, i); } - print_reg(f, env, HEX_REG_SA0); - print_reg(f, env, HEX_REG_LC0); - print_reg(f, env, HEX_REG_SA1); - print_reg(f, env, HEX_REG_LC1); - print_reg(f, env, HEX_REG_M0); - print_reg(f, env, HEX_REG_M1); - print_reg(f, env, HEX_REG_USR); - print_reg(f, env, HEX_REG_P3_0); - print_reg(f, env, HEX_REG_GP); - print_reg(f, env, HEX_REG_UGP); - print_reg(f, env, HEX_REG_PC); + format_reg(buf, env, HEX_REG_SA0); + format_reg(buf, env, HEX_REG_LC0); + format_reg(buf, env, HEX_REG_SA1); + format_reg(buf, env, HEX_REG_LC1); + format_reg(buf, env, HEX_REG_M0); + format_reg(buf, env, HEX_REG_M1); + format_reg(buf, env, HEX_REG_USR); + format_reg(buf, env, HEX_REG_P3_0); + format_reg(buf, env, HEX_REG_GP); + format_reg(buf, env, HEX_REG_UGP); + format_reg(buf, env, HEX_REG_PC); #ifdef CONFIG_USER_ONLY /* * Not modelled in user mode, print junk to minimize the diff's * with LLDB output */ - qemu_fprintf(f, " cause =3D 0x000000db\n"); - qemu_fprintf(f, " badva =3D 0x00000000\n"); - qemu_fprintf(f, " cs0 =3D 0x00000000\n"); - qemu_fprintf(f, " cs1 =3D 0x00000000\n"); + g_string_append_printf(buf, " cause =3D 0x000000db\n"); + g_string_append_printf(buf, " badva =3D 0x00000000\n"); + g_string_append_printf(buf, " cs0 =3D 0x00000000\n"); + g_string_append_printf(buf, " cs1 =3D 0x00000000\n"); #else - print_reg(f, env, HEX_REG_CAUSE); - print_reg(f, env, HEX_REG_BADVA); - print_reg(f, env, HEX_REG_CS0); - print_reg(f, env, HEX_REG_CS1); + format_reg(buf, env, HEX_REG_CAUSE); + format_reg(buf, env, HEX_REG_BADVA); + format_reg(buf, env, HEX_REG_CS0); + format_reg(buf, env, HEX_REG_CS1); #endif - qemu_fprintf(f, "}\n"); -} - -static void hexagon_dump_state(CPUState *cs, FILE *f, int flags) -{ - HexagonCPU *cpu =3D HEXAGON_CPU(cs); - CPUHexagonState *env =3D &cpu->env; - - hexagon_dump(env, f); + g_string_append_printf(buf, "}\n"); } =20 static void hexagon_cpu_set_pc(CPUState *cs, vaddr value) @@ -283,7 +276,7 @@ static void hexagon_cpu_class_init(ObjectClass *c, void= *data) =20 cc->class_by_name =3D hexagon_cpu_class_by_name; cc->has_work =3D hexagon_cpu_has_work; - cc->dump_state =3D hexagon_dump_state; + cc->format_state =3D hexagon_format_state; cc->set_pc =3D hexagon_cpu_set_pc; cc->gdb_read_register =3D hexagon_gdb_read_register; cc->gdb_write_register =3D hexagon_gdb_write_register; --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16316312094251018.3563063235069; Tue, 14 Sep 2021 07:53:29 -0700 (PDT) Received: from localhost ([::1]:37968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9oO-0007t2-7m for importer@patchew.org; Tue, 14 Sep 2021 10:53:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36250) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Mg-0006Vu-AC for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:24:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:38340) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Mc-0005dH-RG for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:24:49 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-247-KzG8qg-VPpene3i-haubDA-1; Tue, 14 Sep 2021 10:24:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 30EE5108468A; Tue, 14 Sep 2021 14:24:41 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id D96745D9CA; Tue, 14 Sep 2021 14:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629486; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=LoFfr8g3FSNNy3L4uDE/+m5DtUq3ewlCSsUT+QmYgig=; b=IHw/n3xZ+bQ2/p8YmShoiSN5Qhjfrl5QHQJMtzkRxAZj6/yJBdhZ2BeY8M1gUMHzda0tN4 or6nCaSyRBpgPazQf0gXr6VDZKpU0xnrCp8hd+Jmyt1phEqKOS/XXYycXpI+r/yXyNx2Iw 2ic+H+Ex+o0bkk7QSd2XTTkexJoy6hk= X-MC-Unique: KzG8qg-VPpene3i-haubDA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 13/53] target/hppa: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:02 +0100 Message-Id: <20210914142042.1655100-14-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631210742100001 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/hppa/cpu.c | 2 +- target/hppa/cpu.h | 2 +- target/hppa/helper.c | 25 ++++++++++++++----------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/target/hppa/cpu.c b/target/hppa/cpu.c index 2eace4ee12..f7fe7c49d6 100644 --- a/target/hppa/cpu.c +++ b/target/hppa/cpu.c @@ -164,7 +164,7 @@ static void hppa_cpu_class_init(ObjectClass *oc, void *= data) =20 cc->class_by_name =3D hppa_cpu_class_by_name; cc->has_work =3D hppa_cpu_has_work; - cc->dump_state =3D hppa_cpu_dump_state; + cc->format_state =3D hppa_cpu_format_state; cc->set_pc =3D hppa_cpu_set_pc; cc->gdb_read_register =3D hppa_cpu_gdb_read_register; cc->gdb_write_register =3D hppa_cpu_gdb_write_register; diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h index 748270bfa3..d4f1922545 100644 --- a/target/hppa/cpu.h +++ b/target/hppa/cpu.h @@ -327,7 +327,7 @@ int hppa_cpu_gdb_read_register(CPUState *cpu, GByteArra= y *buf, int reg); int hppa_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); void hppa_cpu_do_interrupt(CPUState *cpu); bool hppa_cpu_exec_interrupt(CPUState *cpu, int int_req); -void hppa_cpu_dump_state(CPUState *cs, FILE *f, int); +void hppa_cpu_format_state(CPUState *cs, GString *buf, int); bool hppa_cpu_tlb_fill(CPUState *cs, vaddr address, int size, MMUAccessType access_type, int mmu_idx, bool probe, uintptr_t retaddr); diff --git a/target/hppa/helper.c b/target/hppa/helper.c index 1ccff5765a..6e30d1ea63 100644 --- a/target/hppa/helper.c +++ b/target/hppa/helper.c @@ -76,7 +76,7 @@ void cpu_hppa_put_psw(CPUHPPAState *env, target_ureg psw) } } =20 -void hppa_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void hppa_cpu_format_state(CPUState *cs, GString *buf, int flags) { HPPACPU *cpu =3D HPPA_CPU(cs); CPUHPPAState *env =3D &cpu->env; @@ -85,9 +85,10 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f, int flag= s) char psw_c[20]; int i; =20 - qemu_fprintf(f, "IA_F " TARGET_FMT_lx " IA_B " TARGET_FMT_lx "\n", - hppa_form_gva_psw(psw, env->iasq_f, env->iaoq_f), - hppa_form_gva_psw(psw, env->iasq_b, env->iaoq_b)); + g_string_append_printf(buf, + "IA_F " TARGET_FMT_lx " IA_B " TARGET_FMT_lx "\= n", + hppa_form_gva_psw(psw, env->iasq_f, env->iaoq_f= ), + hppa_form_gva_psw(psw, env->iasq_b, env->iaoq_b= )); =20 psw_c[0] =3D (psw & PSW_W ? 'W' : '-'); psw_c[1] =3D (psw & PSW_E ? 'E' : '-'); @@ -110,20 +111,22 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f, int f= lags) psw_c[18] =3D '\0'; psw_cb =3D ((env->psw_cb >> 4) & 0x01111111) | (env->psw_cb_msb << 28); =20 - qemu_fprintf(f, "PSW " TREG_FMT_lx " CB " TREG_FMT_lx " %s\n", - psw, psw_cb, psw_c); + g_string_append_printf(buf, + "PSW " TREG_FMT_lx " CB " TREG_FMT_lx " %s\n= ", + psw, psw_cb, psw_c); =20 for (i =3D 0; i < 32; i++) { - qemu_fprintf(f, "GR%02d " TREG_FMT_lx "%c", i, env->gr[i], - (i & 3) =3D=3D 3 ? '\n' : ' '); + g_string_append_printf(buf, "GR%02d " TREG_FMT_lx "%c", i, env->gr= [i], + (i & 3) =3D=3D 3 ? '\n' : ' '); } #ifndef CONFIG_USER_ONLY for (i =3D 0; i < 8; i++) { - qemu_fprintf(f, "SR%02d %08x%c", i, (uint32_t)(env->sr[i] >> 32), - (i & 3) =3D=3D 3 ? '\n' : ' '); + g_string_append_printf(buf, + "SR%02d %08x%c", i, (uint32_t)(env->sr[i] >= > 32), + (i & 3) =3D=3D 3 ? '\n' : ' '); } #endif - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); =20 /* ??? FR */ } --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631434282415.3999411474456; Tue, 14 Sep 2021 07:57:14 -0700 (PDT) Received: from localhost ([::1]:48732 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9s1-0006ip-3H for importer@patchew.org; Tue, 14 Sep 2021 10:57:13 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36496) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9N2-000776-F1 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:25:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:46884) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Mn-0005kA-JM for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:25:12 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-254-MrNtF9xJPK-y6cwJVlSduA-1; Tue, 14 Sep 2021 10:24:52 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3496618414A0; Tue, 14 Sep 2021 14:24:49 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7B13C5D9DC; Tue, 14 Sep 2021 14:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629494; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6tT/Mro5QGD8I47bCN3lXcYKjcM82mfNp3b6QdQPGv4=; b=QfAak+L3wEczMjZyZ3Go7c/VaKhhk15FkxbhcailNl6ENY1WD8Q+/QEHy+WZeDZSCX/WfS y+pwWuVIB8g9375NnzJfAMlLc5uKUSKr9Yy4K7kRRL9N58YFEmPwiTH+nMaFn3LdQwnlmB 4l4HCefueO8lYK9wKJhtPAAVkJrbunk= X-MC-Unique: MrNtF9xJPK-y6cwJVlSduA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 14/53] target/i386: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:03 +0100 Message-Id: <20210914142042.1655100-15-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631436149100003 Signed-off-by: Daniel P. Berrang=C3=A9 --- target/i386/cpu-dump.c | 328 ++++++++++++++++++++++------------------- target/i386/cpu.c | 2 +- target/i386/cpu.h | 2 +- 3 files changed, 177 insertions(+), 155 deletions(-) diff --git a/target/i386/cpu-dump.c b/target/i386/cpu-dump.c index 02b635a52c..f30fbcb76e 100644 --- a/target/i386/cpu-dump.c +++ b/target/i386/cpu-dump.c @@ -94,41 +94,46 @@ static const char *cc_op_str[CC_OP_NB] =3D { }; =20 static void -cpu_x86_dump_seg_cache(CPUX86State *env, FILE *f, +cpu_x86_dump_seg_cache(CPUX86State *env, GString *buf, const char *name, struct SegmentCache *sc) { #ifdef TARGET_X86_64 if (env->hflags & HF_CS64_MASK) { - qemu_fprintf(f, "%-3s=3D%04x %016" PRIx64 " %08x %08x", name, - sc->selector, sc->base, sc->limit, - sc->flags & 0x00ffff00); + g_string_append_printf(buf, "%-3s=3D%04x %016" PRIx64 " %08x %08x"= , name, + sc->selector, sc->base, sc->limit, + sc->flags & 0x00ffff00); } else #endif { - qemu_fprintf(f, "%-3s=3D%04x %08x %08x %08x", name, sc->selector, - (uint32_t)sc->base, sc->limit, - sc->flags & 0x00ffff00); + g_string_append_printf(buf, "%-3s=3D%04x %08x %08x %08x", + name, sc->selector, + (uint32_t)sc->base, sc->limit, + sc->flags & 0x00ffff00); } =20 if (!(env->hflags & HF_PE_MASK) || !(sc->flags & DESC_P_MASK)) goto done; =20 - qemu_fprintf(f, " DPL=3D%d ", + g_string_append_printf(buf, " DPL=3D%d ", (sc->flags & DESC_DPL_MASK) >> DESC_DPL_SHIFT); if (sc->flags & DESC_S_MASK) { if (sc->flags & DESC_CS_MASK) { - qemu_fprintf(f, (sc->flags & DESC_L_MASK) ? "CS64" : - ((sc->flags & DESC_B_MASK) ? "CS32" : "CS16")); - qemu_fprintf(f, " [%c%c", (sc->flags & DESC_C_MASK) ? 'C' : '-= ', - (sc->flags & DESC_R_MASK) ? 'R' : '-'); + g_string_append_printf(buf, (sc->flags & DESC_L_MASK) ? "CS64"= : + ((sc->flags & DESC_B_MASK) ? + "CS32" : "CS16")); + g_string_append_printf(buf, " [%c%c", + (sc->flags & DESC_C_MASK) ? 'C' : '-', + (sc->flags & DESC_R_MASK) ? 'R' : '-'); } else { - qemu_fprintf(f, (sc->flags & DESC_B_MASK + g_string_append_printf(buf, (sc->flags & DESC_B_MASK || env->hflags & HF_LMA_MASK) ? "DS " : "DS16"); - qemu_fprintf(f, " [%c%c", (sc->flags & DESC_E_MASK) ? 'E' : '-= ', - (sc->flags & DESC_W_MASK) ? 'W' : '-'); + g_string_append_printf(buf, " [%c%c", + (sc->flags & DESC_E_MASK) ? 'E' : '-', + (sc->flags & DESC_W_MASK) ? 'W' : '-'); } - qemu_fprintf(f, "%c]", (sc->flags & DESC_A_MASK) ? 'A' : '-'); + g_string_append_printf(buf, "%c]", + (sc->flags & DESC_A_MASK) ? 'A' : '-'); } else { static const char *sys_type_name[2][16] =3D { { /* 32 bit mode */ @@ -144,12 +149,14 @@ cpu_x86_dump_seg_cache(CPUX86State *env, FILE *f, "Reserved", "IntGate64", "TrapGate64" } }; - qemu_fprintf(f, "%s", - sys_type_name[(env->hflags & HF_LMA_MASK) ? 1 : 0] - [(sc->flags & DESC_TYPE_MASK) >> DESC_TYPE_SHIFT]); + g_string_append_printf(buf, "%s", + sys_type_name[(env->hflags & HF_LMA_MASK) + ? 1 : 0] + [(sc->flags & DESC_TYPE_MASK) >> + DESC_TYPE_SHIFT]); } done: - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } =20 #ifndef CONFIG_USER_ONLY @@ -344,7 +351,7 @@ void x86_cpu_dump_local_apic_state(CPUState *cs, int fl= ags) #define DUMP_CODE_BYTES_TOTAL 50 #define DUMP_CODE_BYTES_BACKWARD 20 =20 -void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void x86_cpu_format_state(CPUState *cs, GString *buf, int flags) { X86CPU *cpu =3D X86_CPU(cs); CPUX86State *env =3D &cpu->env; @@ -355,107 +362,116 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int = flags) eflags =3D cpu_compute_eflags(env); #ifdef TARGET_X86_64 if (env->hflags & HF_CS64_MASK) { - qemu_fprintf(f, "RAX=3D%016" PRIx64 " RBX=3D%016" PRIx64 " RCX=3D%= 016" PRIx64 " RDX=3D%016" PRIx64 "\n" - "RSI=3D%016" PRIx64 " RDI=3D%016" PRIx64 " RBP=3D%016= " PRIx64 " RSP=3D%016" PRIx64 "\n" - "R8 =3D%016" PRIx64 " R9 =3D%016" PRIx64 " R10=3D%016= " PRIx64 " R11=3D%016" PRIx64 "\n" - "R12=3D%016" PRIx64 " R13=3D%016" PRIx64 " R14=3D%016= " PRIx64 " R15=3D%016" PRIx64 "\n" - "RIP=3D%016" PRIx64 " RFL=3D%08x [%c%c%c%c%c%c%c] CPL= =3D%d II=3D%d A20=3D%d SMM=3D%d HLT=3D%d\n", - env->regs[R_EAX], - env->regs[R_EBX], - env->regs[R_ECX], - env->regs[R_EDX], - env->regs[R_ESI], - env->regs[R_EDI], - env->regs[R_EBP], - env->regs[R_ESP], - env->regs[8], - env->regs[9], - env->regs[10], - env->regs[11], - env->regs[12], - env->regs[13], - env->regs[14], - env->regs[15], - env->eip, eflags, - eflags & DF_MASK ? 'D' : '-', - eflags & CC_O ? 'O' : '-', - eflags & CC_S ? 'S' : '-', - eflags & CC_Z ? 'Z' : '-', - eflags & CC_A ? 'A' : '-', - eflags & CC_P ? 'P' : '-', - eflags & CC_C ? 'C' : '-', - env->hflags & HF_CPL_MASK, - (env->hflags >> HF_INHIBIT_IRQ_SHIFT) & 1, - (env->a20_mask >> 20) & 1, - (env->hflags >> HF_SMM_SHIFT) & 1, - cs->halted); + g_string_append_printf(buf, "RAX=3D%016" PRIx64 " RBX=3D%016" PRIx= 64 + " RCX=3D%016" PRIx64 " RDX=3D%016" PRIx64 "= \n" + "RSI=3D%016" PRIx64 " RDI=3D%016" PRIx64 + " RBP=3D%016" PRIx64 " RSP=3D%016" PRIx64 "= \n" + "R8 =3D%016" PRIx64 " R9 =3D%016" PRIx64 + " R10=3D%016" PRIx64 " R11=3D%016" PRIx64 "= \n" + "R12=3D%016" PRIx64 " R13=3D%016" PRIx64 + " R14=3D%016" PRIx64 " R15=3D%016" PRIx64 "= \n" + "RIP=3D%016" PRIx64 " RFL=3D%08x [%c%c%c%c%= c%c%c] " + "CPL=3D%d II=3D%d A20=3D%d SMM=3D%d HLT=3D%= d\n", + env->regs[R_EAX], + env->regs[R_EBX], + env->regs[R_ECX], + env->regs[R_EDX], + env->regs[R_ESI], + env->regs[R_EDI], + env->regs[R_EBP], + env->regs[R_ESP], + env->regs[8], + env->regs[9], + env->regs[10], + env->regs[11], + env->regs[12], + env->regs[13], + env->regs[14], + env->regs[15], + env->eip, eflags, + eflags & DF_MASK ? 'D' : '-', + eflags & CC_O ? 'O' : '-', + eflags & CC_S ? 'S' : '-', + eflags & CC_Z ? 'Z' : '-', + eflags & CC_A ? 'A' : '-', + eflags & CC_P ? 'P' : '-', + eflags & CC_C ? 'C' : '-', + env->hflags & HF_CPL_MASK, + (env->hflags >> HF_INHIBIT_IRQ_SHIFT) & 1, + (env->a20_mask >> 20) & 1, + (env->hflags >> HF_SMM_SHIFT) & 1, + cs->halted); } else #endif { - qemu_fprintf(f, "EAX=3D%08x EBX=3D%08x ECX=3D%08x EDX=3D%08x\n" - "ESI=3D%08x EDI=3D%08x EBP=3D%08x ESP=3D%08x\n" - "EIP=3D%08x EFL=3D%08x [%c%c%c%c%c%c%c] CPL=3D%d II= =3D%d A20=3D%d SMM=3D%d HLT=3D%d\n", - (uint32_t)env->regs[R_EAX], - (uint32_t)env->regs[R_EBX], - (uint32_t)env->regs[R_ECX], - (uint32_t)env->regs[R_EDX], - (uint32_t)env->regs[R_ESI], - (uint32_t)env->regs[R_EDI], - (uint32_t)env->regs[R_EBP], - (uint32_t)env->regs[R_ESP], - (uint32_t)env->eip, eflags, - eflags & DF_MASK ? 'D' : '-', - eflags & CC_O ? 'O' : '-', - eflags & CC_S ? 'S' : '-', - eflags & CC_Z ? 'Z' : '-', - eflags & CC_A ? 'A' : '-', - eflags & CC_P ? 'P' : '-', - eflags & CC_C ? 'C' : '-', - env->hflags & HF_CPL_MASK, - (env->hflags >> HF_INHIBIT_IRQ_SHIFT) & 1, - (env->a20_mask >> 20) & 1, - (env->hflags >> HF_SMM_SHIFT) & 1, - cs->halted); + g_string_append_printf(buf, "EAX=3D%08x EBX=3D%08x ECX=3D%08x EDX= =3D%08x\n" + "ESI=3D%08x EDI=3D%08x EBP=3D%08x ESP=3D%08= x\n" + "EIP=3D%08x EFL=3D%08x [%c%c%c%c%c%c%c] " + "CPL=3D%d II=3D%d A20=3D%d SMM=3D%d HLT=3D%= d\n", + (uint32_t)env->regs[R_EAX], + (uint32_t)env->regs[R_EBX], + (uint32_t)env->regs[R_ECX], + (uint32_t)env->regs[R_EDX], + (uint32_t)env->regs[R_ESI], + (uint32_t)env->regs[R_EDI], + (uint32_t)env->regs[R_EBP], + (uint32_t)env->regs[R_ESP], + (uint32_t)env->eip, eflags, + eflags & DF_MASK ? 'D' : '-', + eflags & CC_O ? 'O' : '-', + eflags & CC_S ? 'S' : '-', + eflags & CC_Z ? 'Z' : '-', + eflags & CC_A ? 'A' : '-', + eflags & CC_P ? 'P' : '-', + eflags & CC_C ? 'C' : '-', + env->hflags & HF_CPL_MASK, + (env->hflags >> HF_INHIBIT_IRQ_SHIFT) & 1, + (env->a20_mask >> 20) & 1, + (env->hflags >> HF_SMM_SHIFT) & 1, + cs->halted); } =20 for(i =3D 0; i < 6; i++) { - cpu_x86_dump_seg_cache(env, f, seg_name[i], &env->segs[i]); + cpu_x86_dump_seg_cache(env, buf, seg_name[i], &env->segs[i]); } - cpu_x86_dump_seg_cache(env, f, "LDT", &env->ldt); - cpu_x86_dump_seg_cache(env, f, "TR", &env->tr); + cpu_x86_dump_seg_cache(env, buf, "LDT", &env->ldt); + cpu_x86_dump_seg_cache(env, buf, "TR", &env->tr); =20 #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) { - qemu_fprintf(f, "GDT=3D %016" PRIx64 " %08x\n", - env->gdt.base, env->gdt.limit); - qemu_fprintf(f, "IDT=3D %016" PRIx64 " %08x\n", - env->idt.base, env->idt.limit); - qemu_fprintf(f, "CR0=3D%08x CR2=3D%016" PRIx64 " CR3=3D%016" PRIx6= 4 " CR4=3D%08x\n", - (uint32_t)env->cr[0], - env->cr[2], - env->cr[3], - (uint32_t)env->cr[4]); + g_string_append_printf(buf, "GDT=3D %016" PRIx64 " %08x\n", + env->gdt.base, env->gdt.limit); + g_string_append_printf(buf, "IDT=3D %016" PRIx64 " %08x\n", + env->idt.base, env->idt.limit); + g_string_append_printf(buf, "CR0=3D%08x CR2=3D%016" PRIx64 + " CR3=3D%016" PRIx64 " CR4=3D%08x\n", + (uint32_t)env->cr[0], + env->cr[2], + env->cr[3], + (uint32_t)env->cr[4]); for(i =3D 0; i < 4; i++) - qemu_fprintf(f, "DR%d=3D%016" PRIx64 " ", i, env->dr[i]); - qemu_fprintf(f, "\nDR6=3D%016" PRIx64 " DR7=3D%016" PRIx64 "\n", - env->dr[6], env->dr[7]); + g_string_append_printf(buf, "DR%d=3D%016" PRIx64 " ", i, env->= dr[i]); + g_string_append_printf(buf, "\nDR6=3D%016" PRIx64 " DR7=3D%016" PR= Ix64 "\n", + env->dr[6], env->dr[7]); } else #endif { - qemu_fprintf(f, "GDT=3D %08x %08x\n", - (uint32_t)env->gdt.base, env->gdt.limit); - qemu_fprintf(f, "IDT=3D %08x %08x\n", - (uint32_t)env->idt.base, env->idt.limit); - qemu_fprintf(f, "CR0=3D%08x CR2=3D%08x CR3=3D%08x CR4=3D%08x\n", - (uint32_t)env->cr[0], - (uint32_t)env->cr[2], - (uint32_t)env->cr[3], - (uint32_t)env->cr[4]); + g_string_append_printf(buf, "GDT=3D %08x %08x\n", + (uint32_t)env->gdt.base, env->gdt.limit); + g_string_append_printf(buf, "IDT=3D %08x %08x\n", + (uint32_t)env->idt.base, env->idt.limit); + g_string_append_printf(buf, "CR0=3D%08x CR2=3D%08x CR3=3D%08x CR4= =3D%08x\n", + (uint32_t)env->cr[0], + (uint32_t)env->cr[2], + (uint32_t)env->cr[3], + (uint32_t)env->cr[4]); for(i =3D 0; i < 4; i++) { - qemu_fprintf(f, "DR%d=3D" TARGET_FMT_lx " ", i, env->dr[i]); + g_string_append_printf(buf, "DR%d=3D" TARGET_FMT_lx + " ", i, env->dr[i]); } - qemu_fprintf(f, "\nDR6=3D" TARGET_FMT_lx " DR7=3D" TARGET_FMT_lx "= \n", - env->dr[6], env->dr[7]); + g_string_append_printf(buf, "\nDR6=3D" TARGET_FMT_lx + " DR7=3D" TARGET_FMT_lx "\n", + env->dr[6], env->dr[7]); } if (flags & CPU_DUMP_CCOP) { if ((unsigned)env->cc_op < CC_OP_NB) @@ -464,18 +480,19 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int fl= ags) snprintf(cc_op_name, sizeof(cc_op_name), "[%d]", env->cc_op); #ifdef TARGET_X86_64 if (env->hflags & HF_CS64_MASK) { - qemu_fprintf(f, "CCS=3D%016" PRIx64 " CCD=3D%016" PRIx64 " CCO= =3D%-8s\n", - env->cc_src, env->cc_dst, - cc_op_name); + g_string_append_printf(buf, "CCS=3D%016" PRIx64 + " CCD=3D%016" PRIx64 " CCO=3D%-8s\n", + env->cc_src, env->cc_dst, + cc_op_name); } else #endif { - qemu_fprintf(f, "CCS=3D%08x CCD=3D%08x CCO=3D%-8s\n", - (uint32_t)env->cc_src, (uint32_t)env->cc_dst, - cc_op_name); + g_string_append_printf(buf, "CCS=3D%08x CCD=3D%08x CCO=3D%-8s\= n", + (uint32_t)env->cc_src, (uint32_t)env->c= c_dst, + cc_op_name); } } - qemu_fprintf(f, "EFER=3D%016" PRIx64 "\n", env->efer); + g_string_append_printf(buf, "EFER=3D%016" PRIx64 "\n", env->efer); if (flags & CPU_DUMP_FPU) { int fptag; const uint64_t avx512_mask =3D XSTATE_OPMASK_MASK | \ @@ -488,64 +505,68 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int fl= ags) fptag |=3D ((!env->fptags[i]) << i); } update_mxcsr_from_sse_status(env); - qemu_fprintf(f, "FCW=3D%04x FSW=3D%04x [ST=3D%d] FTW=3D%02x MXCSR= =3D%08x\n", - env->fpuc, - (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11, - env->fpstt, - fptag, - env->mxcsr); + g_string_append_printf( + buf, "FCW=3D%04x FSW=3D%04x [ST=3D%d] FTW=3D%02x MXCSR=3D%08x\= n", + env->fpuc, + (env->fpus & ~0x3800) | (env->fpstt & 0x7) << 11, + env->fpstt, + fptag, + env->mxcsr); for(i=3D0;i<8;i++) { CPU_LDoubleU u; u.d =3D env->fpregs[i].d; - qemu_fprintf(f, "FPR%d=3D%016" PRIx64 " %04x", - i, u.l.lower, u.l.upper); + g_string_append_printf(buf, "FPR%d=3D%016" PRIx64 " %04x", + i, u.l.lower, u.l.upper); if ((i & 1) =3D=3D 1) - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); else - qemu_fprintf(f, " "); + g_string_append_printf(buf, " "); } - if ((env->xcr0 & avx512_mask) =3D=3D avx512_mask) { /* XSAVE enabled AVX512 */ for (i =3D 0; i < NB_OPMASK_REGS; i++) { - qemu_fprintf(f, "Opmask%02d=3D%016"PRIx64"%s", i, - env->opmask_regs[i], ((i & 3) =3D=3D 3) ? "\n= " : " "); + g_string_append_printf(buf, "Opmask%02d=3D%016"PRIx64"%s",= i, + env->opmask_regs[i], + ((i & 3) =3D=3D 3) ? "\n" : " "); } =20 nb =3D (env->hflags & HF_CS64_MASK) ? 32 : 8; for (i =3D 0; i < nb; i++) { - qemu_fprintf(f, "ZMM%02d=3D%016"PRIx64" %016"PRIx64" %016"= PRIx64 - " %016"PRIx64" %016"PRIx64" %016"PRIx64 - " %016"PRIx64" %016"PRIx64"\n", - i, - env->xmm_regs[i].ZMM_Q(7), - env->xmm_regs[i].ZMM_Q(6), - env->xmm_regs[i].ZMM_Q(5), - env->xmm_regs[i].ZMM_Q(4), - env->xmm_regs[i].ZMM_Q(3), - env->xmm_regs[i].ZMM_Q(2), - env->xmm_regs[i].ZMM_Q(1), - env->xmm_regs[i].ZMM_Q(0)); + g_string_append_printf(buf, "ZMM%02d=3D%016"PRIx64 + " %016"PRIx64" %016"PRIx64 + " %016"PRIx64" %016"PRIx64" %016"PR= Ix64 + " %016"PRIx64" %016"PRIx64"\n", + i, + env->xmm_regs[i].ZMM_Q(7), + env->xmm_regs[i].ZMM_Q(6), + env->xmm_regs[i].ZMM_Q(5), + env->xmm_regs[i].ZMM_Q(4), + env->xmm_regs[i].ZMM_Q(3), + env->xmm_regs[i].ZMM_Q(2), + env->xmm_regs[i].ZMM_Q(1), + env->xmm_regs[i].ZMM_Q(0)); } } else if ((env->xcr0 & avx_mask) =3D=3D avx_mask) { /* XSAVE enabled AVX */ nb =3D env->hflags & HF_CS64_MASK ? 16 : 8; for (i =3D 0; i < nb; i++) { - qemu_fprintf(f, "YMM%02d=3D%016"PRIx64" %016"PRIx64" %016"= PRIx64 - " %016"PRIx64"\n", i, - env->xmm_regs[i].ZMM_Q(3), - env->xmm_regs[i].ZMM_Q(2), - env->xmm_regs[i].ZMM_Q(1), - env->xmm_regs[i].ZMM_Q(0)); + g_string_append_printf(buf, "YMM%02d=3D%016"PRIx64 + " %016"PRIx64" %016"PRIx64 + " %016"PRIx64"\n", i, + env->xmm_regs[i].ZMM_Q(3), + env->xmm_regs[i].ZMM_Q(2), + env->xmm_regs[i].ZMM_Q(1), + env->xmm_regs[i].ZMM_Q(0)); } } else { /* SSE and below cases */ nb =3D env->hflags & HF_CS64_MASK ? 16 : 8; for (i =3D 0; i < nb; i++) { - qemu_fprintf(f, "XMM%02d=3D%016"PRIx64" %016"PRIx64"%s", - i, - env->xmm_regs[i].ZMM_Q(1), - env->xmm_regs[i].ZMM_Q(0), - (i & 1) ? "\n" : " "); + g_string_append_printf(buf, + "XMM%02d=3D%016"PRIx64" %016"PRIx64= "%s", + i, + env->xmm_regs[i].ZMM_Q(1), + env->xmm_regs[i].ZMM_Q(0), + (i & 1) ? "\n" : " "); } } } @@ -555,16 +576,17 @@ void x86_cpu_dump_state(CPUState *cs, FILE *f, int fl= ags) uint8_t code; char codestr[3]; =20 - qemu_fprintf(f, "Code=3D"); + g_string_append_printf(buf, "Code=3D"); for (i =3D 0; i < DUMP_CODE_BYTES_TOTAL; i++) { if (cpu_memory_rw_debug(cs, base - offs + i, &code, 1, 0) =3D= =3D 0) { snprintf(codestr, sizeof(codestr), "%02x", code); } else { snprintf(codestr, sizeof(codestr), "??"); } - qemu_fprintf(f, "%s%s%s%s", i > 0 ? " " : "", - i =3D=3D offs ? "<" : "", codestr, i =3D=3D offs = ? ">" : ""); + g_string_append_printf(buf, "%s%s%s%s", i > 0 ? " " : "", + i =3D=3D offs ? "<" : "", codestr, + i =3D=3D offs ? ">" : ""); } - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 6b029f1bdf..0a5c6a6d19 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6764,7 +6764,7 @@ static void x86_cpu_common_class_init(ObjectClass *oc= , void *data) cc->class_by_name =3D x86_cpu_class_by_name; cc->parse_features =3D x86_cpu_parse_featurestr; cc->has_work =3D x86_cpu_has_work; - cc->dump_state =3D x86_cpu_dump_state; + cc->format_state =3D x86_cpu_format_state; cc->set_pc =3D x86_cpu_set_pc; cc->gdb_read_register =3D x86_cpu_gdb_read_register; cc->gdb_write_register =3D x86_cpu_gdb_write_register; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 71ae3141c3..d87c8808f6 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1825,7 +1825,7 @@ int x86_cpu_write_elf32_qemunote(WriteCoreDumpFunctio= n f, CPUState *cpu, void x86_cpu_get_memory_mapping(CPUState *cpu, MemoryMappingList *list, Error **errp); =20 -void x86_cpu_dump_state(CPUState *cs, FILE *f, int flags); +void x86_cpu_format_state(CPUState *cs, GString *buf, int flags); =20 hwaddr x86_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, MemTxAttrs *attrs); --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631622484721.0801469685009; Tue, 14 Sep 2021 08:00:22 -0700 (PDT) Received: from localhost ([::1]:58044 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9v3-0004TL-97 for importer@patchew.org; Tue, 14 Sep 2021 11:00:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9NS-0007W9-7f for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:25:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24155) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9NE-00061O-I9 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:25:30 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-271-ydjNEARUNZyS4vhl78Z43A-1; Tue, 14 Sep 2021 10:25:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D1AED1084683; Tue, 14 Sep 2021 14:25:08 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 847075D9CA; Tue, 14 Sep 2021 14:24:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629516; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Ww655eJbEg/cuPv+OHOIWZs3b/eFx6RhHXXaU4f3zoo=; b=aTXS9Pxv8KjSvcHRa1nAEiet+rdn0UOlKhSWPgABksuaIKjsAO1Tcxb9eLMUymaodHC/Ih IQRF5fl/vLPtmAZW/15AV0mmyFJT4QDz5pWcZ/MATAKrOXg1Jy3X1/qsu9qlRjxyzdaKrP wFtrCRAXmL00dByxtTX6dPSJ4+vUnVI= X-MC-Unique: ydjNEARUNZyS4vhl78Z43A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 15/53] target/m68k: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:04 +0100 Message-Id: <20210914142042.1655100-16-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631639534100001 Signed-off-by: Daniel P. Berrang=C3=A9 Acked-by: Laurent Vivier Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/m68k/cpu.c | 2 +- target/m68k/cpu.h | 2 +- target/m68k/translate.c | 92 ++++++++++++++++++++++------------------- 3 files changed, 51 insertions(+), 45 deletions(-) diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 72de6e9726..4ccf572a68 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -536,7 +536,7 @@ static void m68k_cpu_class_init(ObjectClass *c, void *d= ata) =20 cc->class_by_name =3D m68k_cpu_class_by_name; cc->has_work =3D m68k_cpu_has_work; - cc->dump_state =3D m68k_cpu_dump_state; + cc->format_state =3D m68k_cpu_format_state; cc->set_pc =3D m68k_cpu_set_pc; cc->gdb_read_register =3D m68k_cpu_gdb_read_register; cc->gdb_write_register =3D m68k_cpu_gdb_write_register; diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index 997d588911..b0641f6d0d 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -168,7 +168,7 @@ struct M68kCPU { =20 void m68k_cpu_do_interrupt(CPUState *cpu); bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_req); -void m68k_cpu_dump_state(CPUState *cpu, FILE *f, int flags); +void m68k_cpu_format_state(CPUState *cpu, GString *buf, int flags); hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/m68k/translate.c b/target/m68k/translate.c index c34d9aed61..951bbed6bf 100644 --- a/target/m68k/translate.c +++ b/target/m68k/translate.c @@ -6316,75 +6316,81 @@ static double floatx80_to_double(CPUM68KState *env,= uint16_t high, uint64_t low) return u.d; } =20 -void m68k_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void m68k_cpu_format_state(CPUState *cs, GString *buf, int flags) { M68kCPU *cpu =3D M68K_CPU(cs); CPUM68KState *env =3D &cpu->env; int i; uint16_t sr; for (i =3D 0; i < 8; i++) { - qemu_fprintf(f, "D%d =3D %08x A%d =3D %08x " - "F%d =3D %04x %016"PRIx64" (%12g)\n", - i, env->dregs[i], i, env->aregs[i], - i, env->fregs[i].l.upper, env->fregs[i].l.lower, - floatx80_to_double(env, env->fregs[i].l.upper, - env->fregs[i].l.lower)); - } - qemu_fprintf(f, "PC =3D %08x ", env->pc); + g_string_append_printf(buf, "D%d =3D %08x A%d =3D %08x " + "F%d =3D %04x %016"PRIx64" (%12g)\n", + i, env->dregs[i], i, env->aregs[i], + i, env->fregs[i].l.upper, env->fregs[i].l.l= ower, + floatx80_to_double(env, env->fregs[i].l.upp= er, + env->fregs[i].l.lower)); + } + g_string_append_printf(buf, "PC =3D %08x ", env->pc); sr =3D env->sr | cpu_m68k_get_ccr(env); - qemu_fprintf(f, "SR =3D %04x T:%x I:%x %c%c %c%c%c%c%c\n", - sr, (sr & SR_T) >> SR_T_SHIFT, (sr & SR_I) >> SR_I_SHIFT, - (sr & SR_S) ? 'S' : 'U', (sr & SR_M) ? '%' : 'I', - (sr & CCF_X) ? 'X' : '-', (sr & CCF_N) ? 'N' : '-', - (sr & CCF_Z) ? 'Z' : '-', (sr & CCF_V) ? 'V' : '-', - (sr & CCF_C) ? 'C' : '-'); - qemu_fprintf(f, "FPSR =3D %08x %c%c%c%c ", env->fpsr, - (env->fpsr & FPSR_CC_A) ? 'A' : '-', - (env->fpsr & FPSR_CC_I) ? 'I' : '-', - (env->fpsr & FPSR_CC_Z) ? 'Z' : '-', - (env->fpsr & FPSR_CC_N) ? 'N' : '-'); - qemu_fprintf(f, "\n " - "FPCR =3D %04x ", env->fpcr); + g_string_append_printf(buf, "SR =3D %04x T:%x I:%x %c%c %c%c%c%c%c\n", + sr, (sr & SR_T) >> SR_T_SHIFT, + (sr & SR_I) >> SR_I_SHIFT, + (sr & SR_S) ? 'S' : 'U', (sr & SR_M) ? '%' : 'I= ', + (sr & CCF_X) ? 'X' : '-', (sr & CCF_N) ? 'N' : = '-', + (sr & CCF_Z) ? 'Z' : '-', (sr & CCF_V) ? 'V' : = '-', + (sr & CCF_C) ? 'C' : '-'); + g_string_append_printf(buf, "FPSR =3D %08x %c%c%c%c ", env->fpsr, + (env->fpsr & FPSR_CC_A) ? 'A' : '-', + (env->fpsr & FPSR_CC_I) ? 'I' : '-', + (env->fpsr & FPSR_CC_Z) ? 'Z' : '-', + (env->fpsr & FPSR_CC_N) ? 'N' : '-'); + g_string_append_printf(buf, "\n " + "FPCR =3D %04x ", env->fpcr); switch (env->fpcr & FPCR_PREC_MASK) { case FPCR_PREC_X: - qemu_fprintf(f, "X "); + g_string_append_printf(buf, "X "); break; case FPCR_PREC_S: - qemu_fprintf(f, "S "); + g_string_append_printf(buf, "S "); break; case FPCR_PREC_D: - qemu_fprintf(f, "D "); + g_string_append_printf(buf, "D "); break; } switch (env->fpcr & FPCR_RND_MASK) { case FPCR_RND_N: - qemu_fprintf(f, "RN "); + g_string_append_printf(buf, "RN "); break; case FPCR_RND_Z: - qemu_fprintf(f, "RZ "); + g_string_append_printf(buf, "RZ "); break; case FPCR_RND_M: - qemu_fprintf(f, "RM "); + g_string_append_printf(buf, "RM "); break; case FPCR_RND_P: - qemu_fprintf(f, "RP "); + g_string_append_printf(buf, "RP "); break; } - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); #ifdef CONFIG_SOFTMMU - qemu_fprintf(f, "%sA7(MSP) =3D %08x %sA7(USP) =3D %08x %sA7(ISP) =3D %= 08x\n", - env->current_sp =3D=3D M68K_SSP ? "->" : " ", env->sp[M6= 8K_SSP], - env->current_sp =3D=3D M68K_USP ? "->" : " ", env->sp[M6= 8K_USP], - env->current_sp =3D=3D M68K_ISP ? "->" : " ", env->sp[M6= 8K_ISP]); - qemu_fprintf(f, "VBR =3D 0x%08x\n", env->vbr); - qemu_fprintf(f, "SFC =3D %x DFC %x\n", env->sfc, env->dfc); - qemu_fprintf(f, "SSW %08x TCR %08x URP %08x SRP %08x\n", - env->mmu.ssw, env->mmu.tcr, env->mmu.urp, env->mmu.srp); - qemu_fprintf(f, "DTTR0/1: %08x/%08x ITTR0/1: %08x/%08x\n", - env->mmu.ttr[M68K_DTTR0], env->mmu.ttr[M68K_DTTR1], - env->mmu.ttr[M68K_ITTR0], env->mmu.ttr[M68K_ITTR1]); - qemu_fprintf(f, "MMUSR %08x, fault at %08x\n", - env->mmu.mmusr, env->mmu.ar); + g_string_append_printf(buf, "%sA7(MSP) =3D %08x %sA7(USP) =3D %08x " + "%sA7(ISP) =3D %08x\n", + env->current_sp =3D=3D M68K_SSP ? + "->" : " ", env->sp[M68K_SSP], + env->current_sp =3D=3D M68K_USP ? + "->" : " ", env->sp[M68K_USP], + env->current_sp =3D=3D M68K_ISP ? + "->" : " ", env->sp[M68K_ISP]); + g_string_append_printf(buf, "VBR =3D 0x%08x\n", env->vbr); + g_string_append_printf(buf, "SFC =3D %x DFC %x\n", env->sfc, env->dfc); + g_string_append_printf(buf, "SSW %08x TCR %08x URP %08x SRP %08x\n", + env->mmu.ssw, env->mmu.tcr, + env->mmu.urp, env->mmu.srp); + g_string_append_printf(buf, "DTTR0/1: %08x/%08x ITTR0/1: %08x/%08x\n", + env->mmu.ttr[M68K_DTTR0], env->mmu.ttr[M68K_DTT= R1], + env->mmu.ttr[M68K_ITTR0], env->mmu.ttr[M68K_ITT= R1]); + g_string_append_printf(buf, "MMUSR %08x, fault at %08x\n", + env->mmu.mmusr, env->mmu.ar); #endif } =20 --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631852982989.8965310910049; Tue, 14 Sep 2021 08:04:12 -0700 (PDT) Received: from localhost ([::1]:39424 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9yl-0002if-OP for importer@patchew.org; Tue, 14 Sep 2021 11:04:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37356) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Og-0000Qh-Bs for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:26:54 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53456) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Oc-00077s-Jl for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:26:54 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-226-626DxAEzNgqnxv_q-JvIMg-1; Tue, 14 Sep 2021 10:26:42 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id F350B835BFE; Tue, 14 Sep 2021 14:26:21 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36DE15D9CA; Tue, 14 Sep 2021 14:25:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629603; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=zc4GAGNd7U60rlRgQ3mzXw+JBUbl9ED6Yoj+89RgeRw=; b=KttHpxUWDTLzKzHVBFPcZXfifryqBZC58BjaE3ukxpMapRDrZ0kECKn4wXxkjHLTKjaf37 7XnWoa6kyWs046h/gDRRffWV2DhA6Vtc0jbVIuY6RyBtwhoW2y9skgrQMqnVYxpZcijNlw tkdiQLzJtiRKJy8XwaKcqU/sKS8lSnU= X-MC-Unique: 626DxAEzNgqnxv_q-JvIMg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 16/53] target/microblaze: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:05 +0100 Message-Id: <20210914142042.1655100-17-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631905048100003 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/microblaze/cpu.c | 2 +- target/microblaze/cpu.h | 2 +- target/microblaze/translate.c | 45 ++++++++++++++++++----------------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/target/microblaze/cpu.c b/target/microblaze/cpu.c index 72d8f2a0da..539b8964bd 100644 --- a/target/microblaze/cpu.c +++ b/target/microblaze/cpu.c @@ -388,7 +388,7 @@ static void mb_cpu_class_init(ObjectClass *oc, void *da= ta) cc->class_by_name =3D mb_cpu_class_by_name; cc->has_work =3D mb_cpu_has_work; =20 - cc->dump_state =3D mb_cpu_dump_state; + cc->format_state =3D mb_cpu_format_state; cc->set_pc =3D mb_cpu_set_pc; cc->gdb_read_register =3D mb_cpu_gdb_read_register; cc->gdb_write_register =3D mb_cpu_gdb_write_register; diff --git a/target/microblaze/cpu.h b/target/microblaze/cpu.h index e4bba8a755..3e90970068 100644 --- a/target/microblaze/cpu.h +++ b/target/microblaze/cpu.h @@ -360,7 +360,7 @@ bool mb_cpu_exec_interrupt(CPUState *cs, int int_req); void mb_cpu_do_unaligned_access(CPUState *cs, vaddr vaddr, MMUAccessType access_type, int mmu_idx, uintptr_t retaddr); -void mb_cpu_dump_state(CPUState *cpu, FILE *f, int flags); +void mb_cpu_format_state(CPUState *cpu, GString *buf, int flags); hwaddr mb_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, MemTxAttrs *attrs); int mb_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); diff --git a/target/microblaze/translate.c b/target/microblaze/translate.c index a14ffed784..c229ba8789 100644 --- a/target/microblaze/translate.c +++ b/target/microblaze/translate.c @@ -1848,54 +1848,55 @@ void gen_intermediate_code(CPUState *cpu, Translati= onBlock *tb, int max_insns) translator_loop(&mb_tr_ops, &dc.base, cpu, tb, max_insns); } =20 -void mb_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void mb_cpu_format_state(CPUState *cs, GString *buf, int flags) { MicroBlazeCPU *cpu =3D MICROBLAZE_CPU(cs); CPUMBState *env =3D &cpu->env; uint32_t iflags; int i; =20 - qemu_fprintf(f, "pc=3D0x%08x msr=3D0x%05x mode=3D%s(saved=3D%s) eip=3D= %d ie=3D%d\n", - env->pc, env->msr, - (env->msr & MSR_UM) ? "user" : "kernel", - (env->msr & MSR_UMS) ? "user" : "kernel", - (bool)(env->msr & MSR_EIP), - (bool)(env->msr & MSR_IE)); + g_string_append_printf(buf, "pc=3D0x%08x msr=3D0x%05x mode=3D%s(saved= =3D%s) " + "eip=3D%d ie=3D%d\n", + env->pc, env->msr, + (env->msr & MSR_UM) ? "user" : "kernel", + (env->msr & MSR_UMS) ? "user" : "kernel", + (bool)(env->msr & MSR_EIP), + (bool)(env->msr & MSR_IE)); =20 iflags =3D env->iflags; - qemu_fprintf(f, "iflags: 0x%08x", iflags); + g_string_append_printf(buf, "iflags: 0x%08x", iflags); if (iflags & IMM_FLAG) { - qemu_fprintf(f, " IMM(0x%08x)", env->imm); + g_string_append_printf(buf, " IMM(0x%08x)", env->imm); } if (iflags & BIMM_FLAG) { - qemu_fprintf(f, " BIMM"); + g_string_append_printf(buf, " BIMM"); } if (iflags & D_FLAG) { - qemu_fprintf(f, " D(btarget=3D0x%08x)", env->btarget); + g_string_append_printf(buf, " D(btarget=3D0x%08x)", env->btarget); } if (iflags & DRTI_FLAG) { - qemu_fprintf(f, " DRTI"); + g_string_append_printf(buf, " DRTI"); } if (iflags & DRTE_FLAG) { - qemu_fprintf(f, " DRTE"); + g_string_append_printf(buf, " DRTE"); } if (iflags & DRTB_FLAG) { - qemu_fprintf(f, " DRTB"); + g_string_append_printf(buf, " DRTB"); } if (iflags & ESR_ESS_FLAG) { - qemu_fprintf(f, " ESR_ESS(0x%04x)", iflags & ESR_ESS_MASK); + g_string_append_printf(buf, " ESR_ESS(0x%04x)", iflags & ESR_ESS_M= ASK); } =20 - qemu_fprintf(f, "\nesr=3D0x%04x fsr=3D0x%02x btr=3D0x%08x edr=3D0x%x\n" - "ear=3D0x" TARGET_FMT_lx " slr=3D0x%x shr=3D0x%x\n", - env->esr, env->fsr, env->btr, env->edr, - env->ear, env->slr, env->shr); + g_string_append_printf(buf, "\nesr=3D0x%04x fsr=3D0x%02x btr=3D0x%08x = edr=3D0x%x\n" + "ear=3D0x" TARGET_FMT_lx " slr=3D0x%x shr=3D0x%= x\n", + env->esr, env->fsr, env->btr, env->edr, + env->ear, env->slr, env->shr); =20 for (i =3D 0; i < 32; i++) { - qemu_fprintf(f, "r%2.2d=3D%08x%c", - i, env->regs[i], i % 4 =3D=3D 3 ? '\n' : ' '); + g_string_append_printf(buf, "r%2.2d=3D%08x%c", + i, env->regs[i], i % 4 =3D=3D 3 ? '\n' : ' = '); } - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } =20 void mb_tcg_init(void) --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631072705936.9522940790476; Tue, 14 Sep 2021 07:51:12 -0700 (PDT) Received: from localhost ([::1]:56104 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9mB-0001BN-FX for importer@patchew.org; Tue, 14 Sep 2021 10:51:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Os-0000dl-35 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:27:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29427) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Om-0007Iy-1u for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:27:05 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-307-KwcF5jD4PpSZf-WEfz9AZg-1; Tue, 14 Sep 2021 10:26:55 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D9ADB802E64; Tue, 14 Sep 2021 14:26:46 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 464045D9CA; Tue, 14 Sep 2021 14:26:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629618; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=PRCBRjWGqeIljdUzcqW2nBCNswQEV4Di7Dt1tu1kl6Q=; b=Djdm1OJA5O++pQ9fVQSNA50/g7aKqgervcjG6HpKREbctp9CQmDIwEJtgkMo3UT8OyeeOJ QolwD8o8gxckSDhvNkZ5x/vh7/LYRfXwcFCIPB62F8mb9ExEOGgPScnhp751KBkunPX4I3 XQSNyLWCJI/FE8ZzYVdRUaLWOwrKHy8= X-MC-Unique: KwcF5jD4PpSZf-WEfz9AZg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 17/53] target/mips: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:06 +0100 Message-Id: <20210914142042.1655100-18-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631074876100001 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/mips/cpu.c | 85 +++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 40 deletions(-) diff --git a/target/mips/cpu.c b/target/mips/cpu.c index d426918291..9ced90d810 100644 --- a/target/mips/cpu.c +++ b/target/mips/cpu.c @@ -42,76 +42,81 @@ const char regnames[32][3] =3D { "t8", "t9", "k0", "k1", "gp", "sp", "s8", "ra", }; =20 -static void fpu_dump_fpr(fpr_t *fpr, FILE *f, bool is_fpu64) +static void fpu_dump_fpr(fpr_t *fpr, GString *buf, bool is_fpu64) { if (is_fpu64) { - qemu_fprintf(f, "w:%08x d:%016" PRIx64 " fd:%13g fs:%13g psu: %13g= \n", - fpr->w[FP_ENDIAN_IDX], fpr->d, - (double)fpr->fd, - (double)fpr->fs[FP_ENDIAN_IDX], - (double)fpr->fs[!FP_ENDIAN_IDX]); + g_string_append_printf(buf, "w:%08x d:%016" PRIx64 + " fd:%13g fs:%13g psu: %13g\n", + fpr->w[FP_ENDIAN_IDX], fpr->d, + (double)fpr->fd, + (double)fpr->fs[FP_ENDIAN_IDX], + (double)fpr->fs[!FP_ENDIAN_IDX]); } else { fpr_t tmp; =20 tmp.w[FP_ENDIAN_IDX] =3D fpr->w[FP_ENDIAN_IDX]; tmp.w[!FP_ENDIAN_IDX] =3D (fpr + 1)->w[FP_ENDIAN_IDX]; - qemu_fprintf(f, "w:%08x d:%016" PRIx64 " fd:%13g fs:%13g psu:%13g\= n", - tmp.w[FP_ENDIAN_IDX], tmp.d, - (double)tmp.fd, - (double)tmp.fs[FP_ENDIAN_IDX], - (double)tmp.fs[!FP_ENDIAN_IDX]); + g_string_append_printf(buf, "w:%08x d:%016" PRIx64 + " fd:%13g fs:%13g psu:%13g\n", + tmp.w[FP_ENDIAN_IDX], tmp.d, + (double)tmp.fd, + (double)tmp.fs[FP_ENDIAN_IDX], + (double)tmp.fs[!FP_ENDIAN_IDX]); } } =20 -static void fpu_dump_state(CPUMIPSState *env, FILE *f, int flags) +static void fpu_format_state(CPUMIPSState *env, GString *buf, int flags) { int i; bool is_fpu64 =3D !!(env->hflags & MIPS_HFLAG_F64); =20 - qemu_fprintf(f, - "CP1 FCR0 0x%08x FCR31 0x%08x SR.FR %d fp_status 0x%02= x\n", - env->active_fpu.fcr0, env->active_fpu.fcr31, is_fpu64, - get_float_exception_flags(&env->active_fpu.fp_status)); + g_string_append_printf(buf, + "CP1 FCR0 0x%08x FCR31 0x%08x SR.FR %d " + " fp_status 0x%02x\n", + env->active_fpu.fcr0, env->active_fpu.fcr31, + is_fpu64, get_float_exception_flags( + &env->active_fpu.fp_status)); for (i =3D 0; i < 32; (is_fpu64) ? i++ : (i +=3D 2)) { - qemu_fprintf(f, "%3s: ", fregnames[i]); - fpu_dump_fpr(&env->active_fpu.fpr[i], f, is_fpu64); + g_string_append_printf(buf, "%3s: ", fregnames[i]); + fpu_dump_fpr(&env->active_fpu.fpr[i], buf, is_fpu64); } } =20 -static void mips_cpu_dump_state(CPUState *cs, FILE *f, int flags) +static void mips_cpu_format_state(CPUState *cs, GString *buf, int flags) { MIPSCPU *cpu =3D MIPS_CPU(cs); CPUMIPSState *env =3D &cpu->env; int i; =20 - qemu_fprintf(f, "pc=3D0x" TARGET_FMT_lx " HI=3D0x" TARGET_FMT_lx - " LO=3D0x" TARGET_FMT_lx " ds %04x " - TARGET_FMT_lx " " TARGET_FMT_ld "\n", - env->active_tc.PC, env->active_tc.HI[0], env->active_tc.L= O[0], - env->hflags, env->btarget, env->bcond); + g_string_append_printf(buf, "pc=3D0x" TARGET_FMT_lx " HI=3D0x" TARGET_= FMT_lx + " LO=3D0x" TARGET_FMT_lx " ds %04x " + TARGET_FMT_lx " " TARGET_FMT_ld "\n", + env->active_tc.PC, env->active_tc.HI[0], + env->active_tc.LO[0], + env->hflags, env->btarget, env->bcond); for (i =3D 0; i < 32; i++) { if ((i & 3) =3D=3D 0) { - qemu_fprintf(f, "GPR%02d:", i); + g_string_append_printf(buf, "GPR%02d:", i); } - qemu_fprintf(f, " %s " TARGET_FMT_lx, - regnames[i], env->active_tc.gpr[i]); + g_string_append_printf(buf, " %s " TARGET_FMT_lx, + regnames[i], env->active_tc.gpr[i]); if ((i & 3) =3D=3D 3) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } =20 - qemu_fprintf(f, "CP0 Status 0x%08x Cause 0x%08x EPC 0x" - TARGET_FMT_lx "\n", - env->CP0_Status, env->CP0_Cause, env->CP0_EPC); - qemu_fprintf(f, " Config0 0x%08x Config1 0x%08x LLAddr 0x%016" - PRIx64 "\n", - env->CP0_Config0, env->CP0_Config1, env->CP0_LLAddr); - qemu_fprintf(f, " Config2 0x%08x Config3 0x%08x\n", - env->CP0_Config2, env->CP0_Config3); - qemu_fprintf(f, " Config4 0x%08x Config5 0x%08x\n", - env->CP0_Config4, env->CP0_Config5); + g_string_append_printf(buf, "CP0 Status 0x%08x Cause 0x%08x EPC = 0x" + TARGET_FMT_lx "\n", + env->CP0_Status, env->CP0_Cause, env->CP0_EPC); + g_string_append_printf(buf, " Config0 0x%08x Config1 0x%08x LLAddr " + "0x%016" PRIx64 "\n", + env->CP0_Config0, env->CP0_Config1, env->CP0_LL= Addr); + g_string_append_printf(buf, " Config2 0x%08x Config3 0x%08x\n", + env->CP0_Config2, env->CP0_Config3); + g_string_append_printf(buf, " Config4 0x%08x Config5 0x%08x\n", + env->CP0_Config4, env->CP0_Config5); if ((flags & CPU_DUMP_FPU) && (env->hflags & MIPS_HFLAG_FPU)) { - fpu_dump_state(env, f, flags); + fpu_format_state(env, buf, flags); } } =20 @@ -564,7 +569,7 @@ static void mips_cpu_class_init(ObjectClass *c, void *d= ata) =20 cc->class_by_name =3D mips_cpu_class_by_name; cc->has_work =3D mips_cpu_has_work; - cc->dump_state =3D mips_cpu_dump_state; + cc->format_state =3D mips_cpu_format_state; cc->set_pc =3D mips_cpu_set_pc; cc->gdb_read_register =3D mips_cpu_gdb_read_register; cc->gdb_write_register =3D mips_cpu_gdb_write_register; --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631193057865.7380305541798; Tue, 14 Sep 2021 07:53:13 -0700 (PDT) Received: from localhost ([::1]:36434 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9o8-0006rS-1P for importer@patchew.org; Tue, 14 Sep 2021 10:53:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37646) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9P6-0000oP-QV for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:27:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49120) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Ov-0007RQ-CT for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:27:19 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-201-4cFRpq3QPRWx92hlR6xsbw-1; Tue, 14 Sep 2021 10:27:07 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D5F2F36418; Tue, 14 Sep 2021 14:27:01 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 314435D9CA; Tue, 14 Sep 2021 14:26:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629628; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=GzpbfU4A9btQY9RS5Bo61BZfvRRoLXi0U6P5LuLSTCs=; b=dJe14Dnkzfp/wvMo7YNfg/Vpoz9ldXtr1VIs5amJ7XlYkvH8imBs0DtyuBRM9Gr+coi2JE dEdLEjmFSOqn8JGjVmz1iUgSDNCnh5QM6TgSJPD8QEiknYeUHqzPEioY8ca6+SlzvO5gZP 8Ue0IAELuKV0ELgaG5EcbN2+Cf8nNhA= X-MC-Unique: 4cFRpq3QPRWx92hlR6xsbw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 18/53] target/nios2: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:07 +0100 Message-Id: <20210914142042.1655100-19-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631193771100001 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/nios2/cpu.c | 2 +- target/nios2/cpu.h | 2 +- target/nios2/translate.c | 20 ++++++++++---------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index 5e37defef8..cbf15fb1c9 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -241,7 +241,7 @@ static void nios2_cpu_class_init(ObjectClass *oc, void = *data) =20 cc->class_by_name =3D nios2_cpu_class_by_name; cc->has_work =3D nios2_cpu_has_work; - cc->dump_state =3D nios2_cpu_dump_state; + cc->format_state =3D nios2_cpu_format_state; cc->set_pc =3D nios2_cpu_set_pc; cc->disas_set_info =3D nios2_cpu_disas_set_info; #ifndef CONFIG_USER_ONLY diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 2ab82fdc71..3b16cd1f3c 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -195,7 +195,7 @@ void nios2_tcg_init(void); void nios2_cpu_do_interrupt(CPUState *cs); int cpu_nios2_signal_handler(int host_signum, void *pinfo, void *puc); void dump_mmu(CPUNios2State *env); -void nios2_cpu_dump_state(CPUState *cpu, FILE *f, int flags); +void nios2_cpu_format_state(CPUState *cpu, GString *buf, int flags); hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/target/nios2/translate.c b/target/nios2/translate.c index 08d7ac5398..a5f0f56e1a 100644 --- a/target/nios2/translate.c +++ b/target/nios2/translate.c @@ -855,7 +855,7 @@ void gen_intermediate_code(CPUState *cs, TranslationBlo= ck *tb, int max_insns) translator_loop(&nios2_tr_ops, &dc.base, cs, tb, max_insns); } =20 -void nios2_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void nios2_cpu_format_state(CPUState *cs, GString *buf, int flags) { Nios2CPU *cpu =3D NIOS2_CPU(cs); CPUNios2State *env =3D &cpu->env; @@ -865,22 +865,22 @@ void nios2_cpu_dump_state(CPUState *cs, FILE *f, int = flags) return; } =20 - qemu_fprintf(f, "IN: PC=3D%x %s\n", - env->regs[R_PC], lookup_symbol(env->regs[R_PC])); + g_string_append_printf(buf, "IN: PC=3D%x %s\n", + env->regs[R_PC], lookup_symbol(env->regs[R_PC])= ); =20 for (i =3D 0; i < NUM_CORE_REGS; i++) { - qemu_fprintf(f, "%9s=3D%8.8x ", regnames[i], env->regs[i]); + g_string_append_printf(buf, "%9s=3D%8.8x ", regnames[i], env->regs= [i]); if ((i + 1) % 4 =3D=3D 0) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } #if !defined(CONFIG_USER_ONLY) - qemu_fprintf(f, " mmu write: VPN=3D%05X PID %02X TLBACC %08X\n", - env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK, - (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> 4, - env->mmu.tlbacc_wr); + g_string_append_printf(buf, " mmu write: VPN=3D%05X PID %02X TLBACC %0= 8X\n", + env->mmu.pteaddr_wr & CR_PTEADDR_VPN_MASK, + (env->mmu.tlbmisc_wr & CR_TLBMISC_PID_MASK) >> = 4, + env->mmu.tlbacc_wr); #endif - qemu_fprintf(f, "\n\n"); + g_string_append_printf(buf, "\n\n"); } =20 void nios2_tcg_init(void) --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631401758601.411786435807; Tue, 14 Sep 2021 07:56:41 -0700 (PDT) Received: from localhost ([::1]:46102 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9rU-0004z2-JB for importer@patchew.org; Tue, 14 Sep 2021 10:56:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9P8-0000oU-UG for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:27:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:21913) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9P6-0007XH-Jw for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:27:22 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-476-T2ixmEeIOZmDohW-2iSoeA-1; Tue, 14 Sep 2021 10:27:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 120531084681; Tue, 14 Sep 2021 14:27:13 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 28BDB5D9CA; Tue, 14 Sep 2021 14:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629639; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+wDxv/ynJAT6bxB9NSeiHYS4UowdIUh6a7fG4sUwkpU=; b=H/W2ihAB9RFkqY/xLjWQLYnCeRmPPURRaWGmJ6IYo6L+d4lV8meKjeCWvd4A2New+xCf7/ J8sK7/fVc7HtPXfqYa03Mp0JV2ZOWrwiMLqn1uI+1A3Jx9a6T0pSre2VMqHIK6PvkCNvHs us4x60+y8TJkz+4Gee0lfmHd4bCx/zs= X-MC-Unique: T2ixmEeIOZmDohW-2iSoeA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 19/53] target/openrisc: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:08 +0100 Message-Id: <20210914142042.1655100-20-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631403466100001 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/openrisc/cpu.c | 2 +- target/openrisc/cpu.h | 2 +- target/openrisc/translate.c | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/target/openrisc/cpu.c b/target/openrisc/cpu.c index bd34e429ec..d60d248958 100644 --- a/target/openrisc/cpu.c +++ b/target/openrisc/cpu.c @@ -206,7 +206,7 @@ static void openrisc_cpu_class_init(ObjectClass *oc, vo= id *data) =20 cc->class_by_name =3D openrisc_cpu_class_by_name; cc->has_work =3D openrisc_cpu_has_work; - cc->dump_state =3D openrisc_cpu_dump_state; + cc->format_state =3D openrisc_cpu_format_state; cc->set_pc =3D openrisc_cpu_set_pc; cc->gdb_read_register =3D openrisc_cpu_gdb_read_register; cc->gdb_write_register =3D openrisc_cpu_gdb_write_register; diff --git a/target/openrisc/cpu.h b/target/openrisc/cpu.h index 82cbaeb4f8..112b845b10 100644 --- a/target/openrisc/cpu.h +++ b/target/openrisc/cpu.h @@ -314,7 +314,7 @@ struct OpenRISCCPU { void cpu_openrisc_list(void); void openrisc_cpu_do_interrupt(CPUState *cpu); bool openrisc_cpu_exec_interrupt(CPUState *cpu, int int_req); -void openrisc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); +void openrisc_cpu_format_state(CPUState *cpu, GString *buf, int flags); hwaddr openrisc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int openrisc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg= ); int openrisc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/openrisc/translate.c b/target/openrisc/translate.c index d6ea536744..0155f2b160 100644 --- a/target/openrisc/translate.c +++ b/target/openrisc/translate.c @@ -1723,16 +1723,16 @@ void gen_intermediate_code(CPUState *cs, Translatio= nBlock *tb, int max_insns) translator_loop(&openrisc_tr_ops, &ctx.base, cs, tb, max_insns); } =20 -void openrisc_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void openrisc_cpu_format_state(CPUState *cs, GString *buf, int flags) { OpenRISCCPU *cpu =3D OPENRISC_CPU(cs); CPUOpenRISCState *env =3D &cpu->env; int i; =20 - qemu_fprintf(f, "PC=3D%08x\n", env->pc); + g_string_append_printf(buf, "PC=3D%08x\n", env->pc); for (i =3D 0; i < 32; ++i) { - qemu_fprintf(f, "R%02d=3D%08x%c", i, cpu_get_gpr(env, i), - (i % 4) =3D=3D 3 ? '\n' : ' '); + g_string_append_printf(buf, "R%02d=3D%08x%c", i, cpu_get_gpr(env, = i), + (i % 4) =3D=3D 3 ? '\n' : ' '); } } =20 --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631632093250139.17510387660832; Tue, 14 Sep 2021 08:08:13 -0700 (PDT) Received: from localhost ([::1]:52866 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQA2d-0003eJ-VE for importer@patchew.org; Tue, 14 Sep 2021 11:08:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38026) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9PX-00013c-Lu for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:27:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:53854) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9PO-0007rA-NC for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:27:46 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-551-7pcFh4DxMim4vOfG1WuzTA-1; Tue, 14 Sep 2021 10:27:36 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DF0E8800FF4; Tue, 14 Sep 2021 14:27:32 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F46A5D9CA; Tue, 14 Sep 2021 14:27:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629657; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=TVhUD4M4QIyfpdQHCllc9n629wx0pJ553X4xNf1WDo8=; b=YoAhOjpxzRXOwNGx35dauYg/XBRe6R6OOVPwYz9aOf7Q5vT9AsbnPM4wWChh5NXWtG97CT WYAdf74Dh0kVU49vG35YUr6h9j4hI3wkmYX5XgJ2M+3Bavuy0aYkaols96ObHwJVajYmiw fvEQf4AkuYQZVmRecRm5WEkKLrHBtJM= X-MC-Unique: 7pcFh4DxMim4vOfG1WuzTA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 20/53] target/ppc: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:09 +0100 Message-Id: <20210914142042.1655100-21-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632124689100001 Signed-off-by: Daniel P. Berrang=C3=A9 Acked-by: David Gibson Acked-by: Greg Kurz --- target/ppc/cpu.h | 2 +- target/ppc/cpu_init.c | 212 +++++++++++++++++++++++++----------------- 2 files changed, 126 insertions(+), 88 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index 500205229c..c84ae29b98 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1256,7 +1256,7 @@ DECLARE_OBJ_CHECKERS(PPCVirtualHypervisor, PPCVirtual= HypervisorClass, =20 void ppc_cpu_do_interrupt(CPUState *cpu); bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req); -void ppc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); +void ppc_cpu_format_state(CPUState *cpu, GString *buf, int flags); hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int ppc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int ppc_cpu_gdb_read_register_apple(CPUState *cpu, GByteArray *buf, int re= g); diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index ad7abc6041..3456be465c 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -9043,7 +9043,7 @@ static void ppc_cpu_class_init(ObjectClass *oc, void = *data) =20 cc->class_by_name =3D ppc_cpu_class_by_name; cc->has_work =3D ppc_cpu_has_work; - cc->dump_state =3D ppc_cpu_dump_state; + cc->format_state =3D ppc_cpu_format_state; cc->set_pc =3D ppc_cpu_set_pc; cc->gdb_read_register =3D ppc_cpu_gdb_read_register; cc->gdb_write_register =3D ppc_cpu_gdb_write_register; @@ -9104,7 +9104,7 @@ static void ppc_cpu_register_types(void) #endif } =20 -void ppc_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void ppc_cpu_format_state(CPUState *cs, GString *buf, int flags) { #define RGPL 4 #define RFPL 4 @@ -9113,39 +9113,41 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, int = flags) CPUPPCState *env =3D &cpu->env; int i; =20 - qemu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR " - TARGET_FMT_lx " XER " TARGET_FMT_lx " CPU#%d\n", - env->nip, env->lr, env->ctr, cpu_read_xer(env), - cs->cpu_index); - qemu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF " - "%08x iidx %d didx %d\n", - env->msr, env->spr[SPR_HID0], env->hflags, - cpu_mmu_index(env, true), cpu_mmu_index(env, false)); + g_string_append_printf(buf, + "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " C= TR " + TARGET_FMT_lx " XER " TARGET_FMT_lx " CPU#%d\n", + env->nip, env->lr, env->ctr, cpu_read_xer(env), + cs->cpu_index); + g_string_append_printf(buf, + "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " = HF " + "%08x iidx %d didx %d\n", + env->msr, env->spr[SPR_HID0], env->hflags, + cpu_mmu_index(env, true), cpu_mmu_index(env, fa= lse)); #if !defined(NO_TIMER_DUMP) - qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64 + g_string_append_printf(buf, "TB %08" PRIu32 " %08" PRIu64 #if !defined(CONFIG_USER_ONLY) - " DECR " TARGET_FMT_lu + " DECR " TARGET_FMT_lu #endif - "\n", - cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env) + "\n", + cpu_ppc_load_tbu(env), cpu_ppc_load_tbl(env) #if !defined(CONFIG_USER_ONLY) - , cpu_ppc_load_decr(env) + , cpu_ppc_load_decr(env) #endif ); #endif for (i =3D 0; i < 32; i++) { if ((i & (RGPL - 1)) =3D=3D 0) { - qemu_fprintf(f, "GPR%02d", i); + g_string_append_printf(buf, "GPR%02d", i); } - qemu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i)); + g_string_append_printf(buf, " %016" PRIx64, ppc_dump_gpr(env, i)); if ((i & (RGPL - 1)) =3D=3D (RGPL - 1)) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } - qemu_fprintf(f, "CR "); + g_string_append_printf(buf, "CR "); for (i =3D 0; i < 8; i++) - qemu_fprintf(f, "%01x", env->crf[i]); - qemu_fprintf(f, " ["); + g_string_append_printf(buf, "%01x", env->crf[i]); + g_string_append_printf(buf, " ["); for (i =3D 0; i < 8; i++) { char a =3D '-'; if (env->crf[i] & 0x08) { @@ -9155,75 +9157,97 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, int = flags) } else if (env->crf[i] & 0x02) { a =3D 'E'; } - qemu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' '); + g_string_append_printf(buf, " %c%c", a, env->crf[i] & 0x01 ? 'O' := ' '); } - qemu_fprintf(f, " ] RES " TARGET_FMT_lx "\n", - env->reserve_addr); + g_string_append_printf(buf, " ] RES " TARGET_FMT_lx "\n", + env->reserve_addr); =20 if (flags & CPU_DUMP_FPU) { for (i =3D 0; i < 32; i++) { if ((i & (RFPL - 1)) =3D=3D 0) { - qemu_fprintf(f, "FPR%02d", i); + g_string_append_printf(buf, "FPR%02d", i); } - qemu_fprintf(f, " %016" PRIx64, *cpu_fpr_ptr(env, i)); + g_string_append_printf(buf, " %016" PRIx64, *cpu_fpr_ptr(env, = i)); if ((i & (RFPL - 1)) =3D=3D (RFPL - 1)) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } - qemu_fprintf(f, "FPSCR " TARGET_FMT_lx "\n", env->fpscr); + g_string_append_printf(buf, "FPSCR " TARGET_FMT_lx "\n", env->fpsc= r); } =20 #if !defined(CONFIG_USER_ONLY) - qemu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx - " PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n", - env->spr[SPR_SRR0], env->spr[SPR_SRR1], - env->spr[SPR_PVR], env->spr[SPR_VRSAVE]); - - qemu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx - " SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n", - env->spr[SPR_SPRG0], env->spr[SPR_SPRG1], - env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]); - - qemu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx - " SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n", - env->spr[SPR_SPRG4], env->spr[SPR_SPRG5], - env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]); + g_string_append_printf(buf, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FM= T_lx + " PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_= lx + "\n", + env->spr[SPR_SRR0], env->spr[SPR_SRR1], + env->spr[SPR_PVR], env->spr[SPR_VRSAVE]); + + g_string_append_printf(buf, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FM= T_lx + " SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_= lx + "\n", + env->spr[SPR_SPRG0], env->spr[SPR_SPRG1], + env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]); + + g_string_append_printf(buf, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FM= T_lx + " SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_= lx + "\n", + env->spr[SPR_SPRG4], env->spr[SPR_SPRG5], + env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]); =20 #if defined(TARGET_PPC64) if (env->excp_model =3D=3D POWERPC_EXCP_POWER7 || env->excp_model =3D=3D POWERPC_EXCP_POWER8 || env->excp_model =3D=3D POWERPC_EXCP_POWER9 || env->excp_model =3D=3D POWERPC_EXCP_POWER10) { - qemu_fprintf(f, "HSRR0 " TARGET_FMT_lx " HSRR1 " TARGET_FMT_lx "\n= ", - env->spr[SPR_HSRR0], env->spr[SPR_HSRR1]); + g_string_append_printf(buf, "HSRR0 " TARGET_FMT_lx + " HSRR1 " TARGET_FMT_lx "\n", + env->spr[SPR_HSRR0], env->spr[SPR_HSRR1]); } #endif if (env->excp_model =3D=3D POWERPC_EXCP_BOOKE) { - qemu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx - " MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n= ", - env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1], - env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1= ]); - - qemu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx - " ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n= ", - env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR], - env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]); - - qemu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx - " IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n= ", - env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR], - env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]); - - qemu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx - " EPR " TARGET_FMT_lx "\n", - env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8], - env->spr[SPR_BOOKE_EPR]); + g_string_append_printf(buf, "CSRR0 " TARGET_FMT_lx + " CSRR1 " TARGET_FMT_lx + " MCSRR0 " TARGET_FMT_lx + " MCSRR1 " TARGET_FMT_lx "\n", + env->spr[SPR_BOOKE_CSRR0], + env->spr[SPR_BOOKE_CSRR1], + env->spr[SPR_BOOKE_MCSRR0], + env->spr[SPR_BOOKE_MCSRR1]); + + g_string_append_printf(buf, " TCR " TARGET_FMT_lx + " TSR " TARGET_FMT_lx + " ESR " TARGET_FMT_lx + " DEAR " TARGET_FMT_lx "\n", + env->spr[SPR_BOOKE_TCR], + env->spr[SPR_BOOKE_TSR], + env->spr[SPR_BOOKE_ESR], + env->spr[SPR_BOOKE_DEAR]); + + g_string_append_printf(buf, " PIR " TARGET_FMT_lx + " DECAR " TARGET_FMT_lx + " IVPR " TARGET_FMT_lx + " EPCR " TARGET_FMT_lx "\n", + env->spr[SPR_BOOKE_PIR], + env->spr[SPR_BOOKE_DECAR], + env->spr[SPR_BOOKE_IVPR], + env->spr[SPR_BOOKE_EPCR]); + + g_string_append_printf(buf, " MCSR " TARGET_FMT_lx + " SPRG8 " TARGET_FMT_lx + " EPR " TARGET_FMT_lx "\n", + env->spr[SPR_BOOKE_MCSR], + env->spr[SPR_BOOKE_SPRG8], + env->spr[SPR_BOOKE_EPR]); =20 /* FSL-specific */ - qemu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx - " PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n= ", - env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1], - env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]); + g_string_append_printf(buf, " MCAR " TARGET_FMT_lx + " PID1 " TARGET_FMT_lx + " PID2 " TARGET_FMT_lx + " SVR " TARGET_FMT_lx "\n", + env->spr[SPR_Exxx_MCAR], + env->spr[SPR_BOOKE_PID1], + env->spr[SPR_BOOKE_PID2], + env->spr[SPR_E500_SVR]); =20 /* * IVORs are left out as they are large and do not change often -- @@ -9233,12 +9257,13 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, int = flags) =20 #if defined(TARGET_PPC64) if (env->flags & POWERPC_FLAG_CFAR) { - qemu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar); + g_string_append_printf(buf, " CFAR " TARGET_FMT_lx"\n", env->cfar); } #endif =20 if (env->spr_cb[SPR_LPCR].name) { - qemu_fprintf(f, " LPCR " TARGET_FMT_lx "\n", env->spr[SPR_LPCR]); + g_string_append_printf(buf, + " LPCR " TARGET_FMT_lx "\n", env->spr[SPR_L= PCR]); } =20 switch (env->mmu_model) { @@ -9254,29 +9279,42 @@ void ppc_cpu_dump_state(CPUState *cs, FILE *f, int = flags) case POWERPC_MMU_3_00: #endif if (env->spr_cb[SPR_SDR1].name) { /* SDR1 Exists */ - qemu_fprintf(f, " SDR1 " TARGET_FMT_lx " ", env->spr[SPR_SDR1]= ); + g_string_append_printf(buf, " SDR1 " TARGET_FMT_lx " ", + env->spr[SPR_SDR1]); } if (env->spr_cb[SPR_PTCR].name) { /* PTCR Exists */ - qemu_fprintf(f, " PTCR " TARGET_FMT_lx " ", env->spr[SPR_PTCR]= ); + g_string_append_printf(buf, " PTCR " TARGET_FMT_lx " ", + env->spr[SPR_PTCR]); } - qemu_fprintf(f, " DAR " TARGET_FMT_lx " DSISR " TARGET_FMT_lx "\= n", - env->spr[SPR_DAR], env->spr[SPR_DSISR]); + g_string_append_printf(buf, " DAR " TARGET_FMT_lx " DSISR " + TARGET_FMT_lx "\n", + env->spr[SPR_DAR], env->spr[SPR_DSISR]); break; case POWERPC_MMU_BOOKE206: - qemu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx - " MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n= ", - env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1], - env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]); - - qemu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx - " MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n= ", - env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6], - env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]); - - qemu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx - " TLB1CFG " TARGET_FMT_lx "\n", - env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG], - env->spr[SPR_BOOKE_TLB1CFG]); + g_string_append_printf(buf, " MAS0 " TARGET_FMT_lx + " MAS1 " TARGET_FMT_lx + " MAS2 " TARGET_FMT_lx + " MAS3 " TARGET_FMT_lx "\n", + env->spr[SPR_BOOKE_MAS0], + env->spr[SPR_BOOKE_MAS1], + env->spr[SPR_BOOKE_MAS2], + env->spr[SPR_BOOKE_MAS3]); + + g_string_append_printf(buf, " MAS4 " TARGET_FMT_lx + " MAS6 " TARGET_FMT_lx + " MAS7 " TARGET_FMT_lx + " PID " TARGET_FMT_lx "\n", + env->spr[SPR_BOOKE_MAS4], + env->spr[SPR_BOOKE_MAS6], + env->spr[SPR_BOOKE_MAS7], + env->spr[SPR_BOOKE_PID]); + + g_string_append_printf(buf, "MMUCFG " TARGET_FMT_lx + " TLB0CFG " TARGET_FMT_lx + " TLB1CFG " TARGET_FMT_lx "\n", + env->spr[SPR_MMUCFG], + env->spr[SPR_BOOKE_TLB0CFG], + env->spr[SPR_BOOKE_TLB1CFG]); break; default: break; --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631605092706.8181226940425; Tue, 14 Sep 2021 08:00:05 -0700 (PDT) Received: from localhost ([::1]:57600 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9ul-0004CR-LC for importer@patchew.org; Tue, 14 Sep 2021 11:00:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38342) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Pv-0001JD-Po for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:28:11 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:24266) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Pn-0008Al-RX for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:28:11 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-413-i_sCcCilOp6A9yK0ziaS-Q-1; Tue, 14 Sep 2021 10:28:00 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D8D17802923; Tue, 14 Sep 2021 14:27:56 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 389C65D9CA; Tue, 14 Sep 2021 14:27:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629682; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DKozBoKyAUU0vbnpIl9GkAhnB7lfTQjmZkYHvWnT9rU=; b=OTi5p22WF3jsDW6221OMquRBmgVRngjTQDiJh20ggg3RpFnR4/qLP7KN88SY/X6U4UV81l smAjYH7OuiVD5j/l0qMmg5KkMuSQ48cOhiiwivtYiYEiu8HJ7ulHIspLfQ2GVsjwSQzNjq A4683uvA+GnsLUTXsP9r77o0pz7kbuM= X-MC-Unique: i_sCcCilOp6A9yK0ziaS-Q-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 21/53] target/riscv: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:10 +0100 Message-Id: <20210914142042.1655100-22-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631618411100001 Signed-off-by: Daniel P. Berrang=C3=A9 --- target/riscv/cpu.c | 105 ++++++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 39 deletions(-) diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c index 1a2b03d579..7a9e013e32 100644 --- a/target/riscv/cpu.c +++ b/target/riscv/cpu.c @@ -242,7 +242,7 @@ static ObjectClass *riscv_cpu_class_by_name(const char = *cpu_model) return oc; } =20 -static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags) +static void riscv_cpu_format_state(CPUState *cs, GString *buf, int flags) { RISCVCPU *cpu =3D RISCV_CPU(cs); CPURISCVState *env =3D &cpu->env; @@ -250,71 +250,98 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *= f, int flags) =20 #if !defined(CONFIG_USER_ONLY) if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s %d\n", "V =3D ", riscv_cpu_virt_enabled= (env)); + g_string_append_printf(buf, " %s %d\n", "V =3D ", + riscv_cpu_virt_enabled(env)); } #endif - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "pc ", env->pc); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "pc ", env->pc); #ifndef CONFIG_USER_ONLY - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mhartid ", env->mhartid); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatus ", (target_ulong)e= nv->mstatus); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "mhartid ", env->mhartid); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "mstatus ", (target_ulong)env->mstatus); if (riscv_cpu_is_32bit(env)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mstatush ", - (target_ulong)(env->mstatus >> 32)); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", "mstatush ", + (target_ulong)(env->mstatus >> 32)); } if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "hstatus ", env->hstatu= s); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vsstatus ", - (target_ulong)env->vsstatus); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "hstatus ", env->hstatus); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "vsstatus ", (target_ulong)env->vsstatus); } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mip ", env->mip); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mie ", env->mie); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mideleg ", env->mideleg); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "mip ", env->mip); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "mie ", env->mie); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "mideleg ", env->mideleg); if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "hideleg ", env->hidele= g); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "hideleg ", env->hideleg); } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "medeleg ", env->medeleg); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "medeleg ", env->medeleg); if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "hedeleg ", env->hedele= g); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "hedeleg ", env->hedeleg); } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtvec ", env->mtvec); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stvec ", env->stvec); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "mtvec ", env->mtvec); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "stvec ", env->stvec); if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vstvec ", env->vstvec= ); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "vstvec ", env->vstvec); } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mepc ", env->mepc); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "sepc ", env->sepc); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "mepc ", env->mepc); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "sepc ", env->sepc); if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vsepc ", env->vsepc); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "vsepc ", env->vsepc); } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mcause ", env->mcause); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "scause ", env->scause); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "mcause ", env->mcause); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "scause ", env->scause); if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "vscause ", env->vscaus= e); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "vscause ", env->vscause); } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval ", env->mtval); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "stval ", env->stval); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "mtval ", env->mtval); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "stval ", env->stval); if (riscv_has_ext(env, RVH)) { - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "htval ", env->htval); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mtval2 ", env->mtval2); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "htval ", env->htval); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "mtval2 ", env->mtval2); } - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "mscratch", env->mscratch); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "sscratch", env->sscratch); - qemu_fprintf(f, " %s " TARGET_FMT_lx "\n", "satp ", env->satp); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "mscratch", env->mscratch); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "sscratch", env->sscratch); + g_string_append_printf(buf, " %s " TARGET_FMT_lx "\n", + "satp ", env->satp); #endif =20 for (i =3D 0; i < 32; i++) { - qemu_fprintf(f, " %s " TARGET_FMT_lx, - riscv_int_regnames[i], env->gpr[i]); + g_string_append_printf(buf, " %s " TARGET_FMT_lx, + riscv_int_regnames[i], env->gpr[i]); if ((i & 3) =3D=3D 3) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } if (flags & CPU_DUMP_FPU) { for (i =3D 0; i < 32; i++) { - qemu_fprintf(f, " %s %016" PRIx64, - riscv_fpr_regnames[i], env->fpr[i]); + g_string_append_printf(buf, " %s %016" PRIx64, + riscv_fpr_regnames[i], env->fpr[i]); if ((i & 3) =3D=3D 3) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } } @@ -667,7 +694,7 @@ static void riscv_cpu_class_init(ObjectClass *c, void *= data) =20 cc->class_by_name =3D riscv_cpu_class_by_name; cc->has_work =3D riscv_cpu_has_work; - cc->dump_state =3D riscv_cpu_dump_state; + cc->format_state =3D riscv_cpu_format_state; cc->set_pc =3D riscv_cpu_set_pc; cc->gdb_read_register =3D riscv_cpu_gdb_read_register; cc->gdb_write_register =3D riscv_cpu_gdb_write_register; --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631632130547380.5801619434162; Tue, 14 Sep 2021 08:08:50 -0700 (PDT) Received: from localhost ([::1]:55082 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQA3F-0005Hw-Hk for importer@patchew.org; Tue, 14 Sep 2021 11:08:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38620) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Qh-0002kn-QB for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:28:59 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:51289) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9QZ-0000GL-Qr for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:28:55 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-208-yKE_4DFNPHKCIDnj822tIg-1; Tue, 14 Sep 2021 10:28:49 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9B2DFA0CCD; Tue, 14 Sep 2021 14:28:45 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2AE295D9CA; Tue, 14 Sep 2021 14:27:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629731; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qmRjzYwG+Lqfcps3G17xaNhRzRStWHGYP7XEVvjTzcM=; b=aD9lNuCXnA3NfKFIRR7jpQfJanT4MLYd52X5tmfN59NqekPvFJGrj3uBEj73nJlcm9S7VZ vbqi9y9jLQ/3pjveqLT0tHTYqUARl1HJCjg8pBHaaM81j6wCKYSNpAlXrqwsWYXsANt67z OcugroLO2b4DnGnAtJ+v5mX07IQQAG0= X-MC-Unique: yKE_4DFNPHKCIDnj822tIg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 22/53] target/rx: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:11 +0100 Message-Id: <20210914142042.1655100-23-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632154507100003 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/rx/cpu.c | 2 +- target/rx/cpu.h | 2 +- target/rx/translate.c | 14 ++++++++------ 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/target/rx/cpu.c b/target/rx/cpu.c index 96cc96e514..f7f158cfa5 100644 --- a/target/rx/cpu.c +++ b/target/rx/cpu.c @@ -207,7 +207,7 @@ static void rx_cpu_class_init(ObjectClass *klass, void = *data) =20 cc->class_by_name =3D rx_cpu_class_by_name; cc->has_work =3D rx_cpu_has_work; - cc->dump_state =3D rx_cpu_dump_state; + cc->format_state =3D rx_cpu_format_state; cc->set_pc =3D rx_cpu_set_pc; =20 #ifndef CONFIG_USER_ONLY diff --git a/target/rx/cpu.h b/target/rx/cpu.h index 0b4b998c7b..97fc1b9ed6 100644 --- a/target/rx/cpu.h +++ b/target/rx/cpu.h @@ -126,7 +126,7 @@ typedef RXCPU ArchCPU; const char *rx_crname(uint8_t cr); void rx_cpu_do_interrupt(CPUState *cpu); bool rx_cpu_exec_interrupt(CPUState *cpu, int int_req); -void rx_cpu_dump_state(CPUState *cpu, FILE *f, int flags); +void rx_cpu_format_state(CPUState *cpu, GString *buf, int flags); int rx_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int rx_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); hwaddr rx_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); diff --git a/target/rx/translate.c b/target/rx/translate.c index a3cf720455..2d3bdabce4 100644 --- a/target/rx/translate.c +++ b/target/rx/translate.c @@ -125,7 +125,7 @@ static int bdsp_s(DisasContext *ctx, int d) /* Include the auto-generated decoder. */ #include "decode-insns.c.inc" =20 -void rx_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void rx_cpu_format_state(CPUState *cs, GString *buf, int flags) { RXCPU *cpu =3D RX_CPU(cs); CPURXState *env =3D &cpu->env; @@ -133,12 +133,14 @@ void rx_cpu_dump_state(CPUState *cs, FILE *f, int fla= gs) uint32_t psw; =20 psw =3D rx_cpu_pack_psw(env); - qemu_fprintf(f, "pc=3D0x%08x psw=3D0x%08x\n", - env->pc, psw); + g_string_append_printf(buf, "pc=3D0x%08x psw=3D0x%08x\n", + env->pc, psw); for (i =3D 0; i < 16; i +=3D 4) { - qemu_fprintf(f, "r%d=3D0x%08x r%d=3D0x%08x r%d=3D0x%08x r%d=3D0x%0= 8x\n", - i, env->regs[i], i + 1, env->regs[i + 1], - i + 2, env->regs[i + 2], i + 3, env->regs[i + 3]); + g_string_append_printf(buf, + "r%d=3D0x%08x r%d=3D0x%08x r%d=3D0x%08x r%d= =3D0x%08x\n", + i, env->regs[i], i + 1, env->regs[i + 1], + i + 2, env->regs[i + 2], i + 3, + env->regs[i + 3]); } } =20 --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631908468299.6135918009901; Tue, 14 Sep 2021 08:05:08 -0700 (PDT) Received: from localhost ([::1]:43352 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9zf-0005Hc-9x for importer@patchew.org; Tue, 14 Sep 2021 11:05:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38814) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9R3-0003gY-11 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:29:21 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42626) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Qo-0000RL-Rm for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:29:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-459-I2ieP_RGMkWjPpCx5-6cVg-1; Tue, 14 Sep 2021 10:29:04 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 348FD19200C1; Tue, 14 Sep 2021 14:29:01 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id E11ED5D9CA; Tue, 14 Sep 2021 14:28:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629746; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x065cSLMcIxjIsC6dZCKtLmVC91lemlf3ABAXb8msuA=; b=Pyb60yDb1+EfUKPxl3x+0xHcdN3cgzuovieB/A1D8kRaXloXHuIrjrHyUkde5EiN/ouOt1 62G0C10WmXa3p0pVy3Nlg0feo8lnVbMyLhyRxHYRN7r77KgXT8DDMWW81tUF0aRNCE5BSP lyd63Po4EPUPqny+fYY6tl0BhZwo5YA= X-MC-Unique: I2ieP_RGMkWjPpCx5-6cVg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 23/53] target/s390x: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:12 +0100 Message-Id: <20210914142042.1655100-24-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -24 X-Spam_score: -2.5 X-Spam_bar: -- X-Spam_report: (-2.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631960354100001 Signed-off-by: Daniel P. Berrang=C3=A9 --- target/s390x/cpu-dump.c | 43 ++++++++++++++++++----------------- target/s390x/cpu.c | 2 +- target/s390x/s390x-internal.h | 2 +- 3 files changed, 24 insertions(+), 23 deletions(-) diff --git a/target/s390x/cpu-dump.c b/target/s390x/cpu-dump.c index 0f5c062994..9c6eaa9938 100644 --- a/target/s390x/cpu-dump.c +++ b/target/s390x/cpu-dump.c @@ -25,66 +25,67 @@ #include "qemu/qemu-print.h" #include "sysemu/tcg.h" =20 -void s390_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void s390_cpu_format_state(CPUState *cs, GString *buf, int flags) { S390CPU *cpu =3D S390_CPU(cs); CPUS390XState *env =3D &cpu->env; int i; =20 - qemu_fprintf(f, "PSW=3Dmask %016" PRIx64 " addr %016" PRIx64, - s390_cpu_get_psw_mask(env), env->psw.addr); + g_string_append_printf(buf, "PSW=3Dmask %016" PRIx64 " addr %016" PRIx= 64, + s390_cpu_get_psw_mask(env), env->psw.addr); if (!tcg_enabled()) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } else if (env->cc_op > 3) { - qemu_fprintf(f, " cc %15s\n", cc_name(env->cc_op)); + g_string_append_printf(buf, " cc %15s\n", cc_name(env->cc_op)); } else { - qemu_fprintf(f, " cc %02x\n", env->cc_op); + g_string_append_printf(buf, " cc %02x\n", env->cc_op); } =20 for (i =3D 0; i < 16; i++) { - qemu_fprintf(f, "R%02d=3D%016" PRIx64, i, env->regs[i]); + g_string_append_printf(buf, "R%02d=3D%016" PRIx64, i, env->regs[i]= ); if ((i % 4) =3D=3D 3) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } else { - qemu_fprintf(f, " "); + g_string_append_printf(buf, " "); } } =20 if (flags & CPU_DUMP_FPU) { if (s390_has_feat(S390_FEAT_VECTOR)) { for (i =3D 0; i < 32; i++) { - qemu_fprintf(f, "V%02d=3D%016" PRIx64 "%016" PRIx64 "%c", - i, env->vregs[i][0], env->vregs[i][1], - i % 2 ? '\n' : ' '); + g_string_append_printf(buf, + "V%02d=3D%016" PRIx64 "%016" PRIx64= "%c", + i, env->vregs[i][0], env->vregs[i][= 1], + i % 2 ? '\n' : ' '); } } else { for (i =3D 0; i < 16; i++) { - qemu_fprintf(f, "F%02d=3D%016" PRIx64 "%c", - i, *get_freg(env, i), - (i % 4) =3D=3D 3 ? '\n' : ' '); + g_string_append_printf(buf, "F%02d=3D%016" PRIx64 "%c", + i, *get_freg(env, i), + (i % 4) =3D=3D 3 ? '\n' : ' '); } } } =20 #ifndef CONFIG_USER_ONLY for (i =3D 0; i < 16; i++) { - qemu_fprintf(f, "C%02d=3D%016" PRIx64, i, env->cregs[i]); + g_string_append_printf(buf, "C%02d=3D%016" PRIx64, i, env->cregs[i= ]); if ((i % 4) =3D=3D 3) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } else { - qemu_fprintf(f, " "); + g_string_append_printf(buf, " "); } } #endif =20 #ifdef DEBUG_INLINE_BRANCHES for (i =3D 0; i < CC_OP_MAX; i++) { - qemu_fprintf(f, " %15s =3D %10ld\t%10ld\n", cc_name(i), - inline_branch_miss[i], inline_branch_hit[i]); + g_string_append_printf(buf, " %15s =3D %10ld\t%10ld\n", cc_name(i= ), + inline_branch_miss[i], inline_branch_hit[i]= ); } #endif =20 - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } =20 const char *cc_name(enum cc_op cc_op) diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index 7b7b05f1d3..b6bf628074 100644 --- a/target/s390x/cpu.c +++ b/target/s390x/cpu.c @@ -293,7 +293,7 @@ static void s390_cpu_class_init(ObjectClass *oc, void *= data) scc->reset =3D s390_cpu_reset; cc->class_by_name =3D s390_cpu_class_by_name, cc->has_work =3D s390_cpu_has_work; - cc->dump_state =3D s390_cpu_dump_state; + cc->format_state =3D s390_cpu_format_state; cc->set_pc =3D s390_cpu_set_pc; cc->gdb_read_register =3D s390_cpu_gdb_read_register; cc->gdb_write_register =3D s390_cpu_gdb_write_register; diff --git a/target/s390x/s390x-internal.h b/target/s390x/s390x-internal.h index 7a6aa4dacc..0ee99b8b1e 100644 --- a/target/s390x/s390x-internal.h +++ b/target/s390x/s390x-internal.h @@ -313,7 +313,7 @@ void s390_cpu_gdb_init(CPUState *cs); =20 =20 /* helper.c */ -void s390_cpu_dump_state(CPUState *cpu, FILE *f, int flags); +void s390_cpu_format_state(CPUState *cpu, GString *buf, int flags); void do_restart_interrupt(CPUS390XState *env); #ifndef CONFIG_USER_ONLY void s390_cpu_recompute_watchpoints(CPUState *cs); --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631630955768155.55435712352676; Tue, 14 Sep 2021 07:49:15 -0700 (PDT) Received: from localhost ([::1]:52064 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9kI-0006ip-Lo for importer@patchew.org; Tue, 14 Sep 2021 10:49:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9R2-0003fz-A6 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:29:20 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:49430) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9R0-0000Yr-IU for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:29:20 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-440-cz3Eq-PQOrqyuHhZrqUQVQ-1; Tue, 14 Sep 2021 10:29:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CC8B9802B9E; Tue, 14 Sep 2021 14:29:12 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7E5AB5D9CA; Tue, 14 Sep 2021 14:29:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629757; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L3WVzLsV8w9sLuJjLsdwBP1aEjXJoaulIiYN1Q8Dh6w=; b=db4zq0iOUduB7NfRaaDioYQiNH0ivps4yTBJNRxtxIXUxoK7BNA1ghHGCnbso76vhN9lRn 1VuCiSHZuC9+IdYRnQyP/ORjz4he2a6R3IcvtXtVfQitVuXyee1CLqFk6TIdKHjeR7Cc+g SH0IDJnu5tU/rc2MQjwQoxtZRrzHXc8= X-MC-Unique: cz3Eq-PQOrqyuHhZrqUQVQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 24/53] target/sh: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:13 +0100 Message-Id: <20210914142042.1655100-25-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631630957083100001 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/sh4/cpu.c | 2 +- target/sh4/cpu.h | 2 +- target/sh4/translate.c | 36 ++++++++++++++++++++---------------- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 8326922942..0ac881d6af 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -259,7 +259,7 @@ static void superh_cpu_class_init(ObjectClass *oc, void= *data) =20 cc->class_by_name =3D superh_cpu_class_by_name; cc->has_work =3D superh_cpu_has_work; - cc->dump_state =3D superh_cpu_dump_state; + cc->format_state =3D superh_cpu_format_state; cc->set_pc =3D superh_cpu_set_pc; cc->gdb_read_register =3D superh_cpu_gdb_read_register; cc->gdb_write_register =3D superh_cpu_gdb_write_register; diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 01c4344082..6940ca417a 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -206,7 +206,7 @@ struct SuperHCPU { =20 void superh_cpu_do_interrupt(CPUState *cpu); bool superh_cpu_exec_interrupt(CPUState *cpu, int int_req); -void superh_cpu_dump_state(CPUState *cpu, FILE *f, int flags); +void superh_cpu_format_state(CPUState *cpu, GString *buf, int flags); hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int superh_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/sh4/translate.c b/target/sh4/translate.c index 8704fea1ca..f6fd8939b0 100644 --- a/target/sh4/translate.c +++ b/target/sh4/translate.c @@ -156,32 +156,36 @@ void sh4_translate_init(void) fregnames[i]); } =20 -void superh_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void superh_cpu_format_state(CPUState *cs, GString *buf, int flags) { SuperHCPU *cpu =3D SUPERH_CPU(cs); CPUSH4State *env =3D &cpu->env; int i; =20 - qemu_fprintf(f, "pc=3D0x%08x sr=3D0x%08x pr=3D0x%08x fpscr=3D0x%08x\n", - env->pc, cpu_read_sr(env), env->pr, env->fpscr); - qemu_fprintf(f, "spc=3D0x%08x ssr=3D0x%08x gbr=3D0x%08x vbr=3D0x%08x\n= ", - env->spc, env->ssr, env->gbr, env->vbr); - qemu_fprintf(f, "sgr=3D0x%08x dbr=3D0x%08x delayed_pc=3D0x%08x fpul=3D= 0x%08x\n", - env->sgr, env->dbr, env->delayed_pc, env->fpul); + g_string_append_printf(buf, "pc=3D0x%08x sr=3D0x%08x pr=3D0x%08x fpscr= =3D0x%08x\n", + env->pc, cpu_read_sr(env), env->pr, env->fpscr); + g_string_append_printf(buf, "spc=3D0x%08x ssr=3D0x%08x gbr=3D0x%08x vb= r=3D0x%08x\n", + env->spc, env->ssr, env->gbr, env->vbr); + g_string_append_printf(buf, "sgr=3D0x%08x dbr=3D0x%08x delayed_pc=3D0x= %08x " + "fpul=3D0x%08x\n", + env->sgr, env->dbr, env->delayed_pc, env->fpul); for (i =3D 0; i < 24; i +=3D 4) { - qemu_printf("r%d=3D0x%08x r%d=3D0x%08x r%d=3D0x%08x r%d=3D0x%08x\n= ", - i, env->gregs[i], i + 1, env->gregs[i + 1], - i + 2, env->gregs[i + 2], i + 3, env->gregs[i + 3]); + g_string_append_printf(buf, "r%d=3D0x%08x r%d=3D0x%08x r%d=3D0x%08= x " + "r%d=3D0x%08x\n", + i, env->gregs[i], i + 1, env->gregs[i + 1], + i + 2, env->gregs[i + 2], i + 3, + env->gregs[i + 3]); } if (env->flags & DELAY_SLOT) { - qemu_printf("in delay slot (delayed_pc=3D0x%08x)\n", - env->delayed_pc); + g_string_append_printf(buf, "in delay slot (delayed_pc=3D0x%08x)\n= ", + env->delayed_pc); } else if (env->flags & DELAY_SLOT_CONDITIONAL) { - qemu_printf("in conditional delay slot (delayed_pc=3D0x%08x)\n", - env->delayed_pc); + g_string_append_printf(buf, "in conditional delay slot " + "(delayed_pc=3D0x%08x)\n", + env->delayed_pc); } else if (env->flags & DELAY_SLOT_RTE) { - qemu_fprintf(f, "in rte delay slot (delayed_pc=3D0x%08x)\n", - env->delayed_pc); + g_string_append_printf(buf, "in rte delay slot (delayed_pc=3D0x%08= x)\n", + env->delayed_pc); } } =20 --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631632387546545.3555002664581; Tue, 14 Sep 2021 08:13:07 -0700 (PDT) Received: from localhost ([::1]:37292 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQA7O-0004cL-E3 for importer@patchew.org; Tue, 14 Sep 2021 11:13:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39002) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9RM-0004jj-7c for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:29:40 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47303) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9RF-0000ji-Hz for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:29:39 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-593-Dc0RwMveOwC2SXjY5oyj2w-1; Tue, 14 Sep 2021 10:29:31 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 15B8810151E0; Tue, 14 Sep 2021 14:29:28 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 218D65D9CA; Tue, 14 Sep 2021 14:29:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629772; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0urF3G3hzjGuk0ruI9Eocq4/BIpoxZRk4EZLPdXK6JQ=; b=HASDb3AjPXIzB+XWBMPD4srXUHHhEjBujh5047bO6oU7cAiP4hP/OOPfeFGLk07MR6+8LC BtBkyDw6eVIy3HaxqOi55JYlUtlKBwBluIZg357RUIeyWVDzReP3hQvYW8F5dNGP3el0Jw slFZUY5ZNhGsy8ehoddeb5pWeezPF/E= X-MC-Unique: Dc0RwMveOwC2SXjY5oyj2w-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 25/53] target/sparc: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:14 +0100 Message-Id: <20210914142042.1655100-26-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, T_SPF_TEMPERROR=0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632389001100001 Signed-off-by: Daniel P. Berrang=C3=A9 Acked-by: Mark Cave-Ayland --- target/sparc/cpu.c | 85 +++++++++++++++++++++++++--------------------- target/sparc/cpu.h | 2 +- 2 files changed, 47 insertions(+), 40 deletions(-) diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index da6b30ec74..9346a79239 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -597,11 +597,11 @@ void sparc_cpu_list(void) "fpu_version mmu_version nwindows\n"); } =20 -static void cpu_print_cc(FILE *f, uint32_t cc) +static void cpu_print_cc(GString *buf, uint32_t cc) { - qemu_fprintf(f, "%c%c%c%c", cc & PSR_NEG ? 'N' : '-', - cc & PSR_ZERO ? 'Z' : '-', cc & PSR_OVF ? 'V' : '-', - cc & PSR_CARRY ? 'C' : '-'); + g_string_append_printf(buf, "%c%c%c%c", cc & PSR_NEG ? 'N' : '-', + cc & PSR_ZERO ? 'Z' : '-', cc & PSR_OVF ? 'V' := '-', + cc & PSR_CARRY ? 'C' : '-'); } =20 #ifdef TARGET_SPARC64 @@ -610,34 +610,36 @@ static void cpu_print_cc(FILE *f, uint32_t cc) #define REGS_PER_LINE 8 #endif =20 -void sparc_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void sparc_cpu_format_state(CPUState *cs, GString *buf, int flags) { SPARCCPU *cpu =3D SPARC_CPU(cs); CPUSPARCState *env =3D &cpu->env; int i, x; =20 - qemu_fprintf(f, "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\n", env= ->pc, - env->npc); + g_string_append_printf(buf, + "pc: " TARGET_FMT_lx " npc: " TARGET_FMT_lx "\= n", + env->pc, env->npc); =20 for (i =3D 0; i < 8; i++) { if (i % REGS_PER_LINE =3D=3D 0) { - qemu_fprintf(f, "%%g%d-%d:", i, i + REGS_PER_LINE - 1); + g_string_append_printf(buf, "%%g%d-%d:", i, i + REGS_PER_LINE = - 1); } - qemu_fprintf(f, " " TARGET_FMT_lx, env->gregs[i]); + g_string_append_printf(buf, " " TARGET_FMT_lx, env->gregs[i]); if (i % REGS_PER_LINE =3D=3D REGS_PER_LINE - 1) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } for (x =3D 0; x < 3; x++) { for (i =3D 0; i < 8; i++) { if (i % REGS_PER_LINE =3D=3D 0) { - qemu_fprintf(f, "%%%c%d-%d: ", + g_string_append_printf(buf, "%%%c%d-%d: ", x =3D=3D 0 ? 'o' : (x =3D=3D 1 ? 'l' : 'i'), i, i + REGS_PER_LINE - 1); } - qemu_fprintf(f, TARGET_FMT_lx " ", env->regwptr[i + x * 8]); + g_string_append_printf(buf, TARGET_FMT_lx " ", + env->regwptr[i + x * 8]); if (i % REGS_PER_LINE =3D=3D REGS_PER_LINE - 1) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } } @@ -645,42 +647,47 @@ void sparc_cpu_dump_state(CPUState *cs, FILE *f, int = flags) if (flags & CPU_DUMP_FPU) { for (i =3D 0; i < TARGET_DPREGS; i++) { if ((i & 3) =3D=3D 0) { - qemu_fprintf(f, "%%f%02d: ", i * 2); + g_string_append_printf(buf, "%%f%02d: ", i * 2); } - qemu_fprintf(f, " %016" PRIx64, env->fpr[i].ll); + g_string_append_printf(buf, " %016" PRIx64, env->fpr[i].ll); if ((i & 3) =3D=3D 3) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } } } =20 #ifdef TARGET_SPARC64 - qemu_fprintf(f, "pstate: %08x ccr: %02x (icc: ", env->pstate, + g_string_append_printf(buf, "pstate: %08x ccr: %02x (icc: ", env->psta= te, (unsigned)cpu_get_ccr(env)); - cpu_print_cc(f, cpu_get_ccr(env) << PSR_CARRY_SHIFT); - qemu_fprintf(f, " xcc: "); - cpu_print_cc(f, cpu_get_ccr(env) << (PSR_CARRY_SHIFT - 4)); - qemu_fprintf(f, ") asi: %02x tl: %d pil: %x gl: %d\n", env->asi, env->= tl, - env->psrpil, env->gl); - qemu_fprintf(f, "tbr: " TARGET_FMT_lx " hpstate: " TARGET_FMT_lx " htb= a: " - TARGET_FMT_lx "\n", env->tbr, env->hpstate, env->htba); - qemu_fprintf(f, "cansave: %d canrestore: %d otherwin: %d wstate: %d " - "cleanwin: %d cwp: %d\n", - env->cansave, env->canrestore, env->otherwin, env->wstate, - env->cleanwin, env->nwindows - 1 - env->cwp); - qemu_fprintf(f, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx " fprs: " - TARGET_FMT_lx "\n", env->fsr, env->y, env->fprs); + cpu_print_cc(buf, cpu_get_ccr(env) << PSR_CARRY_SHIFT); + g_string_append_printf(buf, " xcc: "); + cpu_print_cc(buf, cpu_get_ccr(env) << (PSR_CARRY_SHIFT - 4)); + g_string_append_printf(buf, ") asi: %02x tl: %d pil: %x gl: %d\n", + env->asi, env->tl, env->psrpil, env->gl); + g_string_append_printf(buf, "tbr: " TARGET_FMT_lx " hpstate: " + TARGET_FMT_lx " htba: " TARGET_FMT_lx "\n", + env->tbr, env->hpstate, env->htba); + g_string_append_printf(buf, "cansave: %d canrestore: %d " + "otherwin: %d wstate: %d " + "cleanwin: %d cwp: %d\n", + env->cansave, env->canrestore, + env->otherwin, env->wstate, + env->cleanwin, env->nwindows - 1 - env->cwp); + g_string_append_printf(buf, "fsr: " TARGET_FMT_lx " y: " + TARGET_FMT_lx " fprs: " TARGET_FMT_lx "\n", + env->fsr, env->y, env->fprs); =20 #else - qemu_fprintf(f, "psr: %08x (icc: ", cpu_get_psr(env)); - cpu_print_cc(f, cpu_get_psr(env)); - qemu_fprintf(f, " SPE: %c%c%c) wim: %08x\n", env->psrs ? 'S' : '-', - env->psrps ? 'P' : '-', env->psret ? 'E' : '-', - env->wim); - qemu_fprintf(f, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx "\n", - env->fsr, env->y); + g_string_append_printf(buf, "psr: %08x (icc: ", cpu_get_psr(env)); + cpu_print_cc(buf, cpu_get_psr(env)); + g_string_append_printf(buf, " SPE: %c%c%c) wim: %08x\n", + env->psrs ? 'S' : '-', + env->psrps ? 'P' : '-', env->psret ? 'E' : '-', + env->wim); + g_string_append_printf(buf, "fsr: " TARGET_FMT_lx " y: " TARGET_FMT_lx= "\n", + env->fsr, env->y); #endif - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } =20 static void sparc_cpu_set_pc(CPUState *cs, vaddr value) @@ -889,7 +896,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void = *data) cc->class_by_name =3D sparc_cpu_class_by_name; cc->parse_features =3D sparc_cpu_parse_features; cc->has_work =3D sparc_cpu_has_work; - cc->dump_state =3D sparc_cpu_dump_state; + cc->format_state =3D sparc_cpu_format_state; #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) cc->memory_rw_debug =3D sparc_cpu_memory_rw_debug; #endif diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index ff8ae73002..65a01a7884 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -571,7 +571,7 @@ extern const VMStateDescription vmstate_sparc_cpu; #endif =20 void sparc_cpu_do_interrupt(CPUState *cpu); -void sparc_cpu_dump_state(CPUState *cpu, FILE *f, int flags); +void sparc_cpu_format_state(CPUState *cpu, GString *buf, int flags); hwaddr sparc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int sparc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631166843696.2991242265422; Tue, 14 Sep 2021 07:52:46 -0700 (PDT) Received: from localhost ([::1]:33796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9nh-00054d-Ho for importer@patchew.org; Tue, 14 Sep 2021 10:52:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9RT-0005CF-Sg for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:29:47 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:37800) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9RS-0000tF-68 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:29:47 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-211-_ngq6vkNMNSEfIs-Yi7oXA-1; Tue, 14 Sep 2021 10:29:43 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E74AA10247AB; Tue, 14 Sep 2021 14:29:39 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 635F35D9CA; Tue, 14 Sep 2021 14:29:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629785; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5ox0yxENRArnSajwWt6R0ATTJtvgUIn+1CN57BaiibE=; b=EbCupnzaSYKQq/1KG1fGUCCY73KfyINhdqvifPQ8uNz42srM4iA0OD4yOTw05c86J5aiz7 jqIH81D57wSz3y0yFNxmTwblErKyVkKHPbU1WadjGBltaq7R/W/RvyFpIiFiPF/yp4KpHL a0hEDIWq5yDUZ04/UYtEgi9jmds1xdY= X-MC-Unique: _ngq6vkNMNSEfIs-Yi7oXA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 26/53] target/tricore: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:15 +0100 Message-Id: <20210914142042.1655100-27-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631168531100001 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/tricore/cpu.c | 2 +- target/tricore/cpu.h | 2 +- target/tricore/translate.c | 24 ++++++++++++------------ 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/target/tricore/cpu.c b/target/tricore/cpu.c index b95682b7f0..11f1a79247 100644 --- a/target/tricore/cpu.c +++ b/target/tricore/cpu.c @@ -174,7 +174,7 @@ static void tricore_cpu_class_init(ObjectClass *c, void= *data) cc->gdb_num_core_regs =3D 44; cc->gdb_arch_name =3D tricore_gdb_arch_name; =20 - cc->dump_state =3D tricore_cpu_dump_state; + cc->format_state =3D tricore_cpu_format_state; cc->set_pc =3D tricore_cpu_set_pc; cc->sysemu_ops =3D &tricore_sysemu_ops; cc->tcg_ops =3D &tricore_tcg_ops; diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h index 4b61a2c03f..572bda55e7 100644 --- a/target/tricore/cpu.h +++ b/target/tricore/cpu.h @@ -208,7 +208,7 @@ struct TriCoreCPU { =20 =20 hwaddr tricore_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); -void tricore_cpu_dump_state(CPUState *cpu, FILE *f, int flags); +void tricore_cpu_format_state(CPUState *cpu, GString *buf, int flags); =20 =20 #define MASK_PCXI_PCPN 0xff000000 diff --git a/target/tricore/translate.c b/target/tricore/translate.c index a0cc0f1cb3..a1e56fba32 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -86,7 +86,7 @@ enum { MODE_UU =3D 3, }; =20 -void tricore_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void tricore_cpu_format_state(CPUState *cs, GString *buf, int flags) { TriCoreCPU *cpu =3D TRICORE_CPU(cs); CPUTriCoreState *env =3D &cpu->env; @@ -95,26 +95,26 @@ void tricore_cpu_dump_state(CPUState *cs, FILE *f, int = flags) =20 psw =3D psw_read(env); =20 - qemu_fprintf(f, "PC: " TARGET_FMT_lx, env->PC); - qemu_fprintf(f, " PSW: " TARGET_FMT_lx, psw); - qemu_fprintf(f, " ICR: " TARGET_FMT_lx, env->ICR); - qemu_fprintf(f, "\nPCXI: " TARGET_FMT_lx, env->PCXI); - qemu_fprintf(f, " FCX: " TARGET_FMT_lx, env->FCX); - qemu_fprintf(f, " LCX: " TARGET_FMT_lx, env->LCX); + g_string_append_printf(buf, "PC: " TARGET_FMT_lx, env->PC); + g_string_append_printf(buf, " PSW: " TARGET_FMT_lx, psw); + g_string_append_printf(buf, " ICR: " TARGET_FMT_lx, env->ICR); + g_string_append_printf(buf, "\nPCXI: " TARGET_FMT_lx, env->PCXI); + g_string_append_printf(buf, " FCX: " TARGET_FMT_lx, env->FCX); + g_string_append_printf(buf, " LCX: " TARGET_FMT_lx, env->LCX); =20 for (i =3D 0; i < 16; ++i) { if ((i & 3) =3D=3D 0) { - qemu_fprintf(f, "\nGPR A%02d:", i); + g_string_append_printf(buf, "\nGPR A%02d:", i); } - qemu_fprintf(f, " " TARGET_FMT_lx, env->gpr_a[i]); + g_string_append_printf(buf, " " TARGET_FMT_lx, env->gpr_a[i]); } for (i =3D 0; i < 16; ++i) { if ((i & 3) =3D=3D 0) { - qemu_fprintf(f, "\nGPR D%02d:", i); + g_string_append_printf(buf, "\nGPR D%02d:", i); } - qemu_fprintf(f, " " TARGET_FMT_lx, env->gpr_d[i]); + g_string_append_printf(buf, " " TARGET_FMT_lx, env->gpr_d[i]); } - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); } =20 /* --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631296105783.8836736831224; Tue, 14 Sep 2021 07:54:56 -0700 (PDT) Received: from localhost ([::1]:42334 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9pm-0002Lo-TD for importer@patchew.org; Tue, 14 Sep 2021 10:54:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39234) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Rw-0006Q0-CD for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:30:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:58816) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Rs-0001BV-FS for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:30:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-571-S4FmMyaQPYemK64UexRJLA-1; Tue, 14 Sep 2021 10:30:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 75238800FF4; Tue, 14 Sep 2021 14:29:59 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4B4F85D9DC; Tue, 14 Sep 2021 14:29:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629811; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7KXlBSxjSPGX8vdep8ZUyktA0Aba3nVeAQEL1Cpyva4=; b=SzVSKb+pRrRb7O5F4dihAupJwj8zfqIH84drrhwoswW57dD5FleF7Byusxk84gBOZMEdx5 Ng1/vPOtTrzcqywufN1maLVqWsPQEPA9nDLLI2RqxlkFT/mgEbjaqDNZ2yQ93l1t9prA8Q pQnUdIqurX1cMsnChg1hSk4dBWfmnQY= X-MC-Unique: S4FmMyaQPYemK64UexRJLA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 27/53] target/xtensa: convert to use format_state instead of dump_state Date: Tue, 14 Sep 2021 15:20:16 +0100 Message-Id: <20210914142042.1655100-28-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631296940100001 Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/xtensa/cpu.c | 2 +- target/xtensa/cpu.h | 2 +- target/xtensa/translate.c | 45 ++++++++++++++++++++------------------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/target/xtensa/cpu.c b/target/xtensa/cpu.c index 58ec3a0862..a5a416e0b3 100644 --- a/target/xtensa/cpu.c +++ b/target/xtensa/cpu.c @@ -216,7 +216,7 @@ static void xtensa_cpu_class_init(ObjectClass *oc, void= *data) =20 cc->class_by_name =3D xtensa_cpu_class_by_name; cc->has_work =3D xtensa_cpu_has_work; - cc->dump_state =3D xtensa_cpu_dump_state; + cc->format_state =3D xtensa_cpu_format_state; cc->set_pc =3D xtensa_cpu_set_pc; cc->gdb_read_register =3D xtensa_cpu_gdb_read_register; cc->gdb_write_register =3D xtensa_cpu_gdb_write_register; diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 2345cb59c7..97cd6892df 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -572,7 +572,7 @@ void xtensa_cpu_do_transaction_failed(CPUState *cs, hwa= ddr physaddr, vaddr addr, unsigned size, MMUAccessType access_= type, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t reta= ddr); -void xtensa_cpu_dump_state(CPUState *cpu, FILE *f, int flags); +void xtensa_cpu_format_state(CPUState *cpu, GString *buf, int flags); hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void xtensa_count_regs(const XtensaConfig *config, unsigned *n_regs, unsigned *n_core_regs); diff --git a/target/xtensa/translate.c b/target/xtensa/translate.c index 20399d6a04..0f57d2abaf 100644 --- a/target/xtensa/translate.c +++ b/target/xtensa/translate.c @@ -1325,14 +1325,14 @@ void gen_intermediate_code(CPUState *cpu, Translati= onBlock *tb, int max_insns) translator_loop(&xtensa_translator_ops, &dc.base, cpu, tb, max_insns); } =20 -void xtensa_cpu_dump_state(CPUState *cs, FILE *f, int flags) +void xtensa_cpu_format_state(CPUState *cs, GString *buf, int flags) { XtensaCPU *cpu =3D XTENSA_CPU(cs); CPUXtensaState *env =3D &cpu->env; xtensa_isa isa =3D env->config->isa; int i, j; =20 - qemu_fprintf(f, "PC=3D%08x\n\n", env->pc); + g_string_append_printf(buf, "PC=3D%08x\n\n", env->pc); =20 for (i =3D j =3D 0; i < xtensa_isa_num_sysregs(isa); ++i) { const uint32_t *reg =3D @@ -1340,55 +1340,56 @@ void xtensa_cpu_dump_state(CPUState *cs, FILE *f, i= nt flags) int regno =3D xtensa_sysreg_number(isa, i); =20 if (regno >=3D 0) { - qemu_fprintf(f, "%12s=3D%08x%c", - xtensa_sysreg_name(isa, i), - reg[regno], - (j++ % 4) =3D=3D 3 ? '\n' : ' '); + g_string_append_printf(buf, "%12s=3D%08x%c", + xtensa_sysreg_name(isa, i), + reg[regno], + (j++ % 4) =3D=3D 3 ? '\n' : ' '); } } =20 - qemu_fprintf(f, (j % 4) =3D=3D 0 ? "\n" : "\n\n"); + g_string_append_printf(buf, (j % 4) =3D=3D 0 ? "\n" : "\n\n"); =20 for (i =3D 0; i < 16; ++i) { - qemu_fprintf(f, " A%02d=3D%08x%c", - i, env->regs[i], (i % 4) =3D=3D 3 ? '\n' : ' '); + g_string_append_printf(buf, " A%02d=3D%08x%c", + i, env->regs[i], (i % 4) =3D=3D 3 ? '\n' : = ' '); } =20 xtensa_sync_phys_from_window(env); - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); =20 for (i =3D 0; i < env->config->nareg; ++i) { - qemu_fprintf(f, "AR%02d=3D%08x ", i, env->phys_regs[i]); + g_string_append_printf(buf, "AR%02d=3D%08x ", i, env->phys_regs[i]= ); if (i % 4 =3D=3D 3) { bool ws =3D (env->sregs[WINDOW_START] & (1 << (i / 4))) !=3D 0; bool cw =3D env->sregs[WINDOW_BASE] =3D=3D i / 4; =20 - qemu_fprintf(f, "%c%c\n", ws ? '<' : ' ', cw ? '=3D' : ' '); + g_string_append_printf(buf, "%c%c\n", + ws ? '<' : ' ', cw ? '=3D' : ' '); } } =20 if ((flags & CPU_DUMP_FPU) && xtensa_option_enabled(env->config, XTENSA_OPTION_FP_COPROCESSOR)) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); =20 for (i =3D 0; i < 16; ++i) { - qemu_fprintf(f, "F%02d=3D%08x (%-+15.8e)%c", i, - float32_val(env->fregs[i].f32[FP_F32_LOW]), - *(float *)(env->fregs[i].f32 + FP_F32_LOW), - (i % 2) =3D=3D 1 ? '\n' : ' '); + g_string_append_printf(buf, "F%02d=3D%08x (%-+15.8e)%c", i, + float32_val(env->fregs[i].f32[FP_F32_LO= W]), + *(float *)(env->fregs[i].f32 + FP_F32_L= OW), + (i % 2) =3D=3D 1 ? '\n' : ' '); } } =20 if ((flags & CPU_DUMP_FPU) && xtensa_option_enabled(env->config, XTENSA_OPTION_DFP_COPROCESSOR) = && !xtensa_option_enabled(env->config, XTENSA_OPTION_DFPU_SINGLE_ONLY= )) { - qemu_fprintf(f, "\n"); + g_string_append_printf(buf, "\n"); =20 for (i =3D 0; i < 16; ++i) { - qemu_fprintf(f, "F%02d=3D%016"PRIx64" (%-+24.16le)%c", i, - float64_val(env->fregs[i].f64), - *(double *)(&env->fregs[i].f64), - (i % 2) =3D=3D 1 ? '\n' : ' '); + g_string_append_printf(buf, "F%02d=3D%016"PRIx64" (%-+24.16le)= %c", i, + float64_val(env->fregs[i].f64), + *(double *)(&env->fregs[i].f64), + (i % 2) =3D=3D 1 ? '\n' : ' '); } } } --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631632213828681.8543464685202; Tue, 14 Sep 2021 08:10:13 -0700 (PDT) Received: from localhost ([::1]:58700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQA4a-0007uK-Qg for importer@patchew.org; Tue, 14 Sep 2021 11:10:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39286) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Ry-0006U5-DB for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:30:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:57443) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Rw-0001Db-4F for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:30:18 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-297-FJ_PELA1Nk-yPfAkS6bYFA-1; Tue, 14 Sep 2021 10:30:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B256835DEE; Tue, 14 Sep 2021 14:30:09 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id AB02B5D9DC; Tue, 14 Sep 2021 14:29:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629815; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=be82tQBLLAMQdwGA50YKu57XeGmPPD0+NHLXGjTgS5Q=; b=UqqmLbtPmig4vqO+SU6KjnKMm8ZnxDXKqY4yDxNJPro55oeBpKhcbSwzPjzkfg5Ta9/aZL g+8rAQRxe3JaDoo+CItHhqJOtDZ4UeqEcZZEAfSyUpc/72GHN39RiJJFt3p2Wne297i1XK 7oV6DRa665hRUNLMNgiCLzNOim8mlEQ= X-MC-Unique: FJ_PELA1Nk-yPfAkS6bYFA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 28/53] monitor: remove 'info ioapic' HMP command Date: Tue, 14 Sep 2021 15:20:17 +0100 Message-Id: <20210914142042.1655100-29-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632217713100001 This command was turned into a no-op four years ago in commit 0c8465440d50c18a7bb13d0a866748f0593e193a Author: Peter Xu Date: Fri Dec 29 15:31:04 2017 +0800 hmp: obsolete "info ioapic" Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hmp-commands-info.hx | 15 --------------- include/monitor/hmp-target.h | 1 - target/i386/monitor.c | 6 ------ 3 files changed, 22 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 27206ac049..f8312342cd 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -127,21 +127,6 @@ SRST Show local APIC state ERST =20 -#if defined(TARGET_I386) - { - .name =3D "ioapic", - .args_type =3D "", - .params =3D "", - .help =3D "show io apic state", - .cmd =3D hmp_info_io_apic, - }, -#endif - -SRST - ``info ioapic`` - Show io APIC state -ERST - { .name =3D "cpus", .args_type =3D "", diff --git a/include/monitor/hmp-target.h b/include/monitor/hmp-target.h index 60fc92722a..df79ad3355 100644 --- a/include/monitor/hmp-target.h +++ b/include/monitor/hmp-target.h @@ -48,6 +48,5 @@ void hmp_info_mem(Monitor *mon, const QDict *qdict); void hmp_info_tlb(Monitor *mon, const QDict *qdict); void hmp_mce(Monitor *mon, const QDict *qdict); void hmp_info_local_apic(Monitor *mon, const QDict *qdict); -void hmp_info_io_apic(Monitor *mon, const QDict *qdict); =20 #endif /* MONITOR_HMP_TARGET_H */ diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 119211f0b0..19468c4e85 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -669,12 +669,6 @@ void hmp_info_local_apic(Monitor *mon, const QDict *qd= ict) x86_cpu_dump_local_apic_state(cs, CPU_DUMP_FPU); } =20 -void hmp_info_io_apic(Monitor *mon, const QDict *qdict) -{ - monitor_printf(mon, "This command is obsolete and will be " - "removed soon. Please use 'info pic' instead.\n"); -} - SevInfo *qmp_query_sev(Error **errp) { SevInfo *info; --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631632676340243.85177620591344; Tue, 14 Sep 2021 08:17:56 -0700 (PDT) Received: from localhost ([::1]:48074 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAC3-0003yR-9n for importer@patchew.org; Tue, 14 Sep 2021 11:17:55 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39746) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Sm-0007SC-HY for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:08 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:24452) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Sj-0001p6-Mm for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:08 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-346-A6dIhPXlOQuOSDTffEcoBQ-1; Tue, 14 Sep 2021 10:30:59 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D409610144E2; Tue, 14 Sep 2021 14:30:55 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9CF65D9DC; Tue, 14 Sep 2021 14:30:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629861; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iGP7dXbjGWq7ILIEw/l3CktBYMqdeJCapqhh4XsPuqw=; b=SEN3yHt0U1Zxum1VPp7JqBunBjC1XAz6YAo0/GaXOmMDpjSlTJ8/PkI3Sw60Tc5DS1AMn/ KdbZHH9sM88OxmqsV01zSAxuvVHaXgyAe2sXPgYnGtT/q5DmWkBaCdIAyoWWZPl6avkeII 4mNPMyd5lKE1N0MeQ25qBeuEjQcFU5U= X-MC-Unique: A6dIhPXlOQuOSDTffEcoBQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 29/53] qapi: introduce x-query-registers QMP command Date: Tue, 14 Sep 2021 15:20:18 +0100 Message-Id: <20210914142042.1655100-30-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632676906100001 This is a counterpart to the HMP "info registers" command. It is being added with an "x-" prefix because this QMP command is intended as an ad hoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/core/machine-qmp-cmds.c | 30 ++++++++++++++++++++++++++++++ monitor/misc.c | 25 ++++++++++++++++--------- qapi/common.json | 11 +++++++++++ qapi/machine.json | 15 +++++++++++++++ 4 files changed, 72 insertions(+), 9 deletions(-) diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 216fdfaf3a..c4e384f7d5 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -204,3 +204,33 @@ MemdevList *qmp_query_memdev(Error **errp) object_child_foreach(obj, query_memdev, &list); return list; } + +HumanReadableText *qmp_x_query_registers(bool has_cpu, int64_t cpu, + Error **errp) +{ + HumanReadableText *ret; + g_autoptr(GString) buf =3D g_string_new(""); + CPUState *cs =3D NULL, *tmp; + + if (has_cpu) { + CPU_FOREACH(tmp) { + if (cpu =3D=3D tmp->cpu_index) { + cs =3D tmp; + } + } + if (!cs) { + error_setg(errp, "CPU %"PRId64" not available", cpu); + return NULL; + } + cpu_format_state(cs, buf, CPU_DUMP_FPU); + } else { + CPU_FOREACH(cs) { + g_string_append_printf(buf, "\nCPU#%d\n", cs->cpu_index); + cpu_format_state(cs, buf, CPU_DUMP_FPU); + } + } + + ret =3D g_new0(HumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} diff --git a/monitor/misc.c b/monitor/misc.c index ffe7966870..f25801a1a3 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -67,6 +67,7 @@ #include "block/block-hmp-cmds.h" #include "qapi/qapi-commands-char.h" #include "qapi/qapi-commands-control.h" +#include "qapi/qapi-commands-machine.h" #include "qapi/qapi-commands-migration.h" #include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-qom.h" @@ -301,23 +302,29 @@ int monitor_get_cpu_index(Monitor *mon) static void hmp_info_registers(Monitor *mon, const QDict *qdict) { bool all_cpus =3D qdict_get_try_bool(qdict, "cpustate_all", false); - CPUState *cs; + bool has_cpu =3D !all_cpus; + int64_t cpu =3D 0; + Error *err =3D NULL; + g_autoptr(HumanReadableText) info =3D NULL; =20 - if (all_cpus) { - CPU_FOREACH(cs) { - monitor_printf(mon, "\nCPU#%d\n", cs->cpu_index); - cpu_dump_state(cs, NULL, CPU_DUMP_FPU); - } - } else { - cs =3D mon_get_cpu(mon); + if (has_cpu) { + CPUState *cs =3D mon_get_cpu(mon); =20 if (!cs) { monitor_printf(mon, "No CPU available\n"); return; } =20 - cpu_dump_state(cs, NULL, CPU_DUMP_FPU); + cpu =3D cs->cpu_index; } + + info =3D qmp_x_query_registers(has_cpu, cpu, &err); + if (err) { + error_report_err(err); + return; + } + + monitor_printf(mon, "%s", info->human_readable_text); } =20 static void hmp_info_sync_profile(Monitor *mon, const QDict *qdict) diff --git a/qapi/common.json b/qapi/common.json index 7c976296f0..de7614ca99 100644 --- a/qapi/common.json +++ b/qapi/common.json @@ -197,3 +197,14 @@ { 'enum': 'GrabToggleKeys', 'data': [ 'ctrl-ctrl', 'alt-alt', 'shift-shift','meta-meta', 'scrolllock= ', 'ctrl-scrolllock' ] } + +## +# @HumanReadableText: +# +# @human-readable-text: Formatted output intended for humans. +# +# Since: 6.2.0 +# +## +{ 'struct': 'HumanReadableText', + 'data': { 'human-readable-text': 'str' } } diff --git a/qapi/machine.json b/qapi/machine.json index 157712f006..8737efa865 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1312,3 +1312,18 @@ '*cores': 'int', '*threads': 'int', '*maxcpus': 'int' } } + +## +# @x-query-registers: +# +# @cpu: the CPU number to query. If omitted, queries all CPUs +# +# Query information on the CPU registers +# +# Returns: CPU state in an architecture-specific format +# +# Since: 6.2 +## +{ 'command': 'x-query-registers', + 'data': {'*cpu': 'int' }, + 'returns': 'HumanReadableText' } --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631632451704707.5312761947001; Tue, 14 Sep 2021 08:14:11 -0700 (PDT) Received: from localhost ([::1]:40596 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQA8Q-0006ww-M0 for importer@patchew.org; Tue, 14 Sep 2021 11:14:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39846) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Ss-0007Xt-Rx for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:22 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:28509) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9So-0001xL-Ta for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:14 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-505-F8zNCVkEPpKPd_8ReUkXYQ-1; Tue, 14 Sep 2021 10:31:08 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5D240BAF81; Tue, 14 Sep 2021 14:31:04 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 386465D9CA; Tue, 14 Sep 2021 14:30:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629869; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cNOaNgDzolO+0it+J7fzAXgDUa5QpcR8ph6GT7968cA=; b=FYF4kXneVqcU0o4E2uvvgT1lRM5wwwsyg+R1FybFPBbfK+qbC9GXaJBnD0CJVFd6P4XS/p nFrwn2YtM8dB4k4FydQtbH5rGdwWPBcailpME/knPWYRq7i1gxe8cTxKiYnHQgoSeRENeB qykrHOnxMH0g8A/gHygE38zPhUNYRYw= X-MC-Unique: F8zNCVkEPpKPd_8ReUkXYQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 30/53] qapi: introduce x-query-roms QMP command Date: Tue, 14 Sep 2021 15:20:19 +0100 Message-Id: <20210914142042.1655100-31-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632454001100001 This is a counterpart to the HMP "info roms" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/core/loader.c | 55 ++++++++++++++++++++++++++++++++--------------- qapi/machine.json | 12 +++++++++++ 2 files changed, 50 insertions(+), 17 deletions(-) diff --git a/hw/core/loader.c b/hw/core/loader.c index c623318b73..014d131847 100644 --- a/hw/core/loader.c +++ b/hw/core/loader.c @@ -46,6 +46,7 @@ #include "qemu-common.h" #include "qemu/datadir.h" #include "qapi/error.h" +#include "qapi/qapi-commands-machine.h" #include "trace.h" #include "hw/hw.h" #include "disas/disas.h" @@ -1472,32 +1473,52 @@ void *rom_ptr_for_as(AddressSpace *as, hwaddr addr,= size_t size) return cbdata.rom; } =20 -void hmp_info_roms(Monitor *mon, const QDict *qdict) +HumanReadableText *qmp_x_query_roms(Error **errp) { Rom *rom; + g_autoptr(GString) buf =3D g_string_new(""); + HumanReadableText *ret; =20 QTAILQ_FOREACH(rom, &roms, next) { if (rom->mr) { - monitor_printf(mon, "%s" - " size=3D0x%06zx name=3D\"%s\"\n", - memory_region_name(rom->mr), - rom->romsize, - rom->name); + g_string_append_printf(buf, "%s" + " size=3D0x%06zx name=3D\"%s\"\n", + memory_region_name(rom->mr), + rom->romsize, + rom->name); } else if (!rom->fw_file) { - monitor_printf(mon, "addr=3D" TARGET_FMT_plx - " size=3D0x%06zx mem=3D%s name=3D\"%s\"\n", - rom->addr, rom->romsize, - rom->isrom ? "rom" : "ram", - rom->name); + g_string_append_printf(buf, "addr=3D" TARGET_FMT_plx + " size=3D0x%06zx mem=3D%s name=3D\"%s\"= \n", + rom->addr, rom->romsize, + rom->isrom ? "rom" : "ram", + rom->name); } else { - monitor_printf(mon, "fw=3D%s/%s" - " size=3D0x%06zx name=3D\"%s\"\n", - rom->fw_dir, - rom->fw_file, - rom->romsize, - rom->name); + g_string_append_printf(buf, "fw=3D%s/%s" + " size=3D0x%06zx name=3D\"%s\"\n", + rom->fw_dir, + rom->fw_file, + rom->romsize, + rom->name); } } + + ret =3D g_new0(HumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} + + +void hmp_info_roms(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + g_autoptr(HumanReadableText) info =3D qmp_x_query_roms(&err); + + if (err) { + error_report_err(err); + return; + } + + monitor_printf(mon, "%s", info->human_readable_text); } =20 typedef enum HexRecord HexRecord; diff --git a/qapi/machine.json b/qapi/machine.json index 8737efa865..a4a1727589 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1327,3 +1327,15 @@ { 'command': 'x-query-registers', 'data': {'*cpu': 'int' }, 'returns': 'HumanReadableText' } + +## +# @x-query-roms: +# +# Query information on the registered ROMS +# +# Returns: registered ROMs +# +# Since: 6.2 +## +{ 'command': 'x-query-roms', + 'returns': 'HumanReadableText' } --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631632869454227.8225333217522; Tue, 14 Sep 2021 08:21:09 -0700 (PDT) Received: from localhost ([::1]:56590 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAFA-0001Eb-D5 for importer@patchew.org; Tue, 14 Sep 2021 11:21:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:39920) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9T4-0007ZE-O8 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:28 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:47531) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9T0-00023q-33 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-DzwM4sEqPIKIg6xNgKRU2A-1; Tue, 14 Sep 2021 10:31:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C533FBAF85; Tue, 14 Sep 2021 14:31:12 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id D34355D9CA; Tue, 14 Sep 2021 14:31:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629878; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WKPtyLPMWCX3yKuA9WhedPW4MlFG6fQaHVMY3/9/jrY=; b=O1fFKwGMUfueoW8o6aJpPNKlsUdEy+P/BYjP2HsLco+9uE44q7e0p3MPmwIt9fH4ev4IYV waG6AWY59a2C9fr7qjS5j3cmc3LiRytuKKttvBoHUtAW9pOIdwtHKg49XrI90G4CvryyXs Mk959YsaWH2YoagoQ5lZ3wMAyhMGmEU= X-MC-Unique: DzwM4sEqPIKIg6xNgKRU2A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 31/53] qapi: introduce x-query-profile QMP command Date: Tue, 14 Sep 2021 15:20:20 +0100 Message-Id: <20210914142042.1655100-32-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632870431100002 This is a counterpart to the HMP "info profile" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. Signed-off-by: Daniel P. Berrang=C3=A9 --- monitor/misc.c | 29 +++++++---------------------- monitor/qmp-cmds.c | 34 ++++++++++++++++++++++++++++++++++ qapi/machine.json | 12 ++++++++++++ tests/qtest/qmp-cmd-test.c | 3 +++ 4 files changed, 56 insertions(+), 22 deletions(-) diff --git a/monitor/misc.c b/monitor/misc.c index f25801a1a3..6b07efdddd 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -936,32 +936,17 @@ static void hmp_info_mtree(Monitor *mon, const QDict = *qdict) mtree_info(flatview, dispatch_tree, owner, disabled); } =20 -#ifdef CONFIG_PROFILER - -int64_t dev_time; - static void hmp_info_profile(Monitor *mon, const QDict *qdict) { - static int64_t last_cpu_exec_time; - int64_t cpu_exec_time; - int64_t delta; - - cpu_exec_time =3D tcg_cpu_exec_time(); - delta =3D cpu_exec_time - last_cpu_exec_time; + Error *err =3D NULL; + g_autoptr(HumanReadableText) info =3D qmp_x_query_profile(&err); =20 - monitor_printf(mon, "async time %" PRId64 " (%0.3f)\n", - dev_time, dev_time / (double)NANOSECONDS_PER_SECOND); - monitor_printf(mon, "qemu time %" PRId64 " (%0.3f)\n", - delta, delta / (double)NANOSECONDS_PER_SECOND); - last_cpu_exec_time =3D cpu_exec_time; - dev_time =3D 0; -} -#else -static void hmp_info_profile(Monitor *mon, const QDict *qdict) -{ - monitor_printf(mon, "Internal profiler not compiled\n"); + if (err) { + error_report_err(err); + return; + } + monitor_printf(mon, "%s", info->human_readable_text); } -#endif =20 /* Capture support */ static QLIST_HEAD (capture_list_head, CaptureState) capture_head; diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 5c0d5e116b..7bae0770a9 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -350,3 +350,37 @@ void qmp_display_reload(DisplayReloadOptions *arg, Err= or **errp) abort(); } } + +#ifdef CONFIG_PROFILER + +int64_t dev_time; + +HumanReadableText *qmp_x_query_profile(Error **errp) +{ + HumanReadableText *ret; + g_autoptr(GString) buf =3D g_string_new(""); + static int64_t last_cpu_exec_time; + int64_t cpu_exec_time; + int64_t delta; + + cpu_exec_time =3D tcg_cpu_exec_time(); + delta =3D cpu_exec_time - last_cpu_exec_time; + + g_string_append_printf(buf, "async time %" PRId64 " (%0.3f)\n", + dev_time, dev_time / (double)NANOSECONDS_PER_SE= COND); + g_string_append_printf(buf, "qemu time %" PRId64 " (%0.3f)\n", + delta, delta / (double)NANOSECONDS_PER_SECOND); + last_cpu_exec_time =3D cpu_exec_time; + dev_time =3D 0; + + ret =3D g_new0(HumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} +#else +HumanReadableText *qmp_x_query_profile(Error **errp) +{ + error_setg(errp, "Internal profiler not compiled"); + return NULL; +} +#endif diff --git a/qapi/machine.json b/qapi/machine.json index a4a1727589..d74c3f3fef 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1313,6 +1313,18 @@ '*threads': 'int', '*maxcpus': 'int' } } =20 +## +# @x-query-profile: +# +# Query TCG profiling information +# +# Returns: profile information +# +# Since: 6.2 +## +{ 'command': 'x-query-profile', + 'returns': 'HumanReadableText' } + ## # @x-query-registers: # diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index c98b78d033..fbd7ac10fb 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -46,6 +46,9 @@ static int query_error_class(const char *cmd) { "query-balloon", ERROR_CLASS_DEVICE_NOT_ACTIVE }, { "query-hotpluggable-cpus", ERROR_CLASS_GENERIC_ERROR }, { "query-vm-generation-id", ERROR_CLASS_GENERIC_ERROR }, +#ifndef CONFIG_PROFILER + { "x-query-profile", ERROR_CLASS_GENERIC_ERROR }, +#endif { NULL, -1 } }; int i; --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631632690321906.3258929197743; Tue, 14 Sep 2021 08:18:10 -0700 (PDT) Received: from localhost ([::1]:49262 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQACH-0004lD-9T for importer@patchew.org; Tue, 14 Sep 2021 11:18:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40000) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9TB-0007qq-VR for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:34 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:60853) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9T8-0002Bi-FW for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:33 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-590-9W2v34IWNiqKtR_BwCE15w-1; Tue, 14 Sep 2021 10:31:28 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1AC6B1054F90; Tue, 14 Sep 2021 14:31:21 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0B3565D9DD; Tue, 14 Sep 2021 14:31:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629889; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x2ItSwilEkeD7dA4djStHQP7kqiJtaHr3ZbwT8gFz/w=; b=cXFA74yAOE6HcErDXxfe/1nqAgJw/ut994Cox68Uo3exTDY6Zl0z62ebpxv/3qETkm2Mj2 j+fm/OptAECW+oa2cVu3/3fQ7USp/vJiIMHJggnSQ+VuFCP0sjUD9bNXWTQhX8ztIBG4m7 FyAbtA3FblUNQnL9HNp92TAinpAwcKc= X-MC-Unique: 9W2v34IWNiqKtR_BwCE15w-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 32/53] qapi: introduce x-query-numa QMP command Date: Tue, 14 Sep 2021 15:20:21 +0100 Message-Id: <20210914142042.1655100-33-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632692545100003 This is a counterpart to the HMP "info numa" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/core/machine-hmp-cmds.c | 33 +++++------------------------- hw/core/machine-qmp-cmds.c | 42 ++++++++++++++++++++++++++++++++++++++ qapi/machine.json | 12 +++++++++++ 3 files changed, 59 insertions(+), 28 deletions(-) diff --git a/hw/core/machine-hmp-cmds.c b/hw/core/machine-hmp-cmds.c index 76b22b00d6..cfa01c6933 100644 --- a/hw/core/machine-hmp-cmds.c +++ b/hw/core/machine-hmp-cmds.c @@ -134,35 +134,12 @@ void hmp_info_memdev(Monitor *mon, const QDict *qdict) =20 void hmp_info_numa(Monitor *mon, const QDict *qdict) { - int i, nb_numa_nodes; - NumaNodeMem *node_mem; - CpuInfoFastList *cpu_list, *cpu; - MachineState *ms =3D MACHINE(qdev_get_machine()); + Error *err =3D NULL; + g_autoptr(HumanReadableText) info =3D qmp_x_query_numa(&err); =20 - nb_numa_nodes =3D ms->numa_state ? ms->numa_state->num_nodes : 0; - monitor_printf(mon, "%d nodes\n", nb_numa_nodes); - if (!nb_numa_nodes) { + if (err) { + error_report_err(err); return; } - - cpu_list =3D qmp_query_cpus_fast(&error_abort); - node_mem =3D g_new0(NumaNodeMem, nb_numa_nodes); - - query_numa_node_mem(node_mem, ms); - for (i =3D 0; i < nb_numa_nodes; i++) { - monitor_printf(mon, "node %d cpus:", i); - for (cpu =3D cpu_list; cpu; cpu =3D cpu->next) { - if (cpu->value->has_props && cpu->value->props->has_node_id && - cpu->value->props->node_id =3D=3D i) { - monitor_printf(mon, " %" PRIi64, cpu->value->cpu_index); - } - } - monitor_printf(mon, "\n"); - monitor_printf(mon, "node %d size: %" PRId64 " MB\n", i, - node_mem[i].node_mem >> 20); - monitor_printf(mon, "node %d plugged: %" PRId64 " MB\n", i, - node_mem[i].node_plugged_mem >> 20); - } - qapi_free_CpuInfoFastList(cpu_list); - g_free(node_mem); + monitor_printf(mon, "%s", info->human_readable_text); } diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index c4e384f7d5..4407e967da 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -234,3 +234,45 @@ HumanReadableText *qmp_x_query_registers(bool has_cpu,= int64_t cpu, ret->human_readable_text =3D g_steal_pointer(&buf->str); return ret; } + +HumanReadableText *qmp_x_query_numa(Error **errp) +{ + HumanReadableText *ret; + g_autoptr(GString) buf =3D g_string_new(""); + int i, nb_numa_nodes; + NumaNodeMem *node_mem; + CpuInfoFastList *cpu_list, *cpu; + MachineState *ms =3D MACHINE(qdev_get_machine()); + + nb_numa_nodes =3D ms->numa_state ? ms->numa_state->num_nodes : 0; + g_string_append_printf(buf, "%d nodes\n", nb_numa_nodes); + if (!nb_numa_nodes) { + goto done; + } + + cpu_list =3D qmp_query_cpus_fast(&error_abort); + node_mem =3D g_new0(NumaNodeMem, nb_numa_nodes); + + query_numa_node_mem(node_mem, ms); + for (i =3D 0; i < nb_numa_nodes; i++) { + g_string_append_printf(buf, "node %d cpus:", i); + for (cpu =3D cpu_list; cpu; cpu =3D cpu->next) { + if (cpu->value->has_props && cpu->value->props->has_node_id && + cpu->value->props->node_id =3D=3D i) { + g_string_append_printf(buf, " %" PRIi64, cpu->value->cpu_i= ndex); + } + } + g_string_append_printf(buf, "\n"); + g_string_append_printf(buf, "node %d size: %" PRId64 " MB\n", i, + node_mem[i].node_mem >> 20); + g_string_append_printf(buf, "node %d plugged: %" PRId64 " MB\n", i, + node_mem[i].node_plugged_mem >> 20); + } + qapi_free_CpuInfoFastList(cpu_list); + g_free(node_mem); + + done: + ret =3D g_new0(HumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} diff --git a/qapi/machine.json b/qapi/machine.json index d74c3f3fef..916f855e9b 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1313,6 +1313,18 @@ '*threads': 'int', '*maxcpus': 'int' } } =20 +## +# @x-query-numa: +# +# Query NUMA topology information +# +# Returns: topology information +# +# Since: 6.2 +## +{ 'command': 'x-query-numa', + 'returns': 'HumanReadableText' } + ## # @x-query-profile: # --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631632915249635.215779924226; Tue, 14 Sep 2021 08:21:55 -0700 (PDT) Received: from localhost ([::1]:58442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAFu-0002Y6-67 for importer@patchew.org; Tue, 14 Sep 2021 11:21:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40102) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9TJ-0007wu-7C for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:41 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:48189) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9TD-0002Et-Ua for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:37 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-45-tjhAf0BdMkOY_rTzK4JcoQ-1; Tue, 14 Sep 2021 10:31:32 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EB966BAF85; Tue, 14 Sep 2021 14:31:28 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 680185D9CA; Tue, 14 Sep 2021 14:31:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629895; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=L95vl1UuVwpTJtxDmY7MB+2pUWJRC8Yr3yhD63QKkCg=; b=aTb6stm/QpNrSKvcFAYZ47mWeBLQXpDk3huqPVSbmaKmvLOXl8WyRUntq9xXPVYRT1rH0o 90677J0q2O9gieoGYMXJHpAOYD7LDa3Xde4sXaw4oJsfM9bNT/y3cRw6Vt9sEtPlhcqM+2 2FkwXKM4eMFhKx7E5UMdLFbufRIFLZ4= X-MC-Unique: tjhAf0BdMkOY_rTzK4JcoQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 33/53] qapi: introduce x-query-usb QMP command Date: Tue, 14 Sep 2021 15:20:22 +0100 Message-Id: <20210914142042.1655100-34-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.129.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632917632100003 This is a counterpart to the HMP "info usb" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/usb/bus.c | 38 +++++++++++++++++++++++++++++--------- qapi/machine.json | 12 ++++++++++++ stubs/usb-dev-stub.c | 8 ++++++++ tests/qtest/qmp-cmd-test.c | 2 ++ 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/hw/usb/bus.c b/hw/usb/bus.c index 07083349f5..f94d872429 100644 --- a/hw/usb/bus.c +++ b/hw/usb/bus.c @@ -2,6 +2,7 @@ #include "hw/qdev-properties.h" #include "hw/usb.h" #include "qapi/error.h" +#include "qapi/qapi-commands-machine.h" #include "qemu/error-report.h" #include "qemu/module.h" #include "sysemu/sysemu.h" @@ -631,15 +632,17 @@ static char *usb_get_fw_dev_path(DeviceState *qdev) return fw_path; } =20 -void hmp_info_usb(Monitor *mon, const QDict *qdict) +HumanReadableText *qmp_x_query_usb(Error **errp) { + HumanReadableText *ret; + g_autoptr(GString) buf =3D g_string_new(""); USBBus *bus; USBDevice *dev; USBPort *port; =20 if (QTAILQ_EMPTY(&busses)) { - monitor_printf(mon, "USB support not enabled\n"); - return; + error_setg(errp, "USB support not enabled"); + return NULL; } =20 QTAILQ_FOREACH(bus, &busses, next) { @@ -647,14 +650,31 @@ void hmp_info_usb(Monitor *mon, const QDict *qdict) dev =3D port->dev; if (!dev) continue; - monitor_printf(mon, " Device %d.%d, Port %s, Speed %s Mb/s, " - "Product %s%s%s\n", - bus->busnr, dev->addr, port->path, - usb_speed(dev->speed), dev->product_desc, - dev->qdev.id ? ", ID: " : "", - dev->qdev.id ?: ""); + g_string_append_printf(buf, + " Device %d.%d, Port %s, Speed %s Mb/s= , " + "Product %s%s%s\n", + bus->busnr, dev->addr, port->path, + usb_speed(dev->speed), dev->product_des= c, + dev->qdev.id ? ", ID: " : "", + dev->qdev.id ?: ""); } } + + ret =3D g_new0(HumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} + +void hmp_info_usb(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + g_autoptr(HumanReadableText) info =3D qmp_x_query_usb(&err); + + if (err) { + error_report_err(err); + return; + } + monitor_printf(mon, "%s", info->human_readable_text); } =20 /* handle legacy -usbdevice cmd line option */ diff --git a/qapi/machine.json b/qapi/machine.json index 916f855e9b..39d800c2c1 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1363,3 +1363,15 @@ ## { 'command': 'x-query-roms', 'returns': 'HumanReadableText' } + +## +# @x-query-usb: +# +# Query information on the USB devices +# +# Returns: USB device information +# +# Since: 6.2 +## +{ 'command': 'x-query-usb', + 'returns': 'HumanReadableText' } diff --git a/stubs/usb-dev-stub.c b/stubs/usb-dev-stub.c index b1adeeb454..aa557692b7 100644 --- a/stubs/usb-dev-stub.c +++ b/stubs/usb-dev-stub.c @@ -8,6 +8,8 @@ =20 #include "qemu/osdep.h" #include "qemu/error-report.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-machine.h" #include "sysemu/sysemu.h" #include "monitor/monitor.h" #include "hw/usb.h" @@ -19,6 +21,12 @@ USBDevice *usbdevice_create(const char *driver) return NULL; } =20 +HumanReadableText *qmp_x_query_usb(Error **errp) +{ + error_setg(errp, "Support for USB devices not built-in"); + return NULL; +} + void hmp_info_usb(Monitor *mon, const QDict *qdict) { monitor_printf(mon, "Support for USB devices not built-in\n"); diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index fbd7ac10fb..15875a14c6 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -49,6 +49,8 @@ static int query_error_class(const char *cmd) #ifndef CONFIG_PROFILER { "x-query-profile", ERROR_CLASS_GENERIC_ERROR }, #endif + /* Only valid with a USB bus added */ + { "x-query-usb", ERROR_CLASS_GENERIC_ERROR }, { NULL, -1 } }; int i; --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631499334659.0286417296719; Tue, 14 Sep 2021 07:58:19 -0700 (PDT) Received: from localhost ([::1]:53554 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9t4-0001U8-5A for importer@patchew.org; Tue, 14 Sep 2021 10:58:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9TZ-0008GO-GV for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:58 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:22191) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9TU-0002Q8-CO for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:57 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-576-EOyYhwVLP9q-Q4clTf899Q-1; Tue, 14 Sep 2021 10:31:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0A7F91922023; Tue, 14 Sep 2021 14:31:37 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4119F5D9CA; Tue, 14 Sep 2021 14:31:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629911; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u7eETvjxivMzE+Swy97bYqjXMqPqicbmd8tpwdrb6q8=; b=ayDky5/4cQUjZMV6YQE7RgvTUAXJQ3iTYPXe7I4CyAFpyhiMdmwZlHtAGW2I0WzKBqL54N I28GvlaH+hn1dZvmzjCfmFnOWTVIFfKrAG9xhymIM09rM6wLfzAVyZhsVCoWdfwH9pWm8n UEevQrgd4rpN+br59KF3wzUEZm7C1pQ= X-MC-Unique: EOyYhwVLP9q-Q4clTf899Q-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 34/53] qapi: introduce x-query-rdma QMP command Date: Tue, 14 Sep 2021 15:20:23 +0100 Message-Id: <20210914142042.1655100-35-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631500416100005 This is a counterpart to the HMP "info rdma" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/rdma/rdma_rm.c | 104 +++++++++++++++++++------------------- hw/rdma/rdma_rm.h | 2 +- hw/rdma/vmw/pvrdma_main.c | 31 ++++++------ include/hw/rdma/rdma.h | 2 +- monitor/hmp-cmds.c | 29 +++-------- monitor/qmp-cmds.c | 35 +++++++++++++ qapi/machine.json | 12 +++++ 7 files changed, 125 insertions(+), 90 deletions(-) diff --git a/hw/rdma/rdma_rm.c b/hw/rdma/rdma_rm.c index 49141d4074..cfd85de3e6 100644 --- a/hw/rdma/rdma_rm.c +++ b/hw/rdma/rdma_rm.c @@ -27,58 +27,58 @@ #define PG_DIR_SZ { TARGET_PAGE_SIZE / sizeof(__u64) } #define PG_TBL_SZ { TARGET_PAGE_SIZE / sizeof(__u64) } =20 -void rdma_dump_device_counters(Monitor *mon, RdmaDeviceResources *dev_res) -{ - monitor_printf(mon, "\ttx : %" PRId64 "\n", - dev_res->stats.tx); - monitor_printf(mon, "\ttx_len : %" PRId64 "\n", - dev_res->stats.tx_len); - monitor_printf(mon, "\ttx_err : %" PRId64 "\n", - dev_res->stats.tx_err); - monitor_printf(mon, "\trx_bufs : %" PRId64 "\n", - dev_res->stats.rx_bufs); - monitor_printf(mon, "\trx_srq : %" PRId64 "\n", - dev_res->stats.rx_srq); - monitor_printf(mon, "\trx_bufs_len : %" PRId64 "\n", - dev_res->stats.rx_bufs_len); - monitor_printf(mon, "\trx_bufs_err : %" PRId64 "\n", - dev_res->stats.rx_bufs_err); - monitor_printf(mon, "\tcomps : %" PRId64 "\n", - dev_res->stats.completions); - monitor_printf(mon, "\tmissing_comps : %" PRId32 "\n", - dev_res->stats.missing_cqe); - monitor_printf(mon, "\tpoll_cq (bk) : %" PRId64 "\n", - dev_res->stats.poll_cq_from_bk); - monitor_printf(mon, "\tpoll_cq_ppoll_to : %" PRId64 "\n", - dev_res->stats.poll_cq_ppoll_to); - monitor_printf(mon, "\tpoll_cq (fe) : %" PRId64 "\n", - dev_res->stats.poll_cq_from_guest); - monitor_printf(mon, "\tpoll_cq_empty : %" PRId64 "\n", - dev_res->stats.poll_cq_from_guest_empty); - monitor_printf(mon, "\tmad_tx : %" PRId64 "\n", - dev_res->stats.mad_tx); - monitor_printf(mon, "\tmad_tx_err : %" PRId64 "\n", - dev_res->stats.mad_tx_err); - monitor_printf(mon, "\tmad_rx : %" PRId64 "\n", - dev_res->stats.mad_rx); - monitor_printf(mon, "\tmad_rx_err : %" PRId64 "\n", - dev_res->stats.mad_rx_err); - monitor_printf(mon, "\tmad_rx_bufs : %" PRId64 "\n", - dev_res->stats.mad_rx_bufs); - monitor_printf(mon, "\tmad_rx_bufs_err : %" PRId64 "\n", - dev_res->stats.mad_rx_bufs_err); - monitor_printf(mon, "\tPDs : %" PRId32 "\n", - dev_res->pd_tbl.used); - monitor_printf(mon, "\tMRs : %" PRId32 "\n", - dev_res->mr_tbl.used); - monitor_printf(mon, "\tUCs : %" PRId32 "\n", - dev_res->uc_tbl.used); - monitor_printf(mon, "\tQPs : %" PRId32 "\n", - dev_res->qp_tbl.used); - monitor_printf(mon, "\tCQs : %" PRId32 "\n", - dev_res->cq_tbl.used); - monitor_printf(mon, "\tCEQ_CTXs : %" PRId32 "\n", - dev_res->cqe_ctx_tbl.used); +void rdma_format_device_counters(RdmaDeviceResources *dev_res, GString *bu= f) +{ + g_string_append_printf(buf, "\ttx : %" PRId64 "\n", + dev_res->stats.tx); + g_string_append_printf(buf, "\ttx_len : %" PRId64 "\n", + dev_res->stats.tx_len); + g_string_append_printf(buf, "\ttx_err : %" PRId64 "\n", + dev_res->stats.tx_err); + g_string_append_printf(buf, "\trx_bufs : %" PRId64 "\n", + dev_res->stats.rx_bufs); + g_string_append_printf(buf, "\trx_srq : %" PRId64 "\n", + dev_res->stats.rx_srq); + g_string_append_printf(buf, "\trx_bufs_len : %" PRId64 "\n", + dev_res->stats.rx_bufs_len); + g_string_append_printf(buf, "\trx_bufs_err : %" PRId64 "\n", + dev_res->stats.rx_bufs_err); + g_string_append_printf(buf, "\tcomps : %" PRId64 "\n", + dev_res->stats.completions); + g_string_append_printf(buf, "\tmissing_comps : %" PRId32 "\n", + dev_res->stats.missing_cqe); + g_string_append_printf(buf, "\tpoll_cq (bk) : %" PRId64 "\n", + dev_res->stats.poll_cq_from_bk); + g_string_append_printf(buf, "\tpoll_cq_ppoll_to : %" PRId64 "\n", + dev_res->stats.poll_cq_ppoll_to); + g_string_append_printf(buf, "\tpoll_cq (fe) : %" PRId64 "\n", + dev_res->stats.poll_cq_from_guest); + g_string_append_printf(buf, "\tpoll_cq_empty : %" PRId64 "\n", + dev_res->stats.poll_cq_from_guest_empty); + g_string_append_printf(buf, "\tmad_tx : %" PRId64 "\n", + dev_res->stats.mad_tx); + g_string_append_printf(buf, "\tmad_tx_err : %" PRId64 "\n", + dev_res->stats.mad_tx_err); + g_string_append_printf(buf, "\tmad_rx : %" PRId64 "\n", + dev_res->stats.mad_rx); + g_string_append_printf(buf, "\tmad_rx_err : %" PRId64 "\n", + dev_res->stats.mad_rx_err); + g_string_append_printf(buf, "\tmad_rx_bufs : %" PRId64 "\n", + dev_res->stats.mad_rx_bufs); + g_string_append_printf(buf, "\tmad_rx_bufs_err : %" PRId64 "\n", + dev_res->stats.mad_rx_bufs_err); + g_string_append_printf(buf, "\tPDs : %" PRId32 "\n", + dev_res->pd_tbl.used); + g_string_append_printf(buf, "\tMRs : %" PRId32 "\n", + dev_res->mr_tbl.used); + g_string_append_printf(buf, "\tUCs : %" PRId32 "\n", + dev_res->uc_tbl.used); + g_string_append_printf(buf, "\tQPs : %" PRId32 "\n", + dev_res->qp_tbl.used); + g_string_append_printf(buf, "\tCQs : %" PRId32 "\n", + dev_res->cq_tbl.used); + g_string_append_printf(buf, "\tCEQ_CTXs : %" PRId32 "\n", + dev_res->cqe_ctx_tbl.used); } =20 static inline void res_tbl_init(const char *name, RdmaRmResTbl *tbl, diff --git a/hw/rdma/rdma_rm.h b/hw/rdma/rdma_rm.h index e8639909cd..d69a917795 100644 --- a/hw/rdma/rdma_rm.h +++ b/hw/rdma/rdma_rm.h @@ -92,6 +92,6 @@ static inline union ibv_gid *rdma_rm_get_gid(RdmaDeviceRe= sources *dev_res, { return &dev_res->port.gid_tbl[sgid_idx].gid; } -void rdma_dump_device_counters(Monitor *mon, RdmaDeviceResources *dev_res); +void rdma_format_device_counters(RdmaDeviceResources *dev_res, GString *bu= f); =20 #endif diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c index 7c0c3551a8..91206dbb8e 100644 --- a/hw/rdma/vmw/pvrdma_main.c +++ b/hw/rdma/vmw/pvrdma_main.c @@ -58,24 +58,25 @@ static Property pvrdma_dev_properties[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 -static void pvrdma_print_statistics(Monitor *mon, RdmaProvider *obj) +static void pvrdma_format_statistics(RdmaProvider *obj, GString *buf) { PVRDMADev *dev =3D PVRDMA_DEV(obj); PCIDevice *pdev =3D PCI_DEVICE(dev); =20 - monitor_printf(mon, "%s, %x.%x\n", pdev->name, PCI_SLOT(pdev->devfn), - PCI_FUNC(pdev->devfn)); - monitor_printf(mon, "\tcommands : %" PRId64 "\n", - dev->stats.commands); - monitor_printf(mon, "\tregs_reads : %" PRId64 "\n", - dev->stats.regs_reads); - monitor_printf(mon, "\tregs_writes : %" PRId64 "\n", - dev->stats.regs_writes); - monitor_printf(mon, "\tuar_writes : %" PRId64 "\n", - dev->stats.uar_writes); - monitor_printf(mon, "\tinterrupts : %" PRId64 "\n", - dev->stats.interrupts); - rdma_dump_device_counters(mon, &dev->rdma_dev_res); + g_string_append_printf(buf, "%s, %x.%x\n", + pdev->name, PCI_SLOT(pdev->devfn), + PCI_FUNC(pdev->devfn)); + g_string_append_printf(buf, "\tcommands : %" PRId64 "\n", + dev->stats.commands); + g_string_append_printf(buf, "\tregs_reads : %" PRId64 "\n", + dev->stats.regs_reads); + g_string_append_printf(buf, "\tregs_writes : %" PRId64 "\n", + dev->stats.regs_writes); + g_string_append_printf(buf, "\tuar_writes : %" PRId64 "\n", + dev->stats.uar_writes); + g_string_append_printf(buf, "\tinterrupts : %" PRId64 "\n", + dev->stats.interrupts); + rdma_format_device_counters(&dev->rdma_dev_res, buf); } =20 static void free_dev_ring(PCIDevice *pci_dev, PvrdmaRing *ring, @@ -699,7 +700,7 @@ static void pvrdma_class_init(ObjectClass *klass, void = *data) device_class_set_props(dc, pvrdma_dev_properties); set_bit(DEVICE_CATEGORY_NETWORK, dc->categories); =20 - ir->print_statistics =3D pvrdma_print_statistics; + ir->format_statistics =3D pvrdma_format_statistics; } =20 static const TypeInfo pvrdma_info =3D { diff --git a/include/hw/rdma/rdma.h b/include/hw/rdma/rdma.h index e77e43a170..80b2e531c4 100644 --- a/include/hw/rdma/rdma.h +++ b/include/hw/rdma/rdma.h @@ -31,7 +31,7 @@ typedef struct RdmaProvider RdmaProvider; struct RdmaProviderClass { InterfaceClass parent; =20 - void (*print_statistics)(Monitor *mon, RdmaProvider *obj); + void (*format_statistics)(RdmaProvider *obj, GString *buf); }; =20 #endif diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index e00255f7ee..d24a1683de 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -54,7 +54,6 @@ #include "qemu/error-report.h" #include "exec/ramlist.h" #include "hw/intc/intc.h" -#include "hw/rdma/rdma.h" #include "migration/snapshot.h" #include "migration/misc.h" =20 @@ -850,30 +849,18 @@ void hmp_info_pic(Monitor *mon, const QDict *qdict) hmp_info_pic_foreach, mon); } =20 -static int hmp_info_rdma_foreach(Object *obj, void *opaque) +void hmp_info_rdma(Monitor *mon, const QDict *qdict) { - RdmaProvider *rdma; - RdmaProviderClass *k; - Monitor *mon =3D opaque; + Error *err =3D NULL; + g_autoptr(HumanReadableText) info =3D NULL; =20 - if (object_dynamic_cast(obj, INTERFACE_RDMA_PROVIDER)) { - rdma =3D RDMA_PROVIDER(obj); - k =3D RDMA_PROVIDER_GET_CLASS(obj); - if (k->print_statistics) { - k->print_statistics(mon, rdma); - } else { - monitor_printf(mon, "RDMA statistics not available for %s.\n", - object_get_typename(obj)); - } + info =3D qmp_x_query_rdma(&err); + if (err) { + error_report_err(err); + return; } =20 - return 0; -} - -void hmp_info_rdma(Monitor *mon, const QDict *qdict) -{ - object_child_foreach_recursive(object_get_root(), - hmp_info_rdma_foreach, mon); + monitor_printf(mon, "%s", info->human_readable_text); } =20 void hmp_info_pci(Monitor *mon, const QDict *qdict) diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 7bae0770a9..9c2c1e4603 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -39,6 +39,7 @@ #include "qapi/qmp/qerror.h" #include "hw/mem/memory-device.h" #include "hw/acpi/acpi_dev_interface.h" +#include "hw/rdma/rdma.h" =20 NameInfo *qmp_query_name(Error **errp) { @@ -384,3 +385,37 @@ HumanReadableText *qmp_x_query_profile(Error **errp) return NULL; } #endif + +static int qmp_x_query_rdma_foreach(Object *obj, void *opaque) +{ + RdmaProvider *rdma; + RdmaProviderClass *k; + GString *buf =3D opaque; + + if (object_dynamic_cast(obj, INTERFACE_RDMA_PROVIDER)) { + rdma =3D RDMA_PROVIDER(obj); + k =3D RDMA_PROVIDER_GET_CLASS(obj); + if (k->format_statistics) { + k->format_statistics(rdma, buf); + } else { + g_string_append_printf(buf, + "RDMA statistics not available for %s.\= n", + object_get_typename(obj)); + } + } + + return 0; +} + +HumanReadableText *qmp_x_query_rdma(Error **errp) +{ + HumanReadableText *ret; + g_autoptr(GString) buf =3D g_string_new(""); + + object_child_foreach_recursive(object_get_root(), + qmp_x_query_rdma_foreach, buf); + + ret =3D g_new0(HumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} diff --git a/qapi/machine.json b/qapi/machine.json index 39d800c2c1..0fe962d916 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1337,6 +1337,18 @@ { 'command': 'x-query-profile', 'returns': 'HumanReadableText' } =20 +## +# @x-query-rdma: +# +# Query RDMA state +# +# Returns: RDMA state +# +# Since: 6.2 +## +{ 'command': 'x-query-rdma', + 'returns': 'HumanReadableText' } + ## # @x-query-registers: # --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631632869454908.5218282429399; Tue, 14 Sep 2021 08:21:09 -0700 (PDT) Received: from localhost ([::1]:56662 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAFA-0001HM-7T for importer@patchew.org; Tue, 14 Sep 2021 11:21:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40210) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9TV-00085Q-QC for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:53 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:42900) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9TT-0002Pq-T7 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:31:53 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-495-kMmXL9LeNXGtQ4n1sCumjQ-1; Tue, 14 Sep 2021 10:31:48 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CB7961922023; Tue, 14 Sep 2021 14:31:44 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 529D55D9CA; Tue, 14 Sep 2021 14:31:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629910; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2AFd+YTtbWmCaBK/9f7YsAzzznYqPy7xWqsdE9totms=; b=EhJ/wlFGsvQ1dG5akqUy+oVdHKWR4F0vomTQnm+IeM5jJ0i4j2O31T1byUeHYc2K7uuOiT 4FW9AnDqjzXRsU4D7yCChTeF+k9aIfiJf90OgXMKV5b+fAAkeTDNrpkci+4T/Efq4w4jIS 6BiECoodPcu0+dpwSqTM6F4A5zvZS6M= X-MC-Unique: kMmXL9LeNXGtQ4n1sCumjQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 35/53] qapi: introduce x-query-ramblock QMP command Date: Tue, 14 Sep 2021 15:20:24 +0100 Message-Id: <20210914142042.1655100-36-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632870431100001 This is a counterpart to the HMP "info ramblock" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. Signed-off-by: Daniel P. Berrang=C3=A9 --- include/exec/ramlist.h | 2 +- monitor/hmp-cmds.c | 12 ++++++++++-- monitor/qmp-cmds.c | 11 +++++++++++ qapi/machine.json | 12 ++++++++++++ softmmu/physmem.c | 19 +++++++++++-------- 5 files changed, 45 insertions(+), 11 deletions(-) diff --git a/include/exec/ramlist.h b/include/exec/ramlist.h index ece6497ee2..2ad2a81acc 100644 --- a/include/exec/ramlist.h +++ b/include/exec/ramlist.h @@ -80,6 +80,6 @@ void ram_block_notify_add(void *host, size_t size, size_t= max_size); void ram_block_notify_remove(void *host, size_t size, size_t max_size); void ram_block_notify_resize(void *host, size_t old_size, size_t new_size); =20 -void ram_block_dump(Monitor *mon); +GString *ram_block_format(void); =20 #endif /* RAMLIST_H */ diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index d24a1683de..77533b2d8a 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -52,7 +52,6 @@ #include "ui/console.h" #include "qemu/cutils.h" #include "qemu/error-report.h" -#include "exec/ramlist.h" #include "hw/intc/intc.h" #include "migration/snapshot.h" #include "migration/misc.h" @@ -2188,7 +2187,16 @@ void hmp_rocker_of_dpa_groups(Monitor *mon, const QD= ict *qdict) =20 void hmp_info_ramblock(Monitor *mon, const QDict *qdict) { - ram_block_dump(mon); + Error *err =3D NULL; + g_autoptr(HumanReadableText) info =3D NULL; + + info =3D qmp_x_query_ramblock(&err); + if (err) { + error_report_err(err); + return; + } + + monitor_printf(mon, "%s", info->human_readable_text); } =20 void hmp_info_vm_generation_id(Monitor *mon, const QDict *qdict) diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 9c2c1e4603..b86fff823e 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -37,6 +37,7 @@ #include "qapi/qapi-commands-misc.h" #include "qapi/qapi-commands-ui.h" #include "qapi/qmp/qerror.h" +#include "exec/ramlist.h" #include "hw/mem/memory-device.h" #include "hw/acpi/acpi_dev_interface.h" #include "hw/rdma/rdma.h" @@ -419,3 +420,13 @@ HumanReadableText *qmp_x_query_rdma(Error **errp) ret->human_readable_text =3D g_steal_pointer(&buf->str); return ret; } + +HumanReadableText *qmp_x_query_ramblock(Error **errp) +{ + HumanReadableText *ret; + g_autoptr(GString) buf =3D ram_block_format(); + + ret =3D g_new0(HumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} diff --git a/qapi/machine.json b/qapi/machine.json index 0fe962d916..3ae7beb7cf 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1337,6 +1337,18 @@ { 'command': 'x-query-profile', 'returns': 'HumanReadableText' } =20 +## +# @x-query-ramblock: +# +# Query system ramblock information +# +# Returns: system ramblock information +# +# Since: 6.2 +## +{ 'command': 'x-query-ramblock', + 'returns': 'HumanReadableText' } + ## # @x-query-rdma: # diff --git a/softmmu/physmem.c b/softmmu/physmem.c index 23e77cb771..bc4a8354d3 100644 --- a/softmmu/physmem.c +++ b/softmmu/physmem.c @@ -1298,23 +1298,26 @@ void qemu_mutex_unlock_ramlist(void) qemu_mutex_unlock(&ram_list.mutex); } =20 -void ram_block_dump(Monitor *mon) +GString *ram_block_format(void) { RAMBlock *block; char *psize; + GString *buf =3D g_string_new(""); =20 RCU_READ_LOCK_GUARD(); - monitor_printf(mon, "%24s %8s %18s %18s %18s\n", - "Block Name", "PSize", "Offset", "Used", "Total"); + g_string_append_printf(buf, "%24s %8s %18s %18s %18s\n", + "Block Name", "PSize", "Offset", "Used", "Total= "); RAMBLOCK_FOREACH(block) { psize =3D size_to_str(block->page_size); - monitor_printf(mon, "%24s %8s 0x%016" PRIx64 " 0x%016" PRIx64 - " 0x%016" PRIx64 "\n", block->idstr, psize, - (uint64_t)block->offset, - (uint64_t)block->used_length, - (uint64_t)block->max_length); + g_string_append_printf(buf, "%24s %8s 0x%016" PRIx64 " 0x%016" PR= Ix64 + " 0x%016" PRIx64 "\n", block->idstr, psize, + (uint64_t)block->offset, + (uint64_t)block->used_length, + (uint64_t)block->max_length); g_free(psize); } + + return buf; } =20 #ifdef __linux__ --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631795394355.02896846414137; Tue, 14 Sep 2021 08:03:15 -0700 (PDT) Received: from localhost ([::1]:35698 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQ9xp-0000Ek-WB for importer@patchew.org; Tue, 14 Sep 2021 11:03:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40442) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Tt-0000S8-Ki for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:32:17 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:51709) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Tm-0002bh-0x for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:32:14 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-239-ctGCrj0kMDOYr0bE3E5bpg-1; Tue, 14 Sep 2021 10:32:07 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23DAB10144E0; Tue, 14 Sep 2021 14:32:04 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F1B15D9CA; Tue, 14 Sep 2021 14:31:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629929; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IbnSHNQ2kA4GdquvgqY/LA7KZ7zRfnEAlFQJqJTL2Zg=; b=Wpvtr4zbCY6xHLkfk6K+JvKju3jxf85f++t8StPkxtfQI46pXuMPrHeORnGy0YjbeBV7L5 PZ8sAOcgDkUUrtdvE/Du+8Pcn/4Fqb6P3XZ4lFU1u9ihdzXQuRGIHYb6WNIjMm484Cud23 jGaFvC4vgEBWrAQ8SnQbhoIYjrLAjFU= X-MC-Unique: ctGCrj0kMDOYr0bE3E5bpg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 36/53] qapi: introduce x-query-skeys QMP command Date: Tue, 14 Sep 2021 15:20:25 +0100 Message-Id: <20210914142042.1655100-37-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631631849103100001 This is a counterpart to the HMP "info skeys" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. This command is unable to use the pre-existing HumanReadableText, because if 'common.json' is included into 'machine-target.json' the static marshalling method for HumanReadableText will be reported as unused by the compiler on all architectures except s390x. Possible options were 1 Support 'if' conditionals on 'include' statements in QAPI 2 Add further commands to 'machine-target.json' that use HumanReadableText, such that it has at least one usage on all architecture targets. 3 Duplicate HumanReadableText as TargetHumanReadableText adding conditions This patch takes option (3) in the belief that we will eventually get to a point where option (2) happens, and TargetHumanReadableText can be removed again. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/s390x/s390-skeys.c | 37 +++++++++++++++++++++++++++++-------- qapi/machine-target.json | 27 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/hw/s390x/s390-skeys.c b/hw/s390x/s390-skeys.c index 5024faf411..3a404d0574 100644 --- a/hw/s390x/s390-skeys.c +++ b/hw/s390x/s390-skeys.c @@ -15,6 +15,7 @@ #include "hw/s390x/storage-keys.h" #include "qapi/error.h" #include "qapi/qapi-commands-misc-target.h" +#include "qapi/qapi-commands-machine-target.h" #include "qapi/qmp/qdict.h" #include "qemu/error-report.h" #include "sysemu/memory_mapping.h" @@ -73,34 +74,54 @@ static void write_keys(FILE *f, uint8_t *keys, uint64_t= startgfn, } } =20 -void hmp_info_skeys(Monitor *mon, const QDict *qdict) +TargetHumanReadableText *qmp_x_query_skeys(int64_t addr, Error **errp) { + TargetHumanReadableText *ret; + g_autoptr(GString) buf =3D g_string_new(""); S390SKeysState *ss =3D s390_get_skeys_device(); S390SKeysClass *skeyclass =3D S390_SKEYS_GET_CLASS(ss); - uint64_t addr =3D qdict_get_int(qdict, "addr"); uint8_t key; int r; =20 /* Quick check to see if guest is using storage keys*/ if (!skeyclass->skeys_are_enabled(ss)) { - monitor_printf(mon, "Error: This guest is not using storage keys\n= "); - return; + error_setg(errp, "this guest is not using storage keys"); + return NULL; } =20 if (!address_space_access_valid(&address_space_memory, addr & TARGET_PAGE_MASK, TARGET_PAGE_S= IZE, false, MEMTXATTRS_UNSPECIFIED)) { - monitor_printf(mon, "Error: The given address is not valid\n"); - return; + error_setg(errp, "the given address is not valid"); + return NULL; } =20 r =3D skeyclass->get_skeys(ss, addr / TARGET_PAGE_SIZE, 1, &key); if (r < 0) { - monitor_printf(mon, "Error: %s\n", strerror(-r)); + error_setg_errno(errp, r, "unable to query storage keys"); + return NULL; + } + + g_string_append_printf(buf, " key: 0x%X\n", key); + + ret =3D g_new0(TargetHumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} + +void hmp_info_skeys(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + g_autoptr(TargetHumanReadableText) info =3D NULL; + uint64_t addr =3D qdict_get_int(qdict, "addr"); + + info =3D qmp_x_query_skeys(addr, &err); + if (err) { + error_report_err(err); return; } =20 - monitor_printf(mon, " key: 0x%X\n", key); + monitor_printf(mon, "%s", info->human_readable_text); } =20 void hmp_dump_skeys(Monitor *mon, const QDict *qdict) diff --git a/qapi/machine-target.json b/qapi/machine-target.json index f5ec4bc172..00476bcdd4 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -341,3 +341,30 @@ 'TARGET_I386', 'TARGET_S390X', 'TARGET_MIPS' ] } } + + +## +# @TargetHumanReadableText: +# +# @human-readable-text: Formatted output intended for humans. +# +# Since: 6.2.0 +# +## +{ 'struct': 'TargetHumanReadableText', + 'data': { 'human-readable-text': 'str' }, + 'if': 'TARGET_S390X' } + +## +# @x-query-skeys: +# +# Query the value of a storage key +# +# Returns: storage key value +# +# Since: 6.2 +## +{ 'command': 'x-query-skeys', + 'data': { 'addr': 'int' }, + 'returns': 'TargetHumanReadableText', + 'if': 'TARGET_S390X' } --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631633110530147.66247233717763; Tue, 14 Sep 2021 08:25:10 -0700 (PDT) Received: from localhost ([::1]:40914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAJ3-0001HR-E0 for importer@patchew.org; Tue, 14 Sep 2021 11:25:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9U5-0000cI-95 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:32:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Ty-0002jY-NR for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:32:25 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-353-33S6BeYEP5iyfar776unSg-1; Tue, 14 Sep 2021 10:32:19 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EF0B0BAF80; Tue, 14 Sep 2021 14:32:15 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6F8CA5D9CA; Tue, 14 Sep 2021 14:32:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629941; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0QtTGVKGmQfXBG/fdEBpdb2kRl84DA2SQ+OZkRmTDyU=; b=KYWzS9pGoMmZvyh80gi0GuiIEEdaIVmQHGEMT6lk3lRlxoBKGCwLYbahV626hDI+CbTooT QTrY4LpQKKScFDrINcL3ANiGnkUy2UhLcv6zoRFMf34gRH4sulGM0sdttSTcWkv8M2Sjwb dR0VUOHbIo7WjHnsEv1GlH26Co1wClA= X-MC-Unique: 33S6BeYEP5iyfar776unSg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 37/53] qapi: introduce x-query-cmma QMP command Date: Tue, 14 Sep 2021 15:20:26 +0100 Message-Id: <20210914142042.1655100-38-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631633112159100001 This is a counterpart to the HMP "info cmma" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. This command is unable to use the pre-existing HumanReadableText, because if 'common.json' is included into 'machine-target.json' the static marshalling method for HumanReadableText will be reported as unused by the compiler on all architectures except s390x. Possible options were 1 Support 'if' conditionals on 'include' statements in QAPI 2 Add further commands to 'machine-target.json' that use HumanReadableText, such that it has at least one usage on all architecture targets. 3 Duplicate HumanReadableText as TargetHumanReadableText adding conditions This patch takes option (3) in the belief that we will eventually get to a point where option (2) happens, and TargetHumanReadableText can be removed again. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/s390x/s390-stattrib.c | 58 +++++++++++++++++++++++++++------------- qapi/machine-target.json | 14 ++++++++++ 2 files changed, 54 insertions(+), 18 deletions(-) diff --git a/hw/s390x/s390-stattrib.c b/hw/s390x/s390-stattrib.c index 9eda1c3b2a..1ff0142b10 100644 --- a/hw/s390x/s390-stattrib.c +++ b/hw/s390x/s390-stattrib.c @@ -17,6 +17,7 @@ #include "qemu/error-report.h" #include "exec/ram_addr.h" #include "qapi/error.h" +#include "qapi/qapi-commands-machine-target.h" #include "qapi/qmp/qdict.h" =20 /* 512KiB cover 2GB of guest memory */ @@ -67,41 +68,62 @@ void hmp_migrationmode(Monitor *mon, const QDict *qdict) } } =20 -void hmp_info_cmma(Monitor *mon, const QDict *qdict) +TargetHumanReadableText *qmp_x_query_cmma(int64_t addr, + bool has_count, + int64_t count, + Error **errp) { + TargetHumanReadableText *ret; + g_autoptr(GString) buf =3D g_string_new(""); S390StAttribState *sas =3D s390_get_stattrib_device(); S390StAttribClass *sac =3D S390_STATTRIB_GET_CLASS(sas); - uint64_t addr =3D qdict_get_int(qdict, "addr"); - uint64_t buflen =3D qdict_get_try_int(qdict, "count", 8); - uint8_t *vals; + g_autofree uint8_t *vals =3D NULL; int cx, len; =20 - vals =3D g_try_malloc(buflen); + vals =3D g_try_malloc(count); if (!vals) { - monitor_printf(mon, "Error: %s\n", strerror(errno)); - return; + error_setg_errno(errp, errno, "cannot allocate CMMA attribute valu= es"); + return NULL; } =20 - len =3D sac->peek_stattr(sas, addr / TARGET_PAGE_SIZE, buflen, vals); + len =3D sac->peek_stattr(sas, addr / TARGET_PAGE_SIZE, count, vals); if (len < 0) { - monitor_printf(mon, "Error: %s", strerror(-len)); - goto out; + error_setg_errno(errp, -len, "cannot peek at CMMA attribute values= "); + return NULL; } =20 - monitor_printf(mon, " CMMA attributes, " - "pages %" PRIu64 "+%d (0x%" PRIx64 "):\n", - addr / TARGET_PAGE_SIZE, len, addr & ~TARGET_PAGE_MASK); + g_string_append_printf(buf, " CMMA attributes, " + "pages %" PRIu64 "+%d (0x%" PRIx64 "):\n", + addr / TARGET_PAGE_SIZE, len, + addr & ~TARGET_PAGE_MASK); for (cx =3D 0; cx < len; cx++) { if (cx % 8 =3D=3D 7) { - monitor_printf(mon, "%02x\n", vals[cx]); + g_string_append_printf(buf, "%02x\n", vals[cx]); } else { - monitor_printf(mon, "%02x", vals[cx]); + g_string_append_printf(buf, "%02x", vals[cx]); } } - monitor_printf(mon, "\n"); + g_string_append_printf(buf, "\n"); + + ret =3D g_new0(TargetHumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} + +void hmp_info_cmma(Monitor *mon, const QDict *qdict) +{ + Error *err =3D NULL; + g_autoptr(TargetHumanReadableText) info =3D NULL; + uint64_t addr =3D qdict_get_int(qdict, "addr"); + uint64_t count =3D qdict_get_try_int(qdict, "count", 8); + + info =3D qmp_x_query_cmma(addr, true, count, &err); + if (err) { + error_report_err(err); + return; + } =20 -out: - g_free(vals); + monitor_printf(mon, "%s", info->human_readable_text); } =20 /* Migration support: */ diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 00476bcdd4..9040aff863 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -355,6 +355,20 @@ 'data': { 'human-readable-text': 'str' }, 'if': 'TARGET_S390X' } =20 +## +# @x-query-cmma: +# +# Query the values of the CMMA storage attributes for a range of pages +# +# Returns: CMMA storage attribute values +# +# Since: 6.2 +## +{ 'command': 'x-query-cmma', + 'data': { 'addr': 'int', '*count': 'int' }, + 'returns': 'TargetHumanReadableText', + 'if': 'TARGET_S390X' } + ## # @x-query-skeys: # --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631631959716560.4709769434613; Tue, 14 Sep 2021 08:05:59 -0700 (PDT) Received: from localhost ([::1]:44652 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQA0U-0006BD-J6 for importer@patchew.org; Tue, 14 Sep 2021 11:05:58 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40784) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9UM-0000mN-Om for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:32:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59465) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9UE-0002wL-SN for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:32:43 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-2-ss83hsYsPamdDB3infvU8A-1; Tue, 14 Sep 2021 10:32:36 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9FE801054FA5; Tue, 14 Sep 2021 14:32:31 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 45B6A5D9DC; Tue, 14 Sep 2021 14:32:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629958; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cLy6EwxITacEuC/jBCLIRMB/Ak0L1zfodmwGOnq/cfw=; b=Ncu/16YL2SVHNXjSrQqWQGjsvu3xJ0wmgpDHjUeTgLUEvia3vygfMDO7ghqRRRh7NgJPCJ GOLTCZ5+gf6rVEMmKKNCyyIuPwFuZ7rJgTLHjSwlQzQe/Ehn8ouEa7ez8EB6kQBWi4LQmW NGA6E8hjpVGT0n++TEbg/cC4A22rvcs= X-MC-Unique: ss83hsYsPamdDB3infvU8A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 38/53] qapi: introduce x-query-lapic QMP command Date: Tue, 14 Sep 2021 15:20:27 +0100 Message-Id: <20210914142042.1655100-39-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632010313100003 This is a counterpart to the HMP "info lapic" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. This command is unable to use the pre-existing HumanReadableText, because if 'common.json' is included into 'machine-target.json' the static marshalling method for HumanReadableText will be reported as unused by the compiler on all architectures except s390x. Possible options were 1 Support 'if' conditionals on 'include' statements in QAPI 2 Add further commands to 'machine-target.json' that use HumanReadableText, such that it has at least one usage on all architecture targets. 3 Duplicate HumanReadableText as TargetHumanReadableText adding conditions This patch takes option (3) in the belief that we will eventually get to a point where option (2) happens, and TargetHumanReadableText can be removed again. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/core/cpu-common.c | 7 ++ include/hw/core/cpu.h | 10 +++ qapi/machine-target.json | 19 ++++- target/i386/cpu-dump.c | 161 ++++++++++++++++++++------------------- target/i386/cpu.h | 4 +- target/i386/monitor.c | 46 +++++++++-- 6 files changed, 160 insertions(+), 87 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index c2cd33a817..d1ebc77d1b 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -49,6 +49,13 @@ CPUState *cpu_by_arch_id(int64_t id) return NULL; } =20 +int64_t cpu_get_arch_id(CPUState *cpu) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + return cc->get_arch_id(cpu); +} + bool cpu_exists(int64_t id) { return !!cpu_by_arch_id(id); diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 1599ef9df3..a0913eedaa 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -780,6 +780,16 @@ bool cpu_exists(int64_t id); */ CPUState *cpu_by_arch_id(int64_t id); =20 +/** + * cpu_get_arch_id: + * @cpu: the CPU to query + * + * Get the guest exposed CPU ID for @cpu + * + * Returns: The guest exposed CPU ID + */ +int64_t cpu_get_arch_id(CPUState *cpu); + /** * cpu_interrupt: * @cpu: The CPU to set an interrupt on. diff --git a/qapi/machine-target.json b/qapi/machine-target.json index 9040aff863..62220d1f08 100644 --- a/qapi/machine-target.json +++ b/qapi/machine-target.json @@ -353,7 +353,8 @@ ## { 'struct': 'TargetHumanReadableText', 'data': { 'human-readable-text': 'str' }, - 'if': 'TARGET_S390X' } + 'if': { 'any': ['TARGET_S390X', + 'TARGET_I386' ] } } =20 ## # @x-query-cmma: @@ -369,6 +370,22 @@ 'returns': 'TargetHumanReadableText', 'if': 'TARGET_S390X' } =20 +## +# @x-query-lapic: +# +# @apic-id: the local APIC ID to report +# +# Query local APIC state. +# +# Returns: local APIC state +# +# Since: 6.2 +## +{ 'command': 'x-query-lapic', + 'data': { 'apic-id': 'int' }, + 'returns': 'TargetHumanReadableText', + 'if': 'TARGET_I386' } + ## # @x-query-skeys: # diff --git a/target/i386/cpu-dump.c b/target/i386/cpu-dump.c index f30fbcb76e..41a1f64138 100644 --- a/target/i386/cpu-dump.c +++ b/target/i386/cpu-dump.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "cpu.h" #include "qemu/qemu-print.h" +#include "qapi/error.h" #ifndef CONFIG_USER_ONLY #include "hw/i386/apic_internal.h" #endif @@ -179,24 +180,26 @@ static inline const char *dm2str(uint32_t dm) return str[dm]; } =20 -static void dump_apic_lvt(const char *name, uint32_t lvt, bool is_timer) +static void format_apic_lvt(const char *name, uint32_t lvt, bool is_timer, + GString *buf) { uint32_t dm =3D (lvt & APIC_LVT_DELIV_MOD) >> APIC_LVT_DELIV_MOD_SHIFT; - qemu_printf("%s\t 0x%08x %s %-5s %-6s %-7s %-12s %-6s", - name, lvt, - lvt & APIC_LVT_INT_POLARITY ? "active-lo" : "active-hi", - lvt & APIC_LVT_LEVEL_TRIGGER ? "level" : "edge", - lvt & APIC_LVT_MASKED ? "masked" : "", - lvt & APIC_LVT_DELIV_STS ? "pending" : "", - !is_timer ? - "" : lvt & APIC_LVT_TIMER_PERIODIC ? - "periodic" : lvt & APIC_LVT_TIMER_TSCDEADLINE ? - "tsc-deadline" : "one-shot", + g_string_append_printf(buf, "%s\t 0x%08x %s %-5s %-6s %-7s %-12s %-6s", + name, lvt, + lvt & APIC_LVT_INT_POLARITY ? + "active-lo" : "active-hi", + lvt & APIC_LVT_LEVEL_TRIGGER ? "level" : "edge", + lvt & APIC_LVT_MASKED ? "masked" : "", + lvt & APIC_LVT_DELIV_STS ? "pending" : "", + !is_timer ? + "" : lvt & APIC_LVT_TIMER_PERIODIC ? + "periodic" : lvt & APIC_LVT_TIMER_TSCDEADLINE ? + "tsc-deadline" : "one-shot", dm2str(dm)); if (dm !=3D APIC_DM_NMI) { - qemu_printf(" (vec %u)\n", lvt & APIC_VECTOR_MASK); + g_string_append_printf(buf, " (vec %u)\n", lvt & APIC_VECTOR_MASK); } else { - qemu_printf("\n"); + g_string_append_printf(buf, "\n"); } } =20 @@ -228,7 +231,7 @@ static inline void mask2str(char *str, uint32_t val, ui= nt8_t size) =20 #define MAX_LOGICAL_APIC_ID_MASK_SIZE 16 =20 -static void dump_apic_icr(APICCommonState *s, CPUX86State *env) +static void format_apic_icr(APICCommonState *s, CPUX86State *env, GString = *buf) { uint32_t icr =3D s->icr[0], icr2 =3D s->icr[1]; uint8_t dest_shorthand =3D \ @@ -238,16 +241,16 @@ static void dump_apic_icr(APICCommonState *s, CPUX86S= tate *env) uint32_t dest_field; bool x2apic; =20 - qemu_printf("ICR\t 0x%08x %s %s %s %s\n", - icr, - logical_mod ? "logical" : "physical", - icr & APIC_ICR_TRIGGER_MOD ? "level" : "edge", - icr & APIC_ICR_LEVEL ? "assert" : "de-assert", - shorthand2str(dest_shorthand)); + g_string_append_printf(buf, "ICR\t 0x%08x %s %s %s %s\n", + icr, + logical_mod ? "logical" : "physical", + icr & APIC_ICR_TRIGGER_MOD ? "level" : "edge", + icr & APIC_ICR_LEVEL ? "assert" : "de-assert", + shorthand2str(dest_shorthand)); =20 - qemu_printf("ICR2\t 0x%08x", icr2); + g_string_append_printf(buf, "ICR2\t 0x%08x", icr2); if (dest_shorthand !=3D 0) { - qemu_printf("\n"); + g_string_append_printf(buf, "\n"); return; } x2apic =3D env->features[FEAT_1_ECX] & CPUID_EXT_X2APIC; @@ -255,96 +258,100 @@ static void dump_apic_icr(APICCommonState *s, CPUX86= State *env) =20 if (!logical_mod) { if (x2apic) { - qemu_printf(" cpu %u (X2APIC ID)\n", dest_field); + g_string_append_printf(buf, " cpu %u (X2APIC ID)\n", dest_fiel= d); } else { - qemu_printf(" cpu %u (APIC ID)\n", - dest_field & APIC_LOGDEST_XAPIC_ID); + g_string_append_printf(buf, " cpu %u (APIC ID)\n", + dest_field & APIC_LOGDEST_XAPIC_ID); } return; } =20 if (s->dest_mode =3D=3D 0xf) { /* flat mode */ mask2str(apic_id_str, icr2 >> APIC_ICR_DEST_SHIFT, 8); - qemu_printf(" mask %s (APIC ID)\n", apic_id_str); + g_string_append_printf(buf, " mask %s (APIC ID)\n", apic_id_str); } else if (s->dest_mode =3D=3D 0) { /* cluster mode */ if (x2apic) { mask2str(apic_id_str, dest_field & APIC_LOGDEST_X2APIC_ID, 16); - qemu_printf(" cluster %u mask %s (X2APIC ID)\n", - dest_field >> APIC_LOGDEST_X2APIC_SHIFT, apic_id_s= tr); + g_string_append_printf(buf, " cluster %u mask %s (X2APIC ID)\n= ", + dest_field >> APIC_LOGDEST_X2APIC_SHIFT, + apic_id_str); } else { mask2str(apic_id_str, dest_field & APIC_LOGDEST_XAPIC_ID, 4); - qemu_printf(" cluster %u mask %s (APIC ID)\n", - dest_field >> APIC_LOGDEST_XAPIC_SHIFT, apic_id_st= r); + g_string_append_printf(buf, " cluster %u mask %s (APIC ID)\n", + dest_field >> APIC_LOGDEST_XAPIC_SHIFT, + apic_id_str); } } } =20 -static void dump_apic_interrupt(const char *name, uint32_t *ireg_tab, - uint32_t *tmr_tab) +static void format_apic_interrupt(const char *name, uint32_t *ireg_tab, + uint32_t *tmr_tab, GString *buf) { int i, empty =3D true; =20 - qemu_printf("%s\t ", name); + g_string_append_printf(buf, "%s\t ", name); for (i =3D 0; i < 256; i++) { if (apic_get_bit(ireg_tab, i)) { - qemu_printf("%u%s ", i, - apic_get_bit(tmr_tab, i) ? "(level)" : ""); + g_string_append_printf(buf, "%u%s ", i, + apic_get_bit(tmr_tab, i) ? "(level)" : = ""); empty =3D false; } } - qemu_printf("%s\n", empty ? "(none)" : ""); + g_string_append_printf(buf, "%s\n", empty ? "(none)" : ""); } =20 -void x86_cpu_dump_local_apic_state(CPUState *cs, int flags) +GString *x86_cpu_format_local_apic_state(CPUState *cs, int flags, Error **= errp) { + g_autoptr(GString) buf =3D g_string_new(""); X86CPU *cpu =3D X86_CPU(cs); APICCommonState *s =3D APIC_COMMON(cpu->apic_state); if (!s) { - qemu_printf("local apic state not available\n"); - return; + error_setg(errp, "local apic state not available"); + return NULL; } uint32_t *lvt =3D s->lvt; =20 - qemu_printf("dumping local APIC state for CPU %-2u\n\n", - CPU(cpu)->cpu_index); - dump_apic_lvt("LVT0", lvt[APIC_LVT_LINT0], false); - dump_apic_lvt("LVT1", lvt[APIC_LVT_LINT1], false); - dump_apic_lvt("LVTPC", lvt[APIC_LVT_PERFORM], false); - dump_apic_lvt("LVTERR", lvt[APIC_LVT_ERROR], false); - dump_apic_lvt("LVTTHMR", lvt[APIC_LVT_THERMAL], false); - dump_apic_lvt("LVTT", lvt[APIC_LVT_TIMER], true); - - qemu_printf("Timer\t DCR=3D0x%x (divide by %u) initial_count =3D %u" - " current_count =3D %u\n", - s->divide_conf & APIC_DCR_MASK, - divider_conf(s->divide_conf), - s->initial_count, apic_get_current_count(s)); - - qemu_printf("SPIV\t 0x%08x APIC %s, focus=3D%s, spurious vec %u\n", - s->spurious_vec, - s->spurious_vec & APIC_SPURIO_ENABLED ? "enabled" : "disab= led", - s->spurious_vec & APIC_SPURIO_FOCUS ? "on" : "off", - s->spurious_vec & APIC_VECTOR_MASK); - - dump_apic_icr(s, &cpu->env); - - qemu_printf("ESR\t 0x%08x\n", s->esr); - - dump_apic_interrupt("ISR", s->isr, s->tmr); - dump_apic_interrupt("IRR", s->irr, s->tmr); - - qemu_printf("\nAPR 0x%02x TPR 0x%02x DFR 0x%02x LDR 0x%02x", - s->arb_id, s->tpr, s->dest_mode, s->log_dest); + g_string_append_printf(buf, "dumping local APIC state for CPU %-2u\n\n= ", + CPU(cpu)->cpu_index); + format_apic_lvt("LVT0", lvt[APIC_LVT_LINT0], false, buf); + format_apic_lvt("LVT1", lvt[APIC_LVT_LINT1], false, buf); + format_apic_lvt("LVTPC", lvt[APIC_LVT_PERFORM], false, buf); + format_apic_lvt("LVTERR", lvt[APIC_LVT_ERROR], false, buf); + format_apic_lvt("LVTTHMR", lvt[APIC_LVT_THERMAL], false, buf); + format_apic_lvt("LVTT", lvt[APIC_LVT_TIMER], true, buf); + + g_string_append_printf(buf, + "Timer\t DCR=3D0x%x (divide by %u) initial_coun= t =3D %u" + " current_count =3D %u\n", + s->divide_conf & APIC_DCR_MASK, + divider_conf(s->divide_conf), + s->initial_count, apic_get_current_count(s)); + + g_string_append_printf(buf, + "SPIV\t 0x%08x APIC %s, focus=3D%s, spurious ve= c %u\n", + s->spurious_vec, + s->spurious_vec & APIC_SPURIO_ENABLED ? + "enabled" : "disabled", + s->spurious_vec & APIC_SPURIO_FOCUS ? "on" : "o= ff", + s->spurious_vec & APIC_VECTOR_MASK); + + format_apic_icr(s, &cpu->env, buf); + + g_string_append_printf(buf, "ESR\t 0x%08x\n", s->esr); + + format_apic_interrupt("ISR", s->isr, s->tmr, buf); + format_apic_interrupt("IRR", s->irr, s->tmr, buf); + + g_string_append_printf(buf, "\nAPR 0x%02x TPR 0x%02x DFR 0x%02x LDR 0x= %02x", + s->arb_id, s->tpr, s->dest_mode, s->log_dest); if (s->dest_mode =3D=3D 0) { - qemu_printf("(cluster %u: id %u)", - s->log_dest >> APIC_LOGDEST_XAPIC_SHIFT, - s->log_dest & APIC_LOGDEST_XAPIC_ID); + g_string_append_printf(buf, "(cluster %u: id %u)", + s->log_dest >> APIC_LOGDEST_XAPIC_SHIFT, + s->log_dest & APIC_LOGDEST_XAPIC_ID); } - qemu_printf(" PPR 0x%02x\n", apic_get_ppr(s)); -} -#else -void x86_cpu_dump_local_apic_state(CPUState *cs, int flags) -{ + g_string_append_printf(buf, " PPR 0x%02x\n", apic_get_ppr(s)); + + return g_steal_pointer(&buf); } #endif /* !CONFIG_USER_ONLY */ =20 diff --git a/target/i386/cpu.h b/target/i386/cpu.h index d87c8808f6..2bcb175da8 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -2201,8 +2201,10 @@ void x86_cpu_set_default_version(X86CPUVersion versi= on); #define APIC_DEFAULT_ADDRESS 0xfee00000 #define APIC_SPACE_SIZE 0x100000 =20 +#ifndef CONFIG_USER_ONLY /* cpu-dump.c */ -void x86_cpu_dump_local_apic_state(CPUState *cs, int flags); +GString *x86_cpu_format_local_apic_state(CPUState *cs, int flags, Error **= errp); +#endif /* !CONFIG_USER_ONLY */ =20 /* cpu.c */ bool cpu_is_bsp(X86CPU *cpu); diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 19468c4e85..fc09f90059 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -33,6 +33,7 @@ #include "qapi/error.h" #include "sev_i386.h" #include "qapi/qapi-commands-misc-target.h" +#include "qapi/qapi-commands-machine-target.h" #include "qapi/qapi-commands-misc.h" #include "hw/i386/pc.h" =20 @@ -650,23 +651,52 @@ const MonitorDef *target_monitor_defs(void) return monitor_defs; } =20 +TargetHumanReadableText *qmp_x_query_lapic(int64_t apicid, + Error **errp) +{ + TargetHumanReadableText *ret; + g_autoptr(GString) buf =3D NULL; + CPUState *cs =3D cpu_by_arch_id(apicid); + + if (!cs) { + error_setg(errp, "No CPU with APIC ID %" PRId64 " available", apic= id); + return NULL; + } + + buf =3D x86_cpu_format_local_apic_state(cs, CPU_DUMP_FPU, errp); + if (!buf) { + return NULL; + } + + ret =3D g_new0(TargetHumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} + void hmp_info_local_apic(Monitor *mon, const QDict *qdict) { - CPUState *cs; + Error *err =3D NULL; + g_autoptr(TargetHumanReadableText) info =3D NULL; + int64_t apicid; =20 if (qdict_haskey(qdict, "apic-id")) { - int id =3D qdict_get_try_int(qdict, "apic-id", 0); - cs =3D cpu_by_arch_id(id); + apicid =3D qdict_get_try_int(qdict, "apic-id", 0); } else { - cs =3D mon_get_cpu(mon); + CPUState *cs =3D mon_get_cpu(mon); + if (!cs) { + monitor_printf(mon, "No CPU available\n"); + return; + } + apicid =3D cpu_get_arch_id(cs); } =20 - - if (!cs) { - monitor_printf(mon, "No CPU available\n"); + info =3D qmp_x_query_lapic(apicid, &err); + if (err) { + error_report_err(err); return; } - x86_cpu_dump_local_apic_state(cs, CPU_DUMP_FPU); + + monitor_printf(mon, "%s", info->human_readable_text); } =20 SevInfo *qmp_query_sev(Error **errp) --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631633387299962.0408893448448; Tue, 14 Sep 2021 08:29:47 -0700 (PDT) Received: from localhost ([::1]:55284 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQANW-0002aY-9A for importer@patchew.org; Tue, 14 Sep 2021 11:29:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40892) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Ub-00014T-5t for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:33:01 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:47662) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9UX-00036e-Kd for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:33:00 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-481-ebDlKE6IOSW5obJSs9l0CQ-1; Tue, 14 Sep 2021 10:32:50 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0E9DF800FF4; Tue, 14 Sep 2021 14:32:47 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id E75B85D9DC; Tue, 14 Sep 2021 14:32:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629972; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=/jRtbUcY39Rqu7qghyi/HTcBufJo3NLVVwGNaTJ569Y=; b=Tdfg8feHbrF36ZV4DMdRsm1MLbV/I//vwDm80BHoSLWggUGRek1G/AB1Xneca0oJouNhdd ERCZ770fqntN5A0RWykYrMeseKwCu/KgnPSJlWezzJw95/QbGrPo5gifeIVSJ38IYsXIu5 nhufeOWdQUKaCAWJvhNMOt4h2WJ/wH8= X-MC-Unique: ebDlKE6IOSW5obJSs9l0CQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 39/53] qapi: introduce x-query-irq QMP command Date: Tue, 14 Sep 2021 15:20:28 +0100 Message-Id: <20210914142042.1655100-40-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631633389038100001 This is a counterpart to the HMP "info irq" command. It is being added with an "x-" prefix because this QMP command is intended as an adhoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. This command is unable to use the pre-existing HumanReadableText, because if 'common.json' is included into 'machine-target.json' the static marshalling method for HumanReadableText will be reported as unused by the compiler on all architectures except s390x. Possible options were 1 Support 'if' conditionals on 'include' statements in QAPI 2 Add further commands to 'machine-target.json' that use HumanReadableText, such that it has at least one usage on all architecture targets. 3 Duplicate HumanReadableText as TargetHumanReadableText adding conditions This patch takes option (3) in the belief that we will eventually get to a point where option (2) happens, and TargetHumanReadableText can be removed again. Signed-off-by: Daniel P. Berrang=C3=A9 --- monitor/hmp-cmds.c | 40 ++++++++------------------------------- monitor/qmp-cmds.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ qapi/machine.json | 12 ++++++++++++ 3 files changed, 67 insertions(+), 32 deletions(-) diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 77533b2d8a..eb2202329d 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -784,42 +784,18 @@ static void hmp_info_pci_device(Monitor *mon, const P= ciDeviceInfo *dev) } } =20 -static int hmp_info_irq_foreach(Object *obj, void *opaque) +void hmp_info_irq(Monitor *mon, const QDict *qdict) { - InterruptStatsProvider *intc; - InterruptStatsProviderClass *k; - Monitor *mon =3D opaque; + Error *err =3D NULL; + g_autoptr(HumanReadableText) info =3D NULL; =20 - if (object_dynamic_cast(obj, TYPE_INTERRUPT_STATS_PROVIDER)) { - intc =3D INTERRUPT_STATS_PROVIDER(obj); - k =3D INTERRUPT_STATS_PROVIDER_GET_CLASS(obj); - uint64_t *irq_counts; - unsigned int nb_irqs, i; - if (k->get_statistics && - k->get_statistics(intc, &irq_counts, &nb_irqs)) { - if (nb_irqs > 0) { - monitor_printf(mon, "IRQ statistics for %s:\n", - object_get_typename(obj)); - for (i =3D 0; i < nb_irqs; i++) { - if (irq_counts[i] > 0) { - monitor_printf(mon, "%2d: %" PRId64 "\n", i, - irq_counts[i]); - } - } - } - } else { - monitor_printf(mon, "IRQ statistics not available for %s.\n", - object_get_typename(obj)); - } + info =3D qmp_x_query_irq(&err); + if (err) { + error_report_err(err); + return; } =20 - return 0; -} - -void hmp_info_irq(Monitor *mon, const QDict *qdict) -{ - object_child_foreach_recursive(object_get_root(), - hmp_info_irq_foreach, mon); + monitor_printf(mon, "%s", info->human_readable_text); } =20 static int hmp_info_pic_foreach(Object *obj, void *opaque) diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index b86fff823e..cfb98658e4 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -40,6 +40,7 @@ #include "exec/ramlist.h" #include "hw/mem/memory-device.h" #include "hw/acpi/acpi_dev_interface.h" +#include "hw/intc/intc.h" #include "hw/rdma/rdma.h" =20 NameInfo *qmp_query_name(Error **errp) @@ -430,3 +431,49 @@ HumanReadableText *qmp_x_query_ramblock(Error **errp) ret->human_readable_text =3D g_steal_pointer(&buf->str); return ret; } + +static int qmp_x_query_irq_foreach(Object *obj, void *opaque) +{ + InterruptStatsProvider *intc; + InterruptStatsProviderClass *k; + GString *buf =3D opaque; + + if (object_dynamic_cast(obj, TYPE_INTERRUPT_STATS_PROVIDER)) { + intc =3D INTERRUPT_STATS_PROVIDER(obj); + k =3D INTERRUPT_STATS_PROVIDER_GET_CLASS(obj); + uint64_t *irq_counts; + unsigned int nb_irqs, i; + if (k->get_statistics && + k->get_statistics(intc, &irq_counts, &nb_irqs)) { + if (nb_irqs > 0) { + g_string_append_printf(buf, "IRQ statistics for %s:\n", + object_get_typename(obj)); + for (i =3D 0; i < nb_irqs; i++) { + if (irq_counts[i] > 0) { + g_string_append_printf(buf, "%2d: %" PRId64 "\n", = i, + irq_counts[i]); + } + } + } + } else { + g_string_append_printf(buf, + "IRQ statistics not available for %s.\n= ", + object_get_typename(obj)); + } + } + + return 0; +} + +HumanReadableText *qmp_x_query_irq(Error **errp) +{ + HumanReadableText *ret; + g_autoptr(GString) buf =3D g_string_new(""); + + object_child_foreach_recursive(object_get_root(), + qmp_x_query_irq_foreach, buf); + + ret =3D g_new0(HumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} diff --git a/qapi/machine.json b/qapi/machine.json index 3ae7beb7cf..e72b47ea7d 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1313,6 +1313,18 @@ '*threads': 'int', '*maxcpus': 'int' } } =20 +## +# @x-query-irq: +# +# Query interrupt statistics +# +# Returns: interrupt statistics +# +# Since: 6.2 +## +{ 'command': 'x-query-irq', + 'returns': 'HumanReadableText' } + ## # @x-query-numa: # --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631633214755876.0801230665027; Tue, 14 Sep 2021 08:26:54 -0700 (PDT) Received: from localhost ([::1]:46196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAKj-0004oV-KG for importer@patchew.org; Tue, 14 Sep 2021 11:26:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41038) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Uj-0001SO-0s for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:33:12 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:56264) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Ue-0003Gu-RM for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:33:08 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-397-GMTEub__Oo-90fowxGl2Ew-1; Tue, 14 Sep 2021 10:33:02 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7CF110144E0; Tue, 14 Sep 2021 14:32:58 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 588B95D9DC; Tue, 14 Sep 2021 14:32:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629984; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=mWi2LfZwGzdEsZktG7Ab29gP8Q0XFlGCSfLs0XA4+QY=; b=Bsm2f/Ff/9amqy4djzotbWABw171stLCEtpZTICWu/VDAOuE3ZiDxc0mxaVjp46rHaYjbE fBEYb5t8KdOvFvXw4zSHZWeTFQzlX6tKvlGA5cd5Cb9lRKddOKSnb2MURcYYuUxEYgD2h0 EglGYxUa6oL+6H3KfRpm6wLa5bEH2no= X-MC-Unique: GMTEub__Oo-90fowxGl2Ew-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 40/53] hw/core: drop "dump_state" callback from CPU targets Date: Tue, 14 Sep 2021 15:20:29 +0100 Message-Id: <20210914142042.1655100-41-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631633216496100001 All targets are now converted to the "format_state" callback. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/core/cpu-common.c | 14 +++----------- include/hw/core/cpu.h | 2 -- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index d1ebc77d1b..494f4f41eb 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -108,17 +108,9 @@ static int cpu_common_gdb_write_register(CPUState *cpu= , uint8_t *buf, int reg) =20 void cpu_dump_state(CPUState *cpu, FILE *f, int flags) { - CPUClass *cc =3D CPU_GET_CLASS(cpu); - - if (cc->dump_state) { - cpu_synchronize_state(cpu); - cc->dump_state(cpu, f, flags); - } else if (cc->format_state) { - g_autoptr(GString) buf =3D g_string_new(""); - cpu_synchronize_state(cpu); - cc->format_state(cpu, buf, flags); - qemu_fprintf(f, "%s", buf->str); - } + g_autoptr(GString) buf =3D g_string_new(""); + cpu_format_state(cpu, buf, flags); + qemu_fprintf(f, "%s", buf->str); } =20 void cpu_format_state(CPUState *cpu, GString *buf, int flags) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index a0913eedaa..9cfc7d7479 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -91,7 +91,6 @@ struct SysemuCPUOps; * @reset_dump_flags: #CPUDumpFlags to use for reset logging. * @has_work: Callback for checking if there is work to do. * @memory_rw_debug: Callback for GDB memory access. - * @dump_state: Callback for dumping state. Deprecated, use @format_state. * @format_state: Callback for formatting state. * @get_arch_id: Callback for getting architecture-dependent CPU ID. * @set_pc: Callback for setting the Program Counter register. This @@ -136,7 +135,6 @@ struct CPUClass { bool (*has_work)(CPUState *cpu); int (*memory_rw_debug)(CPUState *cpu, vaddr addr, uint8_t *buf, int len, bool is_write); - void (*dump_state)(CPUState *cpu, FILE *, int flags); void (*format_state)(CPUState *cpu, GString *buf, int flags); int64_t (*get_arch_id)(CPUState *cpu); void (*set_pc)(CPUState *cpu, vaddr value); --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631633169748314.0286307204768; Tue, 14 Sep 2021 08:26:09 -0700 (PDT) Received: from localhost ([::1]:44232 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAK0-0003Wi-P4 for importer@patchew.org; Tue, 14 Sep 2021 11:26:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41132) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Uz-0001sY-8W for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:33:25 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:23558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Uu-0003RB-Gv for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:33:21 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-292-EFErQYmbNxqE2_ohQcmwiw-1; Tue, 14 Sep 2021 10:33:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 975991808306; Tue, 14 Sep 2021 14:33:14 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id EDE2F5D9CA; Tue, 14 Sep 2021 14:32:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631629999; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iWqi5YvXZxhgluXSBWOP1B0vyK3sX9iLf6wGJw7ZgFs=; b=R+4f5hykpfHKzhUUaiqG+Mc6/Ob5d3knQ3PbN8L7g1zWm7KVYGfOx9drXKk9mIrkrElzIz gqDJzOlq8oIbqIKBlkflgCA1L6BdW2jh8mRap5bt9geKdbg5nwzPAD49VMpeNS5WRF1HhV xdfr21IU8+vcG4ewKWO2nVv/qpekP7E= X-MC-Unique: EFErQYmbNxqE2_ohQcmwiw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 41/53] hw/core: drop support for NULL pointer for FILE * in cpu_dump_state Date: Tue, 14 Sep 2021 15:20:30 +0100 Message-Id: <20210914142042.1655100-42-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631633170507100001 The monitor is converted to use cpu_format_state, so the only remaining users of cpu_dump_state all pass a non-NULL pointer for the FILE * parameter. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/core/cpu-common.c | 2 +- include/hw/core/cpu.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 494f4f41eb..ffd9b9e07e 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -110,7 +110,7 @@ void cpu_dump_state(CPUState *cpu, FILE *f, int flags) { g_autoptr(GString) buf =3D g_string_new(""); cpu_format_state(cpu, buf, flags); - qemu_fprintf(f, "%s", buf->str); + fprintf(f, "%s", buf->str); } =20 void cpu_format_state(CPUState *cpu, GString *buf, int flags) diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 9cfc7d7479..4c47e1df18 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -531,7 +531,7 @@ enum CPUDumpFlags { /** * cpu_dump_state: * @cpu: The CPU whose state is to be dumped. - * @f: If non-null, dump to this stream, else to current print sink. + * @f: dump to this stream * * Dumps CPU state. */ --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631633651784133.86074725390347; Tue, 14 Sep 2021 08:34:11 -0700 (PDT) Received: from localhost ([::1]:36562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQARm-0000cL-ON for importer@patchew.org; Tue, 14 Sep 2021 11:34:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41258) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9V8-00022Q-Jq for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:33:37 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:50830) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9V5-0003YI-Nn for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:33:33 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-244-3-DXuh2MNlq3uRrfn-ga0A-1; Tue, 14 Sep 2021 10:33:29 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EEF251060DB2; Tue, 14 Sep 2021 14:33:25 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE7BC5D9CA; Tue, 14 Sep 2021 14:33:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631630011; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dbdQBxcj/2kjvXDfwwDA21f1GavKLlGLEK8BAYkabCY=; b=I/CFE4+D7hfZV3TBIzQf4qdLttpROoR/WKyz4lIrN76O/vuRnlOD+7BsqEO0pt0eVxwbA4 4zQITMW5nqhJJuNhMpbP0KSGKIUDzTI4yq9fvCdYic7ao5/j2Rr3GMwGzcQ+38xj+I16D+ OxTIMFuXHbTuxAQgR++hoyczyAfUmv4= X-MC-Unique: 3-DXuh2MNlq3uRrfn-ga0A-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 42/53] hw/core: introduce a 'format_tlb' callback Date: Tue, 14 Sep 2021 15:20:31 +0100 Message-Id: <20210914142042.1655100-43-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631633652677100001 This will allow us to reduce duplication between the different targets implementing the 'info tlb' command. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/core/cpu-common.c | 9 +++++++++ include/hw/core/cpu.h | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index ffd9b9e07e..9b11ec3c8d 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -123,6 +123,15 @@ void cpu_format_state(CPUState *cpu, GString *buf, int= flags) } } =20 +void cpu_format_tlb(CPUState *cpu, GString *buf) +{ + CPUClass *cc =3D CPU_GET_CLASS(cpu); + + if (cc->format_tlb) { + cc->format_tlb(cpu, buf); + } +} + void cpu_reset(CPUState *cpu) { device_cold_reset(DEVICE(cpu)); diff --git a/include/hw/core/cpu.h b/include/hw/core/cpu.h index 4c47e1df18..64fc57c8d9 100644 --- a/include/hw/core/cpu.h +++ b/include/hw/core/cpu.h @@ -92,6 +92,7 @@ struct SysemuCPUOps; * @has_work: Callback for checking if there is work to do. * @memory_rw_debug: Callback for GDB memory access. * @format_state: Callback for formatting state. + * @format_tlb: Callback for formatting memory mappings * @get_arch_id: Callback for getting architecture-dependent CPU ID. * @set_pc: Callback for setting the Program Counter register. This * should have the semantics used by the target architecture when @@ -136,6 +137,7 @@ struct CPUClass { int (*memory_rw_debug)(CPUState *cpu, vaddr addr, uint8_t *buf, int len, bool is_write); void (*format_state)(CPUState *cpu, GString *buf, int flags); + void (*format_tlb)(CPUState *cpu, GString *buf); int64_t (*get_arch_id)(CPUState *cpu); void (*set_pc)(CPUState *cpu, vaddr value); int (*gdb_read_register)(CPUState *cpu, GByteArray *buf, int reg); @@ -546,6 +548,15 @@ void cpu_dump_state(CPUState *cpu, FILE *f, int flags); */ void cpu_format_state(CPUState *cpu, GString *buf, int flags); =20 +/** + * cpu_format_tlb: + * @cpu: The CPU whose memory mappings are to be formatted. + * @buf: buffer to format state into + * + * Formats the memory mappings + */ +void cpu_format_tlb(CPUState *cpu, GString *buf); + #ifndef CONFIG_USER_ONLY /** * cpu_get_phys_page_attrs_debug: --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631632129779407.09822626381174; Tue, 14 Sep 2021 08:08:49 -0700 (PDT) Received: from localhost ([::1]:54882 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQA3E-00057s-H1 for importer@patchew.org; Tue, 14 Sep 2021 11:08:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9VN-0002CN-7H for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:33:49 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9VK-0003jZ-WD for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:33:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-398-0fHfBnnePW2Lz4Wnvbn9wg-1; Tue, 14 Sep 2021 10:33:44 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 375C51808304; Tue, 14 Sep 2021 14:33:41 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 41C175D9CA; Tue, 14 Sep 2021 14:33:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631630026; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=u/Q+2lydTjqVkGI5GLlhCmIjg5hJJ1z7UABw+pOKrT4=; b=YHAlNcwJVDVZDgn4VnBffEMWIB3EidlC0T9ZrxpPk3syJgdDI8+E9oIckaHM4e5A4Cj5zA V+Rot/YN6VdjiYHTHMMqV9/Zp+lvj0Gwrlx45wL/oNVkPd5UoMHxxgSD5pQ3YagzFaGhXB nHy5/GVQ2lNBC9UooYBjgjH9yNqUv/o= X-MC-Unique: 0fHfBnnePW2Lz4Wnvbn9wg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 43/53] target/i386: convert to use format_tlb callback Date: Tue, 14 Sep 2021 15:20:32 +0100 Message-Id: <20210914142042.1655100-44-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632153974100001 Change the "info tlb" implementation to use the format_tlb callback. Signed-off-by: Daniel P. Berrang=C3=A9 --- target/i386/cpu.c | 3 ++ target/i386/cpu.h | 1 + target/i386/monitor.c | 107 +++++++++++++++++++++++------------------- 3 files changed, 63 insertions(+), 48 deletions(-) diff --git a/target/i386/cpu.c b/target/i386/cpu.c index 0a5c6a6d19..ab86224ee2 100644 --- a/target/i386/cpu.c +++ b/target/i386/cpu.c @@ -6765,6 +6765,9 @@ static void x86_cpu_common_class_init(ObjectClass *oc= , void *data) cc->parse_features =3D x86_cpu_parse_featurestr; cc->has_work =3D x86_cpu_has_work; cc->format_state =3D x86_cpu_format_state; +#ifndef CONFIG_USER_ONLY + cc->format_tlb =3D x86_cpu_format_tlb; +#endif cc->set_pc =3D x86_cpu_set_pc; cc->gdb_read_register =3D x86_cpu_gdb_read_register; cc->gdb_write_register =3D x86_cpu_gdb_write_register; diff --git a/target/i386/cpu.h b/target/i386/cpu.h index 2bcb175da8..d61eeef617 100644 --- a/target/i386/cpu.h +++ b/target/i386/cpu.h @@ -1826,6 +1826,7 @@ void x86_cpu_get_memory_mapping(CPUState *cpu, Memory= MappingList *list, Error **errp); =20 void x86_cpu_format_state(CPUState *cs, GString *buf, int flags); +void x86_cpu_format_tlb(CPUState *cpu, GString *buf); =20 hwaddr x86_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr, MemTxAttrs *attrs); diff --git a/target/i386/monitor.c b/target/i386/monitor.c index fc09f90059..698fbbc80b 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -54,27 +54,27 @@ static hwaddr addr_canonical(CPUArchState *env, hwaddr = addr) return addr; } =20 -static void print_pte(Monitor *mon, CPUArchState *env, hwaddr addr, - hwaddr pte, hwaddr mask) +static void format_pte(GString *buf, CPUArchState *env, hwaddr addr, + hwaddr pte, hwaddr mask) { addr =3D addr_canonical(env, addr); =20 - monitor_printf(mon, TARGET_FMT_plx ": " TARGET_FMT_plx - " %c%c%c%c%c%c%c%c%c\n", - addr, - pte & mask, - pte & PG_NX_MASK ? 'X' : '-', - pte & PG_GLOBAL_MASK ? 'G' : '-', - pte & PG_PSE_MASK ? 'P' : '-', - pte & PG_DIRTY_MASK ? 'D' : '-', - pte & PG_ACCESSED_MASK ? 'A' : '-', - pte & PG_PCD_MASK ? 'C' : '-', - pte & PG_PWT_MASK ? 'T' : '-', - pte & PG_USER_MASK ? 'U' : '-', - pte & PG_RW_MASK ? 'W' : '-'); + g_string_append_printf(buf, TARGET_FMT_plx ": " TARGET_FMT_plx + " %c%c%c%c%c%c%c%c%c\n", + addr, + pte & mask, + pte & PG_NX_MASK ? 'X' : '-', + pte & PG_GLOBAL_MASK ? 'G' : '-', + pte & PG_PSE_MASK ? 'P' : '-', + pte & PG_DIRTY_MASK ? 'D' : '-', + pte & PG_ACCESSED_MASK ? 'A' : '-', + pte & PG_PCD_MASK ? 'C' : '-', + pte & PG_PWT_MASK ? 'T' : '-', + pte & PG_USER_MASK ? 'U' : '-', + pte & PG_RW_MASK ? 'W' : '-'); } =20 -static void tlb_info_32(Monitor *mon, CPUArchState *env) +static void tlb_info_32(GString *buf, CPUArchState *env) { unsigned int l1, l2; uint32_t pgd, pde, pte; @@ -86,15 +86,15 @@ static void tlb_info_32(Monitor *mon, CPUArchState *env) if (pde & PG_PRESENT_MASK) { if ((pde & PG_PSE_MASK) && (env->cr[4] & CR4_PSE_MASK)) { /* 4M pages */ - print_pte(mon, env, (l1 << 22), pde, ~((1 << 21) - 1)); + format_pte(buf, env, (l1 << 22), pde, ~((1 << 21) - 1)); } else { for(l2 =3D 0; l2 < 1024; l2++) { cpu_physical_memory_read((pde & ~0xfff) + l2 * 4, &pte= , 4); pte =3D le32_to_cpu(pte); if (pte & PG_PRESENT_MASK) { - print_pte(mon, env, (l1 << 22) + (l2 << 12), - pte & ~PG_PSE_MASK, - ~0xfff); + format_pte(buf, env, (l1 << 22) + (l2 << 12), + pte & ~PG_PSE_MASK, + ~0xfff); } } } @@ -102,7 +102,7 @@ static void tlb_info_32(Monitor *mon, CPUArchState *env) } } =20 -static void tlb_info_pae32(Monitor *mon, CPUArchState *env) +static void tlb_info_pae32(GString *buf, CPUArchState *env) { unsigned int l1, l2, l3; uint64_t pdpe, pde, pte; @@ -120,18 +120,18 @@ static void tlb_info_pae32(Monitor *mon, CPUArchState= *env) if (pde & PG_PRESENT_MASK) { if (pde & PG_PSE_MASK) { /* 2M pages with PAE, CR4.PSE is ignored */ - print_pte(mon, env, (l1 << 30) + (l2 << 21), pde, - ~((hwaddr)(1 << 20) - 1)); + format_pte(buf, env, (l1 << 30) + (l2 << 21), pde, + ~((hwaddr)(1 << 20) - 1)); } else { pt_addr =3D pde & 0x3fffffffff000ULL; for (l3 =3D 0; l3 < 512; l3++) { cpu_physical_memory_read(pt_addr + l3 * 8, &pt= e, 8); pte =3D le64_to_cpu(pte); if (pte & PG_PRESENT_MASK) { - print_pte(mon, env, (l1 << 30) + (l2 << 21) - + (l3 << 12), - pte & ~PG_PSE_MASK, - ~(hwaddr)0xfff); + format_pte(buf, env, (l1 << 30) + (l2 << 2= 1) + + (l3 << 12), + pte & ~PG_PSE_MASK, + ~(hwaddr)0xfff); } } } @@ -142,7 +142,7 @@ static void tlb_info_pae32(Monitor *mon, CPUArchState *= env) } =20 #ifdef TARGET_X86_64 -static void tlb_info_la48(Monitor *mon, CPUArchState *env, +static void tlb_info_la48(GString *buf, CPUArchState *env, uint64_t l0, uint64_t pml4_addr) { uint64_t l1, l2, l3, l4; @@ -166,8 +166,8 @@ static void tlb_info_la48(Monitor *mon, CPUArchState *e= nv, =20 if (pdpe & PG_PSE_MASK) { /* 1G pages, CR4.PSE is ignored */ - print_pte(mon, env, (l0 << 48) + (l1 << 39) + (l2 << 30), - pdpe, 0x3ffffc0000000ULL); + format_pte(buf, env, (l0 << 48) + (l1 << 39) + (l2 << 30), + pdpe, 0x3ffffc0000000ULL); continue; } =20 @@ -181,8 +181,8 @@ static void tlb_info_la48(Monitor *mon, CPUArchState *e= nv, =20 if (pde & PG_PSE_MASK) { /* 2M pages, CR4.PSE is ignored */ - print_pte(mon, env, (l0 << 48) + (l1 << 39) + (l2 << 3= 0) + - (l3 << 21), pde, 0x3ffffffe00000ULL); + format_pte(buf, env, (l0 << 48) + (l1 << 39) + (l2 << = 30) + + (l3 << 21), pde, 0x3ffffffe00000ULL); continue; } =20 @@ -193,9 +193,9 @@ static void tlb_info_la48(Monitor *mon, CPUArchState *e= nv, &pte, 8); pte =3D le64_to_cpu(pte); if (pte & PG_PRESENT_MASK) { - print_pte(mon, env, (l0 << 48) + (l1 << 39) + - (l2 << 30) + (l3 << 21) + (l4 << 12), - pte & ~PG_PSE_MASK, 0x3fffffffff000ULL); + format_pte(buf, env, (l0 << 48) + (l1 << 39) + + (l2 << 30) + (l3 << 21) + (l4 << 12), + pte & ~PG_PSE_MASK, 0x3fffffffff000ULL); } } } @@ -203,7 +203,7 @@ static void tlb_info_la48(Monitor *mon, CPUArchState *e= nv, } } =20 -static void tlb_info_la57(Monitor *mon, CPUArchState *env) +static void tlb_info_la57(GString *buf, CPUArchState *env) { uint64_t l0; uint64_t pml5e; @@ -214,44 +214,55 @@ static void tlb_info_la57(Monitor *mon, CPUArchState = *env) cpu_physical_memory_read(pml5_addr + l0 * 8, &pml5e, 8); pml5e =3D le64_to_cpu(pml5e); if (pml5e & PG_PRESENT_MASK) { - tlb_info_la48(mon, env, l0, pml5e & 0x3fffffffff000ULL); + tlb_info_la48(buf, env, l0, pml5e & 0x3fffffffff000ULL); } } } #endif /* TARGET_X86_64 */ =20 -void hmp_info_tlb(Monitor *mon, const QDict *qdict) +void x86_cpu_format_tlb(CPUState *cpu, GString *buf) { CPUArchState *env; =20 - env =3D mon_get_cpu_env(mon); - if (!env) { - monitor_printf(mon, "No CPU available\n"); - return; - } + env =3D cpu->env_ptr; =20 if (!(env->cr[0] & CR0_PG_MASK)) { - monitor_printf(mon, "PG disabled\n"); + g_string_append_printf(buf, "PG disabled\n"); return; } if (env->cr[4] & CR4_PAE_MASK) { #ifdef TARGET_X86_64 if (env->hflags & HF_LMA_MASK) { if (env->cr[4] & CR4_LA57_MASK) { - tlb_info_la57(mon, env); + tlb_info_la57(buf, env); } else { - tlb_info_la48(mon, env, 0, env->cr[3] & 0x3fffffffff000ULL= ); + tlb_info_la48(buf, env, 0, env->cr[3] & 0x3fffffffff000ULL= ); } } else #endif { - tlb_info_pae32(mon, env); + tlb_info_pae32(buf, env); } } else { - tlb_info_32(mon, env); + tlb_info_32(buf, env); } } =20 +void hmp_info_tlb(Monitor *mon, const QDict *qdict) +{ + g_autoptr(GString) buf =3D g_string_new(""); + CPUState *cpu =3D mon_get_cpu(mon); + + if (!cpu) { + monitor_printf(mon, "No CPU available\n"); + return; + } + + cpu_format_tlb(cpu, buf); + + monitor_printf(mon, "%s", buf->str); +} + static void mem_print(Monitor *mon, CPUArchState *env, hwaddr *pstart, int *plast_prot, hwaddr end, int prot) --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631633402659792.2329322853276; Tue, 14 Sep 2021 08:30:02 -0700 (PDT) Received: from localhost ([::1]:55982 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQANl-00031u-JJ for importer@patchew.org; Tue, 14 Sep 2021 11:30:01 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41578) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Vc-0002gt-NB for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:34:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:50082) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9VX-0003rX-VZ for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:34:04 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-449-qAFyWR9zMeGO5aywzna6tA-1; Tue, 14 Sep 2021 10:33:56 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A7A56BAF80; Tue, 14 Sep 2021 14:33:52 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 864FC5D9CA; Tue, 14 Sep 2021 14:33:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631630037; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=bh9ijrtRHqw1dGWJj6Rxy56++d9ni6EtfBBE4iZ7xmU=; b=fFrS4A98Ex3C5KqRvMJ+iTlXBuupmQaWFnWkXTo6q59knLixjuMelyQhho85Ut4HZ0ztf/ CsHB+Zhp3F58rNfCY3R3NgV5OX1HxoGjvI+hcMq9wmE01CC3Sxi/Ior7hfH1CrbEiOw2bS poTxR20A1Et53JmNOQsU8IG/5zke2tM= X-MC-Unique: qAFyWR9zMeGO5aywzna6tA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 44/53] target/m68k: convert to use format_tlb callback Date: Tue, 14 Sep 2021 15:20:33 +0100 Message-Id: <20210914142042.1655100-45-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631633403790100001 Change the "info tlb" implementation to use the format_tlb callback. Signed-off-by: Daniel P. Berrang=C3=A9 Acked-by: Laurent Vivier --- target/m68k/cpu.c | 3 + target/m68k/cpu.h | 3 +- target/m68k/helper.c | 132 ++++++++++++++++++++++-------------------- target/m68k/monitor.c | 11 +++- 4 files changed, 82 insertions(+), 67 deletions(-) diff --git a/target/m68k/cpu.c b/target/m68k/cpu.c index 4ccf572a68..8f143eb540 100644 --- a/target/m68k/cpu.c +++ b/target/m68k/cpu.c @@ -537,6 +537,9 @@ static void m68k_cpu_class_init(ObjectClass *c, void *d= ata) cc->class_by_name =3D m68k_cpu_class_by_name; cc->has_work =3D m68k_cpu_has_work; cc->format_state =3D m68k_cpu_format_state; +#ifndef CONFIG_USER_ONLY + cc->format_tlb =3D m68k_cpu_format_tlb; +#endif cc->set_pc =3D m68k_cpu_set_pc; cc->gdb_read_register =3D m68k_cpu_gdb_read_register; cc->gdb_write_register =3D m68k_cpu_gdb_write_register; diff --git a/target/m68k/cpu.h b/target/m68k/cpu.h index b0641f6d0d..f2d777a1ba 100644 --- a/target/m68k/cpu.h +++ b/target/m68k/cpu.h @@ -169,6 +169,7 @@ struct M68kCPU { void m68k_cpu_do_interrupt(CPUState *cpu); bool m68k_cpu_exec_interrupt(CPUState *cpu, int int_req); void m68k_cpu_format_state(CPUState *cpu, GString *buf, int flags); +void m68k_cpu_format_tlb(CPUState *cpu, GString *buf); hwaddr m68k_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int m68k_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int m68k_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); @@ -612,6 +613,4 @@ static inline void cpu_get_tb_cpu_state(CPUM68KState *e= nv, target_ulong *pc, } } =20 -void dump_mmu(CPUM68KState *env); - #endif diff --git a/target/m68k/helper.c b/target/m68k/helper.c index 137a3e1a3d..050a27d21c 100644 --- a/target/m68k/helper.c +++ b/target/m68k/helper.c @@ -25,6 +25,7 @@ #include "exec/helper-proto.h" #include "fpu/softfloat.h" #include "qemu/qemu-print.h" +#include "qapi/error.h" =20 #define SIGNBIT (1u << 31) =20 @@ -483,27 +484,28 @@ void m68k_switch_sp(CPUM68KState *env) /* MMU: 68040 only */ =20 static void print_address_zone(uint32_t logical, uint32_t physical, - uint32_t size, int attr) + uint32_t size, int attr, GString *buf) { - qemu_printf("%08x - %08x -> %08x - %08x %c ", - logical, logical + size - 1, - physical, physical + size - 1, - attr & 4 ? 'W' : '-'); + g_string_append_printf(buf, "%08x - %08x -> %08x - %08x %c ", + logical, logical + size - 1, + physical, physical + size - 1, + attr & 4 ? 'W' : '-'); size >>=3D 10; if (size < 1024) { - qemu_printf("(%d KiB)\n", size); + g_string_append_printf(buf, "(%d KiB)\n", size); } else { size >>=3D 10; if (size < 1024) { - qemu_printf("(%d MiB)\n", size); + g_string_append_printf(buf, "(%d MiB)\n", size); } else { size >>=3D 10; - qemu_printf("(%d GiB)\n", size); + g_string_append_printf(buf, "(%d GiB)\n", size); } } } =20 -static void dump_address_map(CPUM68KState *env, uint32_t root_pointer) +static void dump_address_map(CPUM68KState *env, uint32_t root_pointer, + GString *buf) { int i, j, k; int tic_size, tic_shift; @@ -573,7 +575,8 @@ static void dump_address_map(CPUM68KState *env, uint32_= t root_pointer) size =3D last_logical + (1 << tic_shift) - first_logical; print_address_zone(first_logical, - first_physical, size, last_attr= ); + first_physical, size, last_attr, + buf); } first_logical =3D logical; first_physical =3D physical; @@ -583,125 +586,130 @@ static void dump_address_map(CPUM68KState *env, uin= t32_t root_pointer) } if (first_logical !=3D logical || (attr & 4) !=3D (last_attr & 4)) { size =3D logical + (1 << tic_shift) - first_logical; - print_address_zone(first_logical, first_physical, size, last_attr); + print_address_zone(first_logical, first_physical, size, last_attr,= buf); } } =20 #define DUMP_CACHEFLAGS(a) \ switch (a & M68K_DESC_CACHEMODE) { \ case M68K_DESC_CM_WRTHRU: /* cachable, write-through */ \ - qemu_printf("T"); \ + g_string_append_printf(buf, "T"); \ break; \ case M68K_DESC_CM_COPYBK: /* cachable, copyback */ \ - qemu_printf("C"); \ + g_string_append_printf(buf, "C"); \ break; \ case M68K_DESC_CM_SERIAL: /* noncachable, serialized */ \ - qemu_printf("S"); \ + g_string_append_printf(buf, "S"); \ break; \ case M68K_DESC_CM_NCACHE: /* noncachable */ \ - qemu_printf("N"); \ + g_string_append_printf(buf, "N"); \ break; \ } =20 -static void dump_ttr(uint32_t ttr) +static void dump_ttr(uint32_t ttr, GString *buf) { if ((ttr & M68K_TTR_ENABLED) =3D=3D 0) { - qemu_printf("disabled\n"); + g_string_append_printf(buf, "disabled\n"); return; } - qemu_printf("Base: 0x%08x Mask: 0x%08x Control: ", - ttr & M68K_TTR_ADDR_BASE, - (ttr & M68K_TTR_ADDR_MASK) << M68K_TTR_ADDR_MASK_SHIFT); + g_string_append_printf(buf, "Base: 0x%08x Mask: 0x%08x Control: ", + ttr & M68K_TTR_ADDR_BASE, + (ttr & M68K_TTR_ADDR_MASK) << + M68K_TTR_ADDR_MASK_SHIFT); switch (ttr & M68K_TTR_SFIELD) { case M68K_TTR_SFIELD_USER: - qemu_printf("U"); + g_string_append_printf(buf, "U"); break; case M68K_TTR_SFIELD_SUPER: - qemu_printf("S"); + g_string_append_printf(buf, "S"); break; default: - qemu_printf("*"); + g_string_append_printf(buf, "*"); break; } DUMP_CACHEFLAGS(ttr); if (ttr & M68K_DESC_WRITEPROT) { - qemu_printf("R"); + g_string_append_printf(buf, "R"); } else { - qemu_printf("W"); + g_string_append_printf(buf, "W"); } - qemu_printf(" U: %d\n", (ttr & M68K_DESC_USERATTR) >> - M68K_DESC_USERATTR_SHIFT); + g_string_append_printf(buf, " U: %d\n", (ttr & M68K_DESC_USERATTR) >> + M68K_DESC_USERATTR_SHIFT); } =20 -void dump_mmu(CPUM68KState *env) + +void m68k_cpu_format_tlb(CPUState *cpu, GString *buf) { + CPUM68KState *env =3D cpu->env_ptr; + if ((env->mmu.tcr & M68K_TCR_ENABLED) =3D=3D 0) { - qemu_printf("Translation disabled\n"); + g_string_append_printf(buf, "Translation disabled\n"); return; } - qemu_printf("Page Size: "); + g_string_append_printf(buf, "Page Size: "); if (env->mmu.tcr & M68K_TCR_PAGE_8K) { - qemu_printf("8kB\n"); + g_string_append_printf(buf, "8kB\n"); } else { - qemu_printf("4kB\n"); + g_string_append_printf(buf, "4kB\n"); } =20 - qemu_printf("MMUSR: "); + g_string_append_printf(buf, "MMUSR: "); if (env->mmu.mmusr & M68K_MMU_B_040) { - qemu_printf("BUS ERROR\n"); + g_string_append_printf(buf, "BUS ERROR\n"); } else { - qemu_printf("Phy=3D%08x Flags: ", env->mmu.mmusr & 0xfffff000); + g_string_append_printf(buf, "Phy=3D%08x Flags: ", + env->mmu.mmusr & 0xfffff000); /* flags found on the page descriptor */ if (env->mmu.mmusr & M68K_MMU_G_040) { - qemu_printf("G"); /* Global */ + g_string_append_printf(buf, "G"); /* Global */ } else { - qemu_printf("."); + g_string_append_printf(buf, "."); } if (env->mmu.mmusr & M68K_MMU_S_040) { - qemu_printf("S"); /* Supervisor */ + g_string_append_printf(buf, "S"); /* Supervisor */ } else { - qemu_printf("."); + g_string_append_printf(buf, "."); } if (env->mmu.mmusr & M68K_MMU_M_040) { - qemu_printf("M"); /* Modified */ + g_string_append_printf(buf, "M"); /* Modified */ } else { - qemu_printf("."); + g_string_append_printf(buf, "."); } if (env->mmu.mmusr & M68K_MMU_WP_040) { - qemu_printf("W"); /* Write protect */ + g_string_append_printf(buf, "W"); /* Write protect */ } else { - qemu_printf("."); + g_string_append_printf(buf, "."); } if (env->mmu.mmusr & M68K_MMU_T_040) { - qemu_printf("T"); /* Transparent */ + g_string_append_printf(buf, "T"); /* Transparent */ } else { - qemu_printf("."); + g_string_append_printf(buf, "."); } if (env->mmu.mmusr & M68K_MMU_R_040) { - qemu_printf("R"); /* Resident */ + g_string_append_printf(buf, "R"); /* Resident */ } else { - qemu_printf("."); + g_string_append_printf(buf, "."); } - qemu_printf(" Cache: "); + g_string_append_printf(buf, " Cache: "); DUMP_CACHEFLAGS(env->mmu.mmusr); - qemu_printf(" U: %d\n", (env->mmu.mmusr >> 8) & 3); - qemu_printf("\n"); + g_string_append_printf(buf, " U: %d\n", (env->mmu.mmusr >> 8) & 3); + g_string_append_printf(buf, "\n"); } =20 - qemu_printf("ITTR0: "); - dump_ttr(env->mmu.ttr[M68K_ITTR0]); - qemu_printf("ITTR1: "); - dump_ttr(env->mmu.ttr[M68K_ITTR1]); - qemu_printf("DTTR0: "); - dump_ttr(env->mmu.ttr[M68K_DTTR0]); - qemu_printf("DTTR1: "); - dump_ttr(env->mmu.ttr[M68K_DTTR1]); + g_string_append_printf(buf, "ITTR0: "); + dump_ttr(env->mmu.ttr[M68K_ITTR0], buf); + g_string_append_printf(buf, "ITTR1: "); + dump_ttr(env->mmu.ttr[M68K_ITTR1], buf); + g_string_append_printf(buf, "DTTR0: "); + dump_ttr(env->mmu.ttr[M68K_DTTR0], buf); + g_string_append_printf(buf, "DTTR1: "); + dump_ttr(env->mmu.ttr[M68K_DTTR1], buf); =20 - qemu_printf("SRP: 0x%08x\n", env->mmu.srp); - dump_address_map(env, env->mmu.srp); + g_string_append_printf(buf, "SRP: 0x%08x\n", env->mmu.srp); + dump_address_map(env, env->mmu.srp, buf); =20 - qemu_printf("URP: 0x%08x\n", env->mmu.urp); - dump_address_map(env, env->mmu.urp); + g_string_append_printf(buf, "URP: 0x%08x\n", env->mmu.urp); + dump_address_map(env, env->mmu.urp, buf); } =20 static int check_TTR(uint32_t ttr, int *prot, target_ulong addr, diff --git a/target/m68k/monitor.c b/target/m68k/monitor.c index 2bdf6acae0..003a665246 100644 --- a/target/m68k/monitor.c +++ b/target/m68k/monitor.c @@ -9,17 +9,22 @@ #include "cpu.h" #include "monitor/hmp-target.h" #include "monitor/monitor.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-machine-target.h" =20 void hmp_info_tlb(Monitor *mon, const QDict *qdict) { - CPUArchState *env1 =3D mon_get_cpu_env(mon); + g_autoptr(GString) buf =3D g_string_new(""); + CPUState *cpu =3D mon_get_cpu(mon); =20 - if (!env1) { + if (!cpu) { monitor_printf(mon, "No CPU available\n"); return; } =20 - dump_mmu(env1); + cpu_format_tlb(cpu, buf); + + monitor_printf(mon, "%s", buf->str); } =20 static const MonitorDef monitor_defs[] =3D { --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16316323691381009.2111866820495; Tue, 14 Sep 2021 08:12:49 -0700 (PDT) Received: from localhost ([::1]:35940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQA75-0003ey-Ub for importer@patchew.org; Tue, 14 Sep 2021 11:12:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41706) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9WA-0003QB-2T for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:34:38 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49804) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Vs-00043s-SC for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:34:37 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-87-H1_BhtnRMo6S6GpsQfTXTQ-1; Tue, 14 Sep 2021 10:34:16 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9D1461808306; Tue, 14 Sep 2021 14:34:12 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id EFA4B5D9CA; Tue, 14 Sep 2021 14:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631630058; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OfuNrJauBgm0uBcnOxhBp2EuyAUbXL9W+QCHdXBJ5JE=; b=JMsr0fK4gEbOj/BO9MBxtuDpLIJWGsWitgSz6wEzQl05ZoC74p6+ymYZET/nFgrt43AsUq 7Krip6Pdnc9sfVSKVcG4V7iHhYP9/SiyfR6VlHoIipGpVFBE1IvGwkbvwPPukHhubcDlTM Et/E/M6L6ICn4jr6cbiM0E5FWF9ZkCU= X-MC-Unique: H1_BhtnRMo6S6GpsQfTXTQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 45/53] target/nios2: convert to use format_tlb callback Date: Tue, 14 Sep 2021 15:20:34 +0100 Message-Id: <20210914142042.1655100-46-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632370216100001 Change the "info tlb" implementation to use the format_tlb callback. Signed-off-by: Daniel P. Berrang=C3=A9 --- target/nios2/cpu.c | 3 +++ target/nios2/cpu.h | 2 +- target/nios2/mmu.c | 37 +++++++++++++++++++------------------ target/nios2/monitor.c | 12 ++++++++++-- 4 files changed, 33 insertions(+), 21 deletions(-) diff --git a/target/nios2/cpu.c b/target/nios2/cpu.c index cbf15fb1c9..60162ee692 100644 --- a/target/nios2/cpu.c +++ b/target/nios2/cpu.c @@ -242,6 +242,9 @@ static void nios2_cpu_class_init(ObjectClass *oc, void = *data) cc->class_by_name =3D nios2_cpu_class_by_name; cc->has_work =3D nios2_cpu_has_work; cc->format_state =3D nios2_cpu_format_state; +#ifndef CONFIG_USER_ONLY + cc->format_tlb =3D nios2_cpu_format_tlb; +#endif cc->set_pc =3D nios2_cpu_set_pc; cc->disas_set_info =3D nios2_cpu_disas_set_info; #ifndef CONFIG_USER_ONLY diff --git a/target/nios2/cpu.h b/target/nios2/cpu.h index 3b16cd1f3c..1167872bd9 100644 --- a/target/nios2/cpu.h +++ b/target/nios2/cpu.h @@ -194,8 +194,8 @@ struct Nios2CPU { void nios2_tcg_init(void); void nios2_cpu_do_interrupt(CPUState *cs); int cpu_nios2_signal_handler(int host_signum, void *pinfo, void *puc); -void dump_mmu(CPUNios2State *env); void nios2_cpu_format_state(CPUState *cpu, GString *buf, int flags); +void nios2_cpu_format_tlb(CPUState *cpu, GString *buf); hwaddr nios2_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void nios2_cpu_do_unaligned_access(CPUState *cpu, vaddr addr, MMUAccessType access_type, diff --git a/target/nios2/mmu.c b/target/nios2/mmu.c index 2545c06761..1c7d3b34c3 100644 --- a/target/nios2/mmu.c +++ b/target/nios2/mmu.c @@ -252,29 +252,30 @@ void mmu_init(CPUNios2State *env) mmu->tlb =3D g_new0(Nios2TLBEntry, cpu->tlb_num_entries); } =20 -void dump_mmu(CPUNios2State *env) +void nios2_cpu_format_tlb(CPUState *cpu, GString *buf) { - Nios2CPU *cpu =3D env_archcpu(env); + CPUNios2State *env =3D cpu->env_ptr; + Nios2CPU *ncpu =3D env_archcpu(env); int i; =20 - qemu_printf("MMU: ways %d, entries %d, pid bits %d\n", - cpu->tlb_num_ways, cpu->tlb_num_entries, - cpu->pid_num_bits); + g_string_append_printf(buf, "MMU: ways %d, entries %d, pid bits %d\n", + ncpu->tlb_num_ways, ncpu->tlb_num_entries, + ncpu->pid_num_bits); =20 - for (i =3D 0; i < cpu->tlb_num_entries; i++) { + for (i =3D 0; i < ncpu->tlb_num_entries; i++) { Nios2TLBEntry *entry =3D &env->mmu.tlb[i]; - qemu_printf("TLB[%d] =3D %08X %08X %c VPN %05X " - "PID %02X %c PFN %05X %c%c%c%c\n", - i, entry->tag, entry->data, - (entry->tag & (1 << 10)) ? 'V' : '-', - entry->tag >> 12, - entry->tag & ((1 << cpu->pid_num_bits) - 1), - (entry->tag & (1 << 11)) ? 'G' : '-', - entry->data & CR_TLBACC_PFN_MASK, - (entry->data & CR_TLBACC_C) ? 'C' : '-', - (entry->data & CR_TLBACC_R) ? 'R' : '-', - (entry->data & CR_TLBACC_W) ? 'W' : '-', - (entry->data & CR_TLBACC_X) ? 'X' : '-'); + g_string_append_printf(buf, "TLB[%d] =3D %08X %08X %c VPN %05X " + "PID %02X %c PFN %05X %c%c%c%c\n", + i, entry->tag, entry->data, + (entry->tag & (1 << 10)) ? 'V' : '-', + entry->tag >> 12, + entry->tag & ((1 << ncpu->pid_num_bits) - 1= ), + (entry->tag & (1 << 11)) ? 'G' : '-', + entry->data & CR_TLBACC_PFN_MASK, + (entry->data & CR_TLBACC_C) ? 'C' : '-', + (entry->data & CR_TLBACC_R) ? 'R' : '-', + (entry->data & CR_TLBACC_W) ? 'W' : '-', + (entry->data & CR_TLBACC_X) ? 'X' : '-'); } } =20 diff --git a/target/nios2/monitor.c b/target/nios2/monitor.c index 0152dec3fa..99d35e8ef1 100644 --- a/target/nios2/monitor.c +++ b/target/nios2/monitor.c @@ -29,7 +29,15 @@ =20 void hmp_info_tlb(Monitor *mon, const QDict *qdict) { - CPUArchState *env1 =3D mon_get_cpu_env(mon); + g_autoptr(GString) buf =3D g_string_new(""); + CPUState *cpu =3D mon_get_cpu(mon); =20 - dump_mmu(env1); + if (!cpu) { + monitor_printf(mon, "No CPU available\n"); + return; + } + + cpu_format_tlb(cpu, buf); + + monitor_printf(mon, "%s", buf->str); } --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631633577565650.8033917785178; Tue, 14 Sep 2021 08:32:57 -0700 (PDT) Received: from localhost ([::1]:32816 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAQZ-0006XI-V4 for importer@patchew.org; Tue, 14 Sep 2021 11:32:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9WD-0003bS-B9 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:34:45 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:20680) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9WA-0004Gz-Qh for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:34:41 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-313-cHcYVXAuP--92nrDZaG9dw-1; Tue, 14 Sep 2021 10:34:36 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DA12B802929; Tue, 14 Sep 2021 14:34:32 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id E52E85D9CA; Tue, 14 Sep 2021 14:34:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631630078; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=xY/JLYmYivkDx/PTFg1nLvvMJr1mCcIozxofn9Axypg=; b=Wp+PFRzfYOCVewzZqh6wVJID2i4/c3lyTbH3+jp3nHaC+z7v3FjHPDTqk72XD2vbaWmoyl AScOt2wbEvHtVHOdzPlR3oNG+vZ3Ev/cmD1dY8B8QkK5ht61IkI2U4BipukzwTgOjDB7Vk jemct7dBze1hFBIQQgMm26Xjc67b3FY= X-MC-Unique: cHcYVXAuP--92nrDZaG9dw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 46/53] target/ppc: convert to use format_tlb callback Date: Tue, 14 Sep 2021 15:20:35 +0100 Message-Id: <20210914142042.1655100-47-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631633579768100001 Change the "info tlb" implementation to use the format_tlb callback. Signed-off-by: Daniel P. Berrang=C3=A9 Acked-by: David Gibson --- target/ppc/cpu.h | 3 +- target/ppc/cpu_init.c | 3 + target/ppc/mmu-hash64.c | 8 +- target/ppc/mmu-hash64.h | 2 +- target/ppc/mmu_common.c | 167 ++++++++++++++++++++++------------------ target/ppc/monitor.c | 10 ++- 6 files changed, 107 insertions(+), 86 deletions(-) diff --git a/target/ppc/cpu.h b/target/ppc/cpu.h index c84ae29b98..37b44bfbc3 100644 --- a/target/ppc/cpu.h +++ b/target/ppc/cpu.h @@ -1257,6 +1257,7 @@ DECLARE_OBJ_CHECKERS(PPCVirtualHypervisor, PPCVirtual= HypervisorClass, void ppc_cpu_do_interrupt(CPUState *cpu); bool ppc_cpu_exec_interrupt(CPUState *cpu, int int_req); void ppc_cpu_format_state(CPUState *cpu, GString *buf, int flags); +void ppc_cpu_format_tlb(CPUState *cpu, GString *buf); hwaddr ppc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int ppc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int ppc_cpu_gdb_read_register_apple(CPUState *cpu, GByteArray *buf, int re= g); @@ -2667,8 +2668,6 @@ static inline bool ppc_interrupts_little_endian(Power= PCCPU *cpu) return false; } =20 -void dump_mmu(CPUPPCState *env); - void ppc_maybe_bswap_register(CPUPPCState *env, uint8_t *mem_buf, int len); void ppc_store_vscr(CPUPPCState *env, uint32_t vscr); uint32_t ppc_get_vscr(CPUPPCState *env); diff --git a/target/ppc/cpu_init.c b/target/ppc/cpu_init.c index 3456be465c..98d6f40a49 100644 --- a/target/ppc/cpu_init.c +++ b/target/ppc/cpu_init.c @@ -9044,6 +9044,9 @@ static void ppc_cpu_class_init(ObjectClass *oc, void = *data) cc->class_by_name =3D ppc_cpu_class_by_name; cc->has_work =3D ppc_cpu_has_work; cc->format_state =3D ppc_cpu_format_state; +#ifndef CONFIG_USER_ONLY + cc->format_tlb =3D ppc_cpu_format_tlb; +#endif cc->set_pc =3D ppc_cpu_set_pc; cc->gdb_read_register =3D ppc_cpu_gdb_read_register; cc->gdb_write_register =3D ppc_cpu_gdb_write_register; diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c index 19832c4b46..73927a0819 100644 --- a/target/ppc/mmu-hash64.c +++ b/target/ppc/mmu-hash64.c @@ -80,7 +80,7 @@ static ppc_slb_t *slb_lookup(PowerPCCPU *cpu, target_ulon= g eaddr) return NULL; } =20 -void dump_slb(PowerPCCPU *cpu) +void dump_slb(PowerPCCPU *cpu, GString *buf) { CPUPPCState *env =3D &cpu->env; int i; @@ -88,15 +88,15 @@ void dump_slb(PowerPCCPU *cpu) =20 cpu_synchronize_state(CPU(cpu)); =20 - qemu_printf("SLB\tESID\t\t\tVSID\n"); + g_string_append_printf(buf, "SLB\tESID\t\t\tVSID\n"); for (i =3D 0; i < cpu->hash64_opts->slb_size; i++) { slbe =3D env->slb[i].esid; slbv =3D env->slb[i].vsid; if (slbe =3D=3D 0 && slbv =3D=3D 0) { continue; } - qemu_printf("%d\t0x%016" PRIx64 "\t0x%016" PRIx64 "\n", - i, slbe, slbv); + g_string_append_printf(buf, "%d\t0x%016" PRIx64 "\t0x%016" PRIx64 = "\n", + i, slbe, slbv); } } =20 diff --git a/target/ppc/mmu-hash64.h b/target/ppc/mmu-hash64.h index c5b2f97ff7..99e03a5849 100644 --- a/target/ppc/mmu-hash64.h +++ b/target/ppc/mmu-hash64.h @@ -4,7 +4,7 @@ #ifndef CONFIG_USER_ONLY =20 #ifdef TARGET_PPC64 -void dump_slb(PowerPCCPU *cpu); +void dump_slb(PowerPCCPU *cpu, GString *buf); int ppc_store_slb(PowerPCCPU *cpu, target_ulong slot, target_ulong esid, target_ulong vsid); bool ppc_hash64_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_t= ype, diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 754509e556..d7b716f30a 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -937,19 +937,19 @@ static const char *book3e_tsize_to_str[32] =3D { "1T", "2T" }; =20 -static void mmubooke_dump_mmu(CPUPPCState *env) +static void mmubooke_dump_mmu(CPUPPCState *env, GString *buf) { ppcemb_tlb_t *entry; int i; =20 if (kvm_enabled() && !env->kvm_sw_tlb) { - qemu_printf("Cannot access KVM TLB\n"); + g_string_append_printf(buf, "Cannot access KVM TLB\n"); return; } =20 - qemu_printf("\nTLB:\n"); - qemu_printf("Effective Physical Size PID Prot = " - "Attr\n"); + g_string_append_printf(buf, "\nTLB:\n"); + g_string_append_printf(buf, "Effective Physical " + "Size PID Prot Attr\n"); =20 entry =3D &env->tlb.tlbe[0]; for (i =3D 0; i < env->nb_tlb; i++, entry++) { @@ -973,22 +973,24 @@ static void mmubooke_dump_mmu(CPUPPCState *env) } else { snprintf(size_buf, sizeof(size_buf), "%3" PRId64 "k", size / K= iB); } - qemu_printf("0x%016" PRIx64 " 0x%016" PRIx64 " %s %-5u %08x %08x\n= ", - (uint64_t)ea, (uint64_t)pa, size_buf, (uint32_t)entry-= >PID, - entry->prot, entry->attr); + g_string_append_printf(buf, "0x%016" PRIx64 " 0x%016" PRIx64 + " %s %-5u %08x %08x\n", + (uint64_t)ea, (uint64_t)pa, size_buf, + (uint32_t)entry->PID, + entry->prot, entry->attr); } =20 } =20 static void mmubooke206_dump_one_tlb(CPUPPCState *env, int tlbn, int offse= t, - int tlbsize) + int tlbsize, GString *buf) { ppcmas_tlb_t *entry; int i; =20 - qemu_printf("\nTLB%d:\n", tlbn); - qemu_printf("Effective Physical Size TID TS SRWX" - " URWX WIMGE U0123\n"); + g_string_append_printf(buf, "\nTLB%d:\n", tlbn); + g_string_append_printf(buf, "Effective Physical " + "Size TID TS SRWX URWX WIMGE U0123\n"); =20 entry =3D &env->tlb.tlbm[offset]; for (i =3D 0; i < tlbsize; i++, entry++) { @@ -1004,37 +1006,38 @@ static void mmubooke206_dump_one_tlb(CPUPPCState *e= nv, int tlbn, int offset, ea =3D entry->mas2 & ~(size - 1); pa =3D entry->mas7_3 & ~(size - 1); =20 - qemu_printf("0x%016" PRIx64 " 0x%016" PRIx64 " %4s %-5u %1u S%c%c= %c" - "U%c%c%c %c%c%c%c%c U%c%c%c%c\n", - (uint64_t)ea, (uint64_t)pa, - book3e_tsize_to_str[tsize], - (entry->mas1 & MAS1_TID_MASK) >> MAS1_TID_SHIFT, - (entry->mas1 & MAS1_TS) >> MAS1_TS_SHIFT, - entry->mas7_3 & MAS3_SR ? 'R' : '-', - entry->mas7_3 & MAS3_SW ? 'W' : '-', - entry->mas7_3 & MAS3_SX ? 'X' : '-', - entry->mas7_3 & MAS3_UR ? 'R' : '-', - entry->mas7_3 & MAS3_UW ? 'W' : '-', - entry->mas7_3 & MAS3_UX ? 'X' : '-', - entry->mas2 & MAS2_W ? 'W' : '-', - entry->mas2 & MAS2_I ? 'I' : '-', - entry->mas2 & MAS2_M ? 'M' : '-', - entry->mas2 & MAS2_G ? 'G' : '-', - entry->mas2 & MAS2_E ? 'E' : '-', - entry->mas7_3 & MAS3_U0 ? '0' : '-', - entry->mas7_3 & MAS3_U1 ? '1' : '-', - entry->mas7_3 & MAS3_U2 ? '2' : '-', - entry->mas7_3 & MAS3_U3 ? '3' : '-'); + g_string_append_printf(buf, "0x%016" PRIx64 " 0x%016" PRIx64 + " %4s %-5u %1u S%c%c%c" + "U%c%c%c %c%c%c%c%c U%c%c%c%c\n", + (uint64_t)ea, (uint64_t)pa, + book3e_tsize_to_str[tsize], + (entry->mas1 & MAS1_TID_MASK) >> MAS1_TID_S= HIFT, + (entry->mas1 & MAS1_TS) >> MAS1_TS_SHIFT, + entry->mas7_3 & MAS3_SR ? 'R' : '-', + entry->mas7_3 & MAS3_SW ? 'W' : '-', + entry->mas7_3 & MAS3_SX ? 'X' : '-', + entry->mas7_3 & MAS3_UR ? 'R' : '-', + entry->mas7_3 & MAS3_UW ? 'W' : '-', + entry->mas7_3 & MAS3_UX ? 'X' : '-', + entry->mas2 & MAS2_W ? 'W' : '-', + entry->mas2 & MAS2_I ? 'I' : '-', + entry->mas2 & MAS2_M ? 'M' : '-', + entry->mas2 & MAS2_G ? 'G' : '-', + entry->mas2 & MAS2_E ? 'E' : '-', + entry->mas7_3 & MAS3_U0 ? '0' : '-', + entry->mas7_3 & MAS3_U1 ? '1' : '-', + entry->mas7_3 & MAS3_U2 ? '2' : '-', + entry->mas7_3 & MAS3_U3 ? '3' : '-'); } } =20 -static void mmubooke206_dump_mmu(CPUPPCState *env) +static void mmubooke206_dump_mmu(CPUPPCState *env, GString *buf) { int offset =3D 0; int i; =20 if (kvm_enabled() && !env->kvm_sw_tlb) { - qemu_printf("Cannot access KVM TLB\n"); + g_string_append_printf(buf, "Cannot access KVM TLB\n"); return; } =20 @@ -1045,12 +1048,12 @@ static void mmubooke206_dump_mmu(CPUPPCState *env) continue; } =20 - mmubooke206_dump_one_tlb(env, i, offset, size); + mmubooke206_dump_one_tlb(env, i, offset, size, buf); offset +=3D size; } } =20 -static void mmu6xx_dump_BATs(CPUPPCState *env, int type) +static void mmu6xx_dump_BATs(CPUPPCState *env, int type, GString *buf) { target_ulong *BATlt, *BATut, *BATu, *BATl; target_ulong BEPIl, BEPIu, bl; @@ -1073,51 +1076,59 @@ static void mmu6xx_dump_BATs(CPUPPCState *env, int = type) BEPIu =3D *BATu & 0xF0000000; BEPIl =3D *BATu & 0x0FFE0000; bl =3D (*BATu & 0x00001FFC) << 15; - qemu_printf("%s BAT%d BATu " TARGET_FMT_lx - " BATl " TARGET_FMT_lx "\n\t" TARGET_FMT_lx " " - TARGET_FMT_lx " " TARGET_FMT_lx "\n", - type =3D=3D ACCESS_CODE ? "code" : "data", i, - *BATu, *BATl, BEPIu, BEPIl, bl); + g_string_append_printf(buf, "%s BAT%d BATu " TARGET_FMT_lx + " BATl " TARGET_FMT_lx "\n\t" TARGET_FMT_lx= " " + TARGET_FMT_lx " " TARGET_FMT_lx "\n", + type =3D=3D ACCESS_CODE ? "code" : "data", = i, + *BATu, *BATl, BEPIu, BEPIl, bl); } } =20 -static void mmu6xx_dump_mmu(CPUPPCState *env) +static void mmu6xx_dump_mmu(CPUPPCState *env, GString *buf) { PowerPCCPU *cpu =3D env_archcpu(env); ppc6xx_tlb_t *tlb; target_ulong sr; int type, way, entry, i; =20 - qemu_printf("HTAB base =3D 0x%"HWADDR_PRIx"\n", ppc_hash32_hpt_base(cp= u)); - qemu_printf("HTAB mask =3D 0x%"HWADDR_PRIx"\n", ppc_hash32_hpt_mask(cp= u)); + g_string_append_printf(buf, "HTAB base =3D 0x%"HWADDR_PRIx"\n", + ppc_hash32_hpt_base(cpu)); + g_string_append_printf(buf, "HTAB mask =3D 0x%"HWADDR_PRIx"\n", + ppc_hash32_hpt_mask(cpu)); =20 - qemu_printf("\nSegment registers:\n"); + g_string_append_printf(buf, "\nSegment registers:\n"); for (i =3D 0; i < 32; i++) { sr =3D env->sr[i]; if (sr & 0x80000000) { - qemu_printf("%02d T=3D%d Ks=3D%d Kp=3D%d BUID=3D0x%03x " - "CNTLR_SPEC=3D0x%05x\n", i, - sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0, - sr & 0x20000000 ? 1 : 0, (uint32_t)((sr >> 20) & 0= x1FF), - (uint32_t)(sr & 0xFFFFF)); + g_string_append_printf(buf, "%02d T=3D%d Ks=3D%d Kp=3D%d BUID= =3D0x%03x " + "CNTLR_SPEC=3D0x%05x\n", i, + sr & 0x80000000 ? 1 : 0, + sr & 0x40000000 ? 1 : 0, + sr & 0x20000000 ? 1 : 0, + (uint32_t)((sr >> 20) & 0x1FF), + (uint32_t)(sr & 0xFFFFF)); } else { - qemu_printf("%02d T=3D%d Ks=3D%d Kp=3D%d N=3D%d VSID=3D0x%06x\= n", i, - sr & 0x80000000 ? 1 : 0, sr & 0x40000000 ? 1 : 0, - sr & 0x20000000 ? 1 : 0, sr & 0x10000000 ? 1 : 0, - (uint32_t)(sr & 0x00FFFFFF)); + g_string_append_printf(buf, "%02d T=3D%d Ks=3D%d Kp=3D%d N=3D%= d " + "VSID=3D0x%06x\n", i, + sr & 0x80000000 ? 1 : 0, + sr & 0x40000000 ? 1 : 0, + sr & 0x20000000 ? 1 : 0, + sr & 0x10000000 ? 1 : 0, + (uint32_t)(sr & 0x00FFFFFF)); } } =20 - qemu_printf("\nBATs:\n"); - mmu6xx_dump_BATs(env, ACCESS_INT); - mmu6xx_dump_BATs(env, ACCESS_CODE); + g_string_append_printf(buf, "\nBATs:\n"); + mmu6xx_dump_BATs(env, ACCESS_INT, buf); + mmu6xx_dump_BATs(env, ACCESS_CODE, buf); =20 if (env->id_tlbs !=3D 1) { - qemu_printf("ERROR: 6xx MMU should have separated TLB" - " for code and data\n"); + g_string_append_printf(buf, "ERROR: 6xx MMU should have separated = TLB" + " for code and data\n"); } =20 - qemu_printf("\nTLBs [EPN EPN + SIZE]\n"); + g_string_append_printf(buf, + "\nTLBs [EPN EPN + SIZ= E]\n"); =20 for (type =3D 0; type < 2; type++) { for (way =3D 0; way < env->nb_ways; way++) { @@ -1126,48 +1137,52 @@ static void mmu6xx_dump_mmu(CPUPPCState *env) entry++) { =20 tlb =3D &env->tlb.tlb6[entry]; - qemu_printf("%s TLB %02d/%02d way:%d %s [" - TARGET_FMT_lx " " TARGET_FMT_lx "]\n", - type ? "code" : "data", entry % env->nb_tlb, - env->nb_tlb, way, - pte_is_valid(tlb->pte0) ? "valid" : "inval", - tlb->EPN, tlb->EPN + TARGET_PAGE_SIZE); + g_string_append_printf(buf, "%s TLB %02d/%02d way:%d %s [" + TARGET_FMT_lx " " TARGET_FMT_lx "]\= n", + type ? "code" : "data", + entry % env->nb_tlb, + env->nb_tlb, way, + pte_is_valid(tlb->pte0) ? + "valid" : "inval", + tlb->EPN, tlb->EPN + TARGET_PAGE_SI= ZE); } } } } =20 -void dump_mmu(CPUPPCState *env) +void ppc_cpu_format_tlb(CPUState *cpu, GString *buf) { + CPUPPCState *env =3D cpu->env_ptr; + switch (env->mmu_model) { case POWERPC_MMU_BOOKE: - mmubooke_dump_mmu(env); + mmubooke_dump_mmu(env, buf); break; case POWERPC_MMU_BOOKE206: - mmubooke206_dump_mmu(env); + mmubooke206_dump_mmu(env, buf); break; case POWERPC_MMU_SOFT_6xx: case POWERPC_MMU_SOFT_74xx: - mmu6xx_dump_mmu(env); + mmu6xx_dump_mmu(env, buf); break; #if defined(TARGET_PPC64) case POWERPC_MMU_64B: case POWERPC_MMU_2_03: case POWERPC_MMU_2_06: case POWERPC_MMU_2_07: - dump_slb(env_archcpu(env)); + dump_slb(env_archcpu(env), buf); break; case POWERPC_MMU_3_00: if (ppc64_v3_radix(env_archcpu(env))) { - qemu_log_mask(LOG_UNIMP, "%s: the PPC64 MMU is unsupported\n", - __func__); + g_string_append_printf(buf, "PPC64 MMU not supported\n"); } else { - dump_slb(env_archcpu(env)); + dump_slb(env_archcpu(env), buf); } break; #endif default: - qemu_log_mask(LOG_UNIMP, "%s: unimplemented\n", __func__); + g_string_append_printf(buf, "MMU model %d not supported\n", + env->mmu_model); } } =20 diff --git a/target/ppc/monitor.c b/target/ppc/monitor.c index a475108b2d..401a36c2eb 100644 --- a/target/ppc/monitor.c +++ b/target/ppc/monitor.c @@ -67,13 +67,17 @@ static target_long monitor_get_tbl(Monitor *mon, const = struct MonitorDef *md, =20 void hmp_info_tlb(Monitor *mon, const QDict *qdict) { - CPUArchState *env1 =3D mon_get_cpu_env(mon); + g_autoptr(GString) buf =3D g_string_new(""); + CPUState *cpu =3D mon_get_cpu(mon); =20 - if (!env1) { + if (!cpu) { monitor_printf(mon, "No CPU available\n"); return; } - dump_mmu(env1); + + cpu_format_tlb(cpu, buf); + + monitor_printf(mon, "%s", buf->str); } =20 const MonitorDef monitor_defs[] =3D { --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631632603283856.3087576096682; Tue, 14 Sep 2021 08:16:43 -0700 (PDT) Received: from localhost ([::1]:45012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAAs-0001kX-00 for importer@patchew.org; Tue, 14 Sep 2021 11:16:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41968) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Wa-0004iW-0s for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:35:04 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59101) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9WX-0004X3-A2 for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:35:03 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-282-WrwCVSFUMpKehRjjLzk-bQ-1; Tue, 14 Sep 2021 10:34:57 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 862DE8145EF; Tue, 14 Sep 2021 14:34:53 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 327825D9CA; Tue, 14 Sep 2021 14:34:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631630100; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=eytxsOj3cJWedkTLYFQf30aw8CYCDUwdC6UE6kvmYNI=; b=ChSn5wP8HsD8H9gIqJ4vtLTyZoeKoDxbFrrDiRZo+1tmtihCdrnv9AMcQahkjiTa0eqXzG utMUeEEgj0D43l/BT9NHTc8vRLagPv18/Vl7gci77v2msZLeXuoRp6ky5eN7vMYjQA0rBF 1fRGnkF1GSugD0HbqTEr+h7QnPtSxCU= X-MC-Unique: WrwCVSFUMpKehRjjLzk-bQ-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 47/53] target/sh4: convert to use format_tlb callback Date: Tue, 14 Sep 2021 15:20:36 +0100 Message-Id: <20210914142042.1655100-48-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632603986100005 Change the "info tlb" implementation to use the format_tlb callback. Signed-off-by: Daniel P. Berrang=C3=A9 --- target/sh4/cpu.c | 3 +++ target/sh4/cpu.h | 1 + target/sh4/monitor.c | 48 +++++++++++++++++++++++++++----------------- 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/target/sh4/cpu.c b/target/sh4/cpu.c index 0ac881d6af..0e49755b2a 100644 --- a/target/sh4/cpu.c +++ b/target/sh4/cpu.c @@ -260,6 +260,9 @@ static void superh_cpu_class_init(ObjectClass *oc, void= *data) cc->class_by_name =3D superh_cpu_class_by_name; cc->has_work =3D superh_cpu_has_work; cc->format_state =3D superh_cpu_format_state; +#ifndef CONFIG_USER_ONLY + cc->format_tlb =3D superh_cpu_format_tlb; +#endif cc->set_pc =3D superh_cpu_set_pc; cc->gdb_read_register =3D superh_cpu_gdb_read_register; cc->gdb_write_register =3D superh_cpu_gdb_write_register; diff --git a/target/sh4/cpu.h b/target/sh4/cpu.h index 6940ca417a..7c139f561c 100644 --- a/target/sh4/cpu.h +++ b/target/sh4/cpu.h @@ -207,6 +207,7 @@ struct SuperHCPU { void superh_cpu_do_interrupt(CPUState *cpu); bool superh_cpu_exec_interrupt(CPUState *cpu, int int_req); void superh_cpu_format_state(CPUState *cpu, GString *buf, int flags); +void superh_cpu_format_tlb(CPUState *cpu, GString *buf); hwaddr superh_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int superh_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int superh_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/sh4/monitor.c b/target/sh4/monitor.c index 2da6a5426e..5ccb95af93 100644 --- a/target/sh4/monitor.c +++ b/target/sh4/monitor.c @@ -27,32 +27,44 @@ #include "monitor/hmp-target.h" #include "monitor/hmp.h" =20 -static void print_tlb(Monitor *mon, int idx, tlb_t *tlb) +static void print_tlb(GString *buf, int idx, tlb_t *tlb) { - monitor_printf(mon, " tlb%i:\t" - "asid=3D%hhu vpn=3D%x\tppn=3D%x\tsz=3D%hhu size=3D%u\t" - "v=3D%hhu shared=3D%hhu cached=3D%hhu prot=3D%hhu " - "dirty=3D%hhu writethrough=3D%hhu\n", - idx, - tlb->asid, tlb->vpn, tlb->ppn, tlb->sz, tlb->size, - tlb->v, tlb->sh, tlb->c, tlb->pr, - tlb->d, tlb->wt); + g_string_append_printf(buf, " tlb%i:\t" + "asid=3D%hhu vpn=3D%x\tppn=3D%x\tsz=3D%hhu size= =3D%u\t" + "v=3D%hhu shared=3D%hhu cached=3D%hhu prot=3D%h= hu " + "dirty=3D%hhu writethrough=3D%hhu\n", + idx, + tlb->asid, tlb->vpn, tlb->ppn, tlb->sz, tlb->si= ze, + tlb->v, tlb->sh, tlb->c, tlb->pr, + tlb->d, tlb->wt); +} + +void superh_cpu_format_tlb(CPUState *cpu, GString *buf) +{ + CPUArchState *env =3D cpu->env_ptr; + size_t i; + + g_string_append_printf(buf, "ITLB:\n"); + for (i =3D 0 ; i < ITLB_SIZE ; i++) { + print_tlb(buf, i, &env->itlb[i]); + } + g_string_append_printf(buf, "UTLB:\n"); + for (i =3D 0 ; i < UTLB_SIZE ; i++) { + print_tlb(buf, i, &env->utlb[i]); + } } =20 void hmp_info_tlb(Monitor *mon, const QDict *qdict) { - CPUArchState *env =3D mon_get_cpu_env(mon); - int i; + g_autoptr(GString) buf =3D g_string_new(""); + CPUState *cpu =3D mon_get_cpu(mon); =20 - if (!env) { + if (!cpu) { monitor_printf(mon, "No CPU available\n"); return; } =20 - monitor_printf (mon, "ITLB:\n"); - for (i =3D 0 ; i < ITLB_SIZE ; i++) - print_tlb (mon, i, &env->itlb[i]); - monitor_printf (mon, "UTLB:\n"); - for (i =3D 0 ; i < UTLB_SIZE ; i++) - print_tlb (mon, i, &env->utlb[i]); + cpu_format_tlb(cpu, buf); + + monitor_printf(mon, "%s", buf->str); } --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163163384338989.1583990681263; Tue, 14 Sep 2021 08:37:23 -0700 (PDT) Received: from localhost ([::1]:44376 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAUs-0006J8-5l for importer@patchew.org; Tue, 14 Sep 2021 11:37:22 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42248) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Wt-0005g4-Hf for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:35:23 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:55961) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Wq-0004iu-1a for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:35:23 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-113-g2SglZttN3mZfmf5T0k0wg-1; Tue, 14 Sep 2021 10:35:18 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 695FA824FA7; Tue, 14 Sep 2021 14:35:14 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id CB3CA5D9CA; Tue, 14 Sep 2021 14:34:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631630119; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rB6piZ9LgrjrkZJSg8goTT4uIcuL7G9qxeyUG5U6r7c=; b=P0/FXrdWBtzqDfPF9mwULR+oeEbtcv8caATnFzPYzQ1xs8uQM3A1AWvT4sjuxdDguAddHk spYY2vR3tWOqS8mkKkqLqf6dXZIT1zNnuQA0esC602/7OdQ1rZ4oLgB0jfEs0TF901hB/H oGowWx77UsEJEwb4y2JqmGHCBv+O3z4= X-MC-Unique: g2SglZttN3mZfmf5T0k0wg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 48/53] target/sparc: convert to use format_tlb callback Date: Tue, 14 Sep 2021 15:20:37 +0100 Message-Id: <20210914142042.1655100-49-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631633845500100001 Change the "info tlb" implementation to use the format_tlb callback. Signed-off-by: Daniel P. Berrang=C3=A9 Acked-by: Mark Cave-Ayland --- target/sparc/cpu.c | 1 + target/sparc/cpu.h | 1 + target/sparc/mmu_helper.c | 43 ++++++++++++++++++++++++--------------- target/sparc/monitor.c | 10 ++++++--- 4 files changed, 36 insertions(+), 19 deletions(-) diff --git a/target/sparc/cpu.c b/target/sparc/cpu.c index 9346a79239..f78ddc72b5 100644 --- a/target/sparc/cpu.c +++ b/target/sparc/cpu.c @@ -898,6 +898,7 @@ static void sparc_cpu_class_init(ObjectClass *oc, void = *data) cc->has_work =3D sparc_cpu_has_work; cc->format_state =3D sparc_cpu_format_state; #if !defined(TARGET_SPARC64) && !defined(CONFIG_USER_ONLY) + cc->format_tlb =3D sparc_cpu_format_tlb; cc->memory_rw_debug =3D sparc_cpu_memory_rw_debug; #endif cc->set_pc =3D sparc_cpu_set_pc; diff --git a/target/sparc/cpu.h b/target/sparc/cpu.h index 65a01a7884..233f0b3eb7 100644 --- a/target/sparc/cpu.h +++ b/target/sparc/cpu.h @@ -572,6 +572,7 @@ extern const VMStateDescription vmstate_sparc_cpu; =20 void sparc_cpu_do_interrupt(CPUState *cpu); void sparc_cpu_format_state(CPUState *cpu, GString *buf, int flags); +void sparc_cpu_format_tlb(CPUState *cpu, GString *buf); hwaddr sparc_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); int sparc_cpu_gdb_read_register(CPUState *cpu, GByteArray *buf, int reg); int sparc_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg); diff --git a/target/sparc/mmu_helper.c b/target/sparc/mmu_helper.c index a44473a1c7..06b16aca6a 100644 --- a/target/sparc/mmu_helper.c +++ b/target/sparc/mmu_helper.c @@ -371,37 +371,39 @@ target_ulong mmu_probe(CPUSPARCState *env, target_ulo= ng address, int mmulev) return 0; } =20 -void dump_mmu(CPUSPARCState *env) +void sparc_cpu_format_tlb(CPUState *cpu, GString *buf) { - CPUState *cs =3D env_cpu(env); + CPUSPARCState *env =3D cpu->env_ptr; target_ulong va, va1, va2; unsigned int n, m, o; hwaddr pa; uint32_t pde; =20 - qemu_printf("Root ptr: " TARGET_FMT_plx ", ctx: %d\n", - (hwaddr)env->mmuregs[1] << 4, env->mmuregs[2]); + g_string_append_printf(buf, "Root ptr: " TARGET_FMT_plx ", ctx: %d\n", + (hwaddr)env->mmuregs[1] << 4, env->mmuregs[2]); for (n =3D 0, va =3D 0; n < 256; n++, va +=3D 16 * 1024 * 1024) { pde =3D mmu_probe(env, va, 2); if (pde) { - pa =3D cpu_get_phys_page_debug(cs, va); - qemu_printf("VA: " TARGET_FMT_lx ", PA: " TARGET_FMT_plx - " PDE: " TARGET_FMT_lx "\n", va, pa, pde); + pa =3D cpu_get_phys_page_debug(cpu, va); + g_string_append_printf(buf, "VA: " TARGET_FMT_lx + ", PA: " TARGET_FMT_plx + " PDE: " TARGET_FMT_lx "\n", va, pa, pd= e); for (m =3D 0, va1 =3D va; m < 64; m++, va1 +=3D 256 * 1024) { pde =3D mmu_probe(env, va1, 1); if (pde) { - pa =3D cpu_get_phys_page_debug(cs, va1); - qemu_printf(" VA: " TARGET_FMT_lx ", PA: " - TARGET_FMT_plx " PDE: " TARGET_FMT_lx "\n", - va1, pa, pde); + pa =3D cpu_get_phys_page_debug(cpu, va1); + g_string_append_printf(buf, " VA: " TARGET_FMT_lx + ", PA: " TARGET_FMT_plx + " PDE: " TARGET_FMT_lx "\n", + va1, pa, pde); for (o =3D 0, va2 =3D va1; o < 64; o++, va2 +=3D 4 * 1= 024) { pde =3D mmu_probe(env, va2, 0); if (pde) { - pa =3D cpu_get_phys_page_debug(cs, va2); - qemu_printf(" VA: " TARGET_FMT_lx ", PA: " - TARGET_FMT_plx " PTE: " - TARGET_FMT_lx "\n", - va2, pa, pde); + pa =3D cpu_get_phys_page_debug(cpu, va2); + g_string_append_printf(buf, " VA: " TARGET_FM= T_lx + ", PA: " TARGET_FMT_plx + " PTE: " TARGET_FMT_lx = "\n", + va2, pa, pde); } } } @@ -410,6 +412,15 @@ void dump_mmu(CPUSPARCState *env) } } =20 +void dump_mmu(CPUSPARCState *env) +{ + CPUState *cs =3D env_cpu(env); + g_autoptr(GString) buf =3D g_string_new(""); + + sparc_cpu_format_tlb(cs, buf); + qemu_printf("%s", buf->str); +} + /* Gdb expects all registers windows to be flushed in ram. This function h= andles * reads (and only reads) in stack frames as if windows were flushed. We a= ssume * that the sparc ABI is followed. diff --git a/target/sparc/monitor.c b/target/sparc/monitor.c index 318413686a..cc7fe74e3e 100644 --- a/target/sparc/monitor.c +++ b/target/sparc/monitor.c @@ -30,13 +30,17 @@ =20 void hmp_info_tlb(Monitor *mon, const QDict *qdict) { - CPUArchState *env1 =3D mon_get_cpu_env(mon); + g_autoptr(GString) buf =3D g_string_new(""); + CPUState *cpu =3D mon_get_cpu(mon); =20 - if (!env1) { + if (!cpu) { monitor_printf(mon, "No CPU available\n"); return; } - dump_mmu(env1); + + cpu_format_tlb(cpu, buf); + + monitor_printf(mon, "%s", buf->str); } =20 #ifndef TARGET_SPARC64 --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631633963263729.0953709030969; Tue, 14 Sep 2021 08:39:23 -0700 (PDT) Received: from localhost ([::1]:49568 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAWn-0001d7-TB for importer@patchew.org; Tue, 14 Sep 2021 11:39:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42572) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9XH-0006Mg-6T for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:35:48 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:25642) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9XC-0004zF-JX for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:35:45 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-177-fIpnYYj7NZ-ipA9555vE7g-1; Tue, 14 Sep 2021 10:35:40 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0EC2B800FF4; Tue, 14 Sep 2021 14:35:36 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id B6E105D9CA; Tue, 14 Sep 2021 14:35:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631630141; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=iNQqtlu9cXciZ4eC5qFV8TN1URWtj6rpxIYVyS3g23o=; b=TqOqhtfbbcPYGDHo8IcAohf+ca1nxFsetxIGIKVK2tDos/CGSALwBCRR3+fjbQBQJFC8vm Pgqk/udsGC26bcl2VQW4dQK3u5MhKWah3TE1liKS7qmWaAKxOdlVEZ05wGqlhTTboGarZZ 8JEck+9PeSuelZQhgQoTX9CtHsDe/y4= X-MC-Unique: fIpnYYj7NZ-ipA9555vE7g-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 49/53] target/xtensa: convert to use format_tlb callback Date: Tue, 14 Sep 2021 15:20:38 +0100 Message-Id: <20210914142042.1655100-50-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631633965082100001 Change the "info tlb" implementation to use the format_tlb callback. Signed-off-by: Daniel P. Berrang=C3=A9 --- target/xtensa/cpu.h | 2 +- target/xtensa/mmu_helper.c | 126 +++++++++++++++++++++---------------- target/xtensa/monitor.c | 10 ++- 3 files changed, 79 insertions(+), 59 deletions(-) diff --git a/target/xtensa/cpu.h b/target/xtensa/cpu.h index 97cd6892df..8c82994826 100644 --- a/target/xtensa/cpu.h +++ b/target/xtensa/cpu.h @@ -573,6 +573,7 @@ void xtensa_cpu_do_transaction_failed(CPUState *cs, hwa= ddr physaddr, vaddr addr, int mmu_idx, MemTxAttrs attrs, MemTxResult response, uintptr_t reta= ddr); void xtensa_cpu_format_state(CPUState *cpu, GString *buf, int flags); +void xtensa_cpu_format_tlb(CPUState *cpu, GString *buf); hwaddr xtensa_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void xtensa_count_regs(const XtensaConfig *config, unsigned *n_regs, unsigned *n_core_regs); @@ -678,7 +679,6 @@ int xtensa_get_physical_addr(CPUXtensaState *env, bool = update_tlb, uint32_t vaddr, int is_write, int mmu_idx, uint32_t *paddr, uint32_t *page_size, unsigned *access); void reset_mmu(CPUXtensaState *env); -void dump_mmu(CPUXtensaState *env); =20 static inline MemoryRegion *xtensa_get_er_region(CPUXtensaState *env) { diff --git a/target/xtensa/mmu_helper.c b/target/xtensa/mmu_helper.c index b01ff9399a..d499255984 100644 --- a/target/xtensa/mmu_helper.c +++ b/target/xtensa/mmu_helper.c @@ -1055,7 +1055,7 @@ int xtensa_get_physical_addr(CPUXtensaState *env, boo= l update_tlb, } } =20 -static void dump_tlb(CPUXtensaState *env, bool dtlb) +static void dump_tlb(CPUXtensaState *env, bool dtlb, GString *buf) { unsigned wi, ei; const xtensa_tlb *conf =3D @@ -1094,34 +1094,40 @@ static void dump_tlb(CPUXtensaState *env, bool dtlb) =20 if (print_header) { print_header =3D false; - qemu_printf("Way %u (%d %s)\n", wi, sz, sz_text); - qemu_printf("\tVaddr Paddr ASID Attr RWX = Cache\n" - "\t---------- ---------- ---- ---- --- = -------\n"); + g_string_append_printf(buf, "Way %u (%d %s)\n", + wi, sz, sz_text); + g_string_append_printf(buf, "\tVaddr Paddr = " + "ASID Attr RWX Cache\n" + "\t---------- ---------- ----= " + "---- --- -------\n"); } - qemu_printf("\t0x%08x 0x%08x 0x%02x 0x%02x %c%c%c %-7s\= n", - entry->vaddr, - entry->paddr, - entry->asid, - entry->attr, - (access & PAGE_READ) ? 'R' : '-', - (access & PAGE_WRITE) ? 'W' : '-', - (access & PAGE_EXEC) ? 'X' : '-', - cache_text[cache_idx] ? - cache_text[cache_idx] : "Invalid"); + g_string_append_printf(buf, "\t0x%08x 0x%08x 0x%02x " + "0x%02x %c%c%c %-7s\n", + entry->vaddr, + entry->paddr, + entry->asid, + entry->attr, + (access & PAGE_READ) ? 'R' : '-', + (access & PAGE_WRITE) ? 'W' : '-', + (access & PAGE_EXEC) ? 'X' : '-', + cache_text[cache_idx] ? + cache_text[cache_idx] : "Invalid"); } } } } =20 static void dump_mpu(CPUXtensaState *env, - const xtensa_mpu_entry *entry, unsigned n) + const xtensa_mpu_entry *entry, unsigned n, GString *b= uf) { unsigned i; =20 - qemu_printf("\t%s Vaddr Attr Ring0 Ring1 System Type = CPU cache\n" - "\t%s ---------- ---------- ----- ----- -------------= ---------\n", - env ? "En" : " ", - env ? "--" : " "); + g_string_append_printf(buf, "\t%s Vaddr Attr " + "Ring0 Ring1 System Type CPU cache\n" + "\t%s ---------- ---------- ----- ----- " + "------------- ---------\n", + env ? "En" : " ", + env ? "--" : " "); =20 for (i =3D 0; i < n; ++i) { uint32_t attr =3D entry[i].attr; @@ -1130,63 +1136,73 @@ static void dump_mpu(CPUXtensaState *env, unsigned type =3D mpu_attr_to_type(attr); char cpu_cache =3D (type & XTENSA_MPU_TYPE_CPU_CACHE) ? '-' : ' '; =20 - qemu_printf("\t %c 0x%08x 0x%08x %c%c%c %c%c%c ", - env ? - ((env->sregs[MPUENB] & (1u << i)) ? '+' : '-') : ' ', - entry[i].vaddr, attr, - (access0 & PAGE_READ) ? 'R' : '-', - (access0 & PAGE_WRITE) ? 'W' : '-', - (access0 & PAGE_EXEC) ? 'X' : '-', - (access1 & PAGE_READ) ? 'R' : '-', - (access1 & PAGE_WRITE) ? 'W' : '-', - (access1 & PAGE_EXEC) ? 'X' : '-'); + g_string_append_printf(buf, "\t %c 0x%08x 0x%08x " + "%c%c%c %c%c%c ", + env ? ((env->sregs[MPUENB] & (1u << i)) ? + '+' : '-') : ' ', + entry[i].vaddr, attr, + (access0 & PAGE_READ) ? 'R' : '-', + (access0 & PAGE_WRITE) ? 'W' : '-', + (access0 & PAGE_EXEC) ? 'X' : '-', + (access1 & PAGE_READ) ? 'R' : '-', + (access1 & PAGE_WRITE) ? 'W' : '-', + (access1 & PAGE_EXEC) ? 'X' : '-'); =20 switch (type & XTENSA_MPU_SYSTEM_TYPE_MASK) { case XTENSA_MPU_SYSTEM_TYPE_DEVICE: - qemu_printf("Device %cB %3s\n", - (type & XTENSA_MPU_TYPE_B) ? ' ' : 'n', - (type & XTENSA_MPU_TYPE_INT) ? "int" : ""); + g_string_append_printf(buf, "Device %cB %3s\n", + (type & XTENSA_MPU_TYPE_B) ? ' ' : 'n', + (type & XTENSA_MPU_TYPE_INT) ? "int" : = ""); break; case XTENSA_MPU_SYSTEM_TYPE_NC: - qemu_printf("Sys NC %cB %c%c%c\n", - (type & XTENSA_MPU_TYPE_B) ? ' ' : 'n', - (type & XTENSA_MPU_TYPE_CPU_R) ? 'r' : cpu_cache, - (type & XTENSA_MPU_TYPE_CPU_W) ? 'w' : cpu_cache, - (type & XTENSA_MPU_TYPE_CPU_C) ? 'c' : cpu_cache); + g_string_append_printf(buf, "Sys NC %cB %c%c%c\n", + (type & XTENSA_MPU_TYPE_B) ? ' ' : 'n', + (type & XTENSA_MPU_TYPE_CPU_R) ? + 'r' : cpu_cache, + (type & XTENSA_MPU_TYPE_CPU_W) ? + 'w' : cpu_cache, + (type & XTENSA_MPU_TYPE_CPU_C) ? + 'c' : cpu_cache); break; case XTENSA_MPU_SYSTEM_TYPE_C: - qemu_printf("Sys C %c%c%c %c%c%c\n", - (type & XTENSA_MPU_TYPE_SYS_R) ? 'R' : '-', - (type & XTENSA_MPU_TYPE_SYS_W) ? 'W' : '-', - (type & XTENSA_MPU_TYPE_SYS_C) ? 'C' : '-', - (type & XTENSA_MPU_TYPE_CPU_R) ? 'r' : cpu_cache, - (type & XTENSA_MPU_TYPE_CPU_W) ? 'w' : cpu_cache, - (type & XTENSA_MPU_TYPE_CPU_C) ? 'c' : cpu_cache); + g_string_append_printf(buf, "Sys C %c%c%c %c%c%c\n", + (type & XTENSA_MPU_TYPE_SYS_R) ? 'R' : = '-', + (type & XTENSA_MPU_TYPE_SYS_W) ? 'W' : = '-', + (type & XTENSA_MPU_TYPE_SYS_C) ? 'C' : = '-', + (type & XTENSA_MPU_TYPE_CPU_R) ? + 'r' : cpu_cache, + (type & XTENSA_MPU_TYPE_CPU_W) ? + 'w' : cpu_cache, + (type & XTENSA_MPU_TYPE_CPU_C) ? + 'c' : cpu_cache); break; default: - qemu_printf("Unknown\n"); + g_string_append_printf(buf, "Unknown\n"); break; } } } =20 -void dump_mmu(CPUXtensaState *env) +void xtensa_cpu_format_tlb(CPUState *cpu, GString *buf) { + CPUXtensaState *env =3D cpu->env_ptr; + if (xtensa_option_bits_enabled(env->config, XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_PROTECTION) | XTENSA_OPTION_BIT(XTENSA_OPTION_REGION_TRANSLATION) | XTENSA_OPTION_BIT(XTENSA_OPTION_MMU))) { =20 - qemu_printf("ITLB:\n"); - dump_tlb(env, false); - qemu_printf("\nDTLB:\n"); - dump_tlb(env, true); + g_string_append_printf(buf, "ITLB:\n"); + dump_tlb(env, false, buf); + g_string_append_printf(buf, "\nDTLB:\n"); + dump_tlb(env, true, buf); } else if (xtensa_option_enabled(env->config, XTENSA_OPTION_MPU)) { - qemu_printf("Foreground map:\n"); - dump_mpu(env, env->mpu_fg, env->config->n_mpu_fg_segments); - qemu_printf("\nBackground map:\n"); - dump_mpu(NULL, env->config->mpu_bg, env->config->n_mpu_bg_segments= ); + g_string_append_printf(buf, "Foreground map:\n"); + dump_mpu(env, env->mpu_fg, env->config->n_mpu_fg_segments, buf); + g_string_append_printf(buf, "\nBackground map:\n"); + dump_mpu(NULL, env->config->mpu_bg, + env->config->n_mpu_bg_segments, buf); } else { - qemu_printf("No TLB for this CPU core\n"); + g_string_append_printf(buf, "No TLB for this CPU core\n"); } } diff --git a/target/xtensa/monitor.c b/target/xtensa/monitor.c index fbf60d5553..99d35e8ef1 100644 --- a/target/xtensa/monitor.c +++ b/target/xtensa/monitor.c @@ -29,11 +29,15 @@ =20 void hmp_info_tlb(Monitor *mon, const QDict *qdict) { - CPUArchState *env1 =3D mon_get_cpu_env(mon); + g_autoptr(GString) buf =3D g_string_new(""); + CPUState *cpu =3D mon_get_cpu(mon); =20 - if (!env1) { + if (!cpu) { monitor_printf(mon, "No CPU available\n"); return; } - dump_mmu(env1); + + cpu_format_tlb(cpu, buf); + + monitor_printf(mon, "%s", buf->str); } --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 163163413168058.73095232358355; Tue, 14 Sep 2021 08:42:11 -0700 (PDT) Received: from localhost ([::1]:56318 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAZW-0006MY-1q for importer@patchew.org; Tue, 14 Sep 2021 11:42:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42882) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Xb-0006X7-Gp for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:36:07 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:49756) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9XX-0005IQ-Jk for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:36:07 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-573-0IulxTMMNcWSB60ECpszPA-1; Tue, 14 Sep 2021 10:36:01 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1F3D1180830C; Tue, 14 Sep 2021 14:35:57 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5970C5D9CA; Tue, 14 Sep 2021 14:35:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631630162; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=N1wcruW+g3FbhxuBTmshlgas1GP2gbIYSddshDcwvVw=; b=exv4JG3huLeEF/ZNBsJQ//WTnAYxMX/kuh3tBe/sfWoNvD+7Ww87VSMJJtkoi53/o+99u5 2bab/P8DsFWYXloDmkZn0Oz+UMuACJqW2UhFAs/rakomTPU1txQJeYsH4DpyRZF43GA92s HCojHd1IT+YGdiNie/Ci5UDmPrMm6BU= X-MC-Unique: 0IulxTMMNcWSB60ECpszPA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 50/53] monitor: merge duplicate "info tlb" handlers Date: Tue, 14 Sep 2021 15:20:39 +0100 Message-Id: <20210914142042.1655100-51-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631634133404100001 Now that all target architectures are converted to use the "format_tlb" callback, we can merge all the duplicate "info tlb" handlers into one and remove the architecture condition on the command. Signed-off-by: Daniel P. Berrang=C3=A9 Acked-by: David Gibson --- hmp-commands-info.hx | 3 --- include/monitor/hmp-target.h | 1 - monitor/misc.c | 15 +++++++++++++++ target/i386/monitor.c | 15 --------------- target/m68k/monitor.c | 15 --------------- target/nios2/monitor.c | 15 --------------- target/ppc/monitor.c | 15 --------------- target/sh4/monitor.c | 15 --------------- target/sparc/monitor.c | 16 ---------------- target/xtensa/monitor.c | 15 --------------- 10 files changed, 15 insertions(+), 110 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index f8312342cd..7bd1e04d46 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -206,8 +206,6 @@ SRST Show PCI information. ERST =20 -#if defined(TARGET_I386) || defined(TARGET_SH4) || defined(TARGET_SPARC) |= | \ - defined(TARGET_PPC) || defined(TARGET_XTENSA) || defined(TARGET_M68K) { .name =3D "tlb", .args_type =3D "", @@ -215,7 +213,6 @@ ERST .help =3D "show virtual to physical memory mappings", .cmd =3D hmp_info_tlb, }, -#endif =20 SRST ``info tlb`` diff --git a/include/monitor/hmp-target.h b/include/monitor/hmp-target.h index df79ad3355..04e02e8895 100644 --- a/include/monitor/hmp-target.h +++ b/include/monitor/hmp-target.h @@ -45,7 +45,6 @@ CPUArchState *mon_get_cpu_env(Monitor *mon); CPUState *mon_get_cpu(Monitor *mon); =20 void hmp_info_mem(Monitor *mon, const QDict *qdict); -void hmp_info_tlb(Monitor *mon, const QDict *qdict); void hmp_mce(Monitor *mon, const QDict *qdict); void hmp_info_local_apic(Monitor *mon, const QDict *qdict); =20 diff --git a/monitor/misc.c b/monitor/misc.c index 6b07efdddd..c7d138914d 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -936,6 +936,21 @@ static void hmp_info_mtree(Monitor *mon, const QDict *= qdict) mtree_info(flatview, dispatch_tree, owner, disabled); } =20 +static void hmp_info_tlb(Monitor *mon, const QDict *qdict) +{ + g_autoptr(GString) buf =3D g_string_new(""); + CPUState *cpu =3D mon_get_cpu(mon); + + if (!cpu) { + monitor_printf(mon, "No CPU available\n"); + return; + } + + cpu_format_tlb(cpu, buf); + + monitor_printf(mon, "%s", buf->str); +} + static void hmp_info_profile(Monitor *mon, const QDict *qdict) { Error *err =3D NULL; diff --git a/target/i386/monitor.c b/target/i386/monitor.c index 698fbbc80b..a7eb4205c7 100644 --- a/target/i386/monitor.c +++ b/target/i386/monitor.c @@ -248,21 +248,6 @@ void x86_cpu_format_tlb(CPUState *cpu, GString *buf) } } =20 -void hmp_info_tlb(Monitor *mon, const QDict *qdict) -{ - g_autoptr(GString) buf =3D g_string_new(""); - CPUState *cpu =3D mon_get_cpu(mon); - - if (!cpu) { - monitor_printf(mon, "No CPU available\n"); - return; - } - - cpu_format_tlb(cpu, buf); - - monitor_printf(mon, "%s", buf->str); -} - static void mem_print(Monitor *mon, CPUArchState *env, hwaddr *pstart, int *plast_prot, hwaddr end, int prot) diff --git a/target/m68k/monitor.c b/target/m68k/monitor.c index 003a665246..0dc729692b 100644 --- a/target/m68k/monitor.c +++ b/target/m68k/monitor.c @@ -12,21 +12,6 @@ #include "qapi/error.h" #include "qapi/qapi-commands-machine-target.h" =20 -void hmp_info_tlb(Monitor *mon, const QDict *qdict) -{ - g_autoptr(GString) buf =3D g_string_new(""); - CPUState *cpu =3D mon_get_cpu(mon); - - if (!cpu) { - monitor_printf(mon, "No CPU available\n"); - return; - } - - cpu_format_tlb(cpu, buf); - - monitor_printf(mon, "%s", buf->str); -} - static const MonitorDef monitor_defs[] =3D { { "d0", offsetof(CPUM68KState, dregs[0]) }, { "d1", offsetof(CPUM68KState, dregs[1]) }, diff --git a/target/nios2/monitor.c b/target/nios2/monitor.c index 99d35e8ef1..1180a32f80 100644 --- a/target/nios2/monitor.c +++ b/target/nios2/monitor.c @@ -26,18 +26,3 @@ #include "monitor/monitor.h" #include "monitor/hmp-target.h" #include "monitor/hmp.h" - -void hmp_info_tlb(Monitor *mon, const QDict *qdict) -{ - g_autoptr(GString) buf =3D g_string_new(""); - CPUState *cpu =3D mon_get_cpu(mon); - - if (!cpu) { - monitor_printf(mon, "No CPU available\n"); - return; - } - - cpu_format_tlb(cpu, buf); - - monitor_printf(mon, "%s", buf->str); -} diff --git a/target/ppc/monitor.c b/target/ppc/monitor.c index 401a36c2eb..3564fd5f45 100644 --- a/target/ppc/monitor.c +++ b/target/ppc/monitor.c @@ -65,21 +65,6 @@ static target_long monitor_get_tbl(Monitor *mon, const s= truct MonitorDef *md, return cpu_ppc_load_tbl(env); } =20 -void hmp_info_tlb(Monitor *mon, const QDict *qdict) -{ - g_autoptr(GString) buf =3D g_string_new(""); - CPUState *cpu =3D mon_get_cpu(mon); - - if (!cpu) { - monitor_printf(mon, "No CPU available\n"); - return; - } - - cpu_format_tlb(cpu, buf); - - monitor_printf(mon, "%s", buf->str); -} - const MonitorDef monitor_defs[] =3D { { "fpscr", offsetof(CPUPPCState, fpscr) }, /* Next instruction pointer */ diff --git a/target/sh4/monitor.c b/target/sh4/monitor.c index 5ccb95af93..d641d95316 100644 --- a/target/sh4/monitor.c +++ b/target/sh4/monitor.c @@ -53,18 +53,3 @@ void superh_cpu_format_tlb(CPUState *cpu, GString *buf) print_tlb(buf, i, &env->utlb[i]); } } - -void hmp_info_tlb(Monitor *mon, const QDict *qdict) -{ - g_autoptr(GString) buf =3D g_string_new(""); - CPUState *cpu =3D mon_get_cpu(mon); - - if (!cpu) { - monitor_printf(mon, "No CPU available\n"); - return; - } - - cpu_format_tlb(cpu, buf); - - monitor_printf(mon, "%s", buf->str); -} diff --git a/target/sparc/monitor.c b/target/sparc/monitor.c index cc7fe74e3e..0c51669c08 100644 --- a/target/sparc/monitor.c +++ b/target/sparc/monitor.c @@ -27,22 +27,6 @@ #include "monitor/hmp-target.h" #include "monitor/hmp.h" =20 - -void hmp_info_tlb(Monitor *mon, const QDict *qdict) -{ - g_autoptr(GString) buf =3D g_string_new(""); - CPUState *cpu =3D mon_get_cpu(mon); - - if (!cpu) { - monitor_printf(mon, "No CPU available\n"); - return; - } - - cpu_format_tlb(cpu, buf); - - monitor_printf(mon, "%s", buf->str); -} - #ifndef TARGET_SPARC64 static target_long monitor_get_psr(Monitor *mon, const struct MonitorDef *= md, int val) diff --git a/target/xtensa/monitor.c b/target/xtensa/monitor.c index 99d35e8ef1..1180a32f80 100644 --- a/target/xtensa/monitor.c +++ b/target/xtensa/monitor.c @@ -26,18 +26,3 @@ #include "monitor/monitor.h" #include "monitor/hmp-target.h" #include "monitor/hmp.h" - -void hmp_info_tlb(Monitor *mon, const QDict *qdict) -{ - g_autoptr(GString) buf =3D g_string_new(""); - CPUState *cpu =3D mon_get_cpu(mon); - - if (!cpu) { - monitor_printf(mon, "No CPU available\n"); - return; - } - - cpu_format_tlb(cpu, buf); - - monitor_printf(mon, "%s", buf->str); -} --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16316328935971011.0520419416765; Tue, 14 Sep 2021 08:21:33 -0700 (PDT) Received: from localhost ([::1]:57400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAFY-0001qk-I3 for importer@patchew.org; Tue, 14 Sep 2021 11:21:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43204) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Xv-0007cV-Na for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:36:27 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:31264) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Xs-0005Xb-9V for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:36:27 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-239-VHsRiiH_O1K_BujAIMDWSA-1; Tue, 14 Sep 2021 10:36:22 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E17C51808304; Tue, 14 Sep 2021 14:36:17 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 680F15D9CA; Tue, 14 Sep 2021 14:35:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631630183; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qjXz354OerT/IdyTAoj8iLAD8TsJq7H30dJHW+kTcBo=; b=erE1Wwjl1hup4T/3lNXtnI2aXq5KnSVk8u/bHN28YuCIhFPgzuyUMxcPQXfSY4TPgUiCdu c+nbXgQwMED3m/tbC7EDaEqe2Gqlp2OEf0ueeOoPpuh77y2+iYVhY2AIKOdCtJIC70mn0+ nrmX0iEr6gjrf3UwA7x/L7YDark3iS0= X-MC-Unique: VHsRiiH_O1K_BujAIMDWSA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 51/53] qapi: introduce x-query-tlb QMP command Date: Tue, 14 Sep 2021 15:20:40 +0100 Message-Id: <20210914142042.1655100-52-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631632894361100003 This is a counterpart to the HMP "info tlb" command. It is being added with an "x-" prefix because this QMP command is intended as an ad hoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. Signed-off-by: Daniel P. Berrang=C3=A9 --- hw/core/machine-qmp-cmds.c | 22 ++++++++++++++++++++++ monitor/misc.c | 15 ++++++++++----- qapi/machine.json | 15 +++++++++++++++ 3 files changed, 47 insertions(+), 5 deletions(-) diff --git a/hw/core/machine-qmp-cmds.c b/hw/core/machine-qmp-cmds.c index 4407e967da..c84cef8667 100644 --- a/hw/core/machine-qmp-cmds.c +++ b/hw/core/machine-qmp-cmds.c @@ -235,6 +235,28 @@ HumanReadableText *qmp_x_query_registers(bool has_cpu,= int64_t cpu, return ret; } =20 +HumanReadableText *qmp_x_query_tlb(int64_t cpu, Error **errp) +{ + HumanReadableText *ret; + g_autoptr(GString) buf =3D g_string_new(""); + CPUState *cs =3D NULL, *tmp; + + CPU_FOREACH(tmp) { + if (cpu =3D=3D tmp->cpu_index) { + cs =3D tmp; + } + } + if (!cs) { + error_setg(errp, "CPU %"PRId64" not available", cpu); + return NULL; + } + cpu_format_tlb(cs, buf); + + ret =3D g_new0(HumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} + HumanReadableText *qmp_x_query_numa(Error **errp) { HumanReadableText *ret; diff --git a/monitor/misc.c b/monitor/misc.c index c7d138914d..7ca529002d 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -938,17 +938,22 @@ static void hmp_info_mtree(Monitor *mon, const QDict = *qdict) =20 static void hmp_info_tlb(Monitor *mon, const QDict *qdict) { - g_autoptr(GString) buf =3D g_string_new(""); - CPUState *cpu =3D mon_get_cpu(mon); + CPUState *cs =3D mon_get_cpu(mon); + Error *err =3D NULL; + g_autoptr(HumanReadableText) info =3D NULL; =20 - if (!cpu) { + if (!cs) { monitor_printf(mon, "No CPU available\n"); return; } =20 - cpu_format_tlb(cpu, buf); + info =3D qmp_x_query_tlb(cs->cpu_index, &err); + if (err) { + error_report_err(err); + return; + } =20 - monitor_printf(mon, "%s", buf->str); + monitor_printf(mon, "%s", info->human_readable_text); } =20 static void hmp_info_profile(Monitor *mon, const QDict *qdict) diff --git a/qapi/machine.json b/qapi/machine.json index e72b47ea7d..0f537a58e0 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1400,6 +1400,21 @@ { 'command': 'x-query-roms', 'returns': 'HumanReadableText' } =20 +## +# @x-query-tlb: +# +# @cpu: the CPU number to query +# +# Return information on the CPU memory mappings +# +# Returns: memory mappings in an architecture-specific format +# +# Since: 6.2 +## +{ 'command': 'x-query-tlb', + 'data': {'cpu': 'int' }, + 'returns': 'HumanReadableText' } + ## # @x-query-usb: # --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631634205712697.261998179484; Tue, 14 Sep 2021 08:43:25 -0700 (PDT) Received: from localhost ([::1]:33812 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAai-0001xI-GX for importer@patchew.org; Tue, 14 Sep 2021 11:43:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43456) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9YH-00080v-1y for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:36:50 -0400 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:21366) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9YB-0005rg-HD for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:36:48 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-145-M1GuuhZyOE-W4SQzAKMs_Q-1; Tue, 14 Sep 2021 10:36:41 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6C89610144E2; Tue, 14 Sep 2021 14:36:37 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id 39FD75D9DC; Tue, 14 Sep 2021 14:36:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631630202; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wy8/gdFSFPTFVlYcj3RIlvpLCGStwBxaoNCHEzByEaY=; b=OYIU7dCgoJA/dv4sm8cgD0BOw0eNusfaujGT1jKrWxQyRQU3kDTBUFSqBVkW89vZmGHVWc Fu8RowHo/3bVkAvoH9spfjaDuk+IflGZYO8BJr94C8vPU4/LvT60apsc0oRJE9GgA0HRn0 pXtuapX8kzNrhLIxmJSgKA7vr3QM85o= X-MC-Unique: M1GuuhZyOE-W4SQzAKMs_Q-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 52/53] qapi: introduce x-query-jit QMP command Date: Tue, 14 Sep 2021 15:20:41 +0100 Message-Id: <20210914142042.1655100-53-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=216.205.24.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631634208282100001 This is a counterpart to the HMP "info jit" command. It is being added with an "x-" prefix because this QMP command is intended as an ad hoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. Signed-off-by: Daniel P. Berrang=C3=A9 --- accel/tcg/cpu-exec.c | 39 +++++++++++++---- accel/tcg/hmp.c | 13 ++++-- accel/tcg/translate-all.c | 80 ++++++++++++++++++---------------- include/exec/cpu-all.h | 4 +- include/tcg/tcg.h | 2 +- qapi/machine.json | 13 ++++++ tcg/tcg.c | 88 ++++++++++++++++++++------------------ tests/qtest/qmp-cmd-test.c | 2 + 8 files changed, 148 insertions(+), 93 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index e5c0ccd1a2..6d27fb62f9 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -20,6 +20,8 @@ #include "qemu/osdep.h" #include "qemu-common.h" #include "qemu/qemu-print.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-machine.h" #include "hw/core/tcg-cpu-ops.h" #include "trace.h" #include "disas/disas.h" @@ -38,6 +40,7 @@ #include "exec/cpu-all.h" #include "sysemu/cpu-timers.h" #include "sysemu/replay.h" +#include "sysemu/tcg.h" #include "exec/helper-proto.h" #include "tb-hash.h" #include "tb-context.h" @@ -1011,23 +1014,41 @@ void tcg_exec_unrealizefn(CPUState *cpu) =20 #ifndef CONFIG_USER_ONLY =20 -void dump_drift_info(void) +void dump_drift_info(GString *buf) { if (!icount_enabled()) { return; } =20 - qemu_printf("Host - Guest clock %"PRIi64" ms\n", - (cpu_get_clock() - icount_get()) / SCALE_MS); + g_string_append_printf(buf, "Host - Guest clock %"PRIi64" ms\n", + (cpu_get_clock() - icount_get()) / SCALE_MS); if (icount_align_option) { - qemu_printf("Max guest delay %"PRIi64" ms\n", - -max_delay / SCALE_MS); - qemu_printf("Max guest advance %"PRIi64" ms\n", - max_advance / SCALE_MS); + g_string_append_printf(buf, "Max guest delay %"PRIi64" ms\n", + -max_delay / SCALE_MS); + g_string_append_printf(buf, "Max guest advance %"PRIi64" ms\n", + max_advance / SCALE_MS); } else { - qemu_printf("Max guest delay NA\n"); - qemu_printf("Max guest advance NA\n"); + g_string_append_printf(buf, "Max guest delay NA\n"); + g_string_append_printf(buf, "Max guest advance NA\n"); } } =20 +HumanReadableText *qmp_x_query_jit(Error **errp) +{ + HumanReadableText *ret; + g_autoptr(GString) buf =3D g_string_new(""); + + if (!tcg_enabled()) { + error_setg(errp, "JIT information is only available with accel=3Dt= cg"); + return NULL; + } + + dump_exec_info(buf); + dump_drift_info(buf); + + ret =3D g_new0(HumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} + #endif /* !CONFIG_USER_ONLY */ diff --git a/accel/tcg/hmp.c b/accel/tcg/hmp.c index a6e72fdb3e..9d7bcd9185 100644 --- a/accel/tcg/hmp.c +++ b/accel/tcg/hmp.c @@ -1,18 +1,23 @@ #include "qemu/osdep.h" #include "qemu/error-report.h" +#include "qapi/error.h" +#include "qapi/qapi-commands-machine.h" #include "exec/exec-all.h" #include "monitor/monitor.h" #include "sysemu/tcg.h" =20 static void hmp_info_jit(Monitor *mon, const QDict *qdict) { - if (!tcg_enabled()) { - error_report("JIT information is only available with accel=3Dtcg"); + Error *err =3D NULL; + g_autoptr(HumanReadableText) info =3D NULL; + + info =3D qmp_x_query_jit(&err); + if (err) { + error_report_err(err); return; } =20 - dump_exec_info(); - dump_drift_info(); + monitor_printf(mon, "%s", info->human_readable_text); } =20 static void hmp_info_opcount(Monitor *mon, const QDict *qdict) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index bbfcfb698c..9c3dbe4409 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2014,7 +2014,7 @@ void cpu_io_recompile(CPUState *cpu, uintptr_t retadd= r) cpu_loop_exit_noexc(cpu); } =20 -static void print_qht_statistics(struct qht_stats hst) +static void print_qht_statistics(struct qht_stats hst, GString *buf) { uint32_t hgram_opts; size_t hgram_bins; @@ -2023,9 +2023,11 @@ static void print_qht_statistics(struct qht_stats hs= t) if (!hst.head_buckets) { return; } - qemu_printf("TB hash buckets %zu/%zu (%0.2f%% head buckets used)\n= ", - hst.used_head_buckets, hst.head_buckets, - (double)hst.used_head_buckets / hst.head_buckets * 100); + g_string_append_printf(buf, "TB hash buckets %zu/%zu " + "(%0.2f%% head buckets used)\n", + hst.used_head_buckets, hst.head_buckets, + (double)hst.used_head_buckets / + hst.head_buckets * 100); =20 hgram_opts =3D QDIST_PR_BORDER | QDIST_PR_LABELS; hgram_opts |=3D QDIST_PR_100X | QDIST_PR_PERCENT; @@ -2033,8 +2035,9 @@ static void print_qht_statistics(struct qht_stats hst) hgram_opts |=3D QDIST_PR_NODECIMAL; } hgram =3D qdist_pr(&hst.occupancy, 10, hgram_opts); - qemu_printf("TB hash occupancy %0.2f%% avg chain occ. Histogram: %s\= n", - qdist_avg(&hst.occupancy) * 100, hgram); + g_string_append_printf(buf, "TB hash occupancy %0.2f%% avg chain occ= . " + "Histogram: %s\n", + qdist_avg(&hst.occupancy) * 100, hgram); g_free(hgram); =20 hgram_opts =3D QDIST_PR_BORDER | QDIST_PR_LABELS; @@ -2046,8 +2049,9 @@ static void print_qht_statistics(struct qht_stats hst) hgram_opts |=3D QDIST_PR_NODECIMAL | QDIST_PR_NOBINRANGE; } hgram =3D qdist_pr(&hst.chain, hgram_bins, hgram_opts); - qemu_printf("TB hash avg chain %0.3f buckets. Histogram: %s\n", - qdist_avg(&hst.chain), hgram); + g_string_append_printf(buf, "TB hash avg chain %0.3f buckets. " + "Histogram: %s\n", + qdist_avg(&hst.chain), hgram); g_free(hgram); } =20 @@ -2084,7 +2088,7 @@ static gboolean tb_tree_stats_iter(gpointer key, gpoi= nter value, gpointer data) return false; } =20 -void dump_exec_info(void) +void dump_exec_info(GString *buf) { struct tb_tree_stats tst =3D {}; struct qht_stats hst; @@ -2093,44 +2097,48 @@ void dump_exec_info(void) tcg_tb_foreach(tb_tree_stats_iter, &tst); nb_tbs =3D tst.nb_tbs; /* XXX: avoid using doubles ? */ - qemu_printf("Translation buffer state:\n"); + g_string_append_printf(buf, "Translation buffer state:\n"); /* * Report total code size including the padding and TB structs; * otherwise users might think "-accel tcg,tb-size" is not honoured. * For avg host size we use the precise numbers from tb_tree_stats tho= ugh. */ - qemu_printf("gen code size %zu/%zu\n", - tcg_code_size(), tcg_code_capacity()); - qemu_printf("TB count %zu\n", nb_tbs); - qemu_printf("TB avg target size %zu max=3D%zu bytes\n", - nb_tbs ? tst.target_size / nb_tbs : 0, - tst.max_target_size); - qemu_printf("TB avg host size %zu bytes (expansion ratio: %0.1f)\n", - nb_tbs ? tst.host_size / nb_tbs : 0, - tst.target_size ? (double)tst.host_size / tst.target_size = : 0); - qemu_printf("cross page TB count %zu (%zu%%)\n", tst.cross_page, - nb_tbs ? (tst.cross_page * 100) / nb_tbs : 0); - qemu_printf("direct jump count %zu (%zu%%) (2 jumps=3D%zu %zu%%)\n", - tst.direct_jmp_count, - nb_tbs ? (tst.direct_jmp_count * 100) / nb_tbs : 0, - tst.direct_jmp2_count, - nb_tbs ? (tst.direct_jmp2_count * 100) / nb_tbs : 0); + g_string_append_printf(buf, "gen code size %zu/%zu\n", + tcg_code_size(), tcg_code_capacity()); + g_string_append_printf(buf, "TB count %zu\n", nb_tbs); + g_string_append_printf(buf, "TB avg target size %zu max=3D%zu bytes\n= ", + nb_tbs ? tst.target_size / nb_tbs : 0, + tst.max_target_size); + g_string_append_printf(buf, "TB avg host size %zu bytes " + "(expansion ratio: %0.1f)\n", + nb_tbs ? tst.host_size / nb_tbs : 0, + tst.target_size ? + (double)tst.host_size / tst.target_size : 0); + g_string_append_printf(buf, "cross page TB count %zu (%zu%%)\n", + tst.cross_page, + nb_tbs ? (tst.cross_page * 100) / nb_tbs : 0); + g_string_append_printf(buf, "direct jump count %zu (%zu%%) " + "(2 jumps=3D%zu %zu%%)\n", + tst.direct_jmp_count, + nb_tbs ? (tst.direct_jmp_count * 100) / nb_tbs = : 0, + tst.direct_jmp2_count, + nb_tbs ? (tst.direct_jmp2_count * 100) / nb_tbs= : 0); =20 qht_statistics_init(&tb_ctx.htable, &hst); - print_qht_statistics(hst); + print_qht_statistics(hst, buf); qht_statistics_destroy(&hst); =20 - qemu_printf("\nStatistics:\n"); - qemu_printf("TB flush count %u\n", - qatomic_read(&tb_ctx.tb_flush_count)); - qemu_printf("TB invalidate count %u\n", - qatomic_read(&tb_ctx.tb_phys_invalidate_count)); + g_string_append_printf(buf, "\nStatistics:\n"); + g_string_append_printf(buf, "TB flush count %u\n", + qatomic_read(&tb_ctx.tb_flush_count)); + g_string_append_printf(buf, "TB invalidate count %u\n", + qatomic_read(&tb_ctx.tb_phys_invalidate_count)); =20 tlb_flush_counts(&flush_full, &flush_part, &flush_elide); - qemu_printf("TLB full flushes %zu\n", flush_full); - qemu_printf("TLB partial flushes %zu\n", flush_part); - qemu_printf("TLB elided flushes %zu\n", flush_elide); - tcg_dump_info(); + g_string_append_printf(buf, "TLB full flushes %zu\n", flush_full); + g_string_append_printf(buf, "TLB partial flushes %zu\n", flush_part); + g_string_append_printf(buf, "TLB elided flushes %zu\n", flush_elide); + tcg_dump_info(buf); } =20 void dump_opcount_info(void) diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index 32cfb634c6..d92f6fa7a9 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -429,9 +429,9 @@ static inline bool tlb_hit(target_ulong tlb_addr, targe= t_ulong addr) =20 #ifdef CONFIG_TCG /* accel/tcg/cpu-exec.c */ -void dump_drift_info(void); +void dump_drift_info(GString *buf); /* accel/tcg/translate-all.c */ -void dump_exec_info(void); +void dump_exec_info(GString *buf); void dump_opcount_info(void); #endif /* CONFIG_TCG */ =20 diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 44ccd86f3e..1b56e382b7 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -943,7 +943,7 @@ int tcg_check_temp_count(void); #endif =20 int64_t tcg_cpu_exec_time(void); -void tcg_dump_info(void); +void tcg_dump_info(GString *buf); void tcg_dump_op_count(void); =20 #define TCG_CT_CONST 1 /* any constant of register size */ diff --git a/qapi/machine.json b/qapi/machine.json index 0f537a58e0..e88aba1199 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1325,6 +1325,19 @@ { 'command': 'x-query-irq', 'returns': 'HumanReadableText' } =20 +## +# @x-query-jit: +# +# Query TCG compiler statistics +# +# Returns: TCG compiler statistics +# +# Since: 6.2 +## +{ 'command': 'x-query-jit', + 'returns': 'HumanReadableText', + 'if': 'CONFIG_TCG' } + ## # @x-query-numa: # diff --git a/tcg/tcg.c b/tcg/tcg.c index 4142d42d77..7fcdfd9c0f 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4382,7 +4382,7 @@ int tcg_gen_code(TCGContext *s, TranslationBlock *tb) } =20 #ifdef CONFIG_PROFILER -void tcg_dump_info(void) +void tcg_dump_info(GString *buf) { TCGProfile prof =3D {}; const TCGProfile *s; @@ -4396,53 +4396,59 @@ void tcg_dump_info(void) tb_div_count =3D tb_count ? tb_count : 1; tot =3D s->interm_time + s->code_time; =20 - qemu_printf("JIT cycles %" PRId64 " (%0.3f s at 2.4 GHz)\n", - tot, tot / 2.4e9); - qemu_printf("translated TBs %" PRId64 " (aborted=3D%" PRId64 - " %0.1f%%)\n", - tb_count, s->tb_count1 - tb_count, - (double)(s->tb_count1 - s->tb_count) - / (s->tb_count1 ? s->tb_count1 : 1) * 100.0); - qemu_printf("avg ops/TB %0.1f max=3D%d\n", - (double)s->op_count / tb_div_count, s->op_count_max); - qemu_printf("deleted ops/TB %0.2f\n", - (double)s->del_op_count / tb_div_count); - qemu_printf("avg temps/TB %0.2f max=3D%d\n", - (double)s->temp_count / tb_div_count, s->temp_count_max); - qemu_printf("avg host code/TB %0.1f\n", - (double)s->code_out_len / tb_div_count); - qemu_printf("avg search data/TB %0.1f\n", - (double)s->search_out_len / tb_div_count); + g_string_append_printf(buf, "JIT cycles %" PRId64 + " (%0.3f s at 2.4 GHz)\n", + tot, tot / 2.4e9); + g_string_append_printf(buf, "translated TBs %" PRId64 + " (aborted=3D%" PRId64 " %0.1f%%)\n", + tb_count, s->tb_count1 - tb_count, + (double)(s->tb_count1 - s->tb_count) + / (s->tb_count1 ? s->tb_count1 : 1) * 100.0); + g_string_append_printf(buf, "avg ops/TB %0.1f max=3D%d\n", + (double)s->op_count / tb_div_count, s->op_count= _max); + g_string_append_printf(buf, "deleted ops/TB %0.2f\n", + (double)s->del_op_count / tb_div_count); + g_string_append_printf(buf, "avg temps/TB %0.2f max=3D%d\n", + (double)s->temp_count / tb_div_count, + s->temp_count_max); + g_string_append_printf(buf, "avg host code/TB %0.1f\n", + (double)s->code_out_len / tb_div_count); + g_string_append_printf(buf, "avg search data/TB %0.1f\n", + (double)s->search_out_len / tb_div_count); =20 - qemu_printf("cycles/op %0.1f\n", - s->op_count ? (double)tot / s->op_count : 0); - qemu_printf("cycles/in byte %0.1f\n", - s->code_in_len ? (double)tot / s->code_in_len : 0); - qemu_printf("cycles/out byte %0.1f\n", - s->code_out_len ? (double)tot / s->code_out_len : 0); - qemu_printf("cycles/search byte %0.1f\n", - s->search_out_len ? (double)tot / s->search_out_len : 0); + g_string_append_printf(buf, "cycles/op %0.1f\n", + s->op_count ? (double)tot / s->op_count : 0); + g_string_append_printf(buf, "cycles/in byte %0.1f\n", + s->code_in_len ? (double)tot / s->code_in_len := 0); + g_string_append_printf(buf, "cycles/out byte %0.1f\n", + s->code_out_len ? (double)tot / s->code_out_len= : 0); + g_string_append_printf(buf, "cycles/search byte %0.1f\n", + s->search_out_len ? + (double)tot / s->search_out_len : 0); if (tot =3D=3D 0) { tot =3D 1; } - qemu_printf(" gen_interm time %0.1f%%\n", - (double)s->interm_time / tot * 100.0); - qemu_printf(" gen_code time %0.1f%%\n", - (double)s->code_time / tot * 100.0); - qemu_printf("optim./code time %0.1f%%\n", - (double)s->opt_time / (s->code_time ? s->code_time : 1) - * 100.0); - qemu_printf("liveness/code time %0.1f%%\n", - (double)s->la_time / (s->code_time ? s->code_time : 1) * 1= 00.0); - qemu_printf("cpu_restore count %" PRId64 "\n", - s->restore_count); - qemu_printf(" avg cycles %0.1f\n", - s->restore_count ? (double)s->restore_time / s->restore_co= unt : 0); + g_string_append_printf(buf, " gen_interm time %0.1f%%\n", + (double)s->interm_time / tot * 100.0); + g_string_append_printf(buf, " gen_code time %0.1f%%\n", + (double)s->code_time / tot * 100.0); + g_string_append_printf(buf, "optim./code time %0.1f%%\n", + (double)s->opt_time / (s->code_time ? + s->code_time : 1) + * 100.0); + g_string_append_printf(buf, "liveness/code time %0.1f%%\n", + (double)s->la_time / (s->code_time ? + s->code_time : 1) * 100.0= ); + g_string_append_printf(buf, "cpu_restore count %" PRId64 "\n", + s->restore_count); + g_string_append_printf(buf, " avg cycles %0.1f\n", + s->restore_count ? + (double)s->restore_time / s->restore_count : 0); } #else -void tcg_dump_info(void) +void tcg_dump_info(GString *buf) { - qemu_printf("[TCG profiler not compiled]\n"); + g_string_append_printf(buf, "[TCG profiler not compiled]\n"); } #endif =20 diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index 15875a14c6..6aa628691a 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -51,6 +51,8 @@ static int query_error_class(const char *cmd) #endif /* Only valid with a USB bus added */ { "x-query-usb", ERROR_CLASS_GENERIC_ERROR }, + /* Only valid with accel=3Dtcg */ + { "x-query-jit", ERROR_CLASS_GENERIC_ERROR }, { NULL, -1 } }; int i; --=20 2.31.1 From nobody Fri Apr 19 15:44:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; 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; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1631634444288921.5893626544851; Tue, 14 Sep 2021 08:47:24 -0700 (PDT) Received: from localhost ([::1]:43096 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQAeZ-0008Us-1o for importer@patchew.org; Tue, 14 Sep 2021 11:47:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43634) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Yi-00008c-Ve for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:37:18 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:43572) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQ9Yb-0006Dz-EZ for qemu-devel@nongnu.org; Tue, 14 Sep 2021 10:37:15 -0400 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-594-Nf-CDhdOPX61ObTmtVUhrw-1; Tue, 14 Sep 2021 10:37:05 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDE91835DE1; Tue, 14 Sep 2021 14:36:59 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.39.193.47]) by smtp.corp.redhat.com (Postfix) with ESMTP id BADA55D9CA; Tue, 14 Sep 2021 14:36:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1631630228; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=jVKry3AGQ0J47lN7ksTFJCPydgWIThxCI8/FSxTWsjQ=; b=X9A1V56F6xxmCLKEbTtoO5gArqgAr+pvwoGCPKDyO77LjwhoyPW8KQzfH2M5DlzlxttlTq /n4rMTGZ2+ZuX4pF3QR7029kOtgxlL0vVxJCEQWqrBmD/E1olso/ShbrOw4o51u8EUz+U1 rmqsxHbMszrl+MntWO4Xklk52hChEBg= X-MC-Unique: Nf-CDhdOPX61ObTmtVUhrw-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: qemu-devel@nongnu.org Subject: [PATCH v2 53/53] qapi: introduce x-query-opcount QMP command Date: Tue, 14 Sep 2021 15:20:42 +0100 Message-Id: <20210914142042.1655100-54-berrange@redhat.com> In-Reply-To: <20210914142042.1655100-1-berrange@redhat.com> References: <20210914142042.1655100-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=berrange@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=berrange@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -31 X-Spam_score: -3.2 X-Spam_bar: --- X-Spam_report: (-3.2 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.398, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Chris Wulff , David Hildenbrand , Bin Meng , Mark Cave-Ayland , Yuval Shaia , Laurent Vivier , Max Filippov , Taylor Simpson , Alistair Francis , Gerd Hoffmann , "Edgar E. Iglesias" , Eric Blake , Marek Vasut , Yoshinori Sato , Markus Armbruster , Halil Pasic , Christian Borntraeger , Palmer Dabbelt , Artyom Tarasenko , Laurent Vivier , Thomas Huth , Eduardo Habkost , Richard Henderson , Greg Kurz , "Dr. David Alan Gilbert" , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Michael Rolnik , Peter Xu , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , Stafford Horne , David Gibson , qemu-riscv@nongnu.org, Bastian Koppelmann , Cornelia Huck , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Paolo Bonzini , Aleksandar Rikalo , Aurelien Jarno Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1631634445540100001 This is a counterpart to the HMP "info opcount" command. It is being added with an "x-" prefix because this QMP command is intended as an ad hoc debugging tool and will thus not be modelled in QAPI as fully structured data, nor will it have long term guaranteed stability. The existing HMP command is rewritten to call the QMP command. Signed-off-by: Daniel P. Berrang=C3=A9 --- accel/tcg/cpu-exec.c | 17 +++++++++++++++++ accel/tcg/hmp.c | 11 ++++++++++- accel/tcg/translate-all.c | 4 ++-- include/exec/cpu-all.h | 2 +- include/tcg/tcg.h | 2 +- qapi/machine.json | 13 +++++++++++++ tcg/tcg.c | 10 +++++----- tests/qtest/qmp-cmd-test.c | 1 + 8 files changed, 50 insertions(+), 10 deletions(-) diff --git a/accel/tcg/cpu-exec.c b/accel/tcg/cpu-exec.c index 6d27fb62f9..613f6fa5be 100644 --- a/accel/tcg/cpu-exec.c +++ b/accel/tcg/cpu-exec.c @@ -1051,4 +1051,21 @@ HumanReadableText *qmp_x_query_jit(Error **errp) return ret; } =20 +HumanReadableText *qmp_x_query_opcount(Error **errp) +{ + HumanReadableText *ret; + g_autoptr(GString) buf =3D g_string_new(""); + + if (!tcg_enabled()) { + error_setg(errp, "JIT information is only available with accel=3Dt= cg"); + return NULL; + } + + dump_opcount_info(buf); + + ret =3D g_new0(HumanReadableText, 1); + ret->human_readable_text =3D g_steal_pointer(&buf->str); + return ret; +} + #endif /* !CONFIG_USER_ONLY */ diff --git a/accel/tcg/hmp.c b/accel/tcg/hmp.c index 9d7bcd9185..9b049d1e76 100644 --- a/accel/tcg/hmp.c +++ b/accel/tcg/hmp.c @@ -22,7 +22,16 @@ static void hmp_info_jit(Monitor *mon, const QDict *qdic= t) =20 static void hmp_info_opcount(Monitor *mon, const QDict *qdict) { - dump_opcount_info(); + Error *err =3D NULL; + g_autoptr(HumanReadableText) info =3D NULL; + + info =3D qmp_x_query_opcount(&err); + if (err) { + error_report_err(err); + return; + } + + monitor_printf(mon, "%s", info->human_readable_text); } =20 static void hmp_tcg_register(void) diff --git a/accel/tcg/translate-all.c b/accel/tcg/translate-all.c index 9c3dbe4409..7a8121e70a 100644 --- a/accel/tcg/translate-all.c +++ b/accel/tcg/translate-all.c @@ -2141,9 +2141,9 @@ void dump_exec_info(GString *buf) tcg_dump_info(buf); } =20 -void dump_opcount_info(void) +void dump_opcount_info(GString *buf) { - tcg_dump_op_count(); + tcg_dump_op_count(buf); } =20 #else /* CONFIG_USER_ONLY */ diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h index d92f6fa7a9..3c8e24292b 100644 --- a/include/exec/cpu-all.h +++ b/include/exec/cpu-all.h @@ -432,7 +432,7 @@ static inline bool tlb_hit(target_ulong tlb_addr, targe= t_ulong addr) void dump_drift_info(GString *buf); /* accel/tcg/translate-all.c */ void dump_exec_info(GString *buf); -void dump_opcount_info(void); +void dump_opcount_info(GString *buf); #endif /* CONFIG_TCG */ =20 #endif /* !CONFIG_USER_ONLY */ diff --git a/include/tcg/tcg.h b/include/tcg/tcg.h index 1b56e382b7..cc7f59070b 100644 --- a/include/tcg/tcg.h +++ b/include/tcg/tcg.h @@ -944,7 +944,7 @@ int tcg_check_temp_count(void); =20 int64_t tcg_cpu_exec_time(void); void tcg_dump_info(GString *buf); -void tcg_dump_op_count(void); +void tcg_dump_op_count(GString *buf); =20 #define TCG_CT_CONST 1 /* any constant of register size */ =20 diff --git a/qapi/machine.json b/qapi/machine.json index e88aba1199..bb24146a40 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1350,6 +1350,19 @@ { 'command': 'x-query-numa', 'returns': 'HumanReadableText' } =20 +## +# @x-query-opcount: +# +# Query TCG opcode counters +# +# Returns: TCG opcode counters +# +# Since: 6.2 +## +{ 'command': 'x-query-opcount', + 'returns': 'HumanReadableText', + 'if': 'CONFIG_TCG' } + ## # @x-query-profile: # diff --git a/tcg/tcg.c b/tcg/tcg.c index 7fcdfd9c0f..d9653990af 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -4115,15 +4115,15 @@ static void tcg_profile_snapshot_table(TCGProfile *= prof) tcg_profile_snapshot(prof, false, true); } =20 -void tcg_dump_op_count(void) +void tcg_dump_op_count(GString *buf) { TCGProfile prof =3D {}; int i; =20 tcg_profile_snapshot_table(&prof); for (i =3D 0; i < NB_OPS; i++) { - qemu_printf("%s %" PRId64 "\n", tcg_op_defs[i].name, - prof.table_op_count[i]); + g_string_append_printf(buf, "%s %" PRId64 "\n", tcg_op_defs[i].nam= e, + prof.table_op_count[i]); } } =20 @@ -4142,9 +4142,9 @@ int64_t tcg_cpu_exec_time(void) return ret; } #else -void tcg_dump_op_count(void) +void tcg_dump_op_count(GString *buf) { - qemu_printf("[TCG profiler not compiled]\n"); + g_string_append_printf(buf, "[TCG profiler not compiled]\n"); } =20 int64_t tcg_cpu_exec_time(void) diff --git a/tests/qtest/qmp-cmd-test.c b/tests/qtest/qmp-cmd-test.c index 6aa628691a..251a14ddf7 100644 --- a/tests/qtest/qmp-cmd-test.c +++ b/tests/qtest/qmp-cmd-test.c @@ -53,6 +53,7 @@ static int query_error_class(const char *cmd) { "x-query-usb", ERROR_CLASS_GENERIC_ERROR }, /* Only valid with accel=3Dtcg */ { "x-query-jit", ERROR_CLASS_GENERIC_ERROR }, + { "x-query-opcount", ERROR_CLASS_GENERIC_ERROR }, { NULL, -1 } }; int i; --=20 2.31.1