From patchwork Sat Sep 3 19:34:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965048 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC966ECAAD4 for ; Sat, 3 Sep 2022 19:40:31 +0000 (UTC) Received: from localhost ([::1]:46274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUZ0I-0006UG-Tf for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:40:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53602) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYuX-0006Ia-2e; Sat, 03 Sep 2022 15:34:33 -0400 Received: from mail-oo1-xc31.google.com ([2607:f8b0:4864:20::c31]:44638) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYuV-0005L8-Hb; Sat, 03 Sep 2022 15:34:32 -0400 Received: by mail-oo1-xc31.google.com with SMTP id q6-20020a4aa886000000b0044b06d0c453so909839oom.11; Sat, 03 Sep 2022 12:34: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:subject:date; bh=HovcpPksbyRH4MetLfjOHLX26QOG2cA8NngwzZBGLTg=; b=kWJbqmdTeAman2sZ9rgUvk25oAgs3vC7PsQ1ZRS6wZvy5NvBFreEwiLUJC3rtkugFl pd9+RURO12Zm72ZXgxNy84+G3uCvtIjVzQPXekkZEcugRtUc8+5yrs9K4DydeChLgvqN KVSo0YIB7UWVCebj51z6ZdQqS+Hpzdmq802RfBzGarDp19Y1tjjEgVJtZP3ywd2zxhRS S0JzlF5CVEYOpdKcqAXayBLAELdOekBhEXYyZ1C/WS2BT0lCB1VW0/I9wG6D9xjgKRRx Uw+bW0Q7P76pnIeTIUI7MdsjTyc1xpoVtyJ2C3/LrvOwDy1nP2K0RE1DAArpPHlo8BDR AZuw== 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 :subject:date; bh=HovcpPksbyRH4MetLfjOHLX26QOG2cA8NngwzZBGLTg=; b=IRZ4VlrqpRZSTbIj3zp4y+cjtm8sIoSUwzsAlcnRdQLrbrEyVzBhCRnHKqAG08Fg8y zWxJc2ZYsfCXJ92J77yjOY/VeAQokH3zcvPj+IsGt94vdPq8gZcH0Krk4Wde+dzG9x93 yGxbzvgev5amfMAfLjAaQ0yBQPgYUHnwl8bA7IT7HZV+2xIEN7aPW3x3/46ZpPNdC1Ow 9MDK3mDo2msxjVBmM5x6SmFzfG9zFJLRyUsSAzkfyNF1dg6VgZSCaz0bslmwkbedCbKj DWBRbTUbt/8DGf6uLjU84YaoQ8c0kc1edpFBkUXYTRDXSi6Xm+0m2/jlEeG+a0oSiOt1 L8JQ== X-Gm-Message-State: ACgBeo2hpCmZKbEsp8HWVwtWyDhSCTwoFRyEAMLWSmcz4tPucseq5uON XgmhtCF7dcCLLWUruT/qmqm1MjL562SfOg== X-Google-Smtp-Source: AA6agR7z5aUtRgOuC80D8Zc/1wYRHCU/gJQFNXhnqtfyYdQyQXoeBm3c/I/yD9DXXAmNf3mg52P32g== X-Received: by 2002:a4a:1787:0:b0:44d:f068:d0e2 with SMTP id 129-20020a4a1787000000b0044df068d0e2mr11928560ooe.27.1662233669512; Sat, 03 Sep 2022 12:34:29 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.34.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:34:29 -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 v5 01/14] hw/arm: do not free machine->fdt in arm_load_dtb() Date: Sat, 3 Sep 2022 16:34:07 -0300 Message-Id: <20220903193420.115986-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::c31; envelope-from=danielhb413@gmail.com; helo=mail-oo1-xc31.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 QMP/HMP FDT command 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index ada2717f76..60bbfba37f 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -684,7 +684,8 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, */ rom_add_blob_fixed_as("dtb", fdt, size, addr, as); - g_free(fdt); + /* Set ms->fdt for 'dumpdtb' QMP/HMP command */ + ms->fdt = fdt; return size; From patchwork Sat Sep 3 19:34:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965051 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6B8F7ECAAD5 for ; Sat, 3 Sep 2022 19:43:07 +0000 (UTC) Received: from localhost ([::1]:53968 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUZ2o-0002YJ-Ge for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:43:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYua-0006R4-Np; Sat, 03 Sep 2022 15:34:36 -0400 Received: from mail-ot1-x334.google.com ([2607:f8b0:4864:20::334]:45626) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYuZ-0005Ln-1c; Sat, 03 Sep 2022 15:34:36 -0400 Received: by mail-ot1-x334.google.com with SMTP id l5-20020a05683004a500b0063707ff8244so3681106otd.12; Sat, 03 Sep 2022 12:34:34 -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:subject:date; bh=cjAKqoCsh4ucsmwOdsaJfx2iBShktx1X0R5EseCjguM=; b=Je0h6qJEfPr7JOVFH/OGrwTfJrPtarYa/1RiFQxr3/67xtHbq38U4V0sb81TIfeKsw j4bNp4OW7OlwO0EavENrcWGs+gG4VOnw2UGRCgBeM6rT4kng5IQ+EVhzG1JDC3z842L1 9t7DoliHbiaWHent5xv8jjDCxJO2T+C+drnYcV/NIYhskm3D0E4srwGRXGkE6Zvfjy5q ZU3eyfuw/bgLJHJzWGyMJJSDtNChE6eqEAb8RdwErXeXVspSrFah+HXbqI0wkPZbwN/O ljMAXGTH4wE0q1wzWJqfxFBXUmONtEPBb9vYS9Shz+D0s5mZ4B2NkZZk4TgN+26RVfWM p4xQ== 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 :subject:date; bh=cjAKqoCsh4ucsmwOdsaJfx2iBShktx1X0R5EseCjguM=; b=aVviAIP+66jBipkgxB5/MjMVr23sStdrfUv09fSKRw79rVi6TfrHLKCpfPiI455v71 dUGNji9m8bXJe1+SvxDc7uoL0/mx0bRA1Q3oXuXoLPIaYEwrFeTqJ8WyrbXTOJdEgnop Yrj2WT8puDAGSn2+ffvsm9bf7GJS8BnfHelz4odoAanCzeVK9ZnQ9MwbKMdaTiDGrUgd FeqTRaamK+0ASND4Q0MI64RvKT4GUT87++WRw/jj+60YGMUjnPo4i1vLADvyNrAL1J2F fOzrZ9/E3E7rY3FEyKhNPfS5PTnuSemDimB8Xpy7xlQE2h4FCp2Can8fdNlK3si7g7Sv H8sA== X-Gm-Message-State: ACgBeo0/6ejbKJjPAnHHDSkp3Lb4FT4NCxVORKMSKisQBo5uMIBQnxWB tms9GivaSfD7CbPQJeAZEBcIxhfMj/AZPw== X-Google-Smtp-Source: AA6agR7XwpsctZtXutFDO7XpWaaMi+cKGfUU2lR9sXzwOY7gX5ljBbaEQSeHgq43co0c1CfFSZl9LQ== X-Received: by 2002:a05:6830:1418:b0:639:48a8:f005 with SMTP id v24-20020a056830141800b0063948a8f005mr17155430otp.94.1662233672689; Sat, 03 Sep 2022 12:34:32 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:34:32 -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 v5 02/14] hw/microblaze: set machine->fdt in microblaze_load_dtb() Date: Sat, 3 Sep 2022 16:34:08 -0300 Message-Id: <20220903193420.115986-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::334; envelope-from=danielhb413@gmail.com; helo=mail-ot1-x334.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This will enable support for 'dumpdtb' QMP/HMP command for all microblaze machines that uses microblaze_load_dtb(). Cc: Edgar E. Iglesias Signed-off-by: Daniel Henrique Barboza --- hw/microblaze/boot.c | 8 +++++++- hw/microblaze/meson.build | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c index 8b92a9801a..c8eff7b6fc 100644 --- a/hw/microblaze/boot.c +++ b/hw/microblaze/boot.c @@ -39,6 +39,8 @@ #include "boot.h" +#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 = MACHINE(qdev_get_machine()); int fdt_size; void *fdt = NULL; int r; @@ -100,7 +103,10 @@ static int microblaze_load_dtb(hwaddr addr, } cpu_physical_memory_write(addr, fdt, fdt_size); - g_free(fdt); + + /* Set machine->fdt for 'dumpdtb' QMP/HMP command */ + machine->fdt = fdt; + return fdt_size; } 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 = 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('petalogix_s3adsp1800_mmu.c')) microblaze_ss.add(when: 'CONFIG_PETALOGIX_ML605', if_true: files('petalogix_ml605_mmu.c')) microblaze_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true: files('xlnx-zynqmp-pmu.c')) From patchwork Sat Sep 3 19:34:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965044 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F9A4ECAAD5 for ; Sat, 3 Sep 2022 19:36:45 +0000 (UTC) Received: from localhost ([::1]:42990 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUYwe-0001ak-2K for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:36:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYuc-0006Wm-Pm; Sat, 03 Sep 2022 15:34:38 -0400 Received: from mail-ot1-x32f.google.com ([2607:f8b0:4864:20::32f]:42958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYub-0005MA-6V; Sat, 03 Sep 2022 15:34:38 -0400 Received: by mail-ot1-x32f.google.com with SMTP id h9-20020a9d5549000000b0063727299bb4so3691516oti.9; Sat, 03 Sep 2022 12:34:36 -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:subject:date; bh=YOFZ9NdiFBAa9F2Aq+WCsRHWWt7d567/X2aplHJ6aKE=; b=Kna+RIN6/TSYfqv0Gx1ltRKmcNvF+byiFVONNyLyLkdCUPfSaxVFd6PqXeTPY2Ylv9 8Ih7bC7cbXj7Z+Hcn5PhMbkIH8JDuoVl5gtgA9ooZEtHu9wOTD4hIw+3WgATlguWXWbT fugLNHObj9v7/EY15Dpem7u5d7SdxUxEb5KLJeIYHgKGtc5X2xgAuySzUCrIzMDA0NHw Z9qJVAxAn1/0CN5W5PquLU21jZnPXOUyAe2rQyIxs+z7rubjdaY0Y+s0vYvwPbz7O4/Y xOeqvdf278vaRzytwPC6Ic5xceCJ9ORqtCP/Xb1tr2NtECxaQ5Uujiagest9s8pAnLgM z9DQ== 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 :subject:date; bh=YOFZ9NdiFBAa9F2Aq+WCsRHWWt7d567/X2aplHJ6aKE=; b=o1VPJkA5WcR6Q90I0t8VdmY6k0Kgo8kcznNW3XgtHdJ5ZDm7Us9kYC7kf0cAj5fWbx +ahoIW+omWrdIsxxdidkPKowd4NBoizbJ1qKIz4qVjzDzk61nlxnXhU/OB4IgcE2w7h9 4ASNBqkmx4kYTQxoPCBk0EQJCaVT8v/Vbq+T/0TIv6HcjF1W0AZzxnJR0BZ2zZ1yvCB5 /JBFy03qD/+HDPeB7aUakyuVG2oQzPidjnWlSTmvieXo1LvSFoqimQEdMFziccYu64cx ekFgY330N5luA+AXKD+utqreT1FETG2NBdrza6uuVO9bI306VZZHrPr8AbpCG2WteYd7 282g== X-Gm-Message-State: ACgBeo2hKypUx+5hIgdN8qQ79eJRglz1V6C2Bwi6xOd3k2MjTrAOY2NZ b4BQLK1sUZvpIUq4RZ36/DifhHVPspyQXA== X-Google-Smtp-Source: AA6agR6OkvU1+DQY5EgezvmuQrNmZilCT6PO5CWQBCa/CWd3vvumdVJSAGYDD/D8YA5QTTbGYFlk3Q== X-Received: by 2002:a05:6830:1496:b0:639:648a:55f4 with SMTP id s22-20020a056830149600b00639648a55f4mr16424672otq.370.1662233675684; Sat, 03 Sep 2022 12:34:35 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:34: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 , Chris Wulff , Marek Vasut Subject: [PATCH v5 03/14] hw/nios2: set machine->fdt in nios2_load_dtb() Date: Sat, 3 Sep 2022 16:34:09 -0300 Message-Id: <20220903193420.115986-4-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::32f; envelope-from=danielhb413@gmail.com; helo=mail-ot1-x32f.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This will enable support for 'dumpdtb' QMP/HMP command 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 | 8 +++++++- hw/nios2/meson.build | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c index 21cbffff47..b30a7b1efb 100644 --- a/hw/nios2/boot.c +++ b/hw/nios2/boot.c @@ -43,6 +43,8 @@ #include "boot.h" +#include + #define NIOS2_MAGIC 0x534f494e static struct nios2_boot_info { @@ -81,6 +83,7 @@ static uint64_t translate_kernel_address(void *opaque, uint64_t addr) static int nios2_load_dtb(struct nios2_boot_info bi, const uint32_t ramsize, const char *kernel_cmdline, const char *dtb_filename) { + MachineState *machine = MACHINE(qdev_get_machine()); int fdt_size; void *fdt = NULL; int r; @@ -113,7 +116,10 @@ static int nios2_load_dtb(struct nios2_boot_info bi, const uint32_t ramsize, } cpu_physical_memory_write(bi.fdt, fdt, fdt_size); - g_free(fdt); + + /* Set machine->fdt for 'dumpdtb' QMP/HMP command */ + machine->fdt = fdt; + return fdt_size; } 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 = 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_nommu.c')) From patchwork Sat Sep 3 19:34:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965054 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4B8C4ECAAD5 for ; Sat, 3 Sep 2022 19:45:55 +0000 (UTC) Received: from localhost ([::1]:59564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUZ5W-00070U-FL for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:45:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37008) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYug-0006gY-61; Sat, 03 Sep 2022 15:34:42 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]:42898) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYue-0005Ml-IZ; Sat, 03 Sep 2022 15:34:41 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-11f34610d4aso12839578fac.9; Sat, 03 Sep 2022 12:34:39 -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:subject:date; bh=mGG3U2Luf4I4urQShsm1RjBsPx5YCf60/nn93DboxwM=; b=G4ydH1+eRpwK7ql9aIgeXgqPjrY1ltzEZ/kiodyFFI/J6XDc+oL8E6AhcL/Vas1Xgf ZV2Q7JHhaBG3MxRnRDfFOpTsgJER3Zodc6CJFLy/vbbVL+UF2SGU4QHYNdJOIlL6a5Ep ZXaWtYUzW0uvYVEm/R1fXPLBxx7aHGxCfcOdj7ziJACAwunRm6dO60//FMPf61JIl6FP SuBq6rh0e4sT+ByJt4x8OB6LBRevkwNNklxEt7UtRf4sq9vqQ2NKtVFX9WlCWMD8w7Ss fkRNLdkQG3Yeu+gSHZ5z6MvHYnUBWLUfwDaCNRe0ceZJbTdV0G7fiiKUixcxJ7qBeThL m5ug== 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 :subject:date; bh=mGG3U2Luf4I4urQShsm1RjBsPx5YCf60/nn93DboxwM=; b=NxrjGRellhcM6rYzTAjvWNplvZPPzKEyuj7bmXLPWCAFtiXicz5iffC1XZRgbif8zL H7tLLlxqSP32fsO/VwV22xFW1aZRN0OvrUzHys1yxU6IWiR/FrJBWmntqUw+DTNJ6Dbf Uwltrk1LoGWhdewWkxViGJG6NcQHbVJs7ACnRFoEkEoJmLA1NWuNiEicz04D/yMYnrNR UeA3+a7BNs3sJJnxZt2u6gN4yyCksyJAEFguMRkXGK/waPmcYufeIOhFW+Wnja8Af6gp hs3Mvn/ve5xvzgbrt+rJI1COFQdmkAwcNxF86bIUdJAR1QvfS3AUVq5H8iTNBp71q5PL rJOg== X-Gm-Message-State: ACgBeo38ogsTXmNExmfz+qQyjzEDEneS7ua4iy7naeTjWj+E1zmqBzMi wfNHlrUEbcGFZx1NYMlz1kmF2c8p8KfPKg== X-Google-Smtp-Source: AA6agR6HOJTlRbS0q6iXIjFGmVKp4Kov43XOg5L07v1OhZdAKG+COyJPvOdkBRxaoM6/uvOvdRjqYA== X-Received: by 2002:a05:6808:654:b0:345:c243:4a1 with SMTP id z20-20020a056808065400b00345c24304a1mr4417959oih.220.1662233678628; Sat, 03 Sep 2022 12:34:38 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.34.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:34:38 -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 v5 04/14] hw/ppc: set machine->fdt in ppce500_load_device_tree() Date: Sat, 3 Sep 2022 16:34:10 -0300 Message-Id: <20220903193420.115986-5-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::29; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x29.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This will enable support for 'dumpdtb' QMP/HMP command for the e500 machine. Cc: Cédric 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..ea5f947824 100644 --- a/hw/ppc/e500.c +++ b/hw/ppc/e500.c @@ -47,6 +47,8 @@ #include "hw/i2c/i2c.h" #include "hw/irq.h" +#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 = fdt_size; - g_free(fdt); + + /* + * Update the machine->fdt pointer to enable support for the + * 'dumpdtb' QMP/HMP command. + * + * The FDT is re-created during reset, so free machine->fdt + * to avoid leaking the old FDT. + */ + g_free(machine->fdt); + machine->fdt = fdt; out: g_free(pci_map); From patchwork Sat Sep 3 19:34:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965045 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BEBA6ECAAD5 for ; Sat, 3 Sep 2022 19:36:49 +0000 (UTC) Received: from localhost ([::1]:42992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUYwi-0001nj-Ra for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:36:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYuj-0006nA-1H; Sat, 03 Sep 2022 15:34:45 -0400 Received: from mail-oa1-x2c.google.com ([2001:4860:4864:20::2c]:33632) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYuh-0005NA-Go; Sat, 03 Sep 2022 15:34:44 -0400 Received: by mail-oa1-x2c.google.com with SMTP id 586e51a60fabf-11eb8b133fbso13022141fac.0; Sat, 03 Sep 2022 12:34:42 -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:subject:date; bh=jd3wQPysMcgs0ZoMNBn7tHzgPrtVMg9YzAzU5clTyec=; b=O5ZJgM6SpQCFnwDgZNxQnHAXL2b2QXu44gaXpkUrq4IcDAHRbyG52uUbNJyMr/ZikE e/841tU6+iFtBFoqMKTGGOrSeSmF6Hid1dprwPuxRPPdXl1bk0ajWLhRPacHfe/OoOQQ tH++Va/nSyy8gmqnhZw4Ml+BKor1LXJbDlmStaMaWv3oYOKSpAczQ2wE5BsFzImABAGn 9oNnb8mgvX5CNNOh8PQ80KeJ8NpoQWLgfVIuvLD6AnAAjXWEPAeBaq5XQpdXyO2f4s5d hHwjrj8Wogas3Jr3TolGjmXif/Eu6T7oDi6PfSODLQxLvts4BOTiWuIkIpQZD4q8NUaE C0OQ== 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 :subject:date; bh=jd3wQPysMcgs0ZoMNBn7tHzgPrtVMg9YzAzU5clTyec=; b=tAv/WjmOBwASl63vzUDQbDThgEXpaM3iNQRCmv04ZCAQSvBDEsy52BKhaCp4Xl4HYT o4m2HjXrMs6pB/VIXdGGmJXwQGzwUFIuLJdcniTXY9KFlTnYkLma131s3wiOm8wut6Dq u9TrbWxoGss8MIlmt9pJKM4MHPoXekU2JiHa6z2F6QeyMSoQfiV54RvbzcMw/COQLhvP uw2xCFiKSkDngiBO1i3ZGXs6RFL6G9hk2IETYk5RMs97Fgc3GSpeIMgBWtlZ+JQhbgZy JhClSorwMngZIqWDEx5zMeqRftLbkTOqG2LyhyavzApMJVeYVDJqZ98kRAF1n1R83AjF 7mEg== X-Gm-Message-State: ACgBeo1RYiFm3fzXtQYWD4B+9ZuhoafHSdhObuwLhvWJHrfxCqu9EvIy ueVHaRwIbyFjR9a0kbzTdFQzmcY1hJHMOA== X-Google-Smtp-Source: AA6agR6kbgXsODO3iMDqCrztxnvTO2SoYInFElFY3khzuRw7HKVXRcSs5B/U/gCpTBecPuSCdi9V9Q== X-Received: by 2002:a05:6808:11c3:b0:345:da0d:82a9 with SMTP id p3-20020a05680811c300b00345da0d82a9mr4320433oiv.244.1662233681198; Sat, 03 Sep 2022 12:34:41 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.34.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:34:40 -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 v5 05/14] hw/ppc: set machine->fdt in bamboo_load_device_tree() Date: Sat, 3 Sep 2022 16:34:11 -0300 Message-Id: <20220903193420.115986-6-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::2c; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x2c.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This will enable support for 'dumpdtb' QMP/HMP command for the bamboo machine. Cc: Cédric 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 ea945a1c99..aa5c901b09 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" +#include + #define BINARY_DEVICE_TREE_FILE "bamboo.dtb" /* from u-boot */ @@ -62,6 +64,7 @@ static int bamboo_load_device_tree(hwaddr addr, hwaddr initrd_size, const char *kernel_cmdline) { + MachineState *machine = MACHINE(qdev_get_machine()); int ret = -1; uint32_t mem_reg_property[] = { 0, 0, cpu_to_be32(ramsize) }; char *filename; @@ -119,7 +122,13 @@ static int bamboo_load_device_tree(hwaddr addr, tb_freq); 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' QMP/HMP command. + */ + machine->fdt = fdt; + return 0; } From patchwork Sat Sep 3 19:34:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965056 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2C1E3ECAAD4 for ; Sat, 3 Sep 2022 19:49:38 +0000 (UTC) Received: from localhost ([::1]:47326 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUZ97-0002TK-9T for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:49:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59678) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYuo-0006wQ-2w; Sat, 03 Sep 2022 15:34:50 -0400 Received: from mail-ot1-x329.google.com ([2607:f8b0:4864:20::329]:43915) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYuk-0005Nc-J1; Sat, 03 Sep 2022 15:34:48 -0400 Received: by mail-ot1-x329.google.com with SMTP id 92-20020a9d0be5000000b0063946111607so3698983oth.10; Sat, 03 Sep 2022 12:34:44 -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:subject:date; bh=NdbrEiqC2XXclgTnOkab3L871EZ9bSK5AzsRTBYhN1c=; b=HTe25KdS8t+J8zETXXfxvXTLyuoVlH5w0pz0XFRzV2tpx1xAh1nsEiojqYl+fbCO39 22K7JPk3xbZAVOx70xeFycPmUxoBcLq2wZX6qlRpkwvRnnB37K0xd3G5+KR4J0AYfahD LYHf5P+Cg9hk5BHh35yfmQc7Y/uxgSrybiuLSVh8NgU9kFLzKVm3VI0b/ofN+cuagEAm drJ+Poe1NJqN1/IfeiNFePn/hAGh4bI5IFvO443J7cgCHP7OUjPBArDd7ceLWGSu394C uAaOqqlHtvtwBoupLN8ZnfEcmuLRDKm27hNYDyjmFsN6W/4ZIdtNTtRKsqwxFP54+Q1m sD4A== 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 :subject:date; bh=NdbrEiqC2XXclgTnOkab3L871EZ9bSK5AzsRTBYhN1c=; b=bbF4Og6A7TzksmtbMha3HAjcgRpvfaugc04sNbMN001TQpSx0MaIbbsl8HMXYAocov H9dpvrzgBP9BRcIy0oPbKVPABp/ksjD2a/SlFXZ8TMYc5ujnuUapoWvsgXh2Q+R1PCfX iNM8d/FRpTRgRpaM3LGReWw0YcukhkcxxBNz741GrTxRe5IfhnZSrgOj0KlSXhK5hWTz BjN2h43nQfHkIunPsikf2FOVViwU5e7vuSlbGM/lWuMqCOtWQs9TJK3UPexBV95Aaq2i D10zAPvouMKbOj3d5DqB2LfIc50lGfk9ds/Xns6WPL09XEw890OMhWh9hhIWs99TooKL O3ug== X-Gm-Message-State: ACgBeo2/U3oqE6h7SWPT+TAFZpJCy5D3/lWLMgp2NKijI8U+Ihx5C9/R zZVWiq6cvIZ702jXmrR6xwOewZfBMhMxgw== X-Google-Smtp-Source: AA6agR53pZycEfHRjyc/21uXrbUbIKn0YVM8f2ny74OyvjXTvpQpqQ8dtlmyJKBSyK3KYC8cnZ7O/Q== X-Received: by 2002:a9d:2dc2:0:b0:637:3176:cf00 with SMTP id g60-20020a9d2dc2000000b006373176cf00mr16083317otb.296.1662233683977; Sat, 03 Sep 2022 12:34:43 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.34.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:34:43 -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 v5 06/14] hw/ppc: set machine->fdt in sam460ex_load_device_tree() Date: Sat, 3 Sep 2022 16:34:12 -0300 Message-Id: <20220903193420.115986-7-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This will enable support for 'dumpdtb' QMP/HMP command for the sam460ex machine. Cc: BALATON Zoltan Signed-off-by: Daniel Henrique Barboza --- hw/ppc/sam460ex.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 850bb3b817..fa6f125fda 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -137,6 +137,7 @@ static int sam460ex_load_device_tree(hwaddr addr, hwaddr initrd_size, const char *kernel_cmdline) { + MachineState *machine = MACHINE(qdev_get_machine()); uint32_t mem_reg_property[] = { 0, 0, cpu_to_be32(ramsize) }; char *filename; int fdt_size; @@ -208,7 +209,9 @@ static int sam460ex_load_device_tree(hwaddr addr, EBC_FREQ); rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr); - g_free(fdt); + + /* Set machine->fdt for 'dumpdtb' QMP/HMP command */ + machine->fdt = fdt; return fdt_size; } From patchwork Sat Sep 3 19:34:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965057 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AE97EECAAD4 for ; Sat, 3 Sep 2022 19:51:05 +0000 (UTC) Received: from localhost ([::1]:34914 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUZAW-00046k-T3 for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:51:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59680) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYup-0006zP-Le; Sat, 03 Sep 2022 15:34:52 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]:46606) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYun-0005O5-QH; Sat, 03 Sep 2022 15:34:51 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11f4e634072so12796673fac.13; Sat, 03 Sep 2022 12:34:48 -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:subject:date; bh=wcu8NnDjsEBMlgSuANlfln4lhGjabF4edEDSGqP1+cc=; b=jjb5fw8DS//AN0T1F36WLcaXMeBP8c3Uie072qKRyXkkR6SAQEM6OTZXGyaAXd/s8U 2nPWFOawC6GxqO3a0lQVhE/HnFhK8GT40DOWOzDKk9MfOkp6KZOucIbKEjVIpiyiDqpH e0RNLCWN/KfeCdhoMXPhgAJkw2/nE3afrgA1lZqloxK8pk1lzCV8f3NO8MHPXuP17SaT 0ZZ+FHTFSUUh1RmsezkRN04K+WMOinZMAyKV244h9htYJhE9AKpsiWB4tcVHw5vY/xpp 5Cc7tX+8cd7hZKeWwuna0CfV3Z+qpVWxw/MgZ+wBs6vHtvXe/NfkSz/lnXU1Jf5e1/z5 +LIw== 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 :subject:date; bh=wcu8NnDjsEBMlgSuANlfln4lhGjabF4edEDSGqP1+cc=; b=lenw/+jCzDdnF85adZwUYn3dKycBPPUp8j2QzBbprsGEtE+mR0feBt16Juej+ka+fT SOp2KFDfLPMF3+zPNei9DE83IJncovhR092e3FC3jtv5RK9ffkLyKFBVO5QLj48DKP2B O9aobyqqhYrAoS6C4Iy7cUR+PxU+XRnU6AuuDR2Kmb6fVgBkAwqpo3eb2yxXK36XkqfK 1Y45R7KVn6cqj3QqYpJuHQd8g2+ULvTdrvZhkFOqPeYh0lZxy9ZLMqsWvuyVm/btjAMD 6r6xNUQKARMH5To2jIYLGcfMU3TcadFGJW+2gyU3oCpSwiQUzjZgSxmk/hhHR1vSX3kL fEMQ== X-Gm-Message-State: ACgBeo2msDg932Zn+wmtPXCIv8pCr87lsqEj55tIsR3l9i+LO6zbwgOt 99ekT3X4FVTTOf6YFWLFywWKjrSEMNnOBg== X-Google-Smtp-Source: AA6agR5W+POh1llsP1fkmQlAtMiXohCAjtpyCafAO3ljAyn1Q1qJ7Ml9gzxZbTF0Pbv/HaRHCv4uQA== X-Received: by 2002:a05:6808:3093:b0:343:1ade:428b with SMTP id bl19-20020a056808309300b003431ade428bmr4278941oib.145.1662233686667; Sat, 03 Sep 2022 12:34:46 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.34.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:34:46 -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 v5 07/14] hw/ppc: set machine->fdt in xilinx_load_device_tree() Date: Sat, 3 Sep 2022 16:34:13 -0300 Message-Id: <20220903193420.115986-8-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This will enable support for 'dumpdtb' QMP/HMP command 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 493ea0c19f..bb21b2a309 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" +#include + #define EPAPR_MAGIC (0x45504150) #define FLASH_SIZE (16 * MiB) @@ -150,6 +152,7 @@ static int xilinx_load_device_tree(hwaddr addr, hwaddr initrd_size, const char *kernel_cmdline) { + MachineState *machine = MACHINE(qdev_get_machine()); char *path; int fdt_size; void *fdt = NULL; @@ -194,7 +197,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'QMP/HMP command. + */ + machine->fdt = fdt; + return fdt_size; } From patchwork Sat Sep 3 19:34:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965047 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 098FFECAAD5 for ; Sat, 3 Sep 2022 19:37:17 +0000 (UTC) Received: from localhost ([::1]:34776 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUYxA-0002vt-6s for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:37:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYur-00070b-Jn; Sat, 03 Sep 2022 15:34:54 -0400 Received: from mail-oa1-x2f.google.com ([2001:4860:4864:20::2f]:37680) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYup-0005OK-NK; Sat, 03 Sep 2022 15:34:53 -0400 Received: by mail-oa1-x2f.google.com with SMTP id 586e51a60fabf-11e7e0a63e2so12914094fac.4; Sat, 03 Sep 2022 12:34: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:subject:date; bh=TbC7OXNGaPRLfVBMKv3PiK63ZCziWYgCmU/Wi2I5iMc=; b=SssYj4Stb9zyWjchxCdQ2uxcwP6XSD/Atfci9SItIAio4yv9po2GrB02lczsWyHGyO dTqP6kJqZyH7g1mO2StDaLCkUJbnCTD43xeGIcBXpTahlapbi9TgZmVVnLXZxavNU+by mt8b9HGz8939EYXgVstubjtU9JzglWQNb/EcsiffW2Z1aVta1BRoyeBIF7JCwTsEY7/E qP5uOmVnIBD5TDs4chVGVu842cb4urxKXi+kPXawjmxVrMDxHjVHKAZCNPwXFMbo45Hx JD1L7thxR0h887rEqmPuUdtHtzq4XTGZypHCE01UDCmaJqKXsfZhBijQm9mk7btKANOt 0HZA== 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 :subject:date; bh=TbC7OXNGaPRLfVBMKv3PiK63ZCziWYgCmU/Wi2I5iMc=; b=S/cAD7O4Q6epdOu7d1p54KetkNc1Mjt0YgU6jX39DiJq3qUsxuveQnV16mNP6+6Ffz W+IN12L5qb+IXJR3PxZJvuUTob8IdmexerjNczJ0Iye5+RY4ycb4g/e2C4zkq60KXU/i ioRMbrk+hJSvaWFy+p6ZAzpoxyR3zk7hfVNFfMQSP79VwPVaKCgOLa6gHunGurtEPiCk 5SJ1+rbg5N6LmK4qF6kkzbuTIH/6SDupHwGMGLqkOEacPJ78NY2Tu9F/j4EHXA1ysptA uIigu0ahmnvXhayObiKNTbJoaVgrQx/12pbWAxPpWYSvHSAZsDBRhTqyolD/uFjvETmj 6rkg== X-Gm-Message-State: ACgBeo0Y3fWU/7GC+eG73HxU4u7gJIiBGJIzR+K5TyxHjQ5qUH7A5rjy UwXFGIs5QZSOIgQC35GQwHKX0sT0XvxgkQ== X-Google-Smtp-Source: AA6agR7/fW3MoWmliQ2/5FFD4iCXfU8z2WQJrxno9oFejPELInroSSIw9FM282a508o8TpCLVK8nRQ== X-Received: by 2002:a05:6808:17a3:b0:343:300a:6a96 with SMTP id bg35-20020a05680817a300b00343300a6a96mr4251068oib.169.1662233689260; Sat, 03 Sep 2022 12:34:49 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.34.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:34: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 , BALATON Zoltan Subject: [PATCH v5 08/14] hw/ppc: set machine->fdt in pegasos2_machine_reset() Date: Sat, 3 Sep 2022 16:34:14 -0300 Message-Id: <20220903193420.115986-9-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" We'll introduce a QMP/HMP command 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..d7ea139ff4 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -331,6 +331,13 @@ static void pegasos2_machine_reset(MachineState *machine) 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' QMP/HMP command. + */ + machine->fdt = fdt; + pm->cpu->vhyp = PPC_VIRTUAL_HYPERVISOR(machine); } From patchwork Sat Sep 3 19:34:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965049 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7C653ECAAD4 for ; Sat, 3 Sep 2022 19:41:13 +0000 (UTC) Received: from localhost ([::1]:50014 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUZ0y-0007jO-GO for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:41:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYuv-000730-Uw; Sat, 03 Sep 2022 15:34:57 -0400 Received: from mail-oa1-x2b.google.com ([2001:4860:4864:20::2b]:36377) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYus-0005Oi-Bd; Sat, 03 Sep 2022 15:34:57 -0400 Received: by mail-oa1-x2b.google.com with SMTP id 586e51a60fabf-11f11d932a8so12918847fac.3; Sat, 03 Sep 2022 12:34: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:subject:date; bh=m2gi4dfAl1OXdDzHLeD2gtzCh2ri3JmVJxGP9lnJ7D0=; b=ORePCByxr4r5iLXPavR9AidoxTKT0oVAiphCjZmN/qBznJQ/RwlbXaZj9QsQZtdIrL WwyvWvNfACJekui+BKfBduCrF+nMhZvsldxTLJtIp43n/oiJNyqGu3o144wITrAgr5zP I/W7NzVMoN4LwgEGCklO+ml64d1mihCbhuNioTHm/bsLrIVTLJ7Hh46NkIH0U0KPAu1E xOHOATyU6mJc1mh1SfqvIpwPvQfnB9CYiXgwFcwpaybLQaiuZHFSE3CYdtp7/9nqzWjy /Q4o+UCBNXVRwc5o167Pe81PAcoV3f6z3A7GV2IBG4m/3HLZVXZq4v6lfcYJEM3Ajhvn SNdg== 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 :subject:date; bh=m2gi4dfAl1OXdDzHLeD2gtzCh2ri3JmVJxGP9lnJ7D0=; b=NOkJkfGI5smUDyw2v6Ry+lTzBTX2zHOTM9QAFmYP9r9niZ+rYf1HXYHPyNeparLGQL QBkAVrGvyzVsapfyqPEDhJqk6xbpxPPBIYQQochc/SC6xaBr2sR0Mp1oLhAcXL1W98qK 48Brfbg/7aaSTAULChGaMAGxUX62fe4rJMyjLdA4GdSwgKtO4R4ffwetW6qPPjMcGWHr LXyeNnTXLOe8uNTVjS1pB6Tn6paFEpkBJKqeU/gX2tsoIqt9pTzVNn3fEnjMZ5q3P5IG KiUpEAq9woSAk653iotAk165NsKSCqkK3cFqw5JR2Zj2A4j2l9J1GV5TJBy4t+3Y4Xnw lgSQ== X-Gm-Message-State: ACgBeo1IU/fYY/3s8WlVI9o2f6q85L3I//LOWi1PvrpAQ7TNacx3G9Oe +ZV7TVJL//KOWNgv4cPleMRWHRV/pfELWA== X-Google-Smtp-Source: AA6agR5tGUFqQcHzilq4WW03aZDBtZOtneTIDLZtuLH6azABM+Z5mzjrTwiY8h98mnPxJ8HrHLWdsQ== X-Received: by 2002:a05:6808:2d7:b0:344:a080:7e8a with SMTP id a23-20020a05680802d700b00344a0807e8amr4351718oid.10.1662233692075; Sat, 03 Sep 2022 12:34:52 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.34.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:34:51 -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 v5 09/14] hw/ppc: set machine->fdt in pnv_reset() Date: Sat, 3 Sep 2022 16:34:15 -0300 Message-Id: <20220903193420.115986-10-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::2b; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x2b.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This will enable support for the 'dumpdtb' QMP/HMP command for all powernv machines. Cc: Cédric 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 354aa289d1..afd90d261b 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -678,7 +678,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)); - g_free(fdt); + /* + * Update the machine->fdt pointer to enable support for + * 'dumpdtb' QMP/HMP command. Free the existing machine->fdt + * to avoid leaking it during a reset. + */ + g_free(machine->fdt); + machine->fdt = fdt; } static ISABus *pnv_chip_power8_isa_create(PnvChip *chip, Error **errp) From patchwork Sat Sep 3 19:34:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965058 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AB855ECAAD4 for ; Sat, 3 Sep 2022 19:52:10 +0000 (UTC) Received: from localhost ([::1]:39560 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUZBZ-0005Zl-OV for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:52:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53694) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYuv-000739-WA; Sat, 03 Sep 2022 15:34:58 -0400 Received: from mail-oa1-x36.google.com ([2001:4860:4864:20::36]:43921) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYuu-0005PI-DG; Sat, 03 Sep 2022 15:34:57 -0400 Received: by mail-oa1-x36.google.com with SMTP id 586e51a60fabf-11eb44f520dso12859465fac.10; Sat, 03 Sep 2022 12:34:55 -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:subject:date; bh=4Py3VaXrPBdhE5ICKwSeppRRZbHoVSkb711NOHh8TUA=; b=j2URrVCqm2SrqZWfqYgKbnC6JtS/ByLx8lGq9HHFroFSGVgO22yV7fjNdk7JFhho/w XxVGDoUSLfv8my5/5bvHG82nDXcxOzro4Fj3Q4yKb6lzPbPpl1NZdSOuXcvf//tNDmFG TTLJeQBGJpyCD9FbhdcV9uOPupmtclu5w9iXO/Q1JS1R1hbSxcEk+tSx9TiDUrrBwZrh KYZb35UU9Wmp4XDhrPWte8W1QLw5mD3knYgULwPy+wtPBSeyWKG38aUdqFQ0ErahZ7U6 /eqahJ6Cq3UGuMSjnET3vPPAoZafBS0zox1dD6U6WNj5WiX7X4FDJjj31fWcdFE9bzYG w8NQ== 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 :subject:date; bh=4Py3VaXrPBdhE5ICKwSeppRRZbHoVSkb711NOHh8TUA=; b=gDiF5l/27EeJKMRAmlzuaECym3j4hxvN+ZNUFb7sb50jBhSYLWGIM+BZxl+aZ+oEAB sGFTwBQKwgGtSLe3oTmiT4iAAoqvO7ERMsL2R3s2abEiGj03ZPGea7eYKQ08DkCRkK4I a8fJ/FfpWi6QtqK4RpMyo6RM+ZP7xgnmRyK3vc0EvP8ml9iFrhxXx8TTtH6m1RyNe62e EBLhITolEsXpjuJttf7DpaeFjWFgwlbtsA9JuMYJQcj4gnJ9D/RpQxY3zAZX4XpOohWh hWakDwTK7XmFHjlsJIGra/de/2cAS+X0tlOloSppAVNsAoiUUH07FvsUUamF9cFO7Ysz QXWA== X-Gm-Message-State: ACgBeo1fyXmZDqMGia5EtZPPsi2FwWK3bAw4fD3CcqZQl9LbMPZ5Pn9T GwWnrrTCvbSPlIoIJ+kIvFFL3n7m65qzIg== X-Google-Smtp-Source: AA6agR6E0zmmN/3vw1RQMJAF8sIvcH+Ht559xw/Lc7jPJQ5O1rqUo8MWkJM8liaIzo89Mrw9j2oH2Q== X-Received: by 2002:a05:6870:15c9:b0:101:e18b:d12d with SMTP id k9-20020a05687015c900b00101e18bd12dmr5202271oad.51.1662233694609; Sat, 03 Sep 2022 12:34:54 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.34.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:34:54 -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 v5 10/14] hw/ppc: set machine->fdt in spapr machine Date: Sat, 3 Sep 2022 16:34:16 -0300 Message-Id: <20220903193420.115986-11-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::36; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x36.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" 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 a QMP/HMP command to dump 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 this QMP/HMP fdt command. 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édric Le Goater Cc: qemu-ppc@nongnu.org Reviewed-by: David Gibson Signed-off-by: Daniel Henrique Barboza --- 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 fb790b61e4..f0e5144d83 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1713,6 +1713,12 @@ static void spapr_machine_reset(MachineState *machine) spapr->fdt_initial_size = spapr->fdt_size; spapr->fdt_blob = fdt; + /* + * Set the common machine->fdt pointer to enable support + * for the 'dumpdtb' QMP/HMP command. + */ + machine->fdt = fdt; + /* Set up the entry state */ first_ppc_cpu->env.gpr[5] = 0; diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index a8d4a6bcf0..891206e893 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1256,6 +1256,14 @@ target_ulong do_client_architecture_support(PowerPCCPU *cpu, spapr->fdt_initial_size = spapr->fdt_size; spapr->fdt_blob = fdt; + /* + * 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 the 'dumpdtb' QMP/HMP + * command. + */ + MACHINE(spapr)->fdt = fdt; + return H_SUCCESS; } From patchwork Sat Sep 3 19:34:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965050 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 559C8ECAAD4 for ; Sat, 3 Sep 2022 19:42:13 +0000 (UTC) Received: from localhost ([::1]:51944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUZ1w-0000vU-Dd for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:42:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:53696) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYuz-00078r-O5; Sat, 03 Sep 2022 15:35:03 -0400 Received: from mail-oa1-x34.google.com ([2001:4860:4864:20::34]:44649) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYux-0005Kq-CP; Sat, 03 Sep 2022 15:35:00 -0400 Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-11eab59db71so12815399fac.11; Sat, 03 Sep 2022 12:34: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:subject:date; bh=jSnxKaWGWO9NSnu9m80T0E8udOWWs5LaK48wxQ12xy4=; b=hQM2ZWjRm8jxyHSXX0Q608SJQ/INOYPSp5V4uXWhixpdqxK1RuzmjgV+6lkhCLmxuN e7Hfpy39zNEo+c7fFTXK48b5eSrlGEJLqx+7p8OC8boifc5wL+9COV7G9zM2TZrPfXsR ZWjxnLO+U4jk20LrJYQQGDLB22cQx/Wbpdvqgv0p71mGqgEyjFu/HipCBFVYovcnXJtC gDA+4VP9uPP6qAZwPP5u1Nu0VSYp+pHEZ25RRZ7SK8BFfwNzr5DTxSgCKOSHzKniWmaH tZZM1yhsaQhCR9cx/KOHl+Kd5wAFby3kekIzW+E8EFa2B/5JjDyukr3xMNhzkMbWF2LB iFIg== 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 :subject:date; bh=jSnxKaWGWO9NSnu9m80T0E8udOWWs5LaK48wxQ12xy4=; b=rNODQ4XSo0nS3JeKJYwrgKed2I262m1tmTtA7aALJLE1gvsrQfbVyYY2UA8hX2MUV6 sWZ7861NNbVhE/T1L1WLcpA9R4B4wqzQtecJxj4D3SO8Yz9QDYxFEOVNiAJrwAoHeHuA TPQkwP5beJT+VGOl52bS+ledKOu62H6qk5PLpBl2fklbkUQFcygSrxi4Y3m0gzZNA7wQ n+oBrAgC+ydV0bPjBwrzT9wXeJq5D2V6W2Iwbu/IlWAgDCXawVNuIQ7heyVE5jr+pBXY Y0unV07kAT+QxSO0yNfvBJ1ywWZIcWchmwfF1JlKKBUKxreUqvJtabNxRBKns8hCMXtI uq+g== X-Gm-Message-State: ACgBeo2lekspJAzTrNftAUdUpCAsq7Z38dEvxcUd2KV2JFBlTFGHFxqs /wYsVc5mA3e+iVSmlRQV8H4LkOkudyTSiw== X-Google-Smtp-Source: AA6agR44+UTHyZmzVCeULSnWz1QRwRFViC+rhtb9W/2/bYHuLRSOHF+scBKWsr5iRFXOKG3tRPewiQ== X-Received: by 2002:a05:6871:8f:b0:116:861f:2684 with SMTP id u15-20020a056871008f00b00116861f2684mr5197402oaa.70.1662233698207; Sat, 03 Sep 2022 12:34:58 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.34.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:34:57 -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 v5 11/14] hw/riscv: set machine->fdt in sifive_u_machine_init() Date: Sat, 3 Sep 2022 16:34:17 -0300 Message-Id: <20220903193420.115986-12-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::34; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x34.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This will enable support for 'dumpdtb' QMP/HMP command 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..07e25d0740 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -634,6 +634,12 @@ static void sifive_u_machine_init(MachineState *machine) start_addr_hi32 = (uint64_t)start_addr >> 32; } + /* + * Update the machine->fdt pointer to enable support for + * the 'dumpdtb' QMP/HMP command. + */ + machine->fdt = s->fdt; + /* reset vector */ uint32_t reset_vec[12] = { s->msel, /* MSEL pin state */ From patchwork Sat Sep 3 19:34:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965053 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A5441ECAAD5 for ; Sat, 3 Sep 2022 19:44:19 +0000 (UTC) Received: from localhost ([::1]:47068 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUZ3y-0005fW-NY for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:44:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47076) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYv4-0007Fn-AN; Sat, 03 Sep 2022 15:35:11 -0400 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]:34762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYv1-0005QP-GE; Sat, 03 Sep 2022 15:35:04 -0400 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-11ee4649dfcso12951324fac.1; Sat, 03 Sep 2022 12:35:02 -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:subject:date; bh=MKKyio2KeN9Vgbf9Aj2APvfD3VWLkoUGAYr+gnarUpY=; b=JsuhKXTFHQL31vadDMO2WR26WmVUbT6dN2G9epHpDaYbJrlCAtTpAahZKm8cb3sbYU oksFL7NP5mWI4Lk67R2wQ0Z5fUCXpo0ePs1jM/SoHx7mT/W9Ndu5rkD/10+zJhFfpTT+ T3lhXWpnJY4/5Jd0vkzQUYJdI3CLWZpO1wp1cCfjcQimMKQo+bTgYfAFFbgU+9ahfefF JvsGw4HT5bRsTosNMuNel4tFu02IGXCBPCGTvvwFE5A+8RsS5Yh17vDuu59CcsutM9Lt iUTJLpobz7RHs7brFK6OlAiyB2aK86j8R4oIebskMHTBpJ5dq5gvmHXfpSYOuOh9bIyG F0Wg== 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 :subject:date; bh=MKKyio2KeN9Vgbf9Aj2APvfD3VWLkoUGAYr+gnarUpY=; b=6r5sA+09DUDoy97M5RDs1j7wEGqubH5d0GBs56ZGeLP+O3y0XV1AGdA710l3RgkEz8 +wRMEng7sH2yGlAIhrBM+poXkoKm/nPI0TvfN0B+GBWsLmAVpW5rYTsj7qVyXpsqzKhU oD31nXPMHbWxnK0n0dIElE9NPwS3X3zRY1WKs4poQ06N37BqT8p3/Rg3Qxu7/j53WNOD hyBjp0C1eXl42nJDaguugMlj1QeZEamnxFwyc7GM0L0xxaR7EQsD1pvYDoEScaTcDCnv lhzjCvEU9Rnq9Tp+NMY+N4bLXAO9y1JSBQFsPShHQcPbxNV142GooJAVCI2otijbd2DL AS1A== X-Gm-Message-State: ACgBeo24UKxVTv5KNyKt2g8Av8H29+exvTneuXWUYCzd0Rb+P5Yg1qHX Pc8zexMANFVq8dqlOcpNwZ+WGgGU4wh4Kw== X-Google-Smtp-Source: AA6agR7GHtvKJLCP137jdTaC7avCGejyexlTb7Ia8eNjp0b/Vf+qQsW5Eh0HucFxNtq3IXAQfPqOkQ== X-Received: by 2002:a05:6871:1d6:b0:10e:6a7f:cc3b with SMTP id q22-20020a05687101d600b0010e6a7fcc3bmr5140318oad.210.1662233701371; Sat, 03 Sep 2022 12:35:01 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.34.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:35:00 -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 v5 12/14] hw/riscv: set machine->fdt in spike_board_init() Date: Sat, 3 Sep 2022 16:34:18 -0300 Message-Id: <20220903193420.115986-13-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This will enable support for the 'dumpdtb' QMP/HMP command 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..1fa41164b3 100644 --- a/hw/riscv/spike.c +++ b/hw/riscv/spike.c @@ -40,6 +40,8 @@ #include "sysemu/device_tree.h" #include "sysemu/sysemu.h" +#include + static const MemMapEntry spike_memmap[] = { [SPIKE_MROM] = { 0x1000, 0xf000 }, [SPIKE_HTIF] = { 0x1000000, 0x1000 }, @@ -304,6 +306,13 @@ static void spike_board_init(MachineState *machine) /* Compute the fdt load address in dram */ fdt_load_addr = riscv_load_fdt(memmap[SPIKE_DRAM].base, machine->ram_size, s->fdt); + + /* + * Update the machine->fdt pointer to enable support for + * the 'dumpdtb' QMP/HMP command. + */ + machine->fdt = s->fdt; + /* load the reset vector */ riscv_setup_rom_reset_vec(machine, &s->soc[0], memmap[SPIKE_DRAM].base, memmap[SPIKE_MROM].base, From patchwork Sat Sep 3 19:34:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965052 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 389C0ECAAD5 for ; Sat, 3 Sep 2022 19:43:35 +0000 (UTC) Received: from localhost ([::1]:57574 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUZ3G-0003gd-Cz for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:43:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYvA-0007GR-8x; Sat, 03 Sep 2022 15:35:12 -0400 Received: from mail-oa1-x30.google.com ([2001:4860:4864:20::30]:40690) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYv5-0005cN-Ih; Sat, 03 Sep 2022 15:35:09 -0400 Received: by mail-oa1-x30.google.com with SMTP id 586e51a60fabf-11f0fa892aeso12882826fac.7; Sat, 03 Sep 2022 12:35: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:subject:date; bh=+yBKZUFA1uSsvFGRHUokL0uEYsI4texFhLK7k9Zdnjk=; b=Zvd9MM09iuiZDSGranT13IiYAklNb2gw42+NewRgrlwlSY/bsteEw2sVFNu1R86frc +mBdjjMJIrEmkIf5ZqOdtdIxBJXllr6m/I8Z1jgfhV1m3HF3FhDr1c93O2U0vEKv/jQc WIlP903cLavt/foY1dTLurkTpypl1qenNfN71iHnYmn7ojAxV0eVUNS0cyTsASf/AtWo rk55kLSU038y0rfu0lpzwbfoA26DSp/EBIWbGsGA78EzfH3pWoYdgyKC/2JzAbomdGVM aeWTxkNf7lQ8xMkg4QvbTRUpKBcEmMzVHcdMHcUCXYD2I6rthn7qRjcLtwZo1to0K9P8 SiRg== 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 :subject:date; bh=+yBKZUFA1uSsvFGRHUokL0uEYsI4texFhLK7k9Zdnjk=; b=nwoa0QhlO/oYyxOapSohX529qBaoaY25xdIE58Oi88yZyDuK8Ku11GYwh2lvDgN6ju wVGzx16QFRYnSOlpQb/eqtypR2SyhnRlZEPbjE/u0z+bgCXOwtW1MUT/lE28nLCjdCGJ xLarLdwXAXTm2Hrd2wvW/HxaWvRsK/lQENbJ/G34oZd5rN6boDrpmeTciM6wNoBScU1l WA8qzivfFeG1vL9OnITLFb7F2lF6xkShgj/ykxN3Rz1py/2cSV7yH0qJYzwoW1YMcJhB k1oSSRC9OMmZ5QJ3yuRP6z46WRkWAPu+A/3KGxrMUordC531jJbEcU2+Ugt2VGSSZlR6 lNqw== X-Gm-Message-State: ACgBeo0p7BjCKSCOi4Tuv038QRjyu1qA59QGbs5BV104r1gYuJvAfpnf 4Nb80yvqpum7GrLHluY6DoTObs6bv0XEJA== X-Google-Smtp-Source: AA6agR4drTekjxloZjyQEA5wPU3R9KAI+EiDbO9ZBEd6psaIXC9DGXrHET4umfLMD/srwuZH29F5VQ== X-Received: by 2002:a05:6870:240d:b0:11e:ff35:5ce8 with SMTP id n13-20020a056870240d00b0011eff355ce8mr5035198oap.232.1662233704161; Sat, 03 Sep 2022 12:35:04 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.35.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:35:03 -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 v5 13/14] hw/xtensa: set machine->fdt in xtfpga_init() Date: Sat, 3 Sep 2022 16:34:19 -0300 Message-Id: <20220903193420.115986-14-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 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: -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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" This will enable support for the 'dumpdtb' QMP/HMP command 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'), fdt]) hw_arch += {'xtensa': xtensa_ss} diff --git a/hw/xtensa/xtfpga.c b/hw/xtensa/xtfpga.c index 2a5556a35f..138453628a 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" +#include + typedef struct XtfpgaFlashDesc { hwaddr base; size_t size; @@ -377,7 +379,12 @@ static void xtfpga_init(const XtfpgaBoardDesc *board, MachineState *machine) cur_tagptr = put_tag(cur_tagptr, BP_TAG_FDT, sizeof(dtb_addr), &dtb_addr); cur_lowmem = QEMU_ALIGN_UP(cur_lowmem + fdt_size, 4 * KiB); - g_free(fdt); + + /* + * Update the machine->fdt pointer to enable support for + * the 'dumpdtb' QMP/HMP command. + */ + machine->fdt = fdt; } #else if (dtb_filename) { From patchwork Sat Sep 3 19:34:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Henrique Barboza X-Patchwork-Id: 12965055 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4BC1FECAAD5 for ; Sat, 3 Sep 2022 19:48:31 +0000 (UTC) Received: from localhost ([::1]:35604 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oUZ82-0000sx-42 for qemu-devel@archiver.kernel.org; Sat, 03 Sep 2022 15:48:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:47080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oUYvD-0007HI-2o; Sat, 03 Sep 2022 15:35:15 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]:42898) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oUYv6-0005Ml-DT; Sat, 03 Sep 2022 15:35:12 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-11f34610d4aso12841529fac.9; Sat, 03 Sep 2022 12:35: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:subject:date; bh=qjmaukKWaG1JJ3p0YVd+GmaIlJfsP8CQbJQ5n47KQDc=; b=TvfH48fqJAWuHvW7fIJIqaIazHCfgI31MtiR801s99ycf9Y0LOQm7vTV4QjbghwOIL KzWqHrYj2znIVwcVcyQRh6pGLn1dPNaR315WfT1vo38WWZPsg10Rrr/qNIJfsuRdPlpC jAdXs09B8zUfNp3MUmcSwi8rJX3VwPZznc4L2Wv0zbavDqH33waYgUMZZAOH4SpaBHiZ 19KPn1OEdUsreLb0uH1ptDsyz0mWyxJBq+htx4TrsDENz3jN1EeYSqX1IxwhjkgumYCq SbygZeqJMS3dVLFOnNQ6q2HxUocWWzOBS8BiCn8+ZP5gG9o9aKCjZW3ZIHy9JPJuSwb2 oE3g== 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 :subject:date; bh=qjmaukKWaG1JJ3p0YVd+GmaIlJfsP8CQbJQ5n47KQDc=; b=1qHWaLnBMctpXlWgi0hTVPzEh1UVn6QPr/QnZWMfgiBWFs2QoHxnaw5GT5tZUuRIsC dj8yUgYCY9QN2wYIf5NPP0HkNc1YmIKLzrgu18lEEDefSczFepjsbxXD8gdR3Qf/XhFX GbKZeLeY3LzsNdq1XVL9A2j+EDOEEu0+O8LV76Yy1jVQSlzc/6Un8CwOI2VRlVRlwSUd Yw1l2PTb/DULmcWsJb0usG/dEE4pJ3XFIuBpmubMaeKp51Ouxwmomq/Skxs7CdYmJlh9 H/d8lxe0SiqOqFgUlrkUzFPvlJDOGvS1EOTEjAz5pp7uQBnigbU9D6LiIMtUr96l5Mn3 RMLg== X-Gm-Message-State: ACgBeo3bm8LFRIY3KMIi9X5+KiM5KvO8EHNkFsiEOqdVGFLLtiYN7HfE MY5dbmyUbBwgoKyYvZJJjGBX8gT330VQBA== X-Google-Smtp-Source: AA6agR7C0V6agI1J0JB6dNHv8EnFgxIaiOJ0kfzG9IPv3qlLSuWZ/PyrKdXGvsEce/woC22uQcMedQ== X-Received: by 2002:a05:6870:c386:b0:102:fcb:86cd with SMTP id g6-20020a056870c38600b001020fcb86cdmr5252651oao.296.1662233707291; Sat, 03 Sep 2022 12:35:07 -0700 (PDT) Received: from balboa.COMFAST (200-207-147-180.dsl.telesp.net.br. [200.207.147.180]) by smtp.gmail.com with ESMTPSA id m2-20020a4aab82000000b00425806a20f5sm1843906oon.3.2022.09.03.12.35.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 03 Sep 2022 12:35:06 -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" , Markus Armbruster Subject: [PATCH v5 14/14] qmp/hmp, device_tree.c: introduce dumpdtb Date: Sat, 3 Sep 2022 16:34:20 -0300 Message-Id: <20220903193420.115986-15-danielhb413@gmail.com> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220903193420.115986-1-danielhb413@gmail.com> References: <20220903193420.115986-1-danielhb413@gmail.com> MIME-Version: 1.0 Received-SPF: pass client-ip=2001:4860:4864:20::29; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x29.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+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" To save the FDT blob we have the '-machine dumpdtb=' 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 Cc: Markus Armbruster Reviewed-by: Alistair Francis Signed-off-by: Daniel Henrique Barboza --- hmp-commands.hx | 15 +++++++++++++++ include/sysemu/device_tree.h | 1 + monitor/misc.c | 1 + qapi/machine.json | 18 ++++++++++++++++++ softmmu/device_tree.c | 31 +++++++++++++++++++++++++++++++ 5 files changed, 66 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index 182e639d14..9a3e57504f 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1800,3 +1800,18 @@ ERST "\n\t\t\t\t\t limit on a specified virtual cpu", .cmd = hmp_cancel_vcpu_dirty_limit, }, + +#if defined(CONFIG_FDT) +SRST +``dumpdtb`` *filename* + Save the FDT in the 'filename' file to be decoded using dtc. + Requires 'libfdt' support. +ERST + { + .name = "dumpdtb", + .args_type = "filename:F", + .params = "filename", + .help = "save the FDT in the 'filename' file to be decoded using dtc", + .cmd = hmp_dumpdtb, + }, +#endif diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h index ef060a9759..e7c5441f56 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) void qemu_fdt_dumpdtb(void *fdt, int size); +void hmp_dumpdtb(Monitor *mon, const QDict *qdict); /** * qemu_fdt_setprop_sized_cells_from_array: diff --git a/monitor/misc.c b/monitor/misc.c index 3d2312ba8d..e7dd63030b 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -49,6 +49,7 @@ #include "sysemu/blockdev.h" #include "sysemu/sysemu.h" #include "sysemu/tpm.h" +#include "sysemu/device_tree.h" #include "qapi/qmp/qdict.h" #include "qapi/qmp/qerror.h" #include "qapi/qmp/qstring.h" diff --git a/qapi/machine.json b/qapi/machine.json index 6afd1936b0..f968a5d343 100644 --- a/qapi/machine.json +++ b/qapi/machine.json @@ -1664,3 +1664,21 @@ '*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' }, + 'if': 'CONFIG_FDT' } diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 6ca3fad285..cdd41b6de6 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -26,6 +26,9 @@ #include "hw/loader.h" #include "hw/boards.h" #include "qemu/config-file.h" +#include "qapi/qapi-commands-machine.h" +#include "qapi/qmp/qdict.h" +#include "monitor/hmp.h" #include @@ -643,3 +646,31 @@ out: g_free(propcells); return ret; } + +void qmp_dumpdtb(const char *filename, Error **errp) +{ + g_autoptr(GError) err = NULL; + int size; + + if (!current_machine->fdt) { + error_setg(errp, "Unable to find the machine FDT"); + return; + } + + size = fdt_totalsize(current_machine->fdt); + + if (!g_file_set_contents(filename, current_machine->fdt, size, &err)) { + error_setg(errp, "Error saving FDT to file %s: %s", + filename, err->message); + } +} + +void hmp_dumpdtb(Monitor *mon, const QDict *qdict) +{ + const char *filename = qdict_get_str(qdict, "filename"); + Error *local_err = NULL; + + qmp_dumpdtb(filename, &local_err); + + hmp_handle_error(mon, local_err); +}