From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661523554; cv=none; d=zohomail.com; s=zohoarc; b=Uo6w3uMGOXq9oDjMU5ZwMG+oQGkU/tNgaGiTohVjcrZvYhe9Ig8TFYpAI27yxeBhXjj+4Jt2eYFWMyga6bRKX5tDngPp7vJjGvhfNA8h1Um87jDXe1lbZuMl5JeaBKMwmIGvuoWu6qPW1ctWNdKs3Dvs6L+e/CkDupw/aHttgas= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661523554; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=7nsBpd6U2T94rIp6E9694uNRx1OUw5ceVkhMbv8n9sQ=; b=eozjJVE4WW3FALjeGB/uA/+KBGUo9poMuvQqzn3twU/wze74fmbh0PHBmL3Fd8N0H/h0o/kfrTzBUjW8j2nKgTGoHNBBc6r66MxCib/77sYDFDX35BHyjJkHzDSaQf65nwYSOSoXPCPEzgSXyTqRHk4mrvpHqVPde3f7fimCCPg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 166152355416648.333596856287386; Fri, 26 Aug 2022 07:19:14 -0700 (PDT) Received: from localhost ([::1]:45214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaAy-0007p0-3D for importer@patchew.org; Fri, 26 Aug 2022 10:19:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57176) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa43-0007Xl-5A; Fri, 26 Aug 2022 10:12:03 -0400 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]:34527) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa41-0003ot-I0; Fri, 26 Aug 2022 10:12:02 -0400 Received: by mail-oi1-x235.google.com with SMTP id r10so2137821oie.1; Fri, 26 Aug 2022 07:12:00 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.11.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:11:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=7nsBpd6U2T94rIp6E9694uNRx1OUw5ceVkhMbv8n9sQ=; b=dHu8iCKsKPB1tufnPw6xfyTL2kEBCGfGhu3tJziTp3HoUR7yAWchSuqbUwotSIisWs NCF/NUNgVCcEYBd+/sYghKYzdxOTHwcUsj7sCwuCVMbj0FCxZVEHMZ16/pDVLPPhSWIA 6mbGZkbE7i15GQulFK0w84gEFXYL1YqM0tl38nkZLmtNnQoeZKTue35n3RugJ2lfwPYf 5iYlINiA0drmTa2IngkPo7ZIoB7anQpBDwIa0iV7/AI5RJ2lRRaZuRoD7RwrB6GfEyTk BC7ohDXI1SciwS888L+KFrGGX+RV24DqQVEA49/k0yGtGIyHd0Aw61PIo4F0U0XfYS7j Q68w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=7nsBpd6U2T94rIp6E9694uNRx1OUw5ceVkhMbv8n9sQ=; b=LgFXJ4QougSPSFfv1DmOlIBzzqJ8fP7I/QtLvocYvhwyvsTt8W7B3bhiR3kzS3DDdv WKTuw/vdUFUDXr/yg6xF1Dwnl5ge0VmCQmU110kwlfsY5WbfDuUbIEPfLZU5j5ilBTa4 Pfvv+axFfcVUEHHCPu7zmX65HTmLkj2hgPi4HqUoL+iF0uTLy5rSFYzTY5qqqVHBdPfl IEnhfWX+1sv7V7uw9KsgqoSCcus/Gh1oIk2t1gN8E3VsSIkVS/SOUIDF5+l96BCI8W5K niNrTpK22PCrs9AV7e8MeKAtXytOpI6XOtsXq5kE/Y5U75f3EWRUqKh5AZp3WO7WoFeq wBWw== X-Gm-Message-State: ACgBeo3TZhrJ/u6Q0wuW/PCvMEssrG8vGNDzvgztlm53XFFmyETkM6lP A5pNO+30sURxitOdAkJmx7Pi4cfwpqs= X-Google-Smtp-Source: AA6agR6qmUresxANBlhkZ2M/Tqj7I4qzlcyVjp17rEp+qhM2MU1S7w7HxgCwW2B6oB3KuPfy7nZRxw== X-Received: by 2002:a54:4598:0:b0:344:e71e:3a13 with SMTP id z24-20020a544598000000b00344e71e3a13mr1760681oib.239.1661523119049; Fri, 26 Aug 2022 07:11:59 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza , Peter Maydell , qemu-arm@nongnu.org Subject: [PATCH for-7.2 v4 01/21] hw/arm: do not free machine->fdt in arm_load_dtb() Date: Fri, 26 Aug 2022 11:11:30 -0300 Message-Id: <20220826141150.7201-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::235; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x235.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661523556400100001 Content-Type: text/plain; charset="utf-8" At this moment, arm_load_dtb() can free machine->fdt when binfo->dtb_filename is NULL. If there's no 'dtb_filename', 'fdt' will be retrieved by binfo->get_dtb(). If get_dtb() returns machine->fdt, as is the case of machvirt_dtb() from hw/arm/virt.c, fdt now has a pointer to machine->fdt. And, in that case, the existing g_free(fdt) at the end of arm_load_dtb() will make machine->fdt point to an invalid memory region. This is not an issue right now because there's no code that access machine->fdt after arm_load_dtb(), but we're going to add a couple do FDT HMP commands that will rely on machine->fdt being valid. Instead of freeing 'fdt' at the end of arm_load_dtb(), assign it to machine->fdt. This will allow the FDT of ARM machines that relies on arm_load_dtb() to be accessed later on. Since all ARM machines allocates the FDT only once, we don't need to worry about leaking the existing FDT during a machine reset (which is something that other machines have to look after, e.g. the ppc64 pSeries machine). Cc: Peter Maydell Cc: qemu-arm@nongnu.org Signed-off-by: Daniel Henrique Barboza --- hw/arm/boot.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index ada2717f76..669a978157 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -684,7 +684,11 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_in= fo *binfo, */ rom_add_blob_fixed_as("dtb", fdt, size, addr, as); =20 - g_free(fdt); + /* + * Update the ms->fdt pointer to enable support for + * 'dumpdtb' and 'info fdt' QMP/HMP commands. + */ + ms->fdt =3D fdt; =20 return size; =20 --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661523360; cv=none; d=zohomail.com; s=zohoarc; b=fZ6o1Y6BrL1ZfeA79LfCSR1nkR6c7dE7LqsrjNyIDhi64t6ahmtzlTajUA3+j6bvFXTSuolVPNMB/5HLY7SKlehZ9lMQeEuqnBThhrTunXE7ZPaJIZqSo/yYIv380mn8uF5gyMDBZ1ElEfDJBUzQPMAXMEKijjO+QEmz4/xB49M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661523360; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j1RYsPISHcQmqkfg0bCXBflgdHOzA77Z6HtOczxpsOA=; b=DHtZQnq5WXr5SNJmuuqunUkLRYxrvPfV/FqNAh4LfuvQ9OyN7SN97FwT4KKfd1PICXvsHoiXfcnGyG+SAqwMzyn76CLK84YbFcjDB6B4XnUvQ8PkgtiFKgGawJzvV0b3FFuM4wr5EO5eqgiYpboObVAgCV5wt7Eyhc8aBQ/RbX4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661523360132509.75120142218327; Fri, 26 Aug 2022 07:16:00 -0700 (PDT) Received: from localhost ([::1]:36796 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRa7r-0003Ws-14 for importer@patchew.org; Fri, 26 Aug 2022 10:15:59 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54098) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4D-0007cQ-4L; Fri, 26 Aug 2022 10:12:13 -0400 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]:43840) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa43-0003qH-V1; Fri, 26 Aug 2022 10:12:12 -0400 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11e86b7379dso924494fac.10; Fri, 26 Aug 2022 07:12:03 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.11.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=j1RYsPISHcQmqkfg0bCXBflgdHOzA77Z6HtOczxpsOA=; b=SV+1hPN5vfdPYqYnEbsFUdulxGd6hv//jAJqny0cgLkZAqe309mR5VESbcSyEAELeB 32zikRo1bnVJWueEJnIJl9OjVo8q6PfybbEYdCWYZJ5VyrJVDLlmUudjr4gUnxvZzP9k DgDdgRt2Qfer+FvS1hrNynoKDRjSrPHbut7JUIkApiU4/JByTKRjQ2D8L4t758EsgdLx 2SYXz/GFsXwS+lpMXkDqwtLkSqVJg+Qz8+fJvBlNbmADoLmk9DCuLleQ7kwAlpwjjn2R xCHOCLkFPeXv4roZabDo8NZ36wWELhndXMFuFJQmhQjD9if9TKwCUCCzvobYhbeWp5It 2s8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=j1RYsPISHcQmqkfg0bCXBflgdHOzA77Z6HtOczxpsOA=; b=BRwTqVesBRFWExDBcWGVPd9ICVsHtSmAzVKjDNbsW+EUiiFFD6PezwFA1h8FhArSmn jb4qBBfaDxBTkKewpxf3b/Om30k0C30eM1vCYg7jFCLCMS++7QGpWIMie2veQ6QA7+Z2 kPMUVLCfZfOuFhORj48j3K0T1HCmFKMWMhTQTHAqHabE0oamz1VbfzT6lhG+BcJwMvgm CniDTicFE42iweiwahsOKZyC4gGyGBDZNr2JMKzsEqYLJMbkqNBvwJV/8+kh3HJJ+iiP 5HEIODXn1T5n/YxkJwj+ETWmjEqKfFbQ1L+RQRrDSHz86wbpMV5I0VTx22nBe/0MupTU sKHQ== X-Gm-Message-State: ACgBeo1yzRNdh9ZVxcPVIM5BuBjSNqMjDgxUpZLGB/z3y29Fs6LZawnL MwQy5g/K665MFaw9lrrHUmcdv27k+iw= X-Google-Smtp-Source: AA6agR74VKXjELPAWCyRXlmKH1A14sZCFuSy0heZEfmTMfyrxp02y1Cq9wBqneX/RkDwvxaCgPMVAA== X-Received: by 2002:a05:6870:c14a:b0:11d:588:da3a with SMTP id g10-20020a056870c14a00b0011d0588da3amr1889262oad.214.1661523121982; Fri, 26 Aug 2022 07:12:01 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza , "Edgar E . Iglesias" Subject: [PATCH for-7.2 v4 02/21] hw/microblaze: set machine->fdt in microblaze_load_dtb() Date: Fri, 26 Aug 2022 11:11:31 -0300 Message-Id: <20220826141150.7201-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::31; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x31.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661523362001100001 Content-Type: text/plain; charset="utf-8" This will enable support for 'dumpdtb' and 'info fdt' HMP commands for all microblaze machines that uses microblaze_load_dtb(). Cc: Edgar E. Iglesias Signed-off-by: Daniel Henrique Barboza --- hw/microblaze/boot.c | 11 ++++++++++- hw/microblaze/meson.build | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c index 8b92a9801a..e9ebc04381 100644 --- a/hw/microblaze/boot.c +++ b/hw/microblaze/boot.c @@ -39,6 +39,8 @@ =20 #include "boot.h" =20 +#include + static struct { void (*machine_cpu_reset)(MicroBlazeCPU *); @@ -72,6 +74,7 @@ static int microblaze_load_dtb(hwaddr addr, const char *kernel_cmdline, const char *dtb_filename) { + MachineState *machine =3D MACHINE(qdev_get_machine()); int fdt_size; void *fdt =3D NULL; int r; @@ -100,7 +103,13 @@ static int microblaze_load_dtb(hwaddr addr, } =20 cpu_physical_memory_write(addr, fdt, fdt_size); - g_free(fdt); + + /* + * Update the machine->fdt pointer to enable support for + * 'dumpdtb' and 'info fdt' QMP/HMP commands. + */ + machine->fdt =3D fdt; + return fdt_size; } =20 diff --git a/hw/microblaze/meson.build b/hw/microblaze/meson.build index bb9e4eb8f4..a38a397872 100644 --- a/hw/microblaze/meson.build +++ b/hw/microblaze/meson.build @@ -1,5 +1,5 @@ microblaze_ss =3D ss.source_set() -microblaze_ss.add(files('boot.c')) +microblaze_ss.add(files('boot.c'), fdt) microblaze_ss.add(when: 'CONFIG_PETALOGIX_S3ADSP1800', if_true: files('pet= alogix_s3adsp1800_mmu.c')) microblaze_ss.add(when: 'CONFIG_PETALOGIX_ML605', if_true: files('petalogi= x_ml605_mmu.c')) microblaze_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true: files('xlnx-zyn= qmp-pmu.c')) --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661523277; cv=none; d=zohomail.com; s=zohoarc; b=Qitge5n80AaZy2XFrGsJgha4R2blSr+oaCJW1pQzZs8bMqsen0cSwgmQBhQrDvIlRTKBGKY5gOA8ndatzug8uL1x7Zo4Qc7w1c3OBrSpkEjTejSLpHbCL8F9R3/t1WKN9DiiRKAtGiwvS3BpNTtlRxC3yn1K3uM6RPTd331pcWw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661523277; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4f24mixCYIhi0sIPdZyXjyavjHpNtJ1OrG02fjTafCg=; b=AxMx+fvlCWQnQcD5tJXuwsg0vi2Ek9TGMSCLF/IdOYkBbeLp8RrMcazLChPTcct0LhsSJFOD7fqnKZGPRtKPwvKSTc0hEic2nZSzGfoFVFSynb7U2GtGExf0E7fEnF3LgK29FoCHd1S0/rEZmUwXdQyghXCT9yk0PXOdTFho1Sc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661523277723402.09167237875715; Fri, 26 Aug 2022 07:14:37 -0700 (PDT) Received: from localhost ([::1]:44470 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRa6V-0002FC-FA for importer@patchew.org; Fri, 26 Aug 2022 10:14:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4C-0007cR-Uk; Fri, 26 Aug 2022 10:12:13 -0400 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]:34527) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa46-0003ot-FM; Fri, 26 Aug 2022 10:12:08 -0400 Received: by mail-oi1-x235.google.com with SMTP id r10so2138135oie.1; Fri, 26 Aug 2022 07:12:05 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=4f24mixCYIhi0sIPdZyXjyavjHpNtJ1OrG02fjTafCg=; b=deNoEQc1bX4txtDGMF8DgvGNBSMNw7oyM3yd91GeJEmjM7yTL4MQYTK7haU/fEF4dO Yqu8n5Z8V6pJF+AqEXLU+u9t7ArkCwUfv9kmzwRU3UfKekXEP8QMCTgYvEi0TC9uXfzQ HQ1bbjrNvyCt4xyN6P1SuO8glZSyvtUshLorwFWXF+8gKotIp76CR1N79cb+7961zBJX 68WRN5utbX+eFs2kbCQQacqko65GXArgcTWNgWtzavHifAlGZbGE0/bcV1DTw4vThCCr yzj618w9vUo2lire/OjBcHM/xSm9SLe0H6wDIyH3R3QuWalSxLesvY0IUd74ZJsfi68X Ujqw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=4f24mixCYIhi0sIPdZyXjyavjHpNtJ1OrG02fjTafCg=; b=S+1OZe2IkeXMTyQe/peaz/hB3GT8NWo6xO6Y82Tawt7+h1zW5D0HScGtGWFsLX022T BOSJNEEeKy5BtXV3NAz1c6tn5Gy2q0pmB8LeJFlYP0DJE0zo5XevS6UQNcinGoIUxUwc ZecaAFWgdwX6orides/6TTm9by51aP2AdI9JrkaM0d3BCzZXDmvBlUnIYpsrv4yb+NE9 dte5lZu611DPgxpc9Mcc1PJFxHXzJTPnstXMv5+pwU4IPHbJfCHm8FncFKx2HRZ8oQEr YYie6EbBhLvWn2IlxE4EFsQrkWdyin1mQvKZ31HljXEx0QGn91OSuE158e4/aBCu9M+d nvgA== X-Gm-Message-State: ACgBeo2V/0+JFkPf6diXdOVSuy28Cr2K1LnOyTVan1SCSC4Y986TPvVp ivw1p311BarhPF+92Fy+SmaJcoerqNg= X-Google-Smtp-Source: AA6agR511igfyPU1kJgocYi2Fz+hrKdiAYiXcW5m2D0n0m2IhT+tM3C4zvxfsxycpt0fLsKLMtlC1g== X-Received: by 2002:aca:5f03:0:b0:343:8774:d67 with SMTP id t3-20020aca5f03000000b0034387740d67mr1691942oib.9.1661523124844; Fri, 26 Aug 2022 07:12:04 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza , Chris Wulff , Marek Vasut Subject: [PATCH for-7.2 v4 03/21] hw/nios2: set machine->fdt in nios2_load_dtb() Date: Fri, 26 Aug 2022 11:11:32 -0300 Message-Id: <20220826141150.7201-4-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::235; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x235.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661523280180100001 Content-Type: text/plain; charset="utf-8" This will enable support for 'dumpdtb' and 'info fdt' HMP commands for all nios2 machines that uses nios2_load_dtb(). Cc: Chris Wulff Cc: Marek Vasut Signed-off-by: Daniel Henrique Barboza --- hw/nios2/boot.c | 11 ++++++++++- hw/nios2/meson.build | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c index 21cbffff47..db3b21fea6 100644 --- a/hw/nios2/boot.c +++ b/hw/nios2/boot.c @@ -43,6 +43,8 @@ =20 #include "boot.h" =20 +#include + #define NIOS2_MAGIC 0x534f494e =20 static struct nios2_boot_info { @@ -81,6 +83,7 @@ static uint64_t translate_kernel_address(void *opaque, ui= nt64_t addr) static int nios2_load_dtb(struct nios2_boot_info bi, const uint32_t ramsiz= e, const char *kernel_cmdline, const char *dtb_file= name) { + MachineState *machine =3D MACHINE(qdev_get_machine()); int fdt_size; void *fdt =3D NULL; int r; @@ -113,7 +116,13 @@ static int nios2_load_dtb(struct nios2_boot_info bi, c= onst uint32_t ramsize, } =20 cpu_physical_memory_write(bi.fdt, fdt, fdt_size); - g_free(fdt); + + /* + * Update the machine->fdt pointer to enable support for + * 'dumpdtb' and 'info fdt' QMP/HMP commands. + */ + machine->fdt =3D fdt; + return fdt_size; } =20 diff --git a/hw/nios2/meson.build b/hw/nios2/meson.build index 6c58e8082b..22277bd6c5 100644 --- a/hw/nios2/meson.build +++ b/hw/nios2/meson.build @@ -1,5 +1,5 @@ nios2_ss =3D ss.source_set() -nios2_ss.add(files('boot.c')) +nios2_ss.add(files('boot.c'), fdt) nios2_ss.add(when: 'CONFIG_NIOS2_10M50', if_true: files('10m50_devboard.c'= )) nios2_ss.add(when: 'CONFIG_NIOS2_GENERIC_NOMMU', if_true: files('generic_n= ommu.c')) =20 --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661523884; cv=none; d=zohomail.com; s=zohoarc; b=JjCw1gPdhDukKm0OYah/JjNQMiTi/IO+nwfVnnda9yx1ZMYdPSjSin6EscmmUAWYN5shNNWG27UOCp+53N1A0Klnrdz9qMLgHmUL2ciHBucZ2wPaBpfEcIxTW1z18KIVwlHem1XOCIGEJ4NVT/+ywbu8LnY3px9AqvivK0sA3Jg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661523884; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=W3OSa9MXxQstpQEShZr7qGq0YKfPJLRHYk7eRBvuzgA=; b=iEfjRmnvkiijlej5YTgJ6b0B2Cugq4zfjqKzqCRV6g4neBmmfAY4D5zR1y1LtmAg9IJCYYCWZt1A7uAkNoHyDmEiQzVHTA9J9CWMUI5uBeZqDJMzzSxGIAFSa4TY0LgF7IHzSmEzlYzstJzSDhCBvt0KqBiDT96KvexbyWeX0s8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661523884301137.66194807533952; Fri, 26 Aug 2022 07:24:44 -0700 (PDT) Received: from localhost ([::1]:40502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaGJ-0008TZ-95 for importer@patchew.org; Fri, 26 Aug 2022 10:24:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:54104) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4F-0007ic-52; Fri, 26 Aug 2022 10:12:15 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]:36704) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4C-0003sz-L4; Fri, 26 Aug 2022 10:12:14 -0400 Received: by mail-ot1-x329.google.com with SMTP id 6-20020a9d0106000000b0063963134d04so1085777otu.3; Fri, 26 Aug 2022 07:12:08 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=W3OSa9MXxQstpQEShZr7qGq0YKfPJLRHYk7eRBvuzgA=; b=RXS9ueKQT7snOt03t+/CILiwktXWtLK5N8PUfa7ylZiUB6AcDZZlkoTkjA8tqV6E1h HNk4cC56dsJDFvdpFpJmSG6iVkpWJK8+DURIvlVIFDKdLqLocvxivUcZrP/nAbknlGXN WtBwotDyGYphPTHB+wbzFVXhPvLMSI6r2DsZlLIObk2/fGnP4Cxqh60t5ukNThTss7ku a6mdnqnfpam0qylXHpUGslmfDg32eI1vFS9snvo8Evj/2IjA3O0cELJhJlvLEwp+KZjQ pMfHIouZGakqGptslaQ06LpNVKYvhc6pgGj49j9BIQ6z1wW5grb5faMoOi37oNS8sk5H VLwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=W3OSa9MXxQstpQEShZr7qGq0YKfPJLRHYk7eRBvuzgA=; b=5fIXNYnNetiV+04MmnsynK2t20z23eX1XpVZ6SpmibFq7T1MzLhhQAnqcr4mW+kJM8 TjExkHt81xCy2rOC4XZgK7oxC4s3vXyzBW63orAXL3iSPi4OvMx0FUJZ3niQSAQWLHsl WLxdgTkMNEK5zSAaW372GUeb0ny6YF7G9fiW5tDsrIv+MhIJKhqCEW3Jtknrue+xMxFC 6sE7L3g7OlzBkPQoEWz3NOAz/8jhPWfmXPJqLgGP0u1y0zUklj807+zg6mQ0S5rLeSwk YsAebNZAcE0PJCKblnX6/wIxf6q+1paKRIVBBbk/QZVnmkC9UQEK7nVlKFR5Kwy4zD9v EiSw== X-Gm-Message-State: ACgBeo3BAdt72vTNcIUWSdeEZyphtzwRGgsGlUsPKGotiKiKsamwm37Q kjfthUAnaIL62hcQiHvJJApdmyJu9l0= X-Google-Smtp-Source: AA6agR4WvfRz1L4IA/1cFDkM/cL0jTMycWadjZ28kiMbaIG1Yl4jRRjjk/UnAf88vSPM3euL/nmWyg== X-Received: by 2002:a9d:4f0d:0:b0:638:b3a7:81a1 with SMTP id d13-20020a9d4f0d000000b00638b3a781a1mr1396568otl.266.1661523127454; Fri, 26 Aug 2022 07:12:07 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza Subject: [PATCH for-7.2 v4 04/21] hw/ppc: set machine->fdt in ppce500_load_device_tree() Date: Fri, 26 Aug 2022 11:11:33 -0300 Message-Id: <20220826141150.7201-5-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 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=2607:f8b0:4864:20::329; envelope-from=danielhb413@gmail.com; helo=mail-ot1-x329.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661523886333100001 This will enable support for 'dumpdtb' and 'info fdt' HMP commands for the e500 machine. Cc: C=C3=A9dric Le Goater Signed-off-by: Daniel Henrique Barboza --- hw/ppc/e500.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 32495d0123..6197a905b8 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -47,6 +47,8 @@ #include "hw/i2c/i2c.h" #include "hw/irq.h" =20 +#include + #define EPAPR_MAGIC (0x45504150) #define DTC_LOAD_PAD 0x1800000 #define DTC_PAD_MASK 0xFFFFF @@ -600,7 +602,16 @@ done: cpu_physical_memory_write(addr, fdt, fdt_size); } ret =3D fdt_size; - g_free(fdt); + + /* + * Update the machine->fdt pointer to enable support for + * 'dumpdtb' and 'info fdt' QMP/HMP commands. + * + * The FDT is re-created during reset, so free machine->fdt + * to avoid leaking the old FDT. + */ + g_free(machine->fdt); + machine->fdt =3D fdt; =20 out: g_free(pci_map); --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661524119; cv=none; d=zohomail.com; s=zohoarc; b=YwGBz62YQ5jGM0wrl8ZboSuIxYb8kUI5qtftKHHcGDE7xo88n++RqvSIGzX4FiyPovj/tNe2S7aEzdZzL4gchMwedjQNTjnQQ96DWvLTfcsl6V7gPa3MYsM/4cTl99fsyb4Y1DTtYYAqSpVh1NvqPrh109uZAl9azSRsFz4pPE4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661524119; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zGRC8t5xyo1fW95WY3WlgHuvRK6Iwk7AWvSowUXHy2c=; b=DoZzK1b6sirK9udB1qDTRLCf5mEIhfEjwFa4ZjObXkZB3Z5z/R46+4bgvcEC1PgRy5MlP9M0lpRoAugysC+cVQ5Hzo9wmxGez4g66AKSw4qVwlraoGZUAOZO89VHyhZejfGzHOAyfpjEJ857XkaT4FpgO+M3uwjeVU9Vi76tg38= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661524119279200.78912677617927; Fri, 26 Aug 2022 07:28:39 -0700 (PDT) Received: from localhost ([::1]:55362 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaK6-0006EB-8K for importer@patchew.org; Fri, 26 Aug 2022 10:28:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34188) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4G-0007md-3x; Fri, 26 Aug 2022 10:12:16 -0400 Received: from mail-ot1-x32e.google.com ([2607:f8b0:4864:20::32e]:34565) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4D-0003to-0y; Fri, 26 Aug 2022 10:12:15 -0400 Received: by mail-ot1-x32e.google.com with SMTP id q39-20020a056830442700b0063889adc0ddso1094028otv.1; Fri, 26 Aug 2022 07:12:11 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=zGRC8t5xyo1fW95WY3WlgHuvRK6Iwk7AWvSowUXHy2c=; b=hG6yFJW5aqv/dhiMilH5SH+/kGIiYXazwH/XIgIxksxMStTpG6P2NQjU74TAiqkwZe AZRDHYcMRcf1X8yLxzilRoHnyD4DY0NeGN7k8LvTV44q2bGsOOR9kSezf+nv/C+mxqAq JPNE7WqGKGAyMhVDZKJvgMPjQR515NHU4gcLdfm2LvxswhB4/08Z6CSsX60jP1EfF96W rI2sY9utY0YB1Cd53MXVu4eCt0ARM4rujz3B5cheZMVYQc77omJwfq7Xislp2NKzJpMW xjY3Lw8KDJbbt6sFysdix8qO5XduEDVK+dDteosn1b7Glmk0u2YP/036+l/NV0IOk9aE XV8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=zGRC8t5xyo1fW95WY3WlgHuvRK6Iwk7AWvSowUXHy2c=; b=MGoOBBQI+2KV+RmskgiqCbXEL65hNwqXMU7BrqBGRgQNCARDi5Q8UubneJOuva2nc2 EzugoscY/fUvChTTNo8gphlMY5QLEHsFUoYYoyC6Nvl+NoDBv6eb6VZO8gb124MBeyix hJgfSnnKqGu2Zd2BsQtv0J8HVdd5Nn2sdfKjO2TvN4SL/2GByuFky+chXkxbKk2vX/gQ VYCRRXDJjux6QSpf7PVJF0DkJ24116gQFvDPBX52AzXrhHvoCG2xyzb4RPc+pGqAKexW yZkg6A+2ZO303g4FXdEgdYabybndEE0/CGwgaunPUzA3sKVh1+X/ZaGNRr+BuFFg0ai+ MHtg== X-Gm-Message-State: ACgBeo2qmziiyw6aiA6Jp8gx3fqQlBFbdWSMP1X8VY5sDyyJABP1WrBS hspE/Bhwbiw3bC8Bq5cYvM0CMDqKe4I= X-Google-Smtp-Source: AA6agR4V9OeONoFHDNH7VoFQK1az0XEqQ8c/xariwSuBt4zxnZFX0cqTbLbulxfQh1GUzReZOnevdA== X-Received: by 2002:a05:6830:1196:b0:638:c5ca:6265 with SMTP id u22-20020a056830119600b00638c5ca6265mr1423259otq.63.1661523130271; Fri, 26 Aug 2022 07:12:10 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza Subject: [PATCH for-7.2 v4 05/21] hw/ppc: set machine->fdt in bamboo_load_device_tree() Date: Fri, 26 Aug 2022 11:11:34 -0300 Message-Id: <20220826141150.7201-6-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 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=2607:f8b0:4864:20::32e; envelope-from=danielhb413@gmail.com; helo=mail-ot1-x32e.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661524120312100001 This will enable support for 'dumpdtb' and 'info fdt' HMP commands for the bamboo machine. Cc: C=C3=A9dric Le Goater Signed-off-by: Daniel Henrique Barboza --- hw/ppc/ppc440_bamboo.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 873f930c77..9c89b23c08 100644 --- a/hw/ppc/ppc440_bamboo.c +++ b/hw/ppc/ppc440_bamboo.c @@ -34,6 +34,8 @@ #include "hw/qdev-properties.h" #include "qapi/error.h" =20 +#include + #define BINARY_DEVICE_TREE_FILE "bamboo.dtb" =20 /* from u-boot */ @@ -62,6 +64,7 @@ static int bamboo_load_device_tree(hwaddr addr, hwaddr initrd_size, const char *kernel_cmdline) { + MachineState *machine =3D MACHINE(qdev_get_machine()); int ret =3D -1; uint32_t mem_reg_property[] =3D { 0, 0, cpu_to_be32(ramsize) }; char *filename; @@ -116,7 +119,13 @@ static int bamboo_load_device_tree(hwaddr addr, tb_freq); =20 rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr); - g_free(fdt); + + /* + * Update the machine->fdt pointer to enable support for + * 'dumpdtb' and 'info fdt' QMP/HMP commands. + */ + machine->fdt =3D fdt; + return 0; } =20 --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661523643; cv=none; d=zohomail.com; s=zohoarc; b=kI9vWRd72cIzmDo/RAoVJnkqRrqgDc5tPtZkez2WsZs1nFNYzPNs+yAQ1L9dY0C90jzZ3eCXgq2kNiILcubphxE3v/e43FMIgCjghlhdO49gZrva2ztgGN3FxlVMT7SjG9ha1wjZC4G42CF5eG/ZWqOezUDgpImS/nIrrMqMP0I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661523643; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MnYaB9DJvwNH6aElOaN8rUTWZD25FX0c/ifXFFw+Ai4=; b=T/EA/EpRf+SkzeGb6VKj1VvVaLz6wZ9K6DmN93cfeicjplVi5N5kwI0+/Ek53JYH7OQxpa8+7CLXfuVX/JkaNiG/N29I3dJT4h3hHthH2dswrQvZvqlPo8FxZYAJRUPyRh2CMnEJKraIsPMY9iveapENMzbPPEt4AjiriIpHtwg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661523643606964.8469317487712; Fri, 26 Aug 2022 07:20:43 -0700 (PDT) Received: from localhost ([::1]:43940 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaCP-00011S-Et for importer@patchew.org; Fri, 26 Aug 2022 10:20:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4G-0007oN-GZ; Fri, 26 Aug 2022 10:12:16 -0400 Received: from mail-oi1-x230.google.com ([2607:f8b0:4864:20::230]:46768) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4E-0003x2-Uc; Fri, 26 Aug 2022 10:12:16 -0400 Received: by mail-oi1-x230.google.com with SMTP id o184so2085385oif.13; Fri, 26 Aug 2022 07:12:14 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=MnYaB9DJvwNH6aElOaN8rUTWZD25FX0c/ifXFFw+Ai4=; b=P1iTHxilagxISeKG9HP7MpOd8F5E/0ofxV34tuQvPrQRSp4DQG+KBjoawBrbo9eUm3 eZiuwmKrD+OyRVsfvEVkstRhG1PoZk2lNIaVcQWnxdGArmUFVCSaeo12wJrewRZY4d+Z ETVeTekb3/0rjQlwVkqwkxrtA4SLFXEgmoyMOB3GVqR+4U9NcEAl0fGAJ78S9r6MqCmy 7KIpGKLHDKtup0Frn5rN1k96YD8t0jZx9Jl2+eY1fqkDetKwjJpXB7+SYdevZ76YePdT OlKy0Zh5LfEKdGHC9O7r5Mzgj0OXsBxSq9MlK1+daqXIaW1RvDawlDgFRNHznVpSMeyG NQGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=MnYaB9DJvwNH6aElOaN8rUTWZD25FX0c/ifXFFw+Ai4=; b=VkRTR27e1Z0fxUZh9ibTBGyBodbnA+XMftbwDccYed/BM+lDhZg2tYmWtXqsKBUKfn x2pzAa5vlqKa7EnjX7hQIig1zI0YiV4eVwGQaAXT4rY5zgETdc/OKvXvDPZKsaWyBjjX u/m/DoZpE3gw5hn+C/R1rs5ZiXQGnluxOAbv4dxtJFb1dCrAaT2KAiW+KCiy62dT9E1u Uv53SJca1R0PMN0gh6rCxl8K+wnU1wIOGZYUnk27C+wFZz2nDImSScmm6LSccr0PCGtf 89qP8EZTNXSu+QLKMco7ly9vWphN1g5G5hCU80gUy9LjX3QRW8CTOHHPhWyJQRx+7Xbt +fZQ== X-Gm-Message-State: ACgBeo1IC5saAtJEgHbWsFzFzXeELdh9udu4K9XO0jDTZmwb6eYGX26J Xdv9SLufElRqQByjciMYf/ndpE+sCVM= X-Google-Smtp-Source: AA6agR7sGWWa+ONKHtaJ9VUxAFkwxRv3IyO1GJv+yZKQjoX8g1vMZz8UDC9dT+pu7lCUZCPBITErWA== X-Received: by 2002:a05:6808:1d9:b0:344:bb8d:588c with SMTP id x25-20020a05680801d900b00344bb8d588cmr1753175oic.87.1661523133145; Fri, 26 Aug 2022 07:12:13 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza , BALATON Zoltan Subject: [PATCH for-7.2 v4 06/21] hw/ppc: set machine->fdt in sam460ex_load_device_tree() Date: Fri, 26 Aug 2022 11:11:35 -0300 Message-Id: <20220826141150.7201-7-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::230; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x230.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661523645089100001 Content-Type: text/plain; charset="utf-8" This will enable support for 'dumpdtb' and 'info fdt' HMP commands for the sam460ex machine. Cc: BALATON Zoltan Signed-off-by: Daniel Henrique Barboza --- hw/ppc/sam460ex.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 0357ee077f..413a425d37 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -138,6 +138,7 @@ static int sam460ex_load_device_tree(hwaddr addr, hwaddr initrd_size, const char *kernel_cmdline) { + MachineState *machine =3D MACHINE(qdev_get_machine()); uint32_t mem_reg_property[] =3D { 0, 0, cpu_to_be32(ramsize) }; char *filename; int fdt_size; @@ -209,7 +210,12 @@ static int sam460ex_load_device_tree(hwaddr addr, EBC_FREQ); =20 rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr); - g_free(fdt); + + /* + * Update the machine->fdt pointer to enable support for + * 'dumpdtb' and 'info fdt' QMP/HMP commands. + */ + machine->fdt =3D fdt; =20 return fdt_size; } --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661523426; cv=none; d=zohomail.com; s=zohoarc; b=n8kQ77ecEe6c4lgFBhy2EgvVo5DEnY/byXbSTAA2l2cX6rORxl8UN2xz2D9UiK5dWfyf0X0iqg0MSNFTNIzdH4Vd+a36q++OlRvAtztN+k1Wu9axltsWRxoARN+CyjUcSJOEyfg8mZlgod6QiKsNB1XwWzA52S9MgfSzmF/R0bg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661523426; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=p2jAW4es8iU3F2bEOcgcbET+++QHlirQwEQQaRm1MtY=; b=IaT9a+5e4c8mMfqINRKvi5cbKx3nfTlwa2hMGhjE5IsnWgLPtJJLgx+e1/QqhXmz3m5BevCMujS6QbjkwYPBkh7GSRp70YycKNpttgCO0txeICajF886S+Vipv7vxkMvHf9ch1fsRlT5tIDfyX29tWsFKB0ivhJwCWuFX7O+oCo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661523426958272.8898426525616; Fri, 26 Aug 2022 07:17:06 -0700 (PDT) Received: from localhost ([::1]:34922 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRa8v-0005FW-V6 for importer@patchew.org; Fri, 26 Aug 2022 10:17:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34192) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4J-0007zl-96; Fri, 26 Aug 2022 10:12:19 -0400 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]:42666) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4H-0003xq-L2; Fri, 26 Aug 2022 10:12:18 -0400 Received: by mail-oi1-x229.google.com with SMTP id p187so2105301oia.9; Fri, 26 Aug 2022 07:12:16 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=p2jAW4es8iU3F2bEOcgcbET+++QHlirQwEQQaRm1MtY=; b=AldqHu+ZcvkJjfd/nkQiUs/jJsC+90rC5V8PTKJ03bZzAmmHqM7bvR+W7QimrF9xeV mnkiez97Qw9JxRJMzRUCUxl0cfixwJz8vrORTLP5SfTOguI4EBn9Mi+6EiurLy1IwewZ M9+KDbKvVvrsm4WHlnjN1qManQiU5Ci99TQ+UaW66zupNRD2eY0+myQ3DigOinzXH02h Q3FnQX7EMlRx8Xv9zTbllhAn/zKkvUJ37yIWAheuTrGvPFG6Hip0SNbYPscNNTrPM3Ar VZywOTXWsYOuqIxWjEQepjmRgbzzliD8RbSHx0TeIXkfN/IPyIoIBgm/tpyYFpFgq9Fr 2mKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=p2jAW4es8iU3F2bEOcgcbET+++QHlirQwEQQaRm1MtY=; b=HE8MOrsINW+mrPMSbEUmtuzeJHenkLtAjiSeiCNRV0jjRs4V167ORiEI/LI7kXX/df uDL07uucl79JKFmAuiIMS3VY0hMb1RZJsMME6QYAkNBgbwETsIVRjCBvAfcAa/gfCkN2 pFlXUoiHcZqU+VSbxvEeHoidAa9VkZGhdXFsFEwTTRnd7ubNWWsmJlFd5rpOAbROiTQI Zldal7gIjmtYoHgt5YVw0gn0vSGK5pfj/0OMwDUt71jD+lqJOP5gyy2ij7eeMzuSDCRe 730/D0+96O8pL2qG0xH0Ns+ZFsk7o/HYaBpbZHLyCODZAKunEWKlnsscLGp3TKo64cRt GrTQ== X-Gm-Message-State: ACgBeo1ptLhI7wJLKYmirTUm5sSEPx3m8olPd+BBTZFbosnvqg8wiTGO Qs9Zh1uio5maA4/Y8YCEf8KE4uzdW4U= X-Google-Smtp-Source: AA6agR5Q8PA0805pAj8f4Vz2O+HcKQXmuBZcqU3RdudnA2NZha6wrj6KLiKF8U6ixIFqz8ouo7UWNQ== X-Received: by 2002:a05:6808:1687:b0:32c:3e3e:89b1 with SMTP id bb7-20020a056808168700b0032c3e3e89b1mr1716221oib.60.1661523135827; Fri, 26 Aug 2022 07:12:15 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza , "Edgar E . Iglesias" Subject: [PATCH for-7.2 v4 07/21] hw/ppc: set machine->fdt in xilinx_load_device_tree() Date: Fri, 26 Aug 2022 11:11:36 -0300 Message-Id: <20220826141150.7201-8-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::229; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x229.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661523428265100001 Content-Type: text/plain; charset="utf-8" This will enable support for 'dumpdtb' and 'info fdt' HMP commands for the virtex_ml507 machine. Cc: Edgar E. Iglesias Signed-off-by: Daniel Henrique Barboza --- hw/ppc/virtex_ml507.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index 53b126ff48..9f4c5d85a4 100644 --- a/hw/ppc/virtex_ml507.c +++ b/hw/ppc/virtex_ml507.c @@ -45,6 +45,8 @@ #include "hw/qdev-properties.h" #include "ppc405.h" =20 +#include + #define EPAPR_MAGIC (0x45504150) #define FLASH_SIZE (16 * MiB) =20 @@ -153,6 +155,7 @@ static int xilinx_load_device_tree(hwaddr addr, hwaddr initrd_size, const char *kernel_cmdline) { + MachineState *machine =3D MACHINE(qdev_get_machine()); char *path; int fdt_size; void *fdt =3D NULL; @@ -197,7 +200,13 @@ static int xilinx_load_device_tree(hwaddr addr, if (r < 0) fprintf(stderr, "couldn't set /chosen/bootargs\n"); cpu_physical_memory_write(addr, fdt, fdt_size); - g_free(fdt); + + /* + * Update the machine->fdt pointer to enable support for + * 'dumpdtb' and 'info fdt' QMP/HMP commands. + */ + machine->fdt =3D fdt; + return fdt_size; } =20 --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661523693; cv=none; d=zohomail.com; s=zohoarc; b=U7wPDIdIoe9Ubd0DOIqemV9LiWe/ePAVs25CnMGxr91CGpaRskRngyNjzWZS3KXC50cKVsZxOmtNB0n9FibbRjj/VVIqQpLcSjbiz7oYX2U7TG4nqpBlFRit1wEcKhywyutgSKJcLmBgoUMd7bijqI0l6fMeCOrekZBh01yT2ew= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661523693; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Fq0fN3wHA48GNTZRD1sHCkuC5wNorM3KMo/gVJyzLng=; b=f3/BjD4+uDaFPC4ijmveihIQRTKO9/2BvccGeSLMFkvZ2ThVe2zFNIeouqzkWU53F2APVcrlK9gy+Qx7H/RviOoW8IA6My1FzeCiDR4nxCD3vRULCWG9nDcPgxXXVkwLDHcqxMI9Q/MBYfMD27IAZRTk7+/Wh9nM7t+Vcc/L7qc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661523693818958.6860136107221; Fri, 26 Aug 2022 07:21:33 -0700 (PDT) Received: from localhost ([::1]:40946 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaDD-0002rM-Hv for importer@patchew.org; Fri, 26 Aug 2022 10:21:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34198) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4M-00085B-6a; Fri, 26 Aug 2022 10:12:23 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]:39558) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4K-0003yU-Gr; Fri, 26 Aug 2022 10:12:21 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11cab7d7e0fso2183843fac.6; Fri, 26 Aug 2022 07:12:19 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=Fq0fN3wHA48GNTZRD1sHCkuC5wNorM3KMo/gVJyzLng=; b=n7g3xNpNfIcYjlEc6I9+k/zvhvJ0MTPgud32NPVtC1cibEXChK2lNU8o8I0Oc7c3kG 5wnDey016f2kxW4ELltj2SfecXFS2s9aM4XsPEtpXvNhqTcT/r1h6DZuHU62oqJVphRL vg21sf2YRac2IpJ6XTz4qDMk5jSkv87Y3TGI/POnijbQvr9lG9tt69PNuFp5CF83pI6T colMNPrFPDRLR7t4pDDnVG5fJpbHzNrOQAQhA8oWWq5OYleQV0PZowxSGkHDMWtHoyC3 UY6LS6PsquZtj5Y+ZUsiQuGp68PaOZazfVOrE8YOly6cEavt2JtTiWJqw74lFwKdL/4q +3dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=Fq0fN3wHA48GNTZRD1sHCkuC5wNorM3KMo/gVJyzLng=; b=nYpyEWw2OB/zfszhhgGybUdZfcn0OAql8h+yfmB/K8FmYZ+jrd2XmGVVqtl7vq7VX2 /4hoqWu8yYD6rrC+obigJzZwG20lH0TGHGm03bsJy5bO38nafx4XXfxYCtoYPDzGz7/p rLW+LIe+CWL2eEDvYouP+zO0xB8mAAqxVMpx1gOPJZii/ocWfs8+H65OLHe1f9Zod6gY ze0wSJcr5TOsYqvRj642Hpay3ejRLIoCobmhYqUNxajJfRFbr0ZbS4Wn0ltVn+DgKv5K pYDdIK4JdAB9P936HtKXdGZXv4vfv2Qv8glloP45n4YGoP5acgBfSfT4OcMpPacpNj4z yEoQ== X-Gm-Message-State: ACgBeo17AG1VQCvf64T2HU+Gai44jKoZj0/pggKgMUjfsIxWwSKnePgR n2kakNeKunRADNWO83K6/4IXCAhMwRY= X-Google-Smtp-Source: AA6agR7PG2o+PqUIYCzyM4bd4NaH9/Gaw9hYmP6OiXODmq2asi1SaJObHwI7MeSaAu0gC0QA8Sff4A== X-Received: by 2002:a05:6870:608e:b0:104:887d:4c64 with SMTP id t14-20020a056870608e00b00104887d4c64mr1986883oae.173.1661523138772; Fri, 26 Aug 2022 07:12:18 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza , BALATON Zoltan Subject: [PATCH for-7.2 v4 08/21] hw/ppc: set machine->fdt in pegasos2_machine_reset() Date: Fri, 26 Aug 2022 11:11:37 -0300 Message-Id: <20220826141150.7201-9-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::2f; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x2f.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661523695680100001 Content-Type: text/plain; charset="utf-8" We'll introduce QMP/HMP commands that requires machine->fdt to be set properly. Cc: BALATON Zoltan Cc: qemu-ppc@nongnu.org Signed-off-by: Daniel Henrique Barboza --- hw/ppc/pegasos2.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 61f4263953..624036d88b 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -331,6 +331,13 @@ static void pegasos2_machine_reset(MachineState *machi= ne) =20 vof_build_dt(fdt, pm->vof); vof_client_open_store(fdt, pm->vof, "/chosen", "stdout", "/failsafe"); + + /* + * Set the common machine->fdt pointer to enable support + * for 'dumpdtb' and 'info fdt' QMP/HMP commands. + */ + machine->fdt =3D fdt; + pm->cpu->vhyp =3D PPC_VIRTUAL_HYPERVISOR(machine); } =20 --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661524452; cv=none; d=zohomail.com; s=zohoarc; b=mtOYV936+FRTCs4Afn58jNKFJI1kBYwhWRa9NJ+JvprHY4Sd8X1IwnvVkdfL4UKmNjLeeESBRrHIOlsDd/DkgGH47v7coV5uODdsXWJcfm+AcXbS91QnbqEKr1NfNMahfDsaVQ24aNQOQCHUSooyyOCBRvJU/1G+4Lm2TnMYDQg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661524452; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+tgSxhNIGYEobQmCYPQhC6Jsb/JEojThXZIWNcaw8QA=; b=ZvDt5U8cIq95r/h5nazLrsMJsYPx5LbpQNpkj+WEDDgyaZDXTzaKOLKD6iNSo+0tpyyhXBGSP5EelXWHjye1ILNTJ0ogvClnywE0aePHew/oqtH+LOpFfCnwmvungeLUp+dqiTmG9dnFqIVEJ8C17SftAef++drp4JGM8frXMAs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661524452162468.04097424676684; Fri, 26 Aug 2022 07:34:12 -0700 (PDT) Received: from localhost ([::1]:57890 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaPT-0004DM-29 for importer@patchew.org; Fri, 26 Aug 2022 10:34:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4T-00087j-UT; Fri, 26 Aug 2022 10:12:29 -0400 Received: from mail-oi1-x235.google.com ([2607:f8b0:4864:20::235]:34527) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4N-0003ot-DC; Fri, 26 Aug 2022 10:12:24 -0400 Received: by mail-oi1-x235.google.com with SMTP id r10so2139081oie.1; Fri, 26 Aug 2022 07:12:22 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=+tgSxhNIGYEobQmCYPQhC6Jsb/JEojThXZIWNcaw8QA=; b=Dr6ruIKObcmYu4vMgPp12YaJro/dezFjmJOondjL1JrY/VNYcpygq5Woxy3K1flMy4 ujlBtbPJjT27jmKtCv4i8PRps2kRUqYvf+tp1GPfYGSukK0BduP2s5KrHDy/FLRV4CoN OoAlKUfjsiZElWr8FTQPfOvCcDnsbCIZYeddvnhj0fMwbhHCriCYqpG/JuoJr+UGmVr2 UCulrN60ev2jg28rPI0+i+TYJPMAJiWUJY/mkTQlhxHWO6H4Hp6xP0txfx4CFDH+wsyO 2L18MuWeOqkh8U9R01RKOpfTa0ynQJOo7pvRU56OUzc5Kbi71wzPZzvqja5S13gyh7Im o7qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=+tgSxhNIGYEobQmCYPQhC6Jsb/JEojThXZIWNcaw8QA=; b=Ue8CUO1yTHm31znfiiQuZRrlA4dcE8CB5BRDSAOdvVLd7d2pf4qyyInO7t1+So5cCl QR1sc5XzlYnq3H/x7jo24Rm3632RpV/v5JWIsfCm03+UJjxT/fKN1thvkeNp8Pi9NqO/ UPjKs2SEMgezctbTjr/IapZbd49hCugFEJc88TzhQpzZAsoDCbtoct4Wadxz5bz7bu4/ spcwAQk9Hy78YEiHuLtEnoQGj1jarSAYbD5sOEyi8phxGC+KUCdAVZDX5ZaEJfFIwwUc G8oOUoHiyaazadefY8aLQ/MjwKll9iepPcltY6H4bFyCUK8p96f8tZWAI3c817MmUp3C 5hsg== X-Gm-Message-State: ACgBeo2ugZyR62g4ZMvL6yKEeWJ5pr5wze5yNf/q/AVZ2/7dyWn+Gy46 zx6JO5X0OfBsYcu3QufFb+6Oj5E4+Jk= X-Google-Smtp-Source: AA6agR5wjJqiG1cOJx8vobq//zZYTB6Ng3eAc3iEl4Fvq9YEofj7Tk+ULduKjjPTL3SIHw/o3r1Wbg== X-Received: by 2002:a05:6808:f8d:b0:343:2d18:c866 with SMTP id o13-20020a0568080f8d00b003432d18c866mr1670333oiw.214.1661523141632; Fri, 26 Aug 2022 07:12:21 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza , Frederic Barrat Subject: [PATCH for-7.2 v4 09/21] hw/ppc: set machine->fdt in pnv_reset() Date: Fri, 26 Aug 2022 11:11:38 -0300 Message-Id: <20220826141150.7201-10-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 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=2607:f8b0:4864:20::235; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x235.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661524453275100001 This will enable support for 'dumpdtb' and 'info fdt' HMP commands for all powernv machines. Cc: C=C3=A9dric Le Goater Cc: Frederic Barrat Signed-off-by: Daniel Henrique Barboza --- hw/ppc/pnv.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index d3f77c8367..296995a600 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -608,7 +608,13 @@ static void pnv_reset(MachineState *machine) qemu_fdt_dumpdtb(fdt, fdt_totalsize(fdt)); cpu_physical_memory_write(PNV_FDT_ADDR, fdt, fdt_totalsize(fdt)); =20 - g_free(fdt); + /* + * Update the machine->fdt pointer to enable support for + * 'dumpdtb' and 'info fdt' commands. Free the existing + * machine->fdt to avoid leaking it during a reset. + */ + g_free(machine->fdt); + machine->fdt =3D fdt; } =20 static ISABus *pnv_chip_power8_isa_create(PnvChip *chip, Error **errp) --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661524870; cv=none; d=zohomail.com; s=zohoarc; b=OBpRg38uv8hBi6j3uO2LGyYxj0uBU95v5WFJ5oqUiM7hvlYKDpu6JH4I3Ro5BVJs1b+S/SMpneD08nHecyeziNaBUIGanPG/oVmgEn138W1jphQyHGNQ1eCZwFbckmYg0FfCgNTRJsI4SjZjj4FFyB2BSfXaX4WzEd+lz/6jOYo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661524870; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=g67u4yFDZGr4nwwRQGD4i/TkPZEjAEmcKuspVyC0JdY=; b=I4LMrBx6jOsTIcLmOH74X8tIs90ZlfoiSgD/eHvBjHM65GbKERMFsJby3MAn67B7bSxq1eyXCEgwXZD3e7WJOlwrU0T8f8LvjmFE1Jz/R4pEuQyUbO+9/QJfets/Oo5quEQXAz/rzpOF1AIBQVgy5Zsr/+Xtyj6LV4rj1mX6Hmw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661524870937587.147415659492; Fri, 26 Aug 2022 07:41:10 -0700 (PDT) Received: from localhost ([::1]:53160 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaWD-0001vw-Tc for importer@patchew.org; Fri, 26 Aug 2022 10:41:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4W-0008CL-5E; Fri, 26 Aug 2022 10:12:32 -0400 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]:38516) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4T-0003zR-UR; Fri, 26 Aug 2022 10:12:31 -0400 Received: by mail-oi1-x233.google.com with SMTP id w197so2120262oie.5; Fri, 26 Aug 2022 07:12:25 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=g67u4yFDZGr4nwwRQGD4i/TkPZEjAEmcKuspVyC0JdY=; b=APVExvu7QiDCY+VgnWtrP7hcp7Xchs3IkhQNVqZIX7GyRAMyY6kBUlnwOaAfjJfwdj XYeoJOcFfuRfcmfgSBmRai110ZegGuTqYaDT+ED01sJYF56/VE0Gp8zK9IH1IS6A4ezt Fr7NEwATGjl+s19JRCZ/yxSNrd744QEMbyoN8WpIJAau4pp99wroDkGl/T4LdBzg4/F5 5qTmeBkJWITaJG9qgDwuCQ8ObfLbippf+KlkNuUVgmHO9aoJ+Siiy8jHlinRj8F31L5t GTYeFLYhSs/oVirSAO4XP6ziRBFeKTF8DwB+/kMeJAUWv842kROaBk2ltE8jttnXRIYs dw7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=g67u4yFDZGr4nwwRQGD4i/TkPZEjAEmcKuspVyC0JdY=; b=1vATVA2g595tc8qJODLEwfnm1fhlgvIsQU8P9+zSIrOrKeRc2DBCZj089KQqFupw9B KbP0OMNtoHB5U+N2IImBnIYlksx131fq18TtE9ZuQbhXaYciN2FXPIaC8GQsjXANkwSE bMaRuzsKmxJx0rzXAj7nGFEltnRkFMtNoZ3pOBgUag+r10uK7eZXmWTqASv213DX5qiu EOaeuUt6A9vqlF6VazzYfAvev0B8CR6l+kc6suMe9aVPLioNQxlhYNgSZeyo1DTyQKea MMqMHSD7eEvG8hCTKppww99r2chCPEQ54DiaQiw0GUjhuRdPqBHWxsH4p9K7y8bvrhPf uNNA== X-Gm-Message-State: ACgBeo2In2sF+0gGpZ92pckRiRe0bLfjLpQycI9xxtwFMpJFlvVI5UEw iYd22wGz95T5Mwh9ctMJkD4z0Rhyo8g= X-Google-Smtp-Source: AA6agR7OEOcRfBYVgM8o3oyVe7wvDmmu+eytnkzMaaiU0bjYCxNnwK4gu0CoUc+KNjau6LUzwo7YQQ== X-Received: by 2002:a05:6808:20a0:b0:343:2cd0:9707 with SMTP id s32-20020a05680820a000b003432cd09707mr1759765oiw.132.1661523144202; Fri, 26 Aug 2022 07:12:24 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza Subject: [PATCH for-7.2 v4 10/21] hw/ppc: set machine->fdt in spapr machine Date: Fri, 26 Aug 2022 11:11:39 -0300 Message-Id: <20220826141150.7201-11-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 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=2607:f8b0:4864:20::233; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x233.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661524872369100001 The pSeries machine never bothered with the common machine->fdt attribute. We do all the FDT related work using spapr->fdt_blob. We're going to introduce HMP commands to read and save the FDT, which will rely on setting machine->fdt properly to work across all machine archs/types. Let's set machine->fdt in two places where we manipulate the FDT: spapr_machine_reset() and CAS. There are other places where the FDT is manipulated in the pSeries machines, most notably the hotplug/unplug path. For now we'll acknowledge that we won't have the most accurate representation of the FDT, depending on the current machine state, when using these QMP/HMP fdt commands. Making the internal FDT representation always match the actual FDT representation that the guest is using is a problem for another day. spapr->fdt_blob is left untouched for now. To replace it with machine->fdt, since we're migrating spapr->fdt_blob, we would need to migrate machine->fdt as well. This is something that we would like to to do keep our code simpler but it's also a work we'll leave for later. Cc: C=C3=A9dric Le Goater Cc: qemu-ppc@nongnu.org Signed-off-by: Daniel Henrique Barboza Reviewed-by: David Gibson --- hw/ppc/spapr.c | 6 ++++++ hw/ppc/spapr_hcall.c | 8 ++++++++ 2 files changed, 14 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index bc9ba6e6dc..7031cf964a 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1713,6 +1713,12 @@ static void spapr_machine_reset(MachineState *machin= e) spapr->fdt_initial_size =3D spapr->fdt_size; spapr->fdt_blob =3D fdt; =20 + /* + * Set the common machine->fdt pointer to enable support + * for 'dumpdtb' and 'info fdt' QMP/HMP commands. + */ + machine->fdt =3D fdt; + /* Set up the entry state */ first_ppc_cpu->env.gpr[5] =3D 0; =20 diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index a8d4a6bcf0..a53bfd76f4 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1256,6 +1256,14 @@ target_ulong do_client_architecture_support(PowerPCC= PU *cpu, spapr->fdt_initial_size =3D spapr->fdt_size; spapr->fdt_blob =3D fdt; =20 + /* + * Set the machine->fdt pointer again since we just freed + * it above (by freeing spapr->fdt_blob). We set this + * pointer to enable support for 'dumpdtb' and 'info fdt' + * QMP/HMP commands. + */ + MACHINE(spapr)->fdt =3D fdt; + return H_SUCCESS; } =20 --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661523888; cv=none; d=zohomail.com; s=zohoarc; b=U0/4t4xiFX7c4HO3cHSxM+snLPtfzlfxG5uKwjHNXAgxYR4EI3mx+HUwj5q+vKlsax4zF4HIqBkrEv/F3B0pDDSEoClODdc7CYCBmTAWasXLONDWSNZcxqAg0CatbHIxYYedWFTi9X9RZt4alsMH4pvDvnolr71wjqCof9lNwcU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661523888; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=c4DO02fMggKj77kLQLbQjKWFx6/+KdtQ2bkm4VISnXU=; b=E0I6ihWH2S8zTIZQrLgyagMyG0RP4pygDoeBAM83tZWlGh8EPceg4CBJdjBQ2+6R6vFV3xd0pZSQZ9BWfDRrRL03THfBOt4pp2lUiD+fRDnaoeMSEotIdaBz+cEMI9M36B7W3vbyTnbS5iioPZrYgI2iq4Jbsh8ZVXm8ki0ajf8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661523888270622.9350457620645; Fri, 26 Aug 2022 07:24:48 -0700 (PDT) Received: from localhost ([::1]:40506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaGN-0000I3-4Z for importer@patchew.org; Fri, 26 Aug 2022 10:24:47 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43690) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4V-0008CJ-Cd; Fri, 26 Aug 2022 10:12:32 -0400 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]:43721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4T-0003zt-UT; Fri, 26 Aug 2022 10:12:31 -0400 Received: by mail-oi1-x232.google.com with SMTP id w196so2103690oiw.10; Fri, 26 Aug 2022 07:12:28 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=c4DO02fMggKj77kLQLbQjKWFx6/+KdtQ2bkm4VISnXU=; b=X22we7pGJG5Hy61HFQyLJ67kAxc0Lbt6tROZD5iAxekoeUh3U8LhQJMXgtGlr9bsEl 6wX4/qaQZO27b5uvCUW3Tt630NXPxwFi3b0+wm2hspcBNNV3uOwGcj4x/C+xxHRQsz3S eILTT+bss5wFWXTxoVQ4EDKcHb2dgaHscfi9FT+C6/ws/nTy37q7hl9GAjaMu8DQxpYQ ocQgTDV6FS7lGRhuzLx/E3iCIQCpOoeJEX/96SnaWxE+Ny1R7uoJ3WYHhbiY+Bl2JwQf a5rhyVkLGjyijQhUvqsLTVMgH4oyxLqWjFqJgRQ/u5vZzU/DfR01S02NTx3P2XirV1wi n/Ow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=c4DO02fMggKj77kLQLbQjKWFx6/+KdtQ2bkm4VISnXU=; b=T+4r3Pk492K3yqINxm8dI+9Cd+Xk7SfArrVSy8Qn1oVEsLkn2vWur9ydzHRt27EEz1 hX9IzbxmgcazPeuHnB7cLHXVpMhUM+vcRzYl0KPDFB3caBpigcEsnm/jJLogMvvCbD7V iyNvuXb9YBuvXjbKpEUUNi+ZGbwxOaFHWCR9xBVfXRcujaQFT5QPAKStqJQQSIL4aMFN 9MSfM+LH/FputUwSb3G+miJm+P7vQgiCW9nELyRRjYyaotYu6x/7eCNzPVE5ec3B3wu1 a4hmIOwe1ixjc5KGqIFCPaQEQBFcyZiG6bid8N554XkACq2yj8CaZMnBi4gbM1EWd3Jv 9LaQ== X-Gm-Message-State: ACgBeo0iu7yABYZwMm3o9ZzFRBkJhUBLn0tPj5LFo2GriN2TUdwvJpxo ieP+rGI+oakKWUtrukL3wiLEAGbSvxk= X-Google-Smtp-Source: AA6agR7okurD3pmkxTQteYD7l+QWZDnzEraA0mCHogeG0+dRkEiBcKRuHu1FaDrI84FvgQYDSBRniQ== X-Received: by 2002:a05:6808:201e:b0:343:6192:1e21 with SMTP id q30-20020a056808201e00b0034361921e21mr1725215oiw.277.1661523147390; Fri, 26 Aug 2022 07:12:27 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza , Alistair Francis , Bin Meng , Palmer Dabbelt Subject: [PATCH for-7.2 v4 11/21] hw/riscv: set machine->fdt in sifive_u_machine_init() Date: Fri, 26 Aug 2022 11:11:40 -0300 Message-Id: <20220826141150.7201-12-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::232; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x232.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661523890676100001 Content-Type: text/plain; charset="utf-8" This will enable support for 'dumpdtb' and 'info fdt' HMP commands for the sifive_u machine. Cc: Alistair Francis Cc: Bin Meng Cc: Palmer Dabbelt Reviewed-by: Alistair Francis Signed-off-by: Daniel Henrique Barboza --- hw/riscv/sifive_u.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index e4c814a3ea..f14d8411df 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -634,6 +634,12 @@ static void sifive_u_machine_init(MachineState *machin= e) start_addr_hi32 =3D (uint64_t)start_addr >> 32; } =20 + /* + * Update the machine->fdt pointer to enable support for + * 'dumpdtb' and 'info fdt' QMP/HMP commands. + */ + machine->fdt =3D s->fdt; + /* reset vector */ uint32_t reset_vec[12] =3D { s->msel, /* MSEL pin state */ --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661523887; cv=none; d=zohomail.com; s=zohoarc; b=HQbwnScKXPxyEeMtxAG62FdceFfrMk3x9G1JyAgDYKQ+5Z/Cx4L2TwYZrtvk80b6bXO6U1GJ/5v/iiecGCEQtS9WQ08bsnXF66Au8L/F9iGYjqJwt4vsqxs4bK4HPyUN3xgYYDxWSlXy/wghRwDiuFKQ/9K0m7AFIgi4kwvLIdE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661523887; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PLxCnDavL3XAQX8RlAlWZXySX+ubp7/4OOfpwRVaIdY=; b=m+hi3429mrVfrrBqf/PZBg/sD7261hpxqDz96dXjGYiAyF3IPpbrgrN90qPDri6eC3RGjGPxKyXqGDlM3b9YW7VneUKaeXWCLVMfvC80QmMpdKKnRHDqAKTjcsmrU5yxFnRKILpWCc4Aoi/V1AaYLDk5uyHO7s4aAXIQosgtDWI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661523887104534.5925910548534; Fri, 26 Aug 2022 07:24:47 -0700 (PDT) Received: from localhost ([::1]:40504 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaGM-0000Ai-5G for importer@patchew.org; Fri, 26 Aug 2022 10:24:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:43696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4X-0008Dv-Tm; Fri, 26 Aug 2022 10:12:36 -0400 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]:40829) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4W-00040a-EJ; Fri, 26 Aug 2022 10:12:33 -0400 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-11d2dcc31dbso2184681fac.7; Fri, 26 Aug 2022 07:12:31 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=PLxCnDavL3XAQX8RlAlWZXySX+ubp7/4OOfpwRVaIdY=; b=AZNTvMppp4bPra/lwMf0liAKErAZqwPwCvSjt7tH3OamR3vXZE8p+JZrajMo4ydTSW D0OEosBQoPYMvFR4KLVJRFnlinX83nNe29lsFuoh0Um6pXRF05EAReiACsASCMAuq/Bd w2H+MMJYDkI3g6QedxVypgQVSGToE//j7Ti/kDBMxNQHWoI2v3MR03C8S1hjEO/TzaUz FBc54itBA1fm8DJj07/pcmJ7UrlToWgohjvat3OcKN9/g0HUATHFkKFaed2Mne1qqANV 1wbVUHbDBJM3ukOtHLxRuTg/vkJU4qN00002IPCrks8hCuemDKBJTxsWrG17+Q5OLRqR 1q+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=PLxCnDavL3XAQX8RlAlWZXySX+ubp7/4OOfpwRVaIdY=; b=wzGNspxCYjxZfJq/oj1jmwAeN2c6mNPuWYfwtZ2coCmUUV7AWZDABNzStOG2xniCNY QaHE+H8Oi2KzH/JjFw8OPidE0Me8G7/8k+726sSBW2BTRcYM6QrmgHTPecS0WyKYf9bR WgYDbuoNGGoG3lkFWoZukl395JwAGvj2FXFGe+z0ocoBymRblZmJdMlOAxxnqLLO1BDX AOwKh1YpCXAi4T/6I87wulEfNoiKE/mMPvLYpnrKY24brnPyH0dyg776HEot5OkxH15c vG4i/YX+yPmoyUTAK5WuFykh8OCDGqgOL/Iuxocmz/GzK5VC9We9ps0RKrPtaVVVDn5N jI4A== X-Gm-Message-State: ACgBeo0NLdXE5qj/R5tCOWonn8OyJEtAbI7FW60Okoq9zeYlXe9TfDqO H1EnFSUkObwd+9qYe6RyXM1FkyjjhGA= X-Google-Smtp-Source: AA6agR7Dxyq0cEfo7wHc8aXbyZIvIzeo06PmX9KNU5m/bGuOrS0MYR7nFbA5gAKgVguufPEWka9zoQ== X-Received: by 2002:a05:6870:89a9:b0:101:d81d:e970 with SMTP id f41-20020a05687089a900b00101d81de970mr1904032oaq.43.1661523150563; Fri, 26 Aug 2022 07:12:30 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza , Palmer Dabbelt , Bin Meng Subject: [PATCH for-7.2 v4 12/21] hw/riscv: set machine->fdt in spike_board_init() Date: Fri, 26 Aug 2022 11:11:41 -0300 Message-Id: <20220826141150.7201-13-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::2d; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x2d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661523888396100001 Content-Type: text/plain; charset="utf-8" This will enable support for 'dumpdtb' and 'info fdt' HMP commands for the spike machine. Cc: Palmer Dabbelt Cc: Alistair Francis Cc: Bin Meng Reviewed-by: Alistair Francis Signed-off-by: Daniel Henrique Barboza --- hw/riscv/spike.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c index e41b6aa9f0..17f517bfa6 100644 --- a/hw/riscv/spike.c +++ b/hw/riscv/spike.c @@ -40,6 +40,8 @@ #include "sysemu/device_tree.h" #include "sysemu/sysemu.h" =20 +#include + static const MemMapEntry spike_memmap[] =3D { [SPIKE_MROM] =3D { 0x1000, 0xf000 }, [SPIKE_HTIF] =3D { 0x1000000, 0x1000 }, @@ -304,6 +306,13 @@ static void spike_board_init(MachineState *machine) /* Compute the fdt load address in dram */ fdt_load_addr =3D riscv_load_fdt(memmap[SPIKE_DRAM].base, machine->ram_size, s->fdt); + + /* + * Update the machine->fdt pointer to enable support for + * 'dumpdtb' and 'info fdt' QMP/HMP commands. + */ + machine->fdt =3D s->fdt; + /* load the reset vector */ riscv_setup_rom_reset_vec(machine, &s->soc[0], memmap[SPIKE_DRAM].base, memmap[SPIKE_MROM].base, --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661524127; cv=none; d=zohomail.com; s=zohoarc; b=K7AB3vc2HDhic0OH49TkUJ7esFE/s9Es6AaAaLTQlaKpMYDjmupBWuHD+F8b0FeCsOqAbDaEV94cbQ9B1QsEP4YzeENJoFkD1v8DXzMHo0CzhjEvRkckmXdc5KhpeOpZzGHqaw3pKShAThg3A/STUSNXw2RHBHztOT7tO+t9RiQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661524127; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VjEUJrauZWG7jLw/LnT3q5WD0y/yipGHIYjGqvGy4S4=; b=XsVtaIXTX0RAqHIxlfkN3TI38DzwOQlNmI7isTwgVUjJ8iWjOsQDOKUOfDzG03R172NTXeUTBPFKacPPOZiNsldKJg52WEn7xdN980sOmzoF/09KW0n6h72Ud2nO04E8bqyTW1f67iyJyVwDyQXiMt68zcx97BnCsGRDl6G2blY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661524127348835.5732902652419; Fri, 26 Aug 2022 07:28:47 -0700 (PDT) Received: from localhost ([::1]:45400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaKD-0006U1-8v for importer@patchew.org; Fri, 26 Aug 2022 10:28:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48912) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4a-0008E6-IT; Fri, 26 Aug 2022 10:12:36 -0400 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]:41651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4Y-000421-Kr; Fri, 26 Aug 2022 10:12:35 -0400 Received: by mail-oi1-x236.google.com with SMTP id t140so2111833oie.8; Fri, 26 Aug 2022 07:12:34 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=VjEUJrauZWG7jLw/LnT3q5WD0y/yipGHIYjGqvGy4S4=; b=Jloh7lAhPBNVGxQiLSrp3UNHVOhjMyS+OfkoQ7Ywi/+e39xMoUQ3saTD+2Sl9E17Im 5F3BJj4vSth2Kuts5NyF+yclGkIEm1UX9684E92axjKs2uOuU5UeDoodpVnf9Jm4IXjX PbJq2Wjk/rxspFgTvGll2LFpctiUdI4hFTflptFYP7R3ExLArA1JojkwWSYaqXrW7wtd 21Ku+KO/gc5xaL7lfBX7WGwbNArU7fzLX02QyVEgCnsJIQ1RxXQ4y1Mw9XfhSOkdgl3o SjDqs4l35Uq92CBuFvYAjPByuSlO5VQ1V83y2xuqmo4zj2hjM1ctA0aA4M7MRF803ZF+ janQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=VjEUJrauZWG7jLw/LnT3q5WD0y/yipGHIYjGqvGy4S4=; b=itjWzbeuisxgHkPgbnNoy40p8ei1BosZpcAGbMBNkkaU8vhjb5c8MqA7Al4RKl+Bly SYWj45XKZU11FyDI3RhLy0RuPY00ZnV0jotFineBO+xHEOqCrAxhnSAnnfvB4EkoSdk7 Yk624/javVwgcZndrRvsV0Mvo0WZARs7+tVuSXxPou3Cm86lExbILGWULtzLWFGCcvzG R84rhePn3hJrq1oFMgG7upUnnhUoEZwDziBhdkc8k+dm+blqSqaDKCsaAn+g8BRaoZNl S2ZtfGNrO8+BzAhAGzRIbscK+X4lqnXZJDSyiUtaUYJEBOOGACqC5XuNTL5Gld3E1LoI yZOQ== X-Gm-Message-State: ACgBeo18/tiCAULfVp6RsoEYAHgGGZZUhW0cJoDBFZWvL+oJMCFpoEPS pe4AJzU9wnGWru/XS19NRCklCRh9pFE= X-Google-Smtp-Source: AA6agR4neHzCSMNbc8Gmv8zwNqN/G4CudBFpBqZ66He6OkZdOBQUn5u5P1UAYh5UIbfd8nEa+L75hQ== X-Received: by 2002:a05:6808:bcd:b0:344:d614:c5e with SMTP id o13-20020a0568080bcd00b00344d6140c5emr1685585oik.78.1661523153044; Fri, 26 Aug 2022 07:12:33 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza Subject: [PATCH for-7.2 v4 13/21] hw/xtensa: set machine->fdt in xtfpga_init() Date: Fri, 26 Aug 2022 11:11:42 -0300 Message-Id: <20220826141150.7201-14-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x236.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661524128143100001 Content-Type: text/plain; charset="utf-8" This will enable support for 'dumpdtb' and 'info fdt' HMP commands for all xtensa machines that uses a FDT. Signed-off-by: Daniel Henrique Barboza --- hw/xtensa/meson.build | 2 +- hw/xtensa/xtfpga.c | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/xtensa/meson.build b/hw/xtensa/meson.build index 1d5835df4b..ebba51cc74 100644 --- a/hw/xtensa/meson.build +++ b/hw/xtensa/meson.build @@ -6,6 +6,6 @@ xtensa_ss.add(files( )) xtensa_ss.add(when: 'CONFIG_XTENSA_SIM', if_true: files('sim.c')) xtensa_ss.add(when: 'CONFIG_XTENSA_VIRT', if_true: files('virt.c')) -xtensa_ss.add(when: 'CONFIG_XTENSA_XTFPGA', if_true: files('xtfpga.c')) +xtensa_ss.add(when: 'CONFIG_XTENSA_XTFPGA', if_true: [files('xtfpga.c'), f= dt]) =20 hw_arch +=3D {'xtensa': xtensa_ss} diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 2a5556a35f..9e2f911caa 100644 --- a/hw/xtensa/xtfpga.c +++ b/hw/xtensa/xtfpga.c @@ -50,6 +50,8 @@ #include "hw/xtensa/mx_pic.h" #include "migration/vmstate.h" =20 +#include + typedef struct XtfpgaFlashDesc { hwaddr base; size_t size; @@ -377,7 +379,12 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, = MachineState *machine) cur_tagptr =3D put_tag(cur_tagptr, BP_TAG_FDT, sizeof(dtb_addr), &dtb_addr); cur_lowmem =3D QEMU_ALIGN_UP(cur_lowmem + fdt_size, 4 * KiB); - g_free(fdt); + + /* + * Update the machine->fdt pointer to enable support for + * 'dumpdtb' and 'info fdt' QMP/HMP commands. + */ + machine->fdt =3D fdt; } #else if (dtb_filename) { --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661524196; cv=none; d=zohomail.com; s=zohoarc; b=dL1BuSy6SrPNUgbRcas4OzdNcbvXhjSDCArInewu7sMYyq4m4tyghFGL5vduU6eglw0uTuuIzIiCEenSxex1A3OxVP514QsKgVbTqbz+Ld2G93Q49XM/NCr5t5peycJMpqgJ67F+MPmqzMdCZ5GKpmTT12pN5qnJieDHJjhOayQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661524196; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jVoGGNXMdLWVBeU6goBOpT7H07W5qN2vMSAqWjeDRSw=; b=GryepNACDX59AwYCIuLeF6qXJ+wdhwwstm5X585ng7+V5+uh2LXO3eXq+ZgkiCyTZX2d3mbVpN29o4/JbDaF+D7qlQkkWmO5rznC7gDCbDJCd2J8hYm5OP2+XkHRmOGHQ1uJVfSXm6eKSgHPnhx+RMbv1V1yEYzKQD8TtP7qm9M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661524196523842.3969490510875; Fri, 26 Aug 2022 07:29:56 -0700 (PDT) Received: from localhost ([::1]:36418 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaLK-0007xn-Ay for importer@patchew.org; Fri, 26 Aug 2022 10:29:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48916) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4c-0008Ff-WC; Fri, 26 Aug 2022 10:12:43 -0400 Received: from mail-oi1-x229.google.com ([2607:f8b0:4864:20::229]:42666) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4b-0003xq-4S; Fri, 26 Aug 2022 10:12:38 -0400 Received: by mail-oi1-x229.google.com with SMTP id p187so2106351oia.9; Fri, 26 Aug 2022 07:12:36 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=jVoGGNXMdLWVBeU6goBOpT7H07W5qN2vMSAqWjeDRSw=; b=KauDos761N8d9qNn5h2KfB+XnFxBbVueWyuVWiML2wr1ZVVrZDmC914/E3A2ZI4i5E fQg0ADs4+alXZWyzBqEhIJOVEfOgV1FO/s5QqGJZ5/M8WnsNHSFjGVNgL7VwzGVJMihd OY2tkDR0zxx2p5RwmbeqDfO2PNnvXSG0zZqm9yy+z5R4D2XdJLhndxOavVL0dZyyYWNi qOcEdMeZ5GjnE6FkRqfzmpMr7yAcuWiD7qp1m6xxhc3ypBx2MjCDYEMwOVXFi78CT5Fv suAM0wYHfzXib9KrHO4O8QE7jowZi3ZBW0fuf6AuNSry2FyP1WZdXwRy9xewdLAjlkMA JIJg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=jVoGGNXMdLWVBeU6goBOpT7H07W5qN2vMSAqWjeDRSw=; b=u8MUzAqVdb6BCc+98KZbiXZMwIUZ9AKkNSnkWb2c3twTC5GWS3r7Kh0TN0rjn+qK3g Y8Bp5sqLnMfcknZL/qwbfR5P/fz8/bJeUAw8ZCCkPbv57tkiyTYs6eKptr6mk5UW9Y+D Ht21tEOupxRJhUm7i0THcximwSPHWB9BsiSi0NaLXYon59sLHPuo830ZOPL2wrSydeLj aK7KzsixW/CEFBEv2sm3r8JAoAfxfnhbJZWMMBR9Dlc0Hdf+BYZ5DUlFImXBErLEYPu8 a2DMtB/31WQaemj0PLrpzFjn0EwCfdLBHPfmUDjMXcgLjcwWlZ8VFjwrp775zORFWdKX Zgrg== X-Gm-Message-State: ACgBeo08MBpy3erJ9X37afw79IDIq1/VK2KHQd4Pa5EPlW2NVB07xo4f jD6SX7mtrPhUZfhtCPkOZHvsuYzqb0k= X-Google-Smtp-Source: AA6agR6uUV41dy2UKcX+plQ5KCY12SsZmzGQapsOvTtoC/73KpQTQKjmusvj3btAw16WOPLIi5hYzg== X-Received: by 2002:a05:6808:14c4:b0:343:7905:bbab with SMTP id f4-20020a05680814c400b003437905bbabmr1690218oiw.93.1661523155901; Fri, 26 Aug 2022 07:12:35 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza , "Dr . David Alan Gilbert" Subject: [PATCH for-7.2 v4 14/21] qmp/hmp, device_tree.c: introduce dumpdtb Date: Fri, 26 Aug 2022 11:11:43 -0300 Message-Id: <20220826141150.7201-15-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::229; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x229.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661524196796100001 Content-Type: text/plain; charset="utf-8" To save the FDT blob we have the '-machine dumpdtb=3D' property. With this property set, the machine saves the FDT in and exit. The created file can then be converted to plain text dts format using 'dtc'. There's nothing particularly sophisticated into saving the FDT that can't be done with the machine at any state, as long as the machine has a valid FDT to be saved. The 'dumpdtb' command receives a 'filename' paramenter and, if a valid FDT is available, it'll save it in a file 'filename'. In short, this is a '-machine dumpdtb' that can be fired on demand via QMP/HMP. A valid FDT consists of a FDT that was created using libfdt being retrieved via 'current_machine->fdt' in device_tree.c. This condition is met by most FDT users in QEMU. This command will always be executed in-band (i.e. holding BQL), avoiding potential race conditions with machines that might change the FDT during runtime (e.g. PowerPC 'pseries' machine). Cc: Dr. David Alan Gilbert Reviewed-by: Alistair Francis Signed-off-by: Daniel Henrique Barboza --- hmp-commands.hx | 13 +++++++++++++ include/monitor/hmp.h | 1 + include/sysemu/device_tree.h | 1 + monitor/hmp-cmds.c | 12 ++++++++++++ monitor/qmp-cmds.c | 13 +++++++++++++ qapi/machine.json | 17 +++++++++++++++++ softmmu/device_tree.c | 18 ++++++++++++++++++ 7 files changed, 75 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 182e639d14..2dd737078e 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1800,3 +1800,16 @@ ERST "\n\t\t\t\t\t limit on a specified virtual cpu", .cmd =3D hmp_cancel_vcpu_dirty_limit, }, + +SRST +``dumpdtb`` *filename* + Save the FDT in the 'filename' file to be decoded using dtc. + Requires 'libfdt' support. +ERST + { + .name =3D "dumpdtb", + .args_type =3D "filename:F", + .params =3D "filename", + .help =3D "save the FDT in the 'filename' file to be decoded= using dtc", + .cmd =3D hmp_dumpdtb, + }, diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index a618eb1e4e..d7f324da59 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -134,6 +134,7 @@ void hmp_calc_dirty_rate(Monitor *mon, const QDict *qdi= ct); void hmp_set_vcpu_dirty_limit(Monitor *mon, const QDict *qdict); void hmp_cancel_vcpu_dirty_limit(Monitor *mon, const QDict *qdict); void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDict *qdict); +void hmp_dumpdtb(Monitor *mon, const QDict *qdict); void hmp_human_readable_text_helper(Monitor *mon, HumanReadableText *(*qmp_handler)(Erro= r **)); void hmp_info_stats(Monitor *mon, const QDict *qdict); diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h index ef060a9759..bf7684e4ed 100644 --- a/include/sysemu/device_tree.h +++ b/include/sysemu/device_tree.h @@ -136,6 +136,7 @@ int qemu_fdt_add_path(void *fdt, const char *path); } while (0) =20 void qemu_fdt_dumpdtb(void *fdt, int size); +void qemu_fdt_qmp_dumpdtb(const char *filename, Error **errp); =20 /** * qemu_fdt_setprop_sized_cells_from_array: diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index c6cd6f91dd..1c7bfd3b9d 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -2472,3 +2472,15 @@ exit: exit_no_print: error_free(err); } + +void hmp_dumpdtb(Monitor *mon, const QDict *qdict) +{ + const char *filename =3D qdict_get_str(qdict, "filename"); + Error *local_err =3D NULL; + + qmp_dumpdtb(filename, &local_err); + + if (local_err) { + hmp_handle_error(mon, local_err); + } +} diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 7314cd813d..8415aca08c 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -45,6 +45,7 @@ #include "hw/intc/intc.h" #include "hw/rdma/rdma.h" #include "monitor/stats.h" +#include "sysemu/device_tree.h" =20 NameInfo *qmp_query_name(Error **errp) { @@ -596,3 +597,15 @@ bool apply_str_list_filter(const char *string, strList= *list) } return false; } + +#ifdef CONFIG_FDT +void qmp_dumpdtb(const char *filename, Error **errp) +{ + return qemu_fdt_qmp_dumpdtb(filename, errp); +} +#else +void qmp_dumpdtb(const char *filename, Error **errp) +{ + error_setg(errp, "dumpdtb requires libfdt"); +} +#endif diff --git a/qapi/machine.json b/qapi/machine.json index 6afd1936b0..aeb013f3dd 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1664,3 +1664,20 @@ '*size': 'size', '*max-size': 'size', '*slots': 'uint64' } } + +## +# @dumpdtb: +# +# Save the FDT in dtb format. Requires 'libfdt' support. +# +# @filename: name of the FDT file to be created +# +# Since: 7.2 +# +# Example: +# {"execute": "dumpdtb"} +# "arguments": { "filename": "/tmp/fdt.dtb" } } +# +## +{ 'command': 'dumpdtb', + 'data': { 'filename': 'str' } } diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 6ca3fad285..cd487ddd4d 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -643,3 +643,21 @@ out: g_free(propcells); return ret; } + +void qemu_fdt_qmp_dumpdtb(const char *filename, Error **errp) +{ + int size; + + if (!current_machine->fdt) { + error_setg(errp, "Unable to find the machine FDT"); + return; + } + + size =3D fdt_totalsize(current_machine->fdt); + + if (g_file_set_contents(filename, current_machine->fdt, size, NULL)) { + return; + } + + error_setg(errp, "Error when saving machine FDT to file %s", filename); +} --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661524453; cv=none; d=zohomail.com; s=zohoarc; b=iVUeoUGGpUo12OWDRTUUo0M6zVMkEDStJ8oJYh5xPQiQpRwMPQlBOaeiiFoWe4PgTX5HPyRi6KSCn4Qd9RXmG2OV6tY1in3WqWHaKEPfHDA+BkWR/QyK+HJ7toaMdqI+2zRl6Ij7E0zXfyHTwbYu/Lxea8AUY/o7SR9jCv7HYXI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661524453; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4vMWFIiY8edz9qwKLIQ1TfpB5gyo8VXp08/rbY8O4KE=; b=D1kDJUWGvGzppjecFSyglGPyyFT5jSsaFc+olOCNBI5Abpyp25s3ky3dzaBOVlh8vAUAJ7paaNqaWF+2Imp6E5+GOeqCyaax6HCpsGZB6WotFv5/o3oBdcMuBJzXliUxF5xgpCSNN4pAJiARwnudY8atHAsfBb7tyyTirOgSpF8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661524453930676.8406462699196; Fri, 26 Aug 2022 07:34:13 -0700 (PDT) Received: from localhost ([::1]:35012 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaPU-0004Ml-UE for importer@patchew.org; Fri, 26 Aug 2022 10:34:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48926) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4h-0008GA-RY; Fri, 26 Aug 2022 10:12:44 -0400 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]:33530) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4f-000448-6k; Fri, 26 Aug 2022 10:12:43 -0400 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11e8b592421so721293fac.0; Fri, 26 Aug 2022 07:12:40 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=4vMWFIiY8edz9qwKLIQ1TfpB5gyo8VXp08/rbY8O4KE=; b=qIVuYcxm0E1bPHXlsv8hxLj4VNE8wGc1AuCBLK2yPu72o0CrABQ4ZTfu6k7pHlMLMl 8a43I9PxKfx3ZBs58Ev5p1px1/vwJvp5s7/aX1fwoQa+FhVBlqQrxeRyQwMOeMkGT4Ho Ucb1pkHXkWr8im8/gUXpyxNSmrMZqXYP7+pxmDdKBu08mWK4PKaDeRTVaqshOP+WzT+I ICsn8lAn2LcWt+atLuVDyFWdJqGuplnKtpW4Aorg213jTN5Ir2v6YImFMMd6uG+6eJA1 7LLrlELuzWUgDyA+y5ekckPvZXARBVC1+La1j2M/cKXzo7/R/oFL4pHQtcxQnAaE1jqj 13EA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=4vMWFIiY8edz9qwKLIQ1TfpB5gyo8VXp08/rbY8O4KE=; b=Xqi9D2Eah9sVdCAcq3tpaAEg0JYSDU1gKuDNINVINRJEoQXK420OTlwDa65gJ6Ok+X r0ReiKRULOq9JB0U8Mhi9oXMoAtpx2pMoAaVXaTyA6sEpsG1PwkE6EspcweE/gEzbYO+ 8rRkJKLExwSeAt51ygGTp2gnI1WABR3L/Ft/pZmp3hUYCDuG46VY5LSYfgPwhClPSYY8 uvEKt/c7gS8dUV5WI2nm1VOA4HISkmR+9VhPijn8745myDX/XKaLqaiAc3Twz5IDWFG1 dgYUaa71/+tCW0BeK8NJc6yzRnISqmQmrxqrbUviQDHc1RsfJD8JPEYMdc7f7jLkEEqT vUhg== X-Gm-Message-State: ACgBeo0MhHO4CZ2apkD3TYI66bOarIcoipxLIoWY1YmqvJ/d7osTUNbU vcrxBH6oN7XpVmYu2Lwatp1I3Vk6lYI= X-Google-Smtp-Source: AA6agR5stmaPlk3Vw6G1EcgWDmlR8Xju4kM3nEHd/e+Z9GKyH3xc9dygW8gh8V7OSa4GgkW8O6No4w== X-Received: by 2002:a05:6870:f20c:b0:10e:e5e3:dac2 with SMTP id t12-20020a056870f20c00b0010ee5e3dac2mr2006895oao.228.1661523159434; Fri, 26 Aug 2022 07:12:39 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza , "Dr . David Alan Gilbert" Subject: [PATCH for-7.2 v4 15/21] qmp/hmp, device_tree.c: introduce 'info fdt' command Date: Fri, 26 Aug 2022 11:11:44 -0300 Message-Id: <20220826141150.7201-16-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::31; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x31.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661524455288100003 Content-Type: text/plain; charset="utf-8" Reading the FDT requires that the user saves the fdt_blob and then use 'dtc' to read the contents. Saving the file and using 'dtc' is a strong use case when we need to compare two FDTs, but it's a lot of steps if you want to do quick check on a certain node or property. 'info fdt' retrieves FDT nodes (and properties, later on) and print it to the user. This can be used to check the FDT on running machines without having to save the blob and use 'dtc'. The implementation is based on the premise that the machine thas a FDT created using libfdt and pointed by 'machine->fdt'. As long as this pre-requisite is met the machine should be able to support it. For now we're going to add the required QMP/HMP boilerplate and the capability of printing the name of the properties of a given node. Next patches will extend 'info fdt' to be able to print nodes recursively, and then individual properties. This command will always be executed in-band (i.e. holding BQL), avoiding potential race conditions with machines that might change the FDT during runtime (e.g. PowerPC 'pseries' machine). 'info fdt' is not something that we expect to be used aside from debugging, so we're implementing it in QMP as 'x-query-fdt'. This is an example of 'info fdt' fetching the '/chosen' node of the pSeries machine: (qemu) info fdt /chosen chosen { ibm,architecture-vec-5; rng-seed; ibm,arch-vec-5-platform-support; linux,pci-probe-only; stdout-path; linux,stdout-path; qemu,graphic-depth; qemu,graphic-height; qemu,graphic-width; }; And the same node for the aarch64 'virt' machine: (qemu) info fdt /chosen chosen { stdout-path; rng-seed; kaslr-seed; }; Cc: Dr. David Alan Gilbert Acked-by: Dr. David Alan Gilbert Signed-off-by: Daniel Henrique Barboza --- hmp-commands-info.hx | 13 ++++++++++ include/monitor/hmp.h | 1 + include/sysemu/device_tree.h | 4 +++ monitor/hmp-cmds.c | 13 ++++++++++ monitor/qmp-cmds.c | 12 +++++++++ qapi/machine.json | 19 +++++++++++++++ softmmu/device_tree.c | 47 ++++++++++++++++++++++++++++++++++++ 7 files changed, 109 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 188d9ece3b..743b48865d 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -921,3 +921,16 @@ SRST ``stats`` Show runtime-collected statistics ERST + + { + .name =3D "fdt", + .args_type =3D "nodepath:s", + .params =3D "nodepath", + .help =3D "show firmware device tree node given its path", + .cmd =3D hmp_info_fdt, + }, + +SRST + ``info fdt`` + Show a firmware device tree node given its path. Requires libfdt. +ERST diff --git a/include/monitor/hmp.h b/include/monitor/hmp.h index d7f324da59..c0883dd1e3 100644 --- a/include/monitor/hmp.h +++ b/include/monitor/hmp.h @@ -135,6 +135,7 @@ void hmp_set_vcpu_dirty_limit(Monitor *mon, const QDict= *qdict); void hmp_cancel_vcpu_dirty_limit(Monitor *mon, const QDict *qdict); void hmp_info_vcpu_dirty_limit(Monitor *mon, const QDict *qdict); void hmp_dumpdtb(Monitor *mon, const QDict *qdict); +void hmp_info_fdt(Monitor *mon, const QDict *qdict); void hmp_human_readable_text_helper(Monitor *mon, HumanReadableText *(*qmp_handler)(Erro= r **)); void hmp_info_stats(Monitor *mon, const QDict *qdict); diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h index bf7684e4ed..057d13e397 100644 --- a/include/sysemu/device_tree.h +++ b/include/sysemu/device_tree.h @@ -14,6 +14,8 @@ #ifndef DEVICE_TREE_H #define DEVICE_TREE_H =20 +#include "qapi/qapi-types-common.h" + void *create_device_tree(int *sizep); void *load_device_tree(const char *filename_path, int *sizep); #ifdef CONFIG_LINUX @@ -137,6 +139,8 @@ int qemu_fdt_add_path(void *fdt, const char *path); =20 void qemu_fdt_dumpdtb(void *fdt, int size); void qemu_fdt_qmp_dumpdtb(const char *filename, Error **errp); +HumanReadableText *qemu_fdt_qmp_query_fdt(const char *nodepath, + Error **errp); =20 /** * qemu_fdt_setprop_sized_cells_from_array: diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 1c7bfd3b9d..93a4103afa 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -2484,3 +2484,16 @@ void hmp_dumpdtb(Monitor *mon, const QDict *qdict) hmp_handle_error(mon, local_err); } } + +void hmp_info_fdt(Monitor *mon, const QDict *qdict) +{ + const char *nodepath =3D qdict_get_str(qdict, "nodepath"); + Error *err =3D NULL; + g_autoptr(HumanReadableText) info =3D qmp_x_query_fdt(nodepath, &err); + + if (hmp_handle_error(mon, err)) { + return; + } + + monitor_printf(mon, "%s", info->human_readable_text); +} diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index 8415aca08c..db2c6aa7da 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -603,9 +603,21 @@ void qmp_dumpdtb(const char *filename, Error **errp) { return qemu_fdt_qmp_dumpdtb(filename, errp); } + +HumanReadableText *qmp_x_query_fdt(const char *nodepath, Error **errp) +{ + return qemu_fdt_qmp_query_fdt(nodepath, errp); +} #else void qmp_dumpdtb(const char *filename, Error **errp) { error_setg(errp, "dumpdtb requires libfdt"); } + +HumanReadableText *qmp_x_query_fdt(const char *nodepath, Error **errp) +{ + error_setg(errp, "this command requires libfdt"); + + return NULL; +} #endif diff --git a/qapi/machine.json b/qapi/machine.json index aeb013f3dd..96cff541ca 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1681,3 +1681,22 @@ ## { 'command': 'dumpdtb', 'data': { 'filename': 'str' } } + +## +# @x-query-fdt: +# +# Query for FDT element (node or property). Requires 'libfdt'. +# +# @nodepath: the path of the FDT node to be retrieved +# +# Features: +# @unstable: This command is meant for debugging. +# +# Returns: FDT node +# +# Since: 7.2 +## +{ 'command': 'x-query-fdt', + 'data': { 'nodepath': 'str' }, + 'returns': 'HumanReadableText', + 'features': [ 'unstable' ] } diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index cd487ddd4d..6b15f6ace2 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -18,6 +18,7 @@ #endif =20 #include "qapi/error.h" +#include "qapi/type-helpers.h" #include "qemu/error-report.h" #include "qemu/option.h" #include "qemu/bswap.h" @@ -661,3 +662,49 @@ void qemu_fdt_qmp_dumpdtb(const char *filename, Error = **errp) =20 error_setg(errp, "Error when saving machine FDT to file %s", filename); } + +static void fdt_format_node(GString *buf, int node, int depth) +{ + const struct fdt_property *prop =3D NULL; + const char *propname =3D NULL; + void *fdt =3D current_machine->fdt; + int padding =3D depth * 4; + int property =3D 0; + int prop_size; + + g_string_append_printf(buf, "%*s%s {\n", padding, "", + fdt_get_name(fdt, node, NULL)); + + padding +=3D 4; + + fdt_for_each_property_offset(property, fdt, node) { + prop =3D fdt_get_property_by_offset(fdt, property, &prop_size); + propname =3D fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); + + g_string_append_printf(buf, "%*s%s;\n", padding, "", propname); + } + + padding -=3D 4; + g_string_append_printf(buf, "%*s};\n", padding, ""); +} + +HumanReadableText *qemu_fdt_qmp_query_fdt(const char *nodepath, Error **er= rp) +{ + g_autoptr(GString) buf =3D g_string_new(""); + int node; + + if (!current_machine->fdt) { + error_setg(errp, "Unable to find the machine FDT"); + return NULL; + } + + node =3D fdt_path_offset(current_machine->fdt, nodepath); + if (node < 0) { + error_setg(errp, "node '%s' not found in FDT", nodepath); + return NULL; + } + + fdt_format_node(buf, node, 0); + + return human_readable_text_from_str(buf); +} --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661523774; cv=none; d=zohomail.com; s=zohoarc; b=d3m4HFvOPbNL5u432hGrDStFd0Up4BNeijqABZLqhxwtWHlaPQbMu2STJnwhqBoZPQyRii9YHq6Xmd5M31b9GQMB1n0/uoYxLYzb3nqTixS9fnk65BxUj+fZmdDuOsZ9UlzloW58tP6xHMrnxWUevgybqbf0UPmA/QS+bBQb3Ds= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661523774; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3WFTx8tKktnqdh/Jp2z4twP6sgM95iWuQSmsE8ZM7FE=; b=dlZU0pT6ECT/TVhQ6tfdpyALlFQOjezR2WyyuPhTUEyCU0cxvNLdsd5Y7phlP/+spt/Nxirj1ETpfPl3K6DTyVCgdRbfcsif0ke0r38i38/Af75vO5VpPVFCFRjOgi8I4TwVTHk6qQaIW0X9FBgIEgB7vE0oYFpmmKnheJgqotc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661523774286681.8812268512914; Fri, 26 Aug 2022 07:22:54 -0700 (PDT) Received: from localhost ([::1]:49304 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaEX-0003pL-21 for importer@patchew.org; Fri, 26 Aug 2022 10:22:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40764) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4j-0008Hf-S9; Fri, 26 Aug 2022 10:12:47 -0400 Received: from mail-oi1-x233.google.com ([2607:f8b0:4864:20::233]:45810) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4h-00044T-Tq; Fri, 26 Aug 2022 10:12:45 -0400 Received: by mail-oi1-x233.google.com with SMTP id o204so2096981oia.12; Fri, 26 Aug 2022 07:12:42 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=3WFTx8tKktnqdh/Jp2z4twP6sgM95iWuQSmsE8ZM7FE=; b=S0blnVW9VmEMh+UMUIc9RX1+9MBJW2FxuiYal6zyVCv+e2684k++d+yEzj7nvzyiUj hNth1m5ZSd37IneoQ9FnCFOLzvEu3lxQuy2dIrMS/gT4qvAqgB0IRS5n6oKNGWP5ZXCU 7uYxQL7VuHQMpz0djXrqWB5PojXL8QKNfxkRQDTjXdNLUHjYD/uhuBSnY9Lq3Qi03OsX GbmFkebQlOw1FeqkZspHkR99yl5h3+ucCMZBuHTuPLOFo3q7CxAHJaWKvlpfx22t3Trs ZwP+zT6O0N9fMl5BTal8CVxrdgrelrWTswgSN8sbEfeQN7dCN2YaoaKdFZeBeoKHoqoQ /qHQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=3WFTx8tKktnqdh/Jp2z4twP6sgM95iWuQSmsE8ZM7FE=; b=gJG2drEORvF1HIKv/z0lD4TsyMjZMl8rHoY9xWzeQy5UJhR9t6ZM+dlUY0ysMwpKcK PZEM++F4fGfyXTnpLk2YcwwA/cI+zVwz9x2xdscgKtmI7bS+CVp2agwUWsc7+a2pbT/w qqUAsVm7ri56l/uEculNWlB2vA9qGrFJdyIwaQ45Yjye6vEApk+yquF8e0XpJs8sHaZv mE7F+J+8eCb/SQMJoPvpH4GkuZGuC9eIMTTzFaSQCV1rijpA6wBXtTHVkwURLFzW3PqA J/MEMwFzRGiNik79dDMK/ziFAJ1uvtS9OdOk67Ya69DfGOp0Eq7PQD96IUBcEsZxDMpR OmZA== X-Gm-Message-State: ACgBeo27rStX/u3TWICez8HjAz9hxmL43kAFsXqt3jDULVQT1cMSdPF3 +OCib46OXw4Tlq4MnhDJ73qgTgcGGj4= X-Google-Smtp-Source: AA6agR6glQoqxi3D2sn2yR0/z5R339lST3+y8tmYR3MXS4mZDdEV5fZ12aRKCkPIZ2gwCVQuOgQzow== X-Received: by 2002:a05:6808:e90:b0:345:6ee0:9a68 with SMTP id k16-20020a0568080e9000b003456ee09a68mr1758963oil.173.1661523161845; Fri, 26 Aug 2022 07:12:41 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza Subject: [PATCH for-7.2 v4 16/21] device_tree.c: support string array prop in fdt_format_node() Date: Fri, 26 Aug 2022 11:11:45 -0300 Message-Id: <20220826141150.7201-17-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::233; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x233.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661523775845100001 Content-Type: text/plain; charset="utf-8" To support printing string properties in 'info fdt' we need to determine whether a void data might contain a string array. We do that by casting the void data to a string array and: - check if the array finishes with a null character - check if there's no empty string in the middle of the array (i.e. consecutive \0\0 characters) - check if all characters of each substring are printable If all conditions are met, we'll consider it to be a string array data type and print it accordingly. After this change, 'info fdt' is now able to print string arrays. Here's an example of string arrays we're able to print in the /rtas node of the ppc64 pSeries machine: (qemu) info fdt /rtas rtas { (...) qemu,hypertas-functions =3D "hcall-memop1"; ibm,hypertas-functions =3D "hcall-pft", "hcall-term", "hcall-dabr", "hc= all-interrupt", "hcall-tce", "hcall-vio", "hcall-splpar", "hcall-join", "hc= all-bulk", "hcall-set-mode", "hcall-sprg0", "hcall-copy", "hcall-debug", "h= call-vphn", "hcall-multi-tce", "hcall-hpt-resize", "hcall-watchdog"; }; 'qemu,hypertas-functions' is a property with a single string while 'ibm,hypertas-functions' is a string array. Signed-off-by: Daniel Henrique Barboza --- softmmu/device_tree.c | 64 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 6b15f6ace2..3e38d9ddad 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -663,6 +663,63 @@ void qemu_fdt_qmp_dumpdtb(const char *filename, Error = **errp) error_setg(errp, "Error when saving machine FDT to file %s", filename); } =20 +static bool fdt_prop_is_string_array(const void *data, int size) +{ + const char *str_arr, *str; + int i, str_len; + + str_arr =3D str =3D data; + + if (size <=3D 0 || str_arr[size - 1] !=3D '\0') { + return false; + } + + while (str < str_arr + size) { + str_len =3D strlen(str); + + /* + * Do not consider empty strings (consecutives \0\0) + * as valid. + */ + if (str_len =3D=3D 0) { + return false; + } + + for (i =3D 0; i < str_len; i++) { + if (!g_ascii_isprint(str[i])) { + return false; + } + } + + str +=3D str_len + 1; + } + + return true; +} + +static void fdt_prop_format_string_array(GString *buf, + const char *propname, + const char *data, + int prop_size, int padding) +{ + const char *str =3D data; + + g_string_append_printf(buf, "%*s%s =3D ", padding, "", propname); + + while (str < data + prop_size) { + /* appends up to the next '\0' */ + g_string_append_printf(buf, "\"%s\"", str); + + str +=3D strlen(str) + 1; + if (str < data + prop_size) { + /* add a comma separator for the next string */ + g_string_append_printf(buf, ", "); + } + } + + g_string_append_printf(buf, ";\n"); +} + static void fdt_format_node(GString *buf, int node, int depth) { const struct fdt_property *prop =3D NULL; @@ -681,7 +738,12 @@ static void fdt_format_node(GString *buf, int node, in= t depth) prop =3D fdt_get_property_by_offset(fdt, property, &prop_size); propname =3D fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); =20 - g_string_append_printf(buf, "%*s%s;\n", padding, "", propname); + if (fdt_prop_is_string_array(prop->data, prop_size)) { + fdt_prop_format_string_array(buf, propname, prop->data, + prop_size, padding); + } else { + g_string_append_printf(buf, "%*s%s;\n", padding, "", propname); + } } =20 padding -=3D 4; --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661523904; cv=none; d=zohomail.com; s=zohoarc; b=OBDXu6qyprLJLHA53rtPaQlizwX3cE5boAKA8r8N9TX/wrzq4AVPl/3hbG0VQznZBSbRZOxvTDkXlgjc3IX74BUkSQjKSqb245n/mn8iCJSNnopq/qECzhkuYzHevgUBOIPjQCUCd42d/sl9PlILMG5SbKSD7Qby9W41UntFsJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661523904; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KRFx6V1DJCNRq8IcfTrxMaL3ZO8XkbM3yOTe5IXGOOU=; b=J8syaQ8e8voYmAOSJBHYDa0z3PM44oQzoyeViuJAZq7J3yQn2uxD8QCuJ4Qp+r8saP34Hnk2uPuC1MJ92domV8UBYNKgB6+lWGbGbEILGhR4N4Gqv7IWGOu00wboaWrMiCJOAQbZ4C6X4278eGFT8zmT01qs2KIf2OtB6VhVuEM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661523904734241.50723693672694; Fri, 26 Aug 2022 07:25:04 -0700 (PDT) Received: from localhost ([::1]:50974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaGd-00017q-FP for importer@patchew.org; Fri, 26 Aug 2022 10:25:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4m-0008JJ-I7; Fri, 26 Aug 2022 10:12:49 -0400 Received: from mail-oa1-x31.google.com ([2001:4860:4864:20::31]:33530) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4k-000448-UP; Fri, 26 Aug 2022 10:12:48 -0400 Received: by mail-oa1-x31.google.com with SMTP id 586e51a60fabf-11e8b592421so721725fac.0; Fri, 26 Aug 2022 07:12:46 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=KRFx6V1DJCNRq8IcfTrxMaL3ZO8XkbM3yOTe5IXGOOU=; b=ONqB98y0jDUIm2Oz4L9XgCud9jicnRFnzYHW//IT1jGRUvBmnNTAAosXYHT3lofO5n F45jpVC+nvEZ5C24BiJLEsvqLK0Ay0seTHzDB4VNAxQ8SwjcVYvJfcQa1WcKIQYb56Q3 H2mCpyGU7FIXqfkLLY5JJJ6yNO6xMrIvg9AK6H0XoTssBwFborL1+nvpwK1092wZi1S/ O8Fl23CK3DNSgX/FLCrBa6e/RdCMszs+Ju0/OR1EK6bHgqXLpjySucCwzzz8JRNwk25w z0I0kZaJIk6xWPj3D5xCOc+zKmoypXx+jMbYWsK0t7YaZjF15zwr6PoJNG3EaexvoDqd h5lw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=KRFx6V1DJCNRq8IcfTrxMaL3ZO8XkbM3yOTe5IXGOOU=; b=6EkbGV5v3WM14BziRFkmeimhXXrI7OvDJqWMdgpJSJ93I1zgVJOod9f6bjSD8FBn9a 92Hon5Qo4ep3IQiAZjxpwl8Rjk1BP2Y1QQCFnlt9jEeBw6oZ6Z7oQeSLY+xtV3E0MWos 9J3y1dWOB9tSu9GVzCqriyw4z3SK52R1yTupw3VAydrexUa9HqaeduMjIqdDWRgISf1Q miomJWxBqNRt/Y7YvOHe4HPB54KwAiKvenL4sphuzFRpSsXwrHEdbU4m9dH7x9FRzbhG zZ4D55Owu3Q50LBi0y0e6sVaE0HGopT1u3L0YCpyR0NXCpL34nTSAWqBBFeBMY5kdtAr nkzA== X-Gm-Message-State: ACgBeo0csd05hx5f5ZrUosnmst59rKk0K+fYCfil86aOfqfZrjpJV9zt aikfnZVEAApwHIrcTm08RnovnTOXvDw= X-Google-Smtp-Source: AA6agR6H71FXi7WTl+H34U8K+h1G1CiM319An9q4JUA63//sftXxoQC1dNcT7GmNYglegMx8FqRcJw== X-Received: by 2002:a05:6870:2488:b0:10c:3362:17ff with SMTP id s8-20020a056870248800b0010c336217ffmr1860749oaq.33.1661523165730; Fri, 26 Aug 2022 07:12:45 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza Subject: [PATCH for-7.2 v4 17/21] device_tree.c: support remaining FDT prop types Date: Fri, 26 Aug 2022 11:11:46 -0300 Message-Id: <20220826141150.7201-18-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::31; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x31.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661523906657100001 Content-Type: text/plain; charset="utf-8" When printing a blob with 'dtc' using the '-O dts' option there are 3 distinct data types being printed: strings, arrays of uint32s and regular byte arrays. Previous patch added support to print strings. Let's add the remaining formats. We want to resemble the format that 'dtc -O dts' uses, so every uint32 array uses angle brackets (<>), and regular byte array uses square brackets ([]). For properties that has no values we keep printing just its name. The /chosen FDT node from the pSeris machine gives an example of all property types 'info fdt' is now able to display: (qemu) info fdt /chosen chosen { ibm,architecture-vec-5 =3D [00 00]; rng-seed =3D <0x9cf5071b 0xf8804213 0xbe797764 0xad3d955 0xe0c9637 0x1f= 99c61e 0xe9243741 0xe800f17d>; ibm,arch-vec-5-platform-support =3D <0x178018c0 0x19001a40>; linux,pci-probe-only =3D <0x0>; stdout-path =3D "/vdevice/vty@71000000"; linux,stdout-path =3D "/vdevice/vty@71000000"; qemu,graphic-depth =3D <0x20>; qemu,graphic-height =3D <0x258>; qemu,graphic-width =3D <0x320>; } Signed-off-by: Daniel Henrique Barboza --- softmmu/device_tree.c | 57 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 56 insertions(+), 1 deletion(-) diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 3e38d9ddad..a770c6c1cc 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -720,6 +720,52 @@ static void fdt_prop_format_string_array(GString *buf, g_string_append_printf(buf, ";\n"); } =20 +static bool fdt_prop_is_uint32_array(int size) +{ + return size % 4 =3D=3D 0; +} + +static void fdt_prop_format_uint32_array(GString *buf, + const char *propname, + const void *data, + int prop_size, int padding) +{ + const fdt32_t *array =3D data; + int array_len =3D prop_size / 4; + int i; + + g_string_append_printf(buf, "%*s%s =3D <", padding, "", propname); + + for (i =3D 0; i < array_len; i++) { + g_string_append_printf(buf, "0x%" PRIx32, fdt32_to_cpu(array[i])); + + if (i < array_len - 1) { + g_string_append_printf(buf, " "); + } + } + + g_string_append_printf(buf, ">;\n"); +} + +static void fdt_prop_format_val(GString *buf, const char *propname, + const void *data, int prop_size, + int padding) +{ + const char *val =3D data; + int i; + + g_string_append_printf(buf, "%*s%s =3D [", padding, "", propname); + + for (i =3D 0; i < prop_size; i++) { + g_string_append_printf(buf, "%02x", val[i]); + if (i < prop_size - 1) { + g_string_append_printf(buf, " "); + } + } + + g_string_append_printf(buf, "];\n"); +} + static void fdt_format_node(GString *buf, int node, int depth) { const struct fdt_property *prop =3D NULL; @@ -738,11 +784,20 @@ static void fdt_format_node(GString *buf, int node, i= nt depth) prop =3D fdt_get_property_by_offset(fdt, property, &prop_size); propname =3D fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); =20 + if (prop_size =3D=3D 0) { + g_string_append_printf(buf, "%*s%s;\n", padding, "", propname); + continue; + } + if (fdt_prop_is_string_array(prop->data, prop_size)) { fdt_prop_format_string_array(buf, propname, prop->data, prop_size, padding); + } else if (fdt_prop_is_uint32_array(prop_size)) { + fdt_prop_format_uint32_array(buf, propname, prop->data, prop_s= ize, + padding); } else { - g_string_append_printf(buf, "%*s%s;\n", padding, "", propname); + fdt_prop_format_val(buf, propname, prop->data, + prop_size, padding); } } =20 --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661525078; cv=none; d=zohomail.com; s=zohoarc; b=cdAvThZ32ZObgGWyPnj5DjKGoNH7oeJb3f+R9yGk1xQsU9KEs1DkDisoY313y3IC7P1MO/0LlNkEOf9JqfOBBI65QlpuCGDmEQWgBQ66EZeQdahmHIJU5Z1d5IwAPtfFq2or968CapknrLtR+SQkpXj7Z2Zq+mGDma8XJGIqk5I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661525078; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3ddj5V0F6lf315I2M7vwNy6gZ2IdsGWlN//eiaxj3pk=; b=FY/HvLc7OBFbatScHGSQakNZOaZxzqEKhSsPRrXj07HUIEyuyizeGlCkCH0O7qav2ZAgHu/PMdps/kOM5oSGCIBn7jTGhrPvvy1ckAZ63dirY9NHsVhlCP9xVkE/En+5MqIjKqywUie5Bmj5wNQP9IVgmmeP7NzrjN9RLdv8HXg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661525078050578.3771286949213; Fri, 26 Aug 2022 07:44:38 -0700 (PDT) Received: from localhost ([::1]:46412 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaZX-0000kB-R2 for importer@patchew.org; Fri, 26 Aug 2022 10:44:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40768) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4p-0008Pf-1u; Fri, 26 Aug 2022 10:12:51 -0400 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]:41651) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4n-000421-Hn; Fri, 26 Aug 2022 10:12:50 -0400 Received: by mail-oi1-x236.google.com with SMTP id t140so2112625oie.8; Fri, 26 Aug 2022 07:12:48 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=3ddj5V0F6lf315I2M7vwNy6gZ2IdsGWlN//eiaxj3pk=; b=HCPiBCFFEbilSkda3/yk+mvVSJmnUEkyPnUMnEMu3hApGRd8W94XP3qLgQPBivNsM5 K4jCZRRCQ8EIQf7iZKIJc1PgsTKlPgTt//EyodyRrAyTjuBFAzzmhMZi7kfWsCQyHzh4 HKZ1q1OKZnNejdzFPI3MGVCV0kdkZOKm0e/wSv5e78OlbKVY1udgCSka3pAf3TqaE2Dq 3AsYsAuA4gO2+97BRxoNKKCpfa3F9TegKncbYBwomuKXFHGutbrDHnbazMOS/eNfoBWd x/wnZAXt8FXUgGMSCwRTAMcKNh1wViW71dav5dOoCPh6Jqe2O0SCeELCiud9k+Pw4n2D hAJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=3ddj5V0F6lf315I2M7vwNy6gZ2IdsGWlN//eiaxj3pk=; b=NXuA4FTj0MKSw45F2iLauS029IR1QfFc2x1fa8n/yzXdNNyMEeYyPyBNDHL4xq/guw Y4YPNQHKDIPzk7dblSi3rM2LZcz9jF25MOboaP9pB6r6SOQQvD6/gQbiQ/TRr/Lj9NlM dgH7pBu5rwTzeuavTT1UuHouiLVCafGGGpi0x44w9nkHbonxk8XGBuVfM2eHHim9Rogv CcX+oCrDPf/Z2noUkn+N0PXF3JYGumaq6QLbHnwmwcrstrxN9W4eVbvRpR6F8081uQYQ sFO5/Ogr8LNheVSTYRPbWmrjOtGlX11VIcTF4GrRYMU/FReLhiXT7Rz7H1txxSQrerTl FwYQ== X-Gm-Message-State: ACgBeo3gXQMP2ueG08FsP2MUUJkC+0xpKYZ89M/ltxY/bjtkm2RxcgNO tSzdQfRCZjHe1uFS0QCkMDK0a/DCDL4= X-Google-Smtp-Source: AA6agR4TRMZjUTw1v4ZPEzXYmsxN4emUROdoghxw+2BJjjf0MfOSKjRE3NXVCn6TPBDO5KYRs2+mwg== X-Received: by 2002:a05:6808:1b8c:b0:33a:d44f:2169 with SMTP id cj12-20020a0568081b8c00b0033ad44f2169mr1734138oib.13.1661523168345; Fri, 26 Aug 2022 07:12:48 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza Subject: [PATCH for-7.2 v4 18/21] device_node.c: enable 'info fdt' to print subnodes Date: Fri, 26 Aug 2022 11:11:47 -0300 Message-Id: <20220826141150.7201-19-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x236.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661525080004100001 Content-Type: text/plain; charset="utf-8" Printing subnodes of a given node will allow us to show a whole subtree, which the additional perk of 'info fdt /' being able to print the whole FDT. Since we're now printing more than one subnode, change 'fdt_info' to print the full path of the first node. This small tweak helps identifying which node or subnode are being displayed. To demostrate this capability without printing the whole FDT, the '/cpus/cpu-map' node from the ARM 'virt' machine has a lot of subnodes: (qemu) info fdt /cpus/cpu-map /cpus/cpu-map { socket0 { cluster0 { core0 { cpu =3D <0x8001> } } } } Signed-off-by: Daniel Henrique Barboza --- softmmu/device_tree.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index a770c6c1cc..5e4cb119f2 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -766,17 +766,26 @@ static void fdt_prop_format_val(GString *buf, const c= har *propname, g_string_append_printf(buf, "];\n"); } =20 -static void fdt_format_node(GString *buf, int node, int depth) + +static void fdt_format_node(GString *buf, int node, int depth, + const char *fullpath) { const struct fdt_property *prop =3D NULL; + const char *nodename =3D NULL; const char *propname =3D NULL; void *fdt =3D current_machine->fdt; int padding =3D depth * 4; int property =3D 0; + int parent =3D node; int prop_size; =20 - g_string_append_printf(buf, "%*s%s {\n", padding, "", - fdt_get_name(fdt, node, NULL)); + if (fullpath !=3D NULL) { + nodename =3D fullpath; + } else { + nodename =3D fdt_get_name(fdt, node, NULL); + } + + g_string_append_printf(buf, "%*s%s {\n", padding, "", nodename); =20 padding +=3D 4; =20 @@ -801,6 +810,10 @@ static void fdt_format_node(GString *buf, int node, in= t depth) } } =20 + fdt_for_each_subnode(node, fdt, parent) { + fdt_format_node(buf, node, depth + 1, NULL); + } + padding -=3D 4; g_string_append_printf(buf, "%*s};\n", padding, ""); } @@ -821,7 +834,7 @@ HumanReadableText *qemu_fdt_qmp_query_fdt(const char *n= odepath, Error **errp) return NULL; } =20 - fdt_format_node(buf, node, 0); + fdt_format_node(buf, node, 0, nodepath); =20 return human_readable_text_from_str(buf); } --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661524882; cv=none; d=zohomail.com; s=zohoarc; b=P5xaPdeeqCzvnTMByS4UPYfitx2aXdX5IAgjur6Xc2HD0SNAOaSD0wn6KAJKXP9qAtOMF/Aurcor63JwwGraeEstMqrukRBl5CAQSlv8Nf313lAZSA/F06/K7pLBQ1w8DBTMQhylOV0NjgqPhooo3lDnKOvLBYT35xZwsXbqt8c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661524882; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=GGIPr/tCDqHwKBtmxyaze85YwD8Hym/cXe/mUpra+nw=; b=mJLKC1qgy8w/lYjPuCWKOcCbcSu+YwKDzjSgYTnVf07cBfmT+Byoj0dDC+/lM8DgkWu+aU14k5fCPi5PyxJ8TEmVjdaspfasqf+g4OjCMuFvbV81TyzOJFGN8WxLpzZA4uvvmWWTFdZwE4zgzeKXq9JcylZhZWjgPHEtNbtiQo0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661524882800610.3707050523126; Fri, 26 Aug 2022 07:41:22 -0700 (PDT) Received: from localhost ([::1]:51208 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaWP-0002ax-LE for importer@patchew.org; Fri, 26 Aug 2022 10:41:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4v-0000J9-DK; Fri, 26 Aug 2022 10:12:57 -0400 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]:37679) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4q-00045q-E9; Fri, 26 Aug 2022 10:12:57 -0400 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-11e7e0a63e2so1347688fac.4; Fri, 26 Aug 2022 07:12:51 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=GGIPr/tCDqHwKBtmxyaze85YwD8Hym/cXe/mUpra+nw=; b=ZNiPhooh8ydDA/MFvoSBqUIXLJ2CkAlhBQUcwYVGPdsXXdoGufjvMWqKISAq/+b5CS K0vIrmRhwhstfjlF3AFCwaOlhgNCpKx8+HzDg+yEiCaEcix+UuEtppKnq5pidK0hNX0n N3zCOE4kA4RYxKHCq5alyWtq3l7YusokTJ2W+GjvIoZtrYJr2uyi8z0uixW71pIXV9v5 rfC5grzHEMJG6TuHMC0SYxH322TZUO2X8owtGy04tolgmQIGq/6kq9suDCxqvQYebUsP B50iZHBuQTFUTMJh0SaXmmFD+iRkqBnXIgqSLUfJMszWBCCyKwHzenhzxgkkx9BBnpod rwQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=GGIPr/tCDqHwKBtmxyaze85YwD8Hym/cXe/mUpra+nw=; b=r1FZiW7mgecJgsX4hJNjwVqQ8dMxwuC0y0zBCgxsOywcsobxgFqWGPO8ZCmcN06wxf 6JPUCm0dlkDR2gBCHVOBMWIBd2fNB5pTagzoanR0yGP8Aj2EZthAaFdNn+8Y19u04dSd d/WcBi8vN4uvHsKacw21Zh7qF5Gi6fLphvIpGrMA24NH/DuAsi/cEUT0VLIkewkftxme /FWA/JFd2zmMDBBz8vLKq6FQAcwXWTqXAXfVIfw51aANbi4C0X7pArvQAENr2iB8OhgC 6vryGZe5mDS5EdWJy0Y9f/TP9YqlRWecPSw0bLvjk579bcoZLPc5TYEi17NEzcm1g5DZ JNcw== X-Gm-Message-State: ACgBeo2Yw98ZfhmE9ZvIwaMK/F1xxUXdGI429l5fcSVotG9OInVsNcgF +wFhr3780BwxUYS+ZxjM2PTS40Y5/0w= X-Google-Smtp-Source: AA6agR7ypqn6+9y4xkX2/HS7fqV6gZHVJnyJDJ5ocihfQEuyY3dxchRgnDvrfpz/qR7HgiZvWyehoQ== X-Received: by 2002:a05:6870:c14a:b0:11d:588:da3a with SMTP id g10-20020a056870c14a00b0011d0588da3amr1891424oad.214.1661523170927; Fri, 26 Aug 2022 07:12:50 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza Subject: [PATCH for-7.2 v4 19/21] device_tree.c: add fdt_format_property() helper Date: Fri, 26 Aug 2022 11:11:48 -0300 Message-Id: <20220826141150.7201-20-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::30; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x30.google.com X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01, T_SPF_TEMPERROR=0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661524884260100001 Content-Type: text/plain; charset="utf-8" We want to be able to also print properties with 'info fdt'. Create a helper to format properties based on the already existing code from fdt_format_node(). Signed-off-by: Daniel Henrique Barboza --- softmmu/device_tree.c | 35 ++++++++++++++++++++--------------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 5e4cb119f2..70a011495d 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -766,6 +766,25 @@ static void fdt_prop_format_val(GString *buf, const ch= ar *propname, g_string_append_printf(buf, "];\n"); } =20 +static void fdt_format_property(GString *buf, const char *propname, + const void *data, int prop_size, + int padding) +{ + if (prop_size =3D=3D 0) { + g_string_append_printf(buf, "%*s%s;\n", padding, "", propname); + return; + } + + if (fdt_prop_is_string_array(data, prop_size)) { + fdt_prop_format_string_array(buf, propname, data, prop_size, + padding); + } else if (fdt_prop_is_uint32_array(prop_size)) { + fdt_prop_format_uint32_array(buf, propname, data, prop_size, + padding); + } else { + fdt_prop_format_val(buf, propname, data, prop_size, padding); + } +} =20 static void fdt_format_node(GString *buf, int node, int depth, const char *fullpath) @@ -793,21 +812,7 @@ static void fdt_format_node(GString *buf, int node, in= t depth, prop =3D fdt_get_property_by_offset(fdt, property, &prop_size); propname =3D fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); =20 - if (prop_size =3D=3D 0) { - g_string_append_printf(buf, "%*s%s;\n", padding, "", propname); - continue; - } - - if (fdt_prop_is_string_array(prop->data, prop_size)) { - fdt_prop_format_string_array(buf, propname, prop->data, - prop_size, padding); - } else if (fdt_prop_is_uint32_array(prop_size)) { - fdt_prop_format_uint32_array(buf, propname, prop->data, prop_s= ize, - padding); - } else { - fdt_prop_format_val(buf, propname, prop->data, - prop_size, padding); - } + fdt_format_property(buf, propname, prop->data, prop_size, padding); } =20 fdt_for_each_subnode(node, fdt, parent) { --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661525449; cv=none; d=zohomail.com; s=zohoarc; b=FbNKCUfIeUdzaHb6VGipLFd6NvvXoz4fMSw+XZlmu6PYkWLat5HfJ+/Vx1vdugx+DomTigF9VZHOvt6tywpEujgFnQiAfSH5um+P2x1yT1U8fZXDj0q7K4HAFXYRulAFV0y42oBGE3bg3o7BgLPEbv52qtRbwKNt7sKaAkUTQgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661525449; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ANVbfUNhn0caCyzAkihc79NuPXOAYDT2141wO72Bs/o=; b=fGkM9S46SDpII16r31/QzmqIMpZcZZ6p18CA/ObP+KOZ2FloWI+6ZphwJPT/ayGFXCnftEQB1bVRHvh0aQKZTWVap4RnpWvaHYpULPbekC66z/E3VL+ed7RUSPsKZj0v343wy2ZCiF1XzJRvQ89/l7iSYms24TlN1k9yuA2OlQU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661525449073592.891588505007; Fri, 26 Aug 2022 07:50:49 -0700 (PDT) Received: from localhost ([::1]:60634 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRafW-0007Qr-LJ for importer@patchew.org; Fri, 26 Aug 2022 10:50:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4x-0000M2-0l; Fri, 26 Aug 2022 10:12:59 -0400 Received: from mail-oi1-x236.google.com ([2607:f8b0:4864:20::236]:39635) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4t-00047M-My; Fri, 26 Aug 2022 10:12:58 -0400 Received: by mail-oi1-x236.google.com with SMTP id j5so2122142oih.6; Fri, 26 Aug 2022 07:12:55 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=ANVbfUNhn0caCyzAkihc79NuPXOAYDT2141wO72Bs/o=; b=IFVsTE2iZ47g5KwtTJjhpgnYUJcBXU5bWxUWfgjWIYUBfuYs6nv9X6HXBUwc2sBC5d rJ6wNz2a5fLGkoVWaLYu+Xi+PyiecwaekpFI8t2YVlWYa8CL+Iausx8st90CTfQId+V0 JxceqD+F9vP1X8mb3Mi5L+hE4rXTe/GkWzLBnrHLX9fA3LhaComjP2l6Tc0JPj9ohw/9 jQRvRFJ5gW/RQAEnWEYzyuHOT33t//hjlPMmoRIVue4zhf0fkn68nnmEf2KQjlVR4I2V 6irz7fAP4R2uDkC+ispLm3pBDYeJgZDeJjzVHMa09KPzfYkY3n28O6dc/j9FV+PP08f4 8oBA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=ANVbfUNhn0caCyzAkihc79NuPXOAYDT2141wO72Bs/o=; b=0JUV8QQXiUP1m+AVhO9kDp54ePPyy2fQqJYBIvefFyI0CfjUvEgqqhElv7bG1MB9Ze TYV9xeYByc5msN7/IT2Ben1IYVeuLBTbWE9Cogk0DGhnm4VKN7DGLVoLZ2TtU8xj6p65 9SLvsfr+UA2jqDUC0KxNcfxTBqcpOzXrOd7wPC/LO4ox325g9y3i/S7HxfbLOtQYaJnq KV6NxZO/ZThCILz2yuV21M1nOiUAa693v7xsb7+vRmyfJzJZdyPAYBjIkT2zGLQ0UqDU S03FzlEyb//JB4qZn6wYh4n5HJvtA6w2Z7QWR10YqrCb0LDvKm6kAWze8j85lQu0vadS in3A== X-Gm-Message-State: ACgBeo0XOJeU82FnE0aBXxT5SiYKKArqB2VAQrSI4jNpeM4EgBVPvP5b Gt4rlOAYj11wqoqB4UyAlABM4xWbrkg= X-Google-Smtp-Source: AA6agR4CCGoQWNPZPo2tZI6DopRhNaiDWfNvdL9R2HF3ItNNfnYSSLWQ5eGUK8pHXsent04uAh6Zmg== X-Received: by 2002:a05:6808:ec3:b0:2ec:8fcb:1d4a with SMTP id q3-20020a0568080ec300b002ec8fcb1d4amr1741675oiv.162.1661523173961; Fri, 26 Aug 2022 07:12:53 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza , "Dr . David Alan Gilbert" Subject: [PATCH for-7.2 v4 20/21] hmp, device_tree.c: add 'info fdt ' support Date: Fri, 26 Aug 2022 11:11:49 -0300 Message-Id: <20220826141150.7201-21-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::236; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x236.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661525450076100001 Content-Type: text/plain; charset="utf-8" 'info fdt' is only able to print full nodes so far. It would be good to be able to also print single properties, since ometimes we just want to verify a single value from the FDT. libfdt does not have support to find a property given its full path, but it does have a way to return a fdt_property given a prop name and its subnode. Add a new optional 'propname' parameter to x-query-fdt to specify the property of a given node. If it's present, we'll proceed to find the node as usual but, instead of printing the node, we'll attempt to find the property and print it standalone. After this change, if an user wants to print just the value of 'cpu' inside /cpu/cpu-map(...) from an ARM FDT, we can do it: (qemu) info fdt /cpus/cpu-map/socket0/cluster0/core0 cpu /cpus/cpu-map/socket0/cluster0/core0/cpu =3D <0x8001>; Or the 'ibm,my-dma-window' from the v-scsi device inside the pSeries FDT: (qemu) info fdt /vdevice/v-scsi@71000003 ibm,my-dma-window /vdevice/v-scsi@71000003/ibm,my-dma-window =3D <0x71000003 0x0 0x0 0x0 0x10= 000000>; Cc: Dr. David Alan Gilbert Acked-by: Dr. David Alan Gilbert Signed-off-by: Daniel Henrique Barboza --- hmp-commands-info.hx | 9 +++++---- include/sysemu/device_tree.h | 2 ++ monitor/hmp-cmds.c | 5 ++++- monitor/qmp-cmds.c | 8 +++++--- qapi/machine.json | 4 +++- softmmu/device_tree.c | 29 ++++++++++++++++++++++++----- 6 files changed, 43 insertions(+), 14 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 743b48865d..17d6ee4d30 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -924,13 +924,14 @@ ERST =20 { .name =3D "fdt", - .args_type =3D "nodepath:s", - .params =3D "nodepath", - .help =3D "show firmware device tree node given its path", + .args_type =3D "nodepath:s,propname:s?", + .params =3D "nodepath [propname]", + .help =3D "show firmware device tree node or property given = its path", .cmd =3D hmp_info_fdt, }, =20 SRST ``info fdt`` - Show a firmware device tree node given its path. Requires libfdt. + Show a firmware device tree node or property given its path. + Requires libfdt. ERST diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h index 057d13e397..551a02dee2 100644 --- a/include/sysemu/device_tree.h +++ b/include/sysemu/device_tree.h @@ -140,6 +140,8 @@ int qemu_fdt_add_path(void *fdt, const char *path); void qemu_fdt_dumpdtb(void *fdt, int size); void qemu_fdt_qmp_dumpdtb(const char *filename, Error **errp); HumanReadableText *qemu_fdt_qmp_query_fdt(const char *nodepath, + bool has_propname, + const char *propname, Error **errp); =20 /** diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 93a4103afa..320204e982 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -2488,8 +2488,11 @@ void hmp_dumpdtb(Monitor *mon, const QDict *qdict) void hmp_info_fdt(Monitor *mon, const QDict *qdict) { const char *nodepath =3D qdict_get_str(qdict, "nodepath"); + const char *propname =3D qdict_get_try_str(qdict, "propname"); Error *err =3D NULL; - g_autoptr(HumanReadableText) info =3D qmp_x_query_fdt(nodepath, &err); + g_autoptr(HumanReadableText) info =3D NULL; + + info =3D qmp_x_query_fdt(nodepath, propname !=3D NULL, propname, &err); =20 if (hmp_handle_error(mon, err)) { return; diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index db2c6aa7da..ca2a96cdf7 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -604,9 +604,10 @@ void qmp_dumpdtb(const char *filename, Error **errp) return qemu_fdt_qmp_dumpdtb(filename, errp); } =20 -HumanReadableText *qmp_x_query_fdt(const char *nodepath, Error **errp) +HumanReadableText *qmp_x_query_fdt(const char *nodepath, bool has_propname, + const char *propname, Error **errp) { - return qemu_fdt_qmp_query_fdt(nodepath, errp); + return qemu_fdt_qmp_query_fdt(nodepath, has_propname, propname, errp); } #else void qmp_dumpdtb(const char *filename, Error **errp) @@ -614,7 +615,8 @@ void qmp_dumpdtb(const char *filename, Error **errp) error_setg(errp, "dumpdtb requires libfdt"); } =20 -HumanReadableText *qmp_x_query_fdt(const char *nodepath, Error **errp) +HumanReadableText *qmp_x_query_fdt(const char *nodepath, bool has_propname, + const char *propname, Error **errp) { error_setg(errp, "this command requires libfdt"); =20 diff --git a/qapi/machine.json b/qapi/machine.json index 96cff541ca..c15ce60f46 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1688,6 +1688,7 @@ # Query for FDT element (node or property). Requires 'libfdt'. # # @nodepath: the path of the FDT node to be retrieved +# @propname: name of the property inside the node # # Features: # @unstable: This command is meant for debugging. @@ -1697,6 +1698,7 @@ # Since: 7.2 ## { 'command': 'x-query-fdt', - 'data': { 'nodepath': 'str' }, + 'data': { 'nodepath': 'str', + '*propname': 'str' }, 'returns': 'HumanReadableText', 'features': [ 'unstable' ] } diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 70a011495d..ad2386295b 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -823,23 +823,42 @@ static void fdt_format_node(GString *buf, int node, i= nt depth, g_string_append_printf(buf, "%*s};\n", padding, ""); } =20 -HumanReadableText *qemu_fdt_qmp_query_fdt(const char *nodepath, Error **er= rp) +HumanReadableText *qemu_fdt_qmp_query_fdt(const char *nodepath, + bool has_propname, + const char *propname, + Error **errp) { g_autoptr(GString) buf =3D g_string_new(""); - int node; + const struct fdt_property *prop =3D NULL; + void *fdt =3D current_machine->fdt; + int node, prop_size; =20 - if (!current_machine->fdt) { + if (!fdt) { error_setg(errp, "Unable to find the machine FDT"); return NULL; } =20 - node =3D fdt_path_offset(current_machine->fdt, nodepath); + node =3D fdt_path_offset(fdt, nodepath); if (node < 0) { error_setg(errp, "node '%s' not found in FDT", nodepath); return NULL; } =20 - fdt_format_node(buf, node, 0, nodepath); + if (!has_propname) { + fdt_format_node(buf, node, 0, nodepath); + } else { + g_autofree char *proppath =3D g_strdup_printf("%s/%s", nodepath, + propname); + + prop =3D fdt_get_property(fdt, node, propname, &prop_size); + if (!prop) { + error_setg(errp, "property '%s' not found in node '%s' in FDT", + propname, nodepath); + return NULL; + } + + fdt_format_property(buf, proppath, prop->data, prop_size, 0); + } =20 return human_readable_text_from_str(buf); } --=20 2.37.2 From nobody Tue May 14 11:11:47 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1661524613; cv=none; d=zohomail.com; s=zohoarc; b=dCe3t30cL4k7UDir6PngvJWTeKZnhUXXaKJdLwkfefzUh/BgCdjt+KVl8GUNo0LmhjeE2xMeECcmi1HS5Xkz17Sr4cXXzsKabUOToRpc7VqAt10QDrsU2AWZPG8bG2T33KJHnoWfVJszFDNt0DjMC+l4Ymui+jgfoVt3jPAzXNY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1661524613; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XZ2+l42NQGkEM1CbxvqM5IAi34JMlT8VNLeZsAU2PwU=; b=BZ/E9VfjxyqA5PQ0+60U5APF2Uv/qpYTwNo78579yXMzcX61y3sgD0YK6qWKMMaN/EnRbb2GopYdAuFiepNgYtErDaiKXH2m7h4hCx2VghSmVRTjC90jCx/RTIwYw63mG1s+dPUp1oTg9/cuj+WCNmBZJWedIYisBYSTq8IZOYY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1661524613955877.9501357357389; Fri, 26 Aug 2022 07:36:53 -0700 (PDT) Received: from localhost ([::1]:49322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oRaS4-0005r7-Tu for importer@patchew.org; Fri, 26 Aug 2022 10:36:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34082) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oRa4z-0000RD-72; Fri, 26 Aug 2022 10:13:01 -0400 Received: from mail-oi1-x232.google.com ([2607:f8b0:4864:20::232]:43721) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oRa4x-0003zt-2c; Fri, 26 Aug 2022 10:13:00 -0400 Received: by mail-oi1-x232.google.com with SMTP id w196so2105235oiw.10; Fri, 26 Aug 2022 07:12:57 -0700 (PDT) Received: from balboa.COMFAST ([177.189.45.98]) by smtp.gmail.com with ESMTPSA id z12-20020a056808064c00b00344aa3f17d9sm1087736oih.10.2022.08.26.07.12.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 26 Aug 2022 07:12:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=XZ2+l42NQGkEM1CbxvqM5IAi34JMlT8VNLeZsAU2PwU=; b=JuHUWni7JweBBhxOklvCTVfkwQLRIGwWvjRtxoH/nXjp5hI15bkA5dg4PDFh7Cc3VR jK0jUZxLnFPYWmIuXyop9IDs1VNUKWUdi8ONNAVDkbiu7sTqgR8CLqI79YZt5oaOENaf sYt0MdJgA9Yk4Nt4hDqcg5pWx/Y0WTbRIJ16eItxndIfCYkkhoK+dNgbtkIaGOPJGBmg IwzJyeSnaJ2ByyhS3bc6KvvHjXcYfP05BrLWgJA2BgMV1YK4URvQuPY3OmG/wMHZ1ykg J8pjSCtt7j8kTRgcOYG3DwpLXQke4jvL+BBM2TfsD3TFrsYF9K8Rt6a6PHDlRTCK7zBw 8mNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=XZ2+l42NQGkEM1CbxvqM5IAi34JMlT8VNLeZsAU2PwU=; b=PleGusDsNpTN26VxdbhJ6ecSeK4nICHcJhBGadP5sUcelkqUSZxnJIBSUdTvurErU8 ByqR8ezR2FoyNub0xl5cZn0QcrqxiMp1CWZDpVPaywWH6bOtu+aGzFCEUFbysylXTiPU 2RInUyMLf/Z77NMEEPD0513xZk0CyPMzoUl+LCGgndTENxx7vxurgADHW+Ri7Ic1cyDo 7zgV6u3ZHh3C8NubtpD0C34OC+PIByKtNvFNEGkGR2sEwxu/6oZL8CObNvPFJYtWM3oj WmHg3wBm+N/bzy+LlN2OObXHkQwgSf58EG/u64aKn4YdqpkC5WvR4E88EibnPZyn7h7x INMQ== X-Gm-Message-State: ACgBeo1n9DWhnTj0bMSJeyQS0j7OurytdHOJdXTGXPqAQcWKapPMfuCk SolV41Sviz4ZCPIgQy/1IxpHo2vTTsY= X-Google-Smtp-Source: AA6agR5CTZbyy1PsGqzceDXdEwSaSBPadcFUHh8q7kSmhrMZKjQkjuYI52nrej/ConCsmhoqM2SfZw== X-Received: by 2002:a05:6808:190e:b0:343:335:c0d1 with SMTP id bf14-20020a056808190e00b003430335c0d1mr1747315oib.246.1661523176690; Fri, 26 Aug 2022 07:12:56 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, clg@kaod.org, david@gibson.dropbear.id.au, alistair.francis@wdc.com, Daniel Henrique Barboza Subject: [PATCH for-7.2 v4 21/21] qmp/hmp, device_tree.c: add textformat dumpdtb option Date: Fri, 26 Aug 2022 11:11:50 -0300 Message-Id: <20220826141150.7201-22-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220826141150.7201-1-danielhb413@gmail.com> References: <20220826141150.7201-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::232; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x232.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1661524614363100001 Content-Type: text/plain; charset="utf-8" The QMP/HMP 'dumpdtb' command is saving the FDT blob to be decoded using 'dtc' like the '-machine dumpdtb' always did. However, after adding support for the 'info fdt' command, we're now able to format a full FDT in text format - which is what 'info fdt /' already does. Let's extend the 'dumpdtb' QMP/HMP command with the capability of saving the FDT in plain text format. A new textformat '-t' option was added to it. With this option, qemu_fdt_qmp_dumpdtb() will call qemu_fdt_qmp_query_fdt() to retrieve the human string that represents the output of 'info fdt /' and write it to the file. This will allow users to dump the FDT in a text file and immediately open it to see its contents, without the need of an extra step to decode a dtb blob with 'dtc'. Here's an example: (qemu) dumpdtb fdt.dtb $ file fdt.dtb fdt.dtb: Device Tree Blob version 17, size=3D15458, boot CPU=3D0, string bl= ock size=3D2318, DT structure block size=3D13084 (qemu) dumpdtb -t fdt.txt $ file fdt.txt fdt.txt: ASCII text, with very long lines (4746) $ grep -A 3 'persistent-memory' fdt.txt ibm,persistent-memory { device_type =3D "ibm,persistent-memory"; #size-cells =3D <0x0>; #address-cells =3D <0x1>; }; Signed-off-by: Daniel Henrique Barboza --- hmp-commands.hx | 7 ++++--- include/sysemu/device_tree.h | 3 ++- monitor/hmp-cmds.c | 3 ++- monitor/qmp-cmds.c | 8 +++++--- qapi/machine.json | 2 +- softmmu/device_tree.c | 25 ++++++++++++++++++++++--- 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/hmp-commands.hx b/hmp-commands.hx index 2dd737078e..8a9595cc26 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1808,8 +1808,9 @@ SRST ERST { .name =3D "dumpdtb", - .args_type =3D "filename:F", - .params =3D "filename", - .help =3D "save the FDT in the 'filename' file to be decoded= using dtc", + .args_type =3D "textformat:-t,filename:F", + .params =3D "[-t] filename", + .help =3D "save the FDT in the 'filename' file to be decoded= using dtc." + "Use '-t' to save the file in text (dts) format.", .cmd =3D hmp_dumpdtb, }, diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h index 551a02dee2..082ff69751 100644 --- a/include/sysemu/device_tree.h +++ b/include/sysemu/device_tree.h @@ -138,7 +138,8 @@ int qemu_fdt_add_path(void *fdt, const char *path); } while (0) =20 void qemu_fdt_dumpdtb(void *fdt, int size); -void qemu_fdt_qmp_dumpdtb(const char *filename, Error **errp); +void qemu_fdt_qmp_dumpdtb(const char *filename, bool textformat, + Error **errp); HumanReadableText *qemu_fdt_qmp_query_fdt(const char *nodepath, bool has_propname, const char *propname, diff --git a/monitor/hmp-cmds.c b/monitor/hmp-cmds.c index 320204e982..ffcb9ffb67 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -2476,9 +2476,10 @@ exit_no_print: void hmp_dumpdtb(Monitor *mon, const QDict *qdict) { const char *filename =3D qdict_get_str(qdict, "filename"); + bool textformat =3D qdict_get_try_bool(qdict, "textformat", false); Error *local_err =3D NULL; =20 - qmp_dumpdtb(filename, &local_err); + qmp_dumpdtb(true, textformat, filename, &local_err); =20 if (local_err) { hmp_handle_error(mon, local_err); diff --git a/monitor/qmp-cmds.c b/monitor/qmp-cmds.c index ca2a96cdf7..8d625e5e7d 100644 --- a/monitor/qmp-cmds.c +++ b/monitor/qmp-cmds.c @@ -599,9 +599,10 @@ bool apply_str_list_filter(const char *string, strList= *list) } =20 #ifdef CONFIG_FDT -void qmp_dumpdtb(const char *filename, Error **errp) +void qmp_dumpdtb(bool has_textformat, bool textformat, + const char *filename, Error **errp) { - return qemu_fdt_qmp_dumpdtb(filename, errp); + return qemu_fdt_qmp_dumpdtb(filename, textformat, errp); } =20 HumanReadableText *qmp_x_query_fdt(const char *nodepath, bool has_propname, @@ -610,7 +611,8 @@ HumanReadableText *qmp_x_query_fdt(const char *nodepath= , bool has_propname, return qemu_fdt_qmp_query_fdt(nodepath, has_propname, propname, errp); } #else -void qmp_dumpdtb(const char *filename, Error **errp) +void qmp_dumpdtb(bool has_textformat, bool textformat, + const char *filename, Error **errp) { error_setg(errp, "dumpdtb requires libfdt"); } diff --git a/qapi/machine.json b/qapi/machine.json index c15ce60f46..8573f96da8 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1680,7 +1680,7 @@ # ## { 'command': 'dumpdtb', - 'data': { 'filename': 'str' } } + 'data': { '*textformat':'bool', 'filename': 'str' } } =20 ## # @x-query-fdt: diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index ad2386295b..34af31552d 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -645,8 +645,10 @@ out: return ret; } =20 -void qemu_fdt_qmp_dumpdtb(const char *filename, Error **errp) +void qemu_fdt_qmp_dumpdtb(const char *filename, bool textformat, Error **e= rrp) { + g_autoptr(HumanReadableText) txt =3D NULL; + void *contents =3D NULL; int size; =20 if (!current_machine->fdt) { @@ -654,9 +656,26 @@ void qemu_fdt_qmp_dumpdtb(const char *filename, Error = **errp) return; } =20 - size =3D fdt_totalsize(current_machine->fdt); + if (textformat) { + /* + * 'info fdt /' returns all the FDT in text format, formatted + * with a style close to what 'dtc' uses to decode the blob + * to a .dts. + */ + txt =3D qemu_fdt_qmp_query_fdt("/", false, NULL, errp); + + if (!txt) { + return; + } + + contents =3D txt->human_readable_text; + size =3D strlen(txt->human_readable_text); + } else { + contents =3D current_machine->fdt; + size =3D fdt_totalsize(current_machine->fdt); + } =20 - if (g_file_set_contents(filename, current_machine->fdt, size, NULL)) { + if (g_file_set_contents(filename, contents, size, NULL)) { return; } =20 --=20 2.37.2