From nobody Sat Apr 27 00:09:43 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=1659692673; cv=none; d=zohomail.com; s=zohoarc; b=Tff2SjL5VxrUbk4SoiYLup/s0fe6ZTmnSOjWvg7By/1boGSRWiW9MT+vOmpHelUqLzh9zpqeV7JOMStfRnLwcndDgu2rjdrJOw0X9WehYvpOUqtjPt2v8JSjRQ82PNgFvb+57Eor0ujRtSYgcisOTtVw9nPtd3KdVtYw94EupuM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659692673; 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=mO1pyhNh7FBjFV2nX8yrWBbovbYOVIGYqaGtZXY/PXk=; b=J3aWN7CT3um/GcLM3yXGZRKBZ+ulKufbmwPyv5aB+pqIrjuSV3CB6Xz1HJdPQ/3zvku2GIKsqc/JuwM8OUzD6oizlkimPO8G+9cQhddTGgU4JQgn6OW6Ebh7k1EcjQMx6BwqXBwzcozYO5bvWYWAgpkDr8I+4oKiKhy2tBEjSJo= 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 1659692673636639.8304398768971; Fri, 5 Aug 2022 02:44:33 -0700 (PDT) Received: from localhost ([::1]:39670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJtsc-000531-OX for importer@patchew.org; Fri, 05 Aug 2022 05:44:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49816) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoE-0007Jk-F2; Fri, 05 Aug 2022 05:39:58 -0400 Received: from mail-vs1-xe2f.google.com ([2607:f8b0:4864:20::e2f]:33384) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoC-0001Qv-Mw; Fri, 05 Aug 2022 05:39:58 -0400 Received: by mail-vs1-xe2f.google.com with SMTP id q15so1988994vsr.0; Fri, 05 Aug 2022 02:39:56 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.39.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:39:54 -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=mO1pyhNh7FBjFV2nX8yrWBbovbYOVIGYqaGtZXY/PXk=; b=QSaN6gPZtzTjgdDmTcn3DNchbUulwX9Yy/j7a8aoeijxntzeCEPrKZkq9wtV5rXdnd 0mmSXrjpQCC4DgTKiGR2e97YRQWUMldHpvMXiSgLuBDrJ8CTdYUtEIJz39xT2oSmzW1p NwrJwbgW3oESUSyE/iOQFjyjIVr3PdQnHMSPjnZ5EgHQo2F2bY3su8CyUnKhB9QvN5Go xvg+ZJd+nth7jHz2vNYGCEvWW1iHYYLg32PvUg957WyYOIpbHjWk3SeS06YEpzI+Xycb 2YaAloEL3rDDwbGhMIpglKGnFg4aIwwgyggyXG2rUFm13Y3AcW0P8mNxOQcITbvLVrAg gS/A== 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=mO1pyhNh7FBjFV2nX8yrWBbovbYOVIGYqaGtZXY/PXk=; b=DdfI2oxuSzh4rdrhVs8OwypgjwLUTrpyQFp1RMdozsAfRgJgAysdT10cmyEhEktrhm K/exwRwGHrVzx/I2qXB8+XVUVIyoBdfkhUYwGNnrZIe/IkvYtbCKZQAy7RVjdP8Qsbyb O9Mm4RN5sC6VLmhTb47fWL8PVvWlYIl1RTr1c59FHmyFdcr5mnu8wIRHI0g3kcwFkHBG ZsjZ00MX6G3+XmB+CDsElVcZdFRZ7Qi0ZfPGqdo8KmmST5gBiE16O5SoHQ6p6Zk65VC8 x1ivNdWqTZyDRtJk9vJTlmiI0SF33iE8iKmxORMXzJJb9t42gz8cUz2RI0xJE5Cc8uwI 9ITA== X-Gm-Message-State: ACgBeo1eptIKauWrSH0J3vwEQZ5Ya7sNS7ClZ6jI+xLj9JBwf/pBpp7f +b3HRth6iYGMgJ13MMCK9tp8WNl6/bw= X-Google-Smtp-Source: AA6agR7RywozYypX/Wn+U3diSsydoifdXaRv3cXORAU6f6eRiBY5EKj/eKb1OZEI37LUIhscZ5ca+g== X-Received: by 2002:a67:cb93:0:b0:388:494d:4419 with SMTP id h19-20020a67cb93000000b00388494d4419mr2510881vsl.28.1659692395327; Fri, 05 Aug 2022 02:39:55 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , Peter Maydell , qemu-arm@nongnu.org Subject: [PATCH for-7.2 v2 01/20] hw/arm: do not free machine->fdt in arm_load_dtb() Date: Fri, 5 Aug 2022 06:39:29 -0300 Message-Id: <20220805093948.82561-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::e2f; envelope-from=danielhb413@gmail.com; helo=mail-vs1-xe2f.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: 1659692675569100001 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 | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index ada2717f76..9f5ceb62d2 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -684,7 +684,13 @@ 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' commands. Use fdt_pack() to shrink the blob + * size we're going to store. + */ + fdt_pack(fdt); + ms->fdt =3D fdt; =20 return size; =20 --=20 2.36.1 From nobody Sat Apr 27 00:09:43 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=1659693021; cv=none; d=zohomail.com; s=zohoarc; b=CXT8F0LQQDeDX51G8TxjFTAES+IsqYGKd38GESfs8agDRCBn+lgySGpIdAvxj/tC92RAZRVhZxGLFt4EgT95MQvTZG6M2IsLRkiy8jznzQu7sAuX4k9TKcvEU3lCuKbp+Aj+8INStiUjag79OwcKoUXCsxX9bAJ2N5JZrrQA8+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659693021; 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=L4TUkDvLOTrmsvqmV/R+O0UADQGB40cLKBf4CYlSw1k=; b=mhA4MKiUPuRJNXndUBvBK3SXhUkIZY8QukueK+ru33ZSV1HVdFelNkA5Xs1k/cdPXAaaEfPAOVqDnZeocDEsPponEm9Pg0DkKczqcRwZ0JjAK5KOlNp5+rey+J82N5RKydZDd7gZt1UXzVbeG96JF077R33leLB00gTdoVMIi8I= 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 1659693021631366.0684474918437; Fri, 5 Aug 2022 02:50:21 -0700 (PDT) Received: from localhost ([::1]:49404 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJtyB-0003aI-D3 for importer@patchew.org; Fri, 05 Aug 2022 05:50:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoH-0007SH-GU for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:01 -0400 Received: from mail-vk1-xa2d.google.com ([2607:f8b0:4864:20::a2d]:40866) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoE-0001RO-Ev for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:01 -0400 Received: by mail-vk1-xa2d.google.com with SMTP id c22so994119vko.7 for ; Fri, 05 Aug 2022 02:39:58 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.39.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:39: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=L4TUkDvLOTrmsvqmV/R+O0UADQGB40cLKBf4CYlSw1k=; b=PV9c63oKZk72v0DwutDQTXJvA6qfYn/uoWmsw/bTZP116sNeB6YTM7ts8vOWtlQiaH cPNyEDejRT/+q4wYXfYab76t3gHTEcy4+18pdCeRIzVbbl5Y/vnD8Y/Nq1emmSDzJcWw 0c+GNRvR9unrAJVnSbq38tzt9crGLWj3jko+GQ9T/QeNO7mMjUUdyMpGmVwOg3TrouBh mV6IECWesBU3bMfIeEHjG5KlexvzvH+mpcyshMQmAKxHxrJQwr0vDa9dzW/d6syVjQGh fwpojBl6JJMZ6lqVEYMNlR7L9utuE09dE//nkvTcWEIVUnHK9D0uXSHlg531Xi8upaM7 htgA== 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=L4TUkDvLOTrmsvqmV/R+O0UADQGB40cLKBf4CYlSw1k=; b=HAu/tvPzt+WNqZZ9b3wbpo1xSdu1SOi4eQtNvASlmx0vYf+6K1VcRclqBd6wqirlHz LuH/zRIffnlmu0PRdyS7hOHkCPqp3aXI630LvI7n0nX/zLin7QhRNTte4QQ9774258oN ZHO7phfH4TlfUpRRZlD0mzNa/ikkV14c5T+9k73crzgbC4cYLnqvexvGlM72AtGzXZix UMHXNTjOGNM8S3V87pet9XNVxN2RAEu7OaD9PeDjqB3RWpK19tSUaIeYnbVNzYGmJPBz 1wkHDLc/tENRFmRUZTCZ8FfWz4V5uGg/GHdZUop9RGr4yd3We3FM2nlIMS7n1703wIb+ qJUg== X-Gm-Message-State: ACgBeo3uTONDXE4tu1X77Pf1BTKarvLpJTggxf5JQ6FEitb6CmOr2k3C 55fRaWAx+kTiicB+v/sv/bsuO3BMFn0= X-Google-Smtp-Source: AA6agR5dYF496mR3IwA8/2IPYq5WxS1H44PBSji+VbGWF91L/TLSYXskIoF3OU3SOGn6G/f86UTZFw== X-Received: by 2002:a1f:4ac4:0:b0:378:397d:c292 with SMTP id x187-20020a1f4ac4000000b00378397dc292mr2404512vka.1.1659692397201; Fri, 05 Aug 2022 02:39:57 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , "Edgar E . Iglesias" Subject: [PATCH for-7.2 v2 02/20] hw/microblaze: set machine->fdt in microblaze_load_dtb() Date: Fri, 5 Aug 2022 06:39:30 -0300 Message-Id: <20220805093948.82561-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::a2d; envelope-from=danielhb413@gmail.com; helo=mail-vk1-xa2d.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: 1659693023494100001 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 | 13 ++++++++++++- hw/microblaze/meson.build | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/microblaze/boot.c b/hw/microblaze/boot.c index 8b92a9801a..001cdefd5c 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,15 @@ 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' commands. Use fdt_pack() to + * shrink the blob size we're going to store. + */ + fdt_pack(fdt); + 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.36.1 From nobody Sat Apr 27 00:09:43 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=1659693471; cv=none; d=zohomail.com; s=zohoarc; b=Gk40pJmmfJpVNdk0uOuhA4jj8yKMzYtwxfjlRBvw3epCA14gaZ/OGEBu/AFZ49kwKarkmI317MIRGmEYr/zwSqnPQDHWbKwBSz+xV4k3fxioDVcx635LoNl5BV4I9qgIVgKAy1Gk+TP2XUSdwsv/QA9eUQh/uPTl4DxCMKDNixM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659693471; 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=FTmhGl0YoPTG0BLmd7LkpyEVJmWkGywjd814ntxc28E=; b=RupF13e1p8qpXw3vME0qwO5FNqXZLAGSCbpnyW9r+R73YAD0Ehf5BdN+Po6daGL24LxCAeqeGMtaBT9tWdYPI9b3xWc6BL/I1zHSOvJC9w/ayt55b1rkbKCZt7EeSIOvo/9ndkcNz0Nqfq+dm2nU32lCLwMAjBtYZl7i+xNzgE4= 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 1659693471238778.8078049680116; Fri, 5 Aug 2022 02:57:51 -0700 (PDT) Received: from localhost ([::1]:57502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJu5U-0000yu-43 for importer@patchew.org; Fri, 05 Aug 2022 05:57:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoI-0007Th-OM for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:02 -0400 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]:39660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoG-0001Rl-Hn for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:02 -0400 Received: by mail-vs1-xe30.google.com with SMTP id c3so1928446vsc.6 for ; Fri, 05 Aug 2022 02:40:00 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.39.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:39:59 -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=FTmhGl0YoPTG0BLmd7LkpyEVJmWkGywjd814ntxc28E=; b=qHiwChWu0iSGesvhoj8NPmTotrwXySP3JogjFoV9L2KqmRxrtUOBIJKhEQx7U1KpaU cOlm7fgTcOvZQF1YY7KW/8M/lCWrC67/DBiZgxnXL01uOwVm3Il61mCUxkTaVhGFInX7 f2phDbnRx1bMGvuVjCi1pRvIh6VDJuvLKtTrNHqWUvR+we0eJ3IOj86bRSl0N8/8o30V u9/enn5VkwDjXDlK/jZhMZhu3+yfF6Ojg/NyRYzMZz9QJBHyV6qG9K8CzEhXzMt656eo 3BoZ2qHBEtkVGevmivdwI6lz8kNNlSsgeJWkT37fIsjxX6yDbeYON1gzZwLAuqmU+ve+ 2uBA== 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=FTmhGl0YoPTG0BLmd7LkpyEVJmWkGywjd814ntxc28E=; b=lECs+06k1I9f3tgk58HUK/Q39bhGLO0Cu14vC7k6LwsXLfM6KIwJ7Km+t8J1xSc2ut lz7qEVwE+xyhudxxe+ba1gWzCSnHFMmYy73CO8rJzqktPhvxgZtZlaa6hbQm4Nt2nj99 45yASr/d5KDhr0vY1Ya4DeSG+J8+juaHorqPlBpFs8Yr501un1I2K13z8I2IPY5QwQgY H7Diqxy1yatAyyIueRK+SvbJViFSvrXzoz2TnFHk9okHMgD+JYghD3OCk85THaMWucy+ wkU7Z6SnkVkTB9ykJapCuYuqOEeWMS32kWIsgLhES5Ekokln/p25Z83qDz8R0td0QOyW r30Q== X-Gm-Message-State: ACgBeo2evRtBB5WFy5Qt0vMWwD7h5PCG5tCHXlG/1XgbMU6zVBmvioqF Q/bQqg4EEki2v/wUUUQglbCXSDMuT8E= X-Google-Smtp-Source: AA6agR513cHLOSoOZHyMyb26BRK2WVuNsptC1td0x0EPeOGLQuGAcfdytpMwD19kB6lpTY1+0HP6sA== X-Received: by 2002:a67:1d03:0:b0:357:283c:567d with SMTP id d3-20020a671d03000000b00357283c567dmr2504113vsd.76.1659692399383; Fri, 05 Aug 2022 02:39:59 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , Chris Wulff , Marek Vasut Subject: [PATCH for-7.2 v2 03/20] hw/nios2: set machine->fdt in nios2_load_dtb() Date: Fri, 5 Aug 2022 06:39:31 -0300 Message-Id: <20220805093948.82561-4-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::e30; envelope-from=danielhb413@gmail.com; helo=mail-vs1-xe30.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: 1659693473898100001 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 | 13 ++++++++++++- hw/nios2/meson.build | 2 +- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/hw/nios2/boot.c b/hw/nios2/boot.c index 21cbffff47..6c40565704 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,15 @@ 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' commands. Use fdt_pack() to + * shrink the blob size we're going to store. + */ + fdt_pack(fdt); + 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.36.1 From nobody Sat Apr 27 00:09:43 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=1659692610; cv=none; d=zohomail.com; s=zohoarc; b=UHY6Pf5NZ9gMnyky55ErF7VfXp9W90dSrZ1cSjV9t+ueBzJ5OPCw1ljf7XFAsM50Wp/ZJeGQl0VmyWyAMHqqG6f0gMx7N/oNzTisBjn1cx+cR8iEfduXVRS6mmSuWRIhrqt+9ZxCvfYIADncnPLlWCzxiG4G/yz8d9YO++cNkaI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659692610; 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=i6lUIAeVHV++Uc3uOSofCj5FLRg63b1CmusxkRCE8K0=; b=dvP6krDFe6fkG9lHTrYk9FQgceugBIJfFVS3jb35j/UvePfBPC1qSfpFHKC75PeWdV/pcx0OVH/4QK/phfnvjgWcGRj5DEIQ4LvHYwtWbG9lJry2JAENBYyXfqt3DyGkGgej6Osvay+F+tok1GmXqbPb4HzA8ey2IwLNy+O1d88= 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 16596926101641001.6164652863953; Fri, 5 Aug 2022 02:43:30 -0700 (PDT) Received: from localhost ([::1]:36114 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJtrd-0002Wk-68 for importer@patchew.org; Fri, 05 Aug 2022 05:43:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49878) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoK-0007VY-Ck for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:04 -0400 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]:39660) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoI-0001Rl-Uz for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:04 -0400 Received: by mail-vs1-xe30.google.com with SMTP id c3so1928526vsc.6 for ; Fri, 05 Aug 2022 02:40:02 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40: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=i6lUIAeVHV++Uc3uOSofCj5FLRg63b1CmusxkRCE8K0=; b=MbX8HuNaNo9Ve+hMDPQYJQ/KZ8GGCl2zgeh/HKUfw0AqtB1fJ26VSZSOsMSI+qybzr Z2DDSPcqq7N4/bTZaJSj6QTrzHy3Yseg1apMxjGOg0RLkV+GhFFeGByR8+BWu5/9i2al a6rLrxNmXMNtg5bYY5cmhmpv2SIuT5oQLdauKGZYX3D26sHHTRd6Y5R3nNc9mywnOQ8B WZc5+PxaHUk2XrMXlg+ez/YBIVOstIFaWOMnzrxsIa5zk3ptvzYTWjul7RG8cbbF6sF6 SO9WiNOUeltxYbdP0DgpgnjMfqoMzzFXhWwvz4snGmt7Qy9e5Esg5FmI6ECtSk1R9we3 C7rw== 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=i6lUIAeVHV++Uc3uOSofCj5FLRg63b1CmusxkRCE8K0=; b=fQGTuCXdqxZ7o81m739RYDrkBGIlZHWMQXiqkEBWbiFVbq+K5JhZI4Mpn4wCAZkrUh QWcSEgC/6xLadR0t1Y0sdX1xgpOwuksFdSC3DMDlBpf8QmYoA5nByWsSPv3AoKJYXKLe WyGTx6mkwbBvXneK9PMrD/B+aQESSEP4AqjrrUO06gdcNRSKRotUgMXvTVSx2m0Cx3Q9 4IE2sVLnG87gfOxiqGJ1x8ipWt2l3DD800K0y86Z9YxYKJIVlIEzujgyliPRjuWOYDfK tdAw34PrSTj5MHH6wVYdMeKcQDJaD44WuxNOqd5D1FAdoLPyKhAuRWS9udzvrlRYtnNH X2hQ== X-Gm-Message-State: ACgBeo3MmBWZfb1zGS2d6KEwNwh6xifezdeTz+fq3MeL4T55kuqdX+Fo iaowguxypzd/ZtCjdLrefuCyzylIOTc= X-Google-Smtp-Source: AA6agR5E5/ayjLGixgw4v6ShKMDI4T4R+SenMx7TFHPW8dz91jG59O3VWMjs320tQ4FCPTsWuzJQBA== X-Received: by 2002:a05:6102:2321:b0:357:c4aa:9877 with SMTP id b1-20020a056102232100b00357c4aa9877mr2375515vsa.56.1659692402080; Fri, 05 Aug 2022 02:40:02 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-7.2 v2 04/20] hw/ppc: set machine->fdt in ppce500_load_device_tree() Date: Fri, 5 Aug 2022 06:39:32 -0300 Message-Id: <20220805093948.82561-5-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::e30; envelope-from=danielhb413@gmail.com; helo=mail-vs1-xe30.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: 1659692611609100001 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 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c index 32495d0123..07c15fc181 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,18 @@ 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' commands. Use fdt_pack() to + * shrink the blob size we're going to store. + * + * The FDT is re-created during reset, so free machine->fdt + * to avoid leaking the old FDT. + */ + g_free(machine->fdt); + fdt_pack(fdt); + machine->fdt =3D fdt; =20 out: g_free(pci_map); --=20 2.36.1 From nobody Sat Apr 27 00:09:43 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=1659692592; cv=none; d=zohomail.com; s=zohoarc; b=RXMFg/1nwZMaMh6HP6CuO/pyY4z0g8ej8r8JcTI7iApv1y1F0u5PS2BjB5zvQUNi7yiJuK/GaLNUr4rUOtpw9Mcfx6oR2j2LdJ4GIg1wfsU89JRPrWsU8O4m04V2pD5M1DOwk0VypfjdCt6JfdwLJwGkwm1yW/voU8+wEpSJreY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659692592; 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=uLt9f+oI98zp3DoKsiJNFo6UPLW/Y2fHFdx+FVb33A0=; b=TU5x97WMj0EGJd1LGCytqor2D0+HawWfygljc4j+nnif2ZkyFWTo/RSAqEZxw3Dl8GxBvqm9RXD3ZKy/2ZXcjFRxiv2Lr3vFEmQBAhTqd0nrUcVFD17Dr0qFKZb0chTifIEJzviq2KHLJLoawd+okMVNVPZ7OBlOU35z7AAp4FE= 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 1659692592116143.3954982752159; Fri, 5 Aug 2022 02:43:12 -0700 (PDT) Received: from localhost ([::1]:35740 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJtrL-0002CH-4c for importer@patchew.org; Fri, 05 Aug 2022 05:43:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49928) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoR-0007XW-Nj for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:14 -0400 Received: from mail-vs1-xe2b.google.com ([2607:f8b0:4864:20::e2b]:46623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoL-0001dv-4r for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:06 -0400 Received: by mail-vs1-xe2b.google.com with SMTP id x125so1887643vsb.13 for ; Fri, 05 Aug 2022 02:40:04 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40:03 -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=uLt9f+oI98zp3DoKsiJNFo6UPLW/Y2fHFdx+FVb33A0=; b=No5L0X3P6ysVQpYkQI5G49yMiFPb+7WYddd49LLCYoeUZCNPJtRqyQ3mi5boMX5nwe EgyNJkOjAYqZ+aADHKA5GUMBtFkOLfVP1ym/kDoXqH6ny+U8gdHcSLKGjzLDf20F8UZm Kbh1jF8IExAWip2RCZpjC9RxwvV4XgSuIsu4JEYY7qDrrG2UiGXV1GG92ieMZ8nvWd1j W5MCuB0FSmc+XzgFM0BugQDkfXP+YU4mEhTav7yNInyPjPf2h+J7sU2BfWo0t3tOw8/P LO8N9CEvvleMKZG18O4VP2SxxjY+ZIQL8T12ZjgTaR5e4DYkbbwtCsNYdYF+4FgvrmJp V3cw== 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=uLt9f+oI98zp3DoKsiJNFo6UPLW/Y2fHFdx+FVb33A0=; b=pv12rgBR9hJ05pFoRyaRbjjdiUb0cIOGCGuq+ofcqmFM2lvTNjOWHrNKv8t9JRq19U SEZftga+/3I3vFYOfZhwPrNDIonbcco51I0yJ/A8Y/y9b8MCy4DT6ul28PNAKnqnz8yL RleuMLvEJ6vIWvPHUYwlNx1IyTL8iI2+9VwYcE+muZIVII9xvhdtxKRMd2YBVdNXaDWU DtfHRTB6PKWE1ng4d3XS3IEcnJpwKz3JVDzGOAJHCFuiAF7pk1xe4kFCXf6TDkryP/9N 75dMgsHqKxlJ8xJZo6lbVDT+mGtZflBVPNqEXI0VBi5nGxNuN2BfN8se+8seCd/rk4MD oFcA== X-Gm-Message-State: ACgBeo0okvBRxdr7XUklomoMDGuS3MILmVrbIQ2F8/ZjYtvKdbqhzmaJ rsAjTUGhHGuSvX68Ixf/dub4hM7XcHg= X-Google-Smtp-Source: AA6agR53Ij7Suig4+yLYzAVhigSQNb5nGJm5XjO56AGqPmcPz96uG45miaStfbPw46d6iBTYuoRaUw== X-Received: by 2002:a67:b009:0:b0:357:af40:6b7e with SMTP id z9-20020a67b009000000b00357af406b7emr2539273vse.67.1659692404116; Fri, 05 Aug 2022 02:40:04 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= Subject: [PATCH for-7.2 v2 05/20] hw/ppc: set machine->fdt in bamboo_load_device_tree() Date: Fri, 5 Aug 2022 06:39:33 -0300 Message-Id: <20220805093948.82561-6-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::e2b; envelope-from=danielhb413@gmail.com; helo=mail-vs1-xe2b.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: 1659692593766100001 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 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/ppc/ppc440_bamboo.c b/hw/ppc/ppc440_bamboo.c index 873f930c77..2ddbb1744d 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,15 @@ 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' commands. Use fdt_pack() to + * shrink the blob size we're going to store. + */ + fdt_pack(fdt); + machine->fdt =3D fdt; + return 0; } =20 --=20 2.36.1 From nobody Sat Apr 27 00:09:43 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=1659693222; cv=none; d=zohomail.com; s=zohoarc; b=ShoCTMXFEsiiPIACXlYobK84DaAYIVgFTaxog5TD024+2PsM98z++b/HwaV6NdaKGl+pEQ8CtgShSlRq+1lTxAi++uISVSnaEQHhXtPGKlQT//cd9yF0R20laa29UaBluvsY+RQt1m0cm2zVVXdpHM9FGIdyGZB9m3RATilHGSo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659693222; 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=zAZciue/fdUeJhydaxYtGuFu9V0rUc6qeoCvbFp8oUM=; b=TkoUT8OmGCB9NQGPeRZ6JckIxjPaFSppQ6/HHSN0756PaVeLsczfCas56QxYeXFSj3BCw67bP3hdrm1qUB/gMAjxmuhRrxEsQI0PJojC7bySXQWDR2HzMQfqywqO+cIyTcRvbqw1ZRMvHR1JtL7zyJ48D1Xk5kT3ymNDl2m24Gg= 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 1659693222983218.60669560133272; Fri, 5 Aug 2022 02:53:42 -0700 (PDT) Received: from localhost ([::1]:52426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJu1V-0005ni-My for importer@patchew.org; Fri, 05 Aug 2022 05:53:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49964) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoT-0007Xd-0T for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:14 -0400 Received: from mail-vk1-xa2d.google.com ([2607:f8b0:4864:20::a2d]:40866) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoQ-0001RO-7Z for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:12 -0400 Received: by mail-vk1-xa2d.google.com with SMTP id c22so994270vko.7 for ; Fri, 05 Aug 2022 02:40:06 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40:06 -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=zAZciue/fdUeJhydaxYtGuFu9V0rUc6qeoCvbFp8oUM=; b=Bc9udDU8vN4dxHOatvQWor6G1dRkCWUTvf4chwOkZhpIKYnC59INs68LrirMeruAsF EuKKWb8AaOrtixO5k4F8pzz4HyfJjgoaw0po26XnuBo09FX0mCcj0khPjbuQxSu+Ewa/ CIMPO0zMbAw17FRlgtoj+p8ueg0/3z0g38QZT8776vni4D9lRqDJOiRR5TS74BriJgH1 jQ1X69hGRpX/ZHv84NNUjsXD+a3DlbMyXvleXc/OCPYedv98hYFKoiGpMhW/U5G0iQzA Wh7WQO5S77d9CbCftRb2/uVtPwbQUmBDL+sbIRAQV1jykRC47Oo7Y6x07A4wOGRXBtI6 m9cA== 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=zAZciue/fdUeJhydaxYtGuFu9V0rUc6qeoCvbFp8oUM=; b=auwB8wOBbK+0Gow29KBd8idx+l5K3Xl12XiszNXKgW9hEu+3PgzrfUGhTuQFEy2m+H 0WZd0mH6wKp9BPtBYXXvaOjVScbIB9EycX4AQ/0D9gVvIJ0Syv1TedRZ2+/+g3iydXcu RGKjinZF6E2CO+clOvDWkX2PQaxkPuvfIUWe6sCsc9IMk1vpZ/9R8r8LE1R6RXFn7ro2 aIA3tTbRt9CxK3KM36/jlKgt9xOM9pXrxE1zlx25R0x17HxndoNI66Kbo9/+w9gsz+G1 UyyYoMhce0BRR25mSg0XTzNtrBAFFqFW1DBqHqP6NDtLFx1ij9J4do1121GWYT1c+26D v/vg== X-Gm-Message-State: ACgBeo2ajtlpnI6EzLSKwaPIoJ2D7cgTpLVnWQpp+zONZRQc03oisiNu 7Hu+yUvwmO/i6qiU/oJ/mi6K1RQKN2U= X-Google-Smtp-Source: AA6agR7sOf/4SawpMYB0yoXu91S6uL3cVkSVhQ0o7fsfGmWrM+htYGUjIL/rSV/0f+iuT4DjeAfmCg== X-Received: by 2002:a1f:b60f:0:b0:377:4f57:fb19 with SMTP id g15-20020a1fb60f000000b003774f57fb19mr2676886vkf.26.1659692406463; Fri, 05 Aug 2022 02:40:06 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , BALATON Zoltan Subject: [PATCH for-7.2 v2 06/20] hw/ppc: set machine->fdt in sam460ex_load_device_tree() Date: Fri, 5 Aug 2022 06:39:34 -0300 Message-Id: <20220805093948.82561-7-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::a2d; envelope-from=danielhb413@gmail.com; helo=mail-vk1-xa2d.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: 1659693224474100001 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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 7e8da657c2..fa20a3ff49 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,14 @@ 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' commands. Use fdt_pack() to + * shrink the blob size we're going to store. + */ + fdt_pack(fdt); + machine->fdt =3D fdt; =20 return fdt_size; } --=20 2.36.1 From nobody Sat Apr 27 00:09:43 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=1659693619; cv=none; d=zohomail.com; s=zohoarc; b=OY0AfIf0obHzZYl61Xw5go0RCwlp4mGqGOIgHbaZtNJdV6+UNpsJG//AUNxKzlIKyTqFUrcS4jgl6x1HWufHKugu+Qup3Yhsle8whq+zavo/RVWcmdaiaWyQFj15oj0LZ0HzKizAyXjKfoDPEGLVJBjGm2TkWI8DI1p4dBno+qA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659693619; 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=3T43QlQibN7vdNRHwhh2Sn7d+vV3xA8nJznfbZuZtAo=; b=J/tOe9nBNCbfVYkhgwFfpBGJ8t19qcVivowocGTlTImlv0FHFSgZiIFf6aOrFsxncPWEDyaLuhYZaomNdN8QmNFuLEMKolyKUdVzB1Shr9r6rstR9mvBS9gWrEOw15puLv8Zvx/WwCKiVx8m16FS3HeNLfF7HfS8rWwz/qw3PWc= 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 1659693619079659.66734453377; Fri, 5 Aug 2022 03:00:19 -0700 (PDT) Received: from localhost ([::1]:37514 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJu7t-0006vg-TT for importer@patchew.org; Fri, 05 Aug 2022 06:00:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49966) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoT-0007Xe-3F for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:14 -0400 Received: from mail-ua1-x929.google.com ([2607:f8b0:4864:20::929]:45847) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoR-0001eJ-I2 for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:12 -0400 Received: by mail-ua1-x929.google.com with SMTP id f15so823648uao.12 for ; Fri, 05 Aug 2022 02:40:09 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40:08 -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=3T43QlQibN7vdNRHwhh2Sn7d+vV3xA8nJznfbZuZtAo=; b=Si6eyF7mClXxSF8DlpMjf/Akk6qIZyKSTI13kwWZoZs+eOz00XBe7MkCUMq/BfaoTE V3W87XhqOk62bSU484KthpUJvs4Paxj+8OyISzCGuiFyMXfx6jsVd2N+zxc8pssLi7NT d72rDwWmAH/kYpqEo+7HFq2N4PGn4iDYue1sCiXIsXRLdnUTclqSfQiDYshMjewrNVkY lUrjTWjAu51cdnpr/mx4Ir13r5cKGWkZ83QZxeQI0XkyAJQDoAFkbozHiGDzzDESPn86 +qOmXregxLcHd1RIRGqMdh0B8lzMlHFc9yB451Vt0NzHWo+sGiuThZ9S3tzgRbqrOOhc 404A== 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=3T43QlQibN7vdNRHwhh2Sn7d+vV3xA8nJznfbZuZtAo=; b=JYvxriDL80yTmaG4KejZYueHszKZ+J80Thk/zzFhmfzkTfbSffqf+YV+lVJGQu53ta SjGwgGQ6vpoj8aisq2zMBqxhnwpYZMogSBw9yfOBRz1IK/Q0cBNA+dijfONCg0DgfakT o2dqBCO5Qi20qFut0F9f98t6OGKWK7BbVuCKYpei/kztiJSsIFSzgNkqdALA32SPjt2A ap6+v2m0kpbLjgwHxdRv6/IEST7KYwIC/yaoEvYvpWTIMv3eCcmi/ENGc2PqX+Lq4kYD QLfCKXjd6LIrg+Tq735ZRsori63LhiFCxG0y3PgOZWCtZ40SKP+hUXLWrdjAn1j4C7Fh Y6bg== X-Gm-Message-State: ACgBeo3tGxh3CDJ0Tx7twuunf3uwKn79674K4hRU9DDA9QDbD9TI3jtT Ekwb/9ZsrZYIa66VGe0+R7l2clNvVas= X-Google-Smtp-Source: AA6agR4XiiWYo/MVxI096pD2elrWqRIVAYIs64AEeIR0eU1aFVxLGetn/eLiWd8U+Mwj4WObYW8fXA== X-Received: by 2002:ab0:764c:0:b0:386:3e8c:4c7b with SMTP id s12-20020ab0764c000000b003863e8c4c7bmr2735357uaq.17.1659692408433; Fri, 05 Aug 2022 02:40:08 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , "Edgar E . Iglesias" Subject: [PATCH for-7.2 v2 07/20] hw/ppc: set machine->fdt in xilinx_load_device_tree() Date: Fri, 5 Aug 2022 06:39:35 -0300 Message-Id: <20220805093948.82561-8-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::929; envelope-from=danielhb413@gmail.com; helo=mail-ua1-x929.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: 1659693620380100001 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 | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/hw/ppc/virtex_ml507.c b/hw/ppc/virtex_ml507.c index 53b126ff48..ed1d37486d 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,15 @@ 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' commands. Use fdt_pack() to + * shrink the blob size we're going to store. + */ + fdt_pack(fdt); + machine->fdt =3D fdt; + return fdt_size; } =20 --=20 2.36.1 From nobody Sat Apr 27 00:09:43 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=1659692985; cv=none; d=zohomail.com; s=zohoarc; b=cSwbjwnYpxcdYCWo25t4nqNxEf6Nl6ci9nbtPi+K+m6FNFvgciRSQDPmlAxOS/Q87kvHIxU4LDB0/kKebJebmstkPnyiQj7xVtt0r1LY2L4rb9wIW6ctrZLd2sned34ngWHMx9eaXRvmVHUKL015kIgSCJ91SqjIeQvCpFck1II= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659692985; 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=xCNzvMXtNX/QLiNlFzE7CA2H9EDZfC8tHBQyniqpW7A=; b=edUAIJqdZwC9/KD56Wfbf2y4TBJagBtgKCpwLQbNFbBOGrdzT4aKZmpGjHJ1qM4a7JebPY0sTY2TPEpOB+2oAxsfA9wOnq/rkNezu5haIkIvwxTdCXR+nCGYAAVG2ExDigYaPdi5R4qJ3e+hBt4yszZYWodKvj4NniiTFz+4OdY= 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 1659692985529130.72788021754195; Fri, 5 Aug 2022 02:49:45 -0700 (PDT) Received: from localhost ([::1]:48120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJtxg-0002jZ-Ew for importer@patchew.org; Fri, 05 Aug 2022 05:49:44 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50006) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoU-0007Xr-B5; Fri, 05 Aug 2022 05:40:15 -0400 Received: from mail-ua1-x92d.google.com ([2607:f8b0:4864:20::92d]:43935) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoS-0001eQ-Ej; Fri, 05 Aug 2022 05:40:13 -0400 Received: by mail-ua1-x92d.google.com with SMTP id s18so825542uac.10; Fri, 05 Aug 2022 02:40:11 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40:10 -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=xCNzvMXtNX/QLiNlFzE7CA2H9EDZfC8tHBQyniqpW7A=; b=ONyDcfn47E4XJAe+TJpkIQcdC+CX8ED3DplYNRzjeb178qGK2fL90LY3U/QYeLyqqJ QPe62+qHkAvo47QLx+kLWxP2YZLdPN39mUo9QGtQs6ky683UvD3PUgWX/vQFQfMgPOWM wvueNaoSy0RUO8kb893ClKC6hCtJQwxxJ6kntpmIalqFH149LUXidoUBPf/6J/yCzSDj ZGKXvYbNIYLCy+OhSGOCLYOv2vqc/ZV/t/xJgafnc81FlFY0d3g0BhphDhlQVfcbfvYC vzROn836lwieuTpmStG3hMMaCx7v2P4cGNCcAz4O370v2fbCagWd0NdrPNqPT7M9tn/d c1CQ== 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=xCNzvMXtNX/QLiNlFzE7CA2H9EDZfC8tHBQyniqpW7A=; b=JaRggg4oMitXOqWDFKL3XsWZOAlXJMnyYPA0sho6EDzlrN2Mx63AJCgnIbcaapwe34 r+Eu2WsoeUgQpTFzporXJpWLb9aR1dKdtnUvwqG+Ji81COmldPRAMt5KM6rd/4lzNpnp 4lPxa5OYh87/yrcM4bHN19DuUz/Nlfz0m83+jIw2LEHiTWxMYmLJJchypActY42wbqCA eiwF4ty1Aw9gyIrQVLbyN+CT0Ahbj9ns9bWYj8ny3A2iTe01DhV4gaYGA2fieSr+LsOp 1G4QKZNM3oqKprAcJhq8Bc959O3ovZ4fDnipLgvYE8lou00i+7GJKOHjdIyXDANzKCTa 99CA== X-Gm-Message-State: ACgBeo3+7bNN0OVEuPcZG/vXt5PGpPjbuB+Kva01keykIlNa6euwk3vv jwkm9Jv1tnL2qrMPZL58BmGnF/L8wbc= X-Google-Smtp-Source: AA6agR6tJRD+ixW0eoqZMKusY5K2zO2teKMgiXRItbr2ezdwLT76DlaMVUWMiZfBV+A/xjQuPIen+w== X-Received: by 2002:ab0:69c5:0:b0:383:4295:fc9d with SMTP id u5-20020ab069c5000000b003834295fc9dmr2678166uaq.92.1659692410566; Fri, 05 Aug 2022 02:40:10 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , BALATON Zoltan , qemu-ppc@nongnu.org Subject: [PATCH for-7.2 v2 08/20] hw/ppc: set machine->fdt in pegasos2_machine_reset() Date: Fri, 5 Aug 2022 06:39:36 -0300 Message-Id: <20220805093948.82561-9-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::92d; envelope-from=danielhb413@gmail.com; helo=mail-ua1-x92d.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: 1659692987535100001 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 | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 61f4263953..8a6c6e4b7d 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -331,6 +331,15 @@ 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' commands. Use fdt_pack() + * to shrink the blob size we're going to store. + */ + fdt_pack(fdt); + machine->fdt =3D fdt; + pm->cpu->vhyp =3D PPC_VIRTUAL_HYPERVISOR(machine); } =20 --=20 2.36.1 From nobody Sat Apr 27 00:09:43 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=1659693520; cv=none; d=zohomail.com; s=zohoarc; b=DjGc1ATyLqxvwrhYZMJuMsOVNdpSCAMZIDhWgKTekFGCzCvZe7iMrYfKxnqKGa/t6GEvQceQ8byuc3nSywvVXsn5AczDK59W3KSSgQ54z/U09oYTfRGk5rTp0faENXm4Y+rf2ZzKH2yZlFgtYtaSsemOWHCDrdfMRCTduYloJW8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659693520; 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=INBPRigKq6rQycZXT1hbwZRQNiwpBIXBjyHgz1OYCoA=; b=S6ogL0f8cLc9Rp6ZtCQrhkOza/k/BmqPOkkoSZmSN7Ef7r4IHxLPE05vcxSz794VwiTJ20cbxfx091hDI5q6PWQ3n9QdnvzV+2iMqVRgrHvOR3oMMGmMovOwTdM2pidxk39W/WIf8gHATz+Ve4jw2acooUTmxZfns1NMXZpJaxg= 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 1659693520296577.8012831322799; Fri, 5 Aug 2022 02:58:40 -0700 (PDT) Received: from localhost ([::1]:60724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJu6J-0003Pl-3i for importer@patchew.org; Fri, 05 Aug 2022 05:58:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50022) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoV-0007Xz-9y for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:21 -0400 Received: from mail-vk1-xa32.google.com ([2607:f8b0:4864:20::a32]:36792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoT-0001fF-PP for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:14 -0400 Received: by mail-vk1-xa32.google.com with SMTP id v13so1004453vke.3 for ; Fri, 05 Aug 2022 02:40:13 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40: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=INBPRigKq6rQycZXT1hbwZRQNiwpBIXBjyHgz1OYCoA=; b=MuMHRqoafB01CWP/F7unJvmj5K/Sq2uLwahO/khD5dDNgm3yYJtnINT2mGcpOdfIig 0VNdkgsz5MXNJGb2YR0+giTlGdKk7SaCWJdu66q2srzMUVxLg1t6TT6L8pgoH50g6Nt9 JJh+5XAenqAKS/4dHws28aoXbfAJVtxEp84HLeYZlgjXl7vyyYivdsg/HrSjexHntqID U0zgYngmbBYra+01MocKEgEeZleUGmK+pR0hABcuuIhyHrm68PCamM9AdCv6spPdd7XU UBlKmFUlzBvvPjCo4LzMMJ8FJBE3OfgbQxwzvogrmFrZC8rvJPEasIN5LGlNF7fDmaoJ Ej3w== 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=INBPRigKq6rQycZXT1hbwZRQNiwpBIXBjyHgz1OYCoA=; b=TJW1JtDSpi5vSUnVkWQYZ/F1f4Fjr5bc8fYS8SUwhNmksjbhtwAofZPPz63NLsL5a6 RYYn8yd3GVHyX363WAlx/9sxgVvkfvnk/B22mcNkGc41l1TCTjVtNXowy4Et2ouhP5jF kZr1uPbF6mj1xun6G88aMuzpyV2Utbf0ETnLlzTYjAr4B5PJbg+H1AolVKCAW0kiz/hf ArGVgLj6bttHOqzwUMDJs+BgkoXviuGugV2NTbnIPV4Fkqq0YjCwQrROBlBBjVOKPqrC 9UOJBAluTdL8QhUii4yMWkv1bd3dsRjg2PJY125Esf0P1FcckmgtRoc6u4faIWOaBvJz C8Kw== X-Gm-Message-State: ACgBeo1IecBiKcpZa347FrkCEahDiCVBKlbxIJhJiUeFKyCRUgt2lUL2 sWKA17KY/+N74kFDq2jOZ6Tu1I6Uc7w= X-Google-Smtp-Source: AA6agR61ZExdF7CnYCQ8YLgE+jybh8clfXipnwwjkh5TC5ja+3bwptUZDQHYRLHgCwp9hBpLwHiWWQ== X-Received: by 2002:a1f:2452:0:b0:377:7b38:9b59 with SMTP id k79-20020a1f2452000000b003777b389b59mr2682381vkk.23.1659692412740; Fri, 05 Aug 2022 02:40:12 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , Frederic Barrat Subject: [PATCH for-7.2 v2 09/20] hw/ppc: set machine->fdt in pnv_reset() Date: Fri, 5 Aug 2022 06:39:37 -0300 Message-Id: <20220805093948.82561-10-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::a32; envelope-from=danielhb413@gmail.com; helo=mail-vk1-xa32.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: 1659693521804100001 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 | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/hw/ppc/pnv.c b/hw/ppc/pnv.c index d3f77c8367..f5162f8b7b 100644 --- a/hw/ppc/pnv.c +++ b/hw/ppc/pnv.c @@ -608,7 +608,11 @@ 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. + */ + machine->fdt =3D fdt; } =20 static ISABus *pnv_chip_power8_isa_create(PnvChip *chip, Error **errp) --=20 2.36.1 From nobody Sat Apr 27 00:09:43 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=1659692898; cv=none; d=zohomail.com; s=zohoarc; b=YLf3NAjxAwCKGGtRoNvuP5EWVgmdcefC0/Bxfnbgck5cUtcb4fYP0vCHpsXf1vA4bPjS/qWPEIJWQv8rPb4PoRkOEN5aOuXCwBHXJtgP7msINs36gT4mzR/Z0YLCiKMo+farhmorUV1vzssKRCzGR6FD9VrUB7iso0furGI7guo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659692898; 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=VQVatWRzJzIALnBx+eLVXqARRsrCtfKyW9iFoiU3AdU=; b=NvCt7KBn25Jz/IP28j79lNmbcqw/Piqt4vjXWZUPR25vT0/8AJx0DXaJyKXAG3wmPDgKzmdcKksEwn8hMKaBDZXgoBTsFuh6NMqp73FNi1nmoNyUQBiCPDHfbn8OXvronO+HIcBb8K/KokBovM8ssBMzLjDac8XuUazux1qUZV8= 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 1659692898946385.59872844416975; Fri, 5 Aug 2022 02:48:18 -0700 (PDT) Received: from localhost ([::1]:44426 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJtwH-0008Uj-Qq for importer@patchew.org; Fri, 05 Aug 2022 05:48:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtob-0007Y9-Dj; Fri, 05 Aug 2022 05:40:21 -0400 Received: from mail-vs1-xe2f.google.com ([2607:f8b0:4864:20::e2f]:36546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoW-0001fk-8H; Fri, 05 Aug 2022 05:40:19 -0400 Received: by mail-vs1-xe2f.google.com with SMTP id o123so1945106vsc.3; Fri, 05 Aug 2022 02:40:15 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40:14 -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=VQVatWRzJzIALnBx+eLVXqARRsrCtfKyW9iFoiU3AdU=; b=gHQmVyo87E/Af2yzQjqxkcrRnCCcCtwAjH/y2anm5RioR4/KtDuyN9DYyT5fzFkSKA LtCIg49AAAftTtsZT/vUZr1AuaiVGMIARy4JzFVbzvQ6WtRVivusm8Rwn5hAAdl+/Dvg 8zN5KbVgbYyA7MXdJ0E7F59I5Fm0jLLQUrY5+AFCCcMilAfBSaKfLXW8tWJykcDJv6uK bJnvTKedtfXqrkNE5zSGhhCJjxTY/06yHTMk2x+XIbm/zCUpD70QECweUr/H9S4MfsnT UB04s6+ewuumQvHL8CaKYd56Vd73pJ9ryVYTw165HOZuQjpRA1UriaJLZQRAPsW0AZm7 vz+g== 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=VQVatWRzJzIALnBx+eLVXqARRsrCtfKyW9iFoiU3AdU=; b=jJi36r1W9auCYmlr7xCAqPGIxHUUPhN7phfi9kwaS2mmjqPzBd0PQb3qMmN4QMIDCZ 1oUeWxafB2abqf5dDwxcZiE/7ewD/ph+ExZjSWWTq2HAYAi5Yk9bG/l599gp6E0si4T0 xmSBfD2zBy+r2yHTcpItM97njJgyHPxUmIDyFHrx85GvCkpDhdl0cr0+ccdi3k74Khuw j229KkdzuI0ZAvvgMtRjzEOkYzR2Wq/gfFvNJsFbhSIS0w30EMqVeezMLH+fWh6InpBx SaeEkKqlR8MqQH/2eD3R7tphou+9EFoj9oq/4vdjUqa+7cF548Aul/z6ch386iN96BgZ iQZg== X-Gm-Message-State: ACgBeo1md2osFw4PuVJnoI+923wDxkCjXjSIoMjZ2Ath9R8jCLq7Bqen y6Yj4w/rMJG8xxAVGMt9lIlfwVfHgOI= X-Google-Smtp-Source: AA6agR7RoKUwkpiMF0/PW43x/V/TvfAiL2bI1NYM8G57h87rHkMtFkzIWDl5Cn29iwZJB2HWP8Bncg== X-Received: by 2002:a67:b24b:0:b0:357:31a6:1767 with SMTP id s11-20020a67b24b000000b0035731a61767mr2497774vsh.29.1659692414943; Fri, 05 Aug 2022 02:40:14 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org Subject: [PATCH for-7.2 v2 10/20] hw/ppc: set machine->fdt in spapr machine Date: Fri, 5 Aug 2022 06:39:38 -0300 Message-Id: <20220805093948.82561-11-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::e2f; envelope-from=danielhb413@gmail.com; helo=mail-vs1-xe2f.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: 1659692901068100001 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 the two places where we manipulate the FDT: spapr_machine_reset() and CAS. spapr->fdt_blob is left untouched: what we want is a way to access the FDT from HMP, not replace spapr->fdt_blob. Cc: C=C3=A9dric Le Goater Cc: qemu-ppc@nongnu.org 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 bc9ba6e6dc..94c90f0351 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' 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..0079bc6fdc 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' + * HMP commands. + */ + MACHINE(spapr)->fdt =3D fdt; + return H_SUCCESS; } =20 --=20 2.36.1 From nobody Sat Apr 27 00:09:43 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=1659693264; cv=none; d=zohomail.com; s=zohoarc; b=A9zjK9GTwTycLbjpKH97PZK89nbXrdF3VT3LcmXOEPZwbkiBwGdPbOW2bSQ5+7vpkS3aKybeV4ciL5PjXG5KHpa3Li/LD+W5rKo5BYK3maoWb1k+dr/SAFXicR0zcTWatIdQU7dWUbSyE1Y7r5iwVqugC2VyDhSlWJcylqOEq7w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659693264; 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=LZCK1LNH2Rj6X2lYdtcZHY6VpwRx32I2PwlVD4SMxlk=; b=jEt817QPGFKReen4JEMUUsNuG6DIuK8ZHPYg2T2X03rj5GbU3vupQ2EjEoIBPOWasCjdtTZQtv68wL+TermE5pSNt47TVXgrsPtijrcpZfvqaidpP8owmtj3p2UX0UWSRxHXE3VodGOj3xnYMek6QZC+84xOvOnZSXnsu1HnXAQ= 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 165969326448564.71152063956174; Fri, 5 Aug 2022 02:54:24 -0700 (PDT) Received: from localhost ([::1]:53738 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJu2B-0006iT-G1 for importer@patchew.org; Fri, 05 Aug 2022 05:54:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50078) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtog-0007Zf-Pa for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:28 -0400 Received: from mail-vs1-xe2f.google.com ([2607:f8b0:4864:20::e2f]:40578) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtob-0001g1-58 for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:23 -0400 Received: by mail-vs1-xe2f.google.com with SMTP id q190so1921781vsb.7 for ; Fri, 05 Aug 2022 02:40:18 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40:17 -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=LZCK1LNH2Rj6X2lYdtcZHY6VpwRx32I2PwlVD4SMxlk=; b=XoZUD7O4xvSOxrCRLxv+o9IXEcjt8dBoTgF6HIDIz5jyIVuR7dTZcN1qt8cD5MdxYX Urrlpg2hUMwV8pjTDJqGlWAXhhBe4Jiwq3wj+Hm2yF91oaHEo7gHsJNEXwirqAwmInh+ 7DRTzepMsbsdKPtuZROHr0p1nMR4VCQPT4L9ZXhuIToOEdjC3/LNYJu/rTyBhlgz68y5 6ZP0mjR7XK3sP+wqeN2B6Yve2hZCDxhkjZ+lY3EnbJgL4t22PfExR3KoZ0DaaLcEYC91 8TIPEe1LODGjlBj3ClxB6C1AkBP6tMiUzbp/IH+UCW0p4/bYb8nM1C1o7UREESwpMPKT 756g== 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=LZCK1LNH2Rj6X2lYdtcZHY6VpwRx32I2PwlVD4SMxlk=; b=YbjC6ADyMn0OouNocVJEVJQ+iZPrvPBuelBygJZ08AUqXfkdrL9Njefx5RylR9LVFi +D7rL5DKfEBCDlbPE0qwALaonTGgQzor7tOJzaUFW4UjL2/oEnHTU7GqITKvX6UoIjZH vDp9oW0CHP5nkjvIa6mUBKVe1sBiVb8wYPGLni3BkbpWKwcNMnCVuVTbFpviIFPs32Hq 1c78x9QBqcv++T1lU7xbz0WM4oFiefLNuzjoTzxBUqhFnpzHP52EGCAPB66GpIuyT3Rk YBAa35uB9hrbC5hAVCPZ3G5UMCQSVFbMq6bYEBecO4Acko5iLcOrSOXpGbbQLTFu3tLK Blhw== X-Gm-Message-State: ACgBeo35o4Jjg+UTVWIAa3kBVY2CRLRmUXz6yafuomAsGnvll3T1hDyC e2BX7hzKyucPhXziI9NepjsGxO2LfJY= X-Google-Smtp-Source: AA6agR4x+oOfAJMTgrn2UF0WIksXVSM/Mq6HQ+vhLjLPLxU4oezy1cCtXC2vSamwc9bO/e7CYnvSkQ== X-Received: by 2002:a67:c009:0:b0:357:92c6:77cc with SMTP id v9-20020a67c009000000b0035792c677ccmr2422917vsi.35.1659692417608; Fri, 05 Aug 2022 02:40:17 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , Alistair Francis , Bin Meng , Palmer Dabbelt Subject: [PATCH for-7.2 v2 11/20] hw/riscv: set machine->fdt in sifive_u_machine_init() Date: Fri, 5 Aug 2022 06:39:39 -0300 Message-Id: <20220805093948.82561-12-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::e2f; envelope-from=danielhb413@gmail.com; helo=mail-vs1-xe2f.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: 1659693265250100001 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 Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- hw/riscv/sifive_u.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/riscv/sifive_u.c b/hw/riscv/sifive_u.c index e4c814a3ea..10f5289966 100644 --- a/hw/riscv/sifive_u.c +++ b/hw/riscv/sifive_u.c @@ -634,6 +634,14 @@ 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' commands. Use fdt_pack() to shrink + * the blob size we're going to store. + */ + fdt_pack(s->fdt); + machine->fdt =3D s->fdt; + /* reset vector */ uint32_t reset_vec[12] =3D { s->msel, /* MSEL pin state */ --=20 2.36.1 From nobody Sat Apr 27 00:09:43 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=1659694250; cv=none; d=zohomail.com; s=zohoarc; b=FKBcOHhyL6f+h+vE92XfbtqguScu0tpfaJMPx9yRpgf5Y6c7HyQTvQn7kJI9mx2JX5EGb5ZHaoqyAYPjM3G8xLQ7kDlYHI9J8bPvN3XtpfYURyjzxjJe/b4sFM9RhxA0jh74/oc+oF4ukI1kF/hil7okAkHH5adMkZayuw6Gytw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659694250; 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=x7DAsznkbtImnLCnedJbCBhvUT58/EO/hETMQi4QGgo=; b=ciotKnp9teemmsfSMuvfGc9VcrSX0vnY7mYatkWPQNFitydZisll8t4A+pXdHIEqPcnKaZeBd0xx77XceXCpoPHHRG1orjkNGmNjBCe+M2LtsRIw8lDIkHd3AmV8b23/o8nUZysfuL2WayKnXmvjNd/ZBcuuRiaLaONN+a6x1/U= 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 1659694250124811.6801185227458; Fri, 5 Aug 2022 03:10:50 -0700 (PDT) Received: from localhost ([::1]:49994 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJuI4-0007tj-NY for importer@patchew.org; Fri, 05 Aug 2022 06:10:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50156) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoo-0007bQ-Id for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:36 -0400 Received: from mail-vs1-xe2b.google.com ([2607:f8b0:4864:20::e2b]:46623) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtob-0001dv-5E for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:27 -0400 Received: by mail-vs1-xe2b.google.com with SMTP id x125so1888130vsb.13 for ; Fri, 05 Aug 2022 02:40:20 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40:19 -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=x7DAsznkbtImnLCnedJbCBhvUT58/EO/hETMQi4QGgo=; b=Bjw4TlNhZAkYt1SyD0gXhzG2LyLTtGnlvJIGyuoTMFdt/6N2LzEf6867stiHvV2ITd ZA35s6XGLvZ9C+ZvoaA4VuxDMkfw7NSJAfzVZ8d1Lt8bDx/HN7WF3XQ2NIQz/56tdSqb M/51oSu0eTz1DSbsS/GaGj4L/0x5yDaeRnGjxJmOwweSyvMzXKtixmawN3lp8U/uQseE PFa6pxqE4CyRrzMZB4CPRMiPHXfpsGuUsv4UAAKzEnysuSf6uV8R+JPGLPYzYQ3b640n ErkZHOygO8UqwV1PBK8OKPeMLz4nPAM5pDU9UQAAcgL0DQ0/7eMDYCNrGcEUqwOylMHY 3veA== 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=x7DAsznkbtImnLCnedJbCBhvUT58/EO/hETMQi4QGgo=; b=DdeAqzpzqS+6F4+2E6zK5Wm9gGDSECYusQu4q6T2BZJLUB8pVOB39QWmfVPhckvqdC K6d39TLlz51H4R8zBlIMybHg5t31YTbCzANP8RbVDN3gd3xYG4yCWa5zlpDi2nfQLquz 1aJX0oodj1XPoKG0p9MPWEtEofNSEPMO0ru3ZlKuEi2cotypQvgLhZe5SsR4kEpd5efs dTtKuREcJHfsX6+o3eORBA4PyQ2MzrNueleK8k2FEouQw0oiky/LWiH1+SvNz7ud+yDZ 34wmKHIxAhJ0CU19A8xSdIhCbCEI0KlawFoC+ZakFGasUmdazX5aCE1Y/P9L++qIrhR3 rHAQ== X-Gm-Message-State: ACgBeo0nXUVXNoBsL7lrC6XafuOvnSvWNN0uOq2LpfaCrRkkGa9q2cS3 6ISpsd+ggMF9NQ+wZ6kwqd+/41gqouo= X-Google-Smtp-Source: AA6agR4fqyNNjJbzYM9QCWJtor/6E4PePcAX8yu6Pyxd7ED241pZkO/u2qdVcRAhgzmCdlRFeoxd5g== X-Received: by 2002:a67:ee12:0:b0:385:7059:ac88 with SMTP id f18-20020a67ee12000000b003857059ac88mr2612813vsp.85.1659692419654; Fri, 05 Aug 2022 02:40:19 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , Palmer Dabbelt , Bin Meng Subject: [PATCH for-7.2 v2 12/20] hw/riscv: set machine->fdt in spike_board_init() Date: Fri, 5 Aug 2022 06:39:40 -0300 Message-Id: <20220805093948.82561-13-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::e2b; envelope-from=danielhb413@gmail.com; helo=mail-vs1-xe2b.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: 1659694251778100001 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 Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- hw/riscv/spike.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/hw/riscv/spike.c b/hw/riscv/spike.c index e41b6aa9f0..2909f7b2a1 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,15 @@ 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' commands. Use fdt_pack() to + * shrink the blob size we're going to store. + */ + fdt_pack(s->fdt); + 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.36.1 From nobody Sat Apr 27 00:09:43 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=1659693555; cv=none; d=zohomail.com; s=zohoarc; b=POkj37/7//Th5CIZnOoS8LtmXxRRMmP+5exWmHx4PhM5mfqSd0Pk6i3t6pO8IIyJGqXvJrJuYNNsYnFWiJGDCkPNmtn43UBkyS4DSkNe5NUp/wZGFC/Fpks19t0fWo/mPjA3VcRP+7Yb1u9ki8RoD15afH1E3apsdi95u8C91/E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659693555; 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=WJuc94Oic3QdxMYiy7FSuuXF2yzCIlzKqZVe0k2s5z8=; b=Pm4XkdwQXALEEuxnmGI2Vq3THJxrcpewlxOCcKhxxvhf/lg6CR8UqRNsqYSNATA5+6QUWvck3FofV/Rtr0VjBJGp8QKmo8kCyCbAnb6FCsKXezl8LxpUYzaYFmb5x34NR5IgeRGuL7XjFjNohosAzqVXWthucJlbBZfKC4HHYZU= 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 1659693555633516.0114232860593; Fri, 5 Aug 2022 02:59:15 -0700 (PDT) Received: from localhost ([::1]:33792 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJu6s-0004ID-Lu for importer@patchew.org; Fri, 05 Aug 2022 05:59:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50154) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoo-0007bP-IP for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:36 -0400 Received: from mail-vs1-xe32.google.com ([2607:f8b0:4864:20::e32]:44938) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoe-0001gG-Py for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:28 -0400 Received: by mail-vs1-xe32.google.com with SMTP id s129so1908328vsb.11 for ; Fri, 05 Aug 2022 02:40:22 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40: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=WJuc94Oic3QdxMYiy7FSuuXF2yzCIlzKqZVe0k2s5z8=; b=j2u63MLXtHhrxpttTY+odumW/mCD4MR0J2cN9sh2KLiDg/HaumLsI67lbhF6CLgkGE 7AtvffaLodQWC+1Teo3jr8e3SiNy4kYq7pycKLNQVdpK1AsOrqJGIkVftqbSH6x61fBe a8MT4x38eRDrGS3ytS24VlbqDem/0nqdX9PIjiCdtY0rd9v6TgvWR3YphuWUmPqNLnaJ LUsP9AYwmU9u1+0OmLKh4ErFC9I51Sk7wDtaoiIRs9/Ls7c8iypngrQQ2rThn5txGhUI Lv+FbN3g/F1XP2HEUE0ldC9k/IEtbGFxgPZ6+xwKB5sSnPvg6xHjCuelvJKcm3i1hjmk gM9w== 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=WJuc94Oic3QdxMYiy7FSuuXF2yzCIlzKqZVe0k2s5z8=; b=tQ99giyW9rnbns05arwSY4EZwaYtt7rrPFFGMy69K44/F4c2avmQVTtoxH0V/u+NQy KlDRSJLI9Zpurvp0bCk0HIgeJs0Nf+yBvxHdOGyC+7vrew5JC+Da25AFGEJs4Z3p812Z aIfxhv1DkScjGutyDYvi/hP9wYk43xzFqoyzQfw9NtTPuQUrgsRPY8+YWKIG/18Nyi/f UbWsfm5Bxk4bequijhpGf2v9NGzR/0oCJWNZgLVtQgKc+TqC4zJnuCBmxaTjx56Tx24I TBuIPgdQY1f6C2ZXz8q8lsYuIRS54pYRFhLr1lbthMwx5a3olJWYs477cVliG/FpEnaD ev0g== X-Gm-Message-State: ACgBeo1qTln75KQwWVT7egOfL81ApeXk4fa4QdeVTB+GzZta0bFKD8ax 3s3oFOSVVtY8V/N1frcUrY1fZoK70MI= X-Google-Smtp-Source: AA6agR7eNW50qKzDTSRGwOCNS4i8Pk8oev8Q1+blrgLPrQE1IaHfJTdCx2lK2aq42yOW4Ki9l6WbTA== X-Received: by 2002:a67:d717:0:b0:385:273b:a208 with SMTP id p23-20020a67d717000000b00385273ba208mr2648010vsj.9.1659692421512; Fri, 05 Aug 2022 02:40:21 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza Subject: [PATCH for-7.2 v2 13/20] hw/xtensa: set machine->fdt in xtfpga_init() Date: Fri, 5 Aug 2022 06:39:41 -0300 Message-Id: <20220805093948.82561-14-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::e32; envelope-from=danielhb413@gmail.com; helo=mail-vs1-xe32.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: 1659693555993100001 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 | 11 ++++++++++- 2 files changed, 11 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..212f5f3dc7 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,14 @@ 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' commands. Use fdt_pack() to + * shrink the blob size we're going to store. + */ + fdt_pack(fdt); + machine->fdt =3D fdt; } #else if (dtb_filename) { --=20 2.36.1 From nobody Sat Apr 27 00:09:43 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=1659693862; cv=none; d=zohomail.com; s=zohoarc; b=TnMj+0ew4iPoaEs2TUsWMTFdq6NJgS51RjuT++070/C9lr3Bn7dQkaR6J+OkuaWjJgdn9Hyjn+hEpUUOVyoZpB5gIycl9jqK1yA8wMn39u5CPcXIqjK5HdvxI9BvQIEB4NpmGrn40Jg+rjTpc6KuTBUubtcgnCqGApsTe/TUaIs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659693862; 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=eQX9n04YPz+bUrrgksUma/VgRZtmN5L8EqxWZCmuRVA=; b=IKlgzU5qVMq0XIdtz+rHdGlPtH/79EpAARhIoi8OfJncgvGsjYMNd95DIpwj9YQxRbxeqpud4rikLtA1OY8eVZjQRaRHdC2h6VSGIerThDspYSEku0FRABcU6cvUF0aX+qf7qM4LeL0LTOYLpaJMz6GY9ozFKvxASDYEZazPE1o= 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 1659693862374724.7243294837732; Fri, 5 Aug 2022 03:04:22 -0700 (PDT) Received: from localhost ([::1]:41726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJuBp-0001kb-1R for importer@patchew.org; Fri, 05 Aug 2022 06:04:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50158) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoo-0007bS-J8 for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:36 -0400 Received: from mail-vk1-xa32.google.com ([2607:f8b0:4864:20::a32]:36792) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtog-0001fF-GS for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:29 -0400 Received: by mail-vk1-xa32.google.com with SMTP id v13so1004608vke.3 for ; Fri, 05 Aug 2022 02:40:24 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40: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=eQX9n04YPz+bUrrgksUma/VgRZtmN5L8EqxWZCmuRVA=; b=oooAJavfQrFb/F1mSAKOvn3DlAVrZfdG4fS7o/L7UwU8b7Wgjmwc0IVyYlwP9lfSu4 dR01LWGdtOmeRMWD5ksuciPn+3Geo6mFMqU5mznnoUg3of3Ku/Ci1030BGdxjyWICG04 qcuanO5YaEudCNaAjqSvqq7+qQuXzxehXyEPrS9qg4trK3pjrOR2GHaNFpcv+fYYKCu5 stZmfXAb06J31P7YbwAEfKOKbRXhBzAWKR3ti8yWrBSmVAMsnAU9kQ8lcQR4ehy7+7V8 LtOWrM8Yt9C+6yEfOQ3ZqmOXyGYYADHHatRLy5Kbei8Rdx5+Ks3cSSuW8mnO9aR0gVPF 2Ubg== 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=eQX9n04YPz+bUrrgksUma/VgRZtmN5L8EqxWZCmuRVA=; b=F8vbYpTtelUxQtn/zLv7+ydQUVKAQ5ibbMCr3fp9739D7pxSTH/J8Moxo39r8mUktN xsWDJvLqW1aRMNjgHzStrnTKhTiesxDLZa/xklU+Scl6jGUfvNSPW3vYwsVolfyZCub5 Ts4voQSVX6dumzNDexGVMCQlNopvQ21CYF7hhtD8iueK9YN1Wprr081P0prGW2s8hBDB z6ChSADUq7Jc5RGGdtBg1bbIoFndJIPBuNTI+8w+V2dTNZA5Y0y1Q0qI4d+CwtrAN0zE X/Hq8T1arJi0MIxZW5h8QheAkB5oviw33phdInM/VHCc34jG9K4sm5oB42K7IRjqS3aP FJqw== X-Gm-Message-State: ACgBeo3hPL3j9ebYqp+7XtrGcVbQCBpYfWiW5AM3H9jaWb/HXnbeZHS2 wUyvvsZyDu8uKEtD0fze1Mkoewo4e/4= X-Google-Smtp-Source: AA6agR7m4vdcp56DjQ/rIpz3gFScBw1V9/oXF1KZD7XaW7cmGcXr1jRPoupsWDjaytZWehpdU+ELUw== X-Received: by 2002:a1f:b455:0:b0:377:c783:e96 with SMTP id d82-20020a1fb455000000b00377c7830e96mr2611473vkf.8.1659692423435; Fri, 05 Aug 2022 02:40:23 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , "Dr . David Alan Gilbert" Subject: [PATCH for-7.2 v2 14/20] qmp/hmp, device_tree.c: introduce dumpdtb Date: Fri, 5 Aug 2022 06:39:42 -0300 Message-Id: <20220805093948.82561-15-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::a32; envelope-from=danielhb413@gmail.com; helo=mail-vk1-xa32.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: 1659693863697100001 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. Cc: Dr. David Alan Gilbert Signed-off-by: Daniel Henrique Barboza Reviewed-by: Alistair Francis --- 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..d2554e9701 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:s", + .params =3D "[filename] file to save the FDT", + .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..d23ec85f9d 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) { + error_report_err(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.36.1 From nobody Sat Apr 27 00:09:43 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=1659694531; cv=none; d=zohomail.com; s=zohoarc; b=lLpDljxJcbJZw9P9//SZM3btxKl7GyUL9w4L+5p/OuhfYIxNbGFlL6jOFXN9kKXuLXN0ubfk4DZsKupDWyF12Gb9ZaUOCbT39tMMFXSI+OdsFnzj7sLAayTkMmEKIy02vTYDQvyyu3LjwqlKhegBQP6KEwwF8atTPiZE9XakPcw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659694531; 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=MJHzoCgCc6e/EQV6aOuaNRufVaVzRs2+XxbcvwTpP08=; b=MMp/2vD9fzZfvMErJbu8+wsoM7/wIy5rdNqyCt9mX+SL1CVW1QfwpGDyoKYLVp9BmNdcsBM/gs67dFSPi2X2NAJ7bLlMB4bcLtwHdrTH4EUrsglH+EwaYxKDGYxwpEz0I8iLKtMSvWpzOxUfGevFzR93Q++nj35T1W/J55kJ7Ks= 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 1659694531060273.87320886083774; Fri, 5 Aug 2022 03:15:31 -0700 (PDT) Received: from localhost ([::1]:58536 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJuMc-0005Rc-1p for importer@patchew.org; Fri, 05 Aug 2022 06:15:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50160) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoo-0007bT-JK for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:36 -0400 Received: from mail-ua1-x92f.google.com ([2607:f8b0:4864:20::92f]:36437) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtog-0001gT-ON for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:29 -0400 Received: by mail-ua1-x92f.google.com with SMTP id t21so840576uaq.3 for ; Fri, 05 Aug 2022 02:40:26 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40:25 -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=MJHzoCgCc6e/EQV6aOuaNRufVaVzRs2+XxbcvwTpP08=; b=WR0wNpfHOKT5ftf6pmeuoDbu/Q82PXEnwl+uBVrvlnasKbpKcOdY2DlCkP0N6hyvUS q4klNYMbSkQySQsDjpQlLxEoimzrB6F41xJc7O0ywazoaMBKEI9V3OxoLah+fUpEosDX pQh9JLMmMnh5lYOwoYbZlC8jLiVGrFwHq0ZypYCFpx7mf/CP/FB9eUWoUcqkJFWFTdAz vFq4FvCIVURdPO/sUuqQgC+kt7/Up3iB89CK1Kd1Nny9yi4Ku2KCgaW46T2yZLQ1FOyO G4NLTSESxrr502YHh2e6ua3F0+ovmwBRJDvvLSKGLMYxGIUyF2aR4WwWK624o8ykNa+A TuZw== 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=MJHzoCgCc6e/EQV6aOuaNRufVaVzRs2+XxbcvwTpP08=; b=qj6jgJshm5iWZwjQJzf+ep5AtIBeddi52Q1FBeeZuxvCuV4F396/OrdvxHZykFvzZ2 oivxj8NZHRt7prCpw82z5YoVMsImzAAGkwYQ1l400whm50/ypGKIMlVDfuQij0pC3bHz OyTVapSHm0jUn8gm7CnAckg3scN6fTeWjSf00j4jESJjd/ItEm+6oj9VwBPf2QMeKtvK EONXqQmHokw0x9w8yOyj3jlFXQbx2Jrzj5lq44D4lGrN6zpZlGdbyOMguIj1m+MCQBrU JGiANFQxeEeEloSvMDIzG3C8WKqPJKX/w1gl0rQKzIOSiBTGXzCM0zqc/tF+W69ZQgg6 8Bvg== X-Gm-Message-State: ACgBeo1sTpCGIlb9KJnn/ZC2E19HtQyl9nkZOuTp/Sir49vlOEu8n/gI kr765Me5NLM6VR4+tC68oL9LhbA3ouE= X-Google-Smtp-Source: AA6agR6B6ktORws5/kCjZOQIP3mlKrVKo3a6miRzVW4iYvBzZ4GEUj7UUVNYekWg8iIo/GYIiOemyg== X-Received: by 2002:ab0:278f:0:b0:387:7d2a:28f6 with SMTP id t15-20020ab0278f000000b003877d2a28f6mr2664619uap.115.1659692425607; Fri, 05 Aug 2022 02:40:25 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , "Dr . David Alan Gilbert" Subject: [PATCH for-7.2 v2 15/20] qmp/hmp, device_tree.c: introduce 'info fdt' command Date: Fri, 5 Aug 2022 06:39:43 -0300 Message-Id: <20220805093948.82561-16-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::92f; envelope-from=danielhb413@gmail.com; helo=mail-ua1-x92f.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: 1659694533095100001 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. '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 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 d23ec85f9d..accde90380 100644 --- a/monitor/hmp-cmds.c +++ b/monitor/hmp-cmds.c @@ -2484,3 +2484,16 @@ void hmp_dumpdtb(Monitor *mon, const QDict *qdict) error_report_err(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..3fb07b537f 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.36.1 From nobody Sat Apr 27 00:09:43 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=1659694957; cv=none; d=zohomail.com; s=zohoarc; b=U/ZdNgWGDZ96N5KXrrdtfnuIVSdyK9jz8e66Wfzd0qQ+fT+ZNd5q+8CAWBxIvqpOwBrVoEJkwdF4zQEzvlve/G5tfKbqpd5RVt4lK3iURnvOhY7YFM5b0hYlM5DRKrk36put3vNSoGYkQCnpASYsefwd1GcUnExr/KEEHEpkpTk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659694957; 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=5dDI8QuLLiahAitilTZUUqiS0BVok6v1BxvdogHOtKE=; b=R1OFxP1MQ9f+VqVG8E3QN4UikGtyw0BhUNG6CBfHbrF+VinvhIyFQCjeYWtVIU2TTTbXFPr+kfTfQxyyG1Kkfx+0oQY8tFEHfpBUxOsIGMRboOV70oN2eOj128ZVzRFq7DoegqdirSwdpETtJleAplmCBR8Gz/pm24sSyg2AK50= 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 1659694957239734.4103566749611; Fri, 5 Aug 2022 03:22:37 -0700 (PDT) Received: from localhost ([::1]:39260 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJuTT-0003K2-0L for importer@patchew.org; Fri, 05 Aug 2022 06:22:35 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50202) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoq-0007c0-Sw for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:38 -0400 Received: from mail-vk1-xa2d.google.com ([2607:f8b0:4864:20::a2d]:33444) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoo-0001h4-AD for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:35 -0400 Received: by mail-vk1-xa2d.google.com with SMTP id r4so1028514vkf.0 for ; Fri, 05 Aug 2022 02:40:28 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40:27 -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=5dDI8QuLLiahAitilTZUUqiS0BVok6v1BxvdogHOtKE=; b=ELmFz9gIo4L1QlSvm7eIGe9i7EVax1lMsrtxhx2UGeaPBerfvKTS6gdDSuVhuVoO9+ oUzIqIQDtNj1AP/3C0aNfI3PI1c4wLfqV0raL2kw80glqL1EWKWTLl5SlvSrTEr2WQbi ile3QbgpwY005LxT1s1zqMYkGZT4Aa0fH0g+80UudV4/ZUkTuc/GPgPmeYYnfBqbv/00 sobV/bV3Ar7WulvTUY7P81ZIDYV6GWwNs49Mfw4O77EpKJIhs21ZpPSBOG18dVpzAHQd PM51+4VaDngFSj0woVGauzGURUtIScXe5806S+v/SXxlWZm0CaZfbfSElSocRHYY+DpY e+sA== 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=5dDI8QuLLiahAitilTZUUqiS0BVok6v1BxvdogHOtKE=; b=PPbrQ31YM3wSlDirC9rVjDBPQFCDBhi3aseD7mm62hXEtntx4n1F0O3Xhei0kYcIIC a+r+TgbHmS2dGhqlyJ+MHkODBR7f4uGyHykBX+/WfGuU/s9k1lxCzJ78KoEL1J48FA2B O7pxaYLXlrZqMqxvEqpCV0lMjBNQQaTRftrxmsv16bU2BCTssg9dSqlJRq6oq7xiY5qb +XOj6CeaAROiMjExjvY+6mI522Tlmck6lFufxSg+9nsIDrZ1XTZfpEJ4mTjdgsn11ml9 yONSHww5y2BkriI470QNacbAujZuoUwDjixvIau7bZxo4YP+QO7qqJjzqw/WmqDbegDH 9h8w== X-Gm-Message-State: ACgBeo1sVISVDNHJii0aMEUbZx9G410qzwt9KIsi79og4Lg/oN4j/0Q2 T2fLfmCz45gilLn5b99elSHsvcg5cPY= X-Google-Smtp-Source: AA6agR75UgSpX0o5ff+29FEV3OT5qTqAruxjvffi18RNufPH0QVRVxMt6GtrtfXu0r49QNZAMgHLAw== X-Received: by 2002:a05:6122:4c6:b0:377:ee81:893e with SMTP id s6-20020a05612204c600b00377ee81893emr2555573vkn.13.1659692427679; Fri, 05 Aug 2022 02:40:27 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza Subject: [PATCH for-7.2 v2 16/20] device_tree.c: support string props in fdt_format_node() Date: Fri, 5 Aug 2022 06:39:44 -0300 Message-Id: <20220805093948.82561-17-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::a2d; envelope-from=danielhb413@gmail.com; helo=mail-vk1-xa2d.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: 1659694958019100001 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. We do that by casting the void data to a string array and: - check if the array finishes with a null character - check if all characters are printable If both conditions are met, we'll consider it to be a string data type and print it accordingly. After this change, 'info fdt' is now able to print string properties. Here's an example with the ARM 'virt' machine: (qemu) info fdt /chosen chosen { stdout-path =3D '/pl011@9000000' rng-seed; kaslr-seed; } Signed-off-by: Daniel Henrique Barboza --- softmmu/device_tree.c | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 3fb07b537f..8691c3ccc0 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -663,6 +663,24 @@ 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(const void *data, int size) +{ + const char *str =3D data; + int i; + + if (size <=3D 0 || str[size - 1] !=3D '\0') { + return false; + } + + for (i =3D 0; i < size - 1; i++) { + if (!g_ascii_isprint(str[i])) { + return false; + } + } + + return true; +} + static void fdt_format_node(GString *buf, int node, int depth) { const struct fdt_property *prop =3D NULL; @@ -681,7 +699,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(prop->data, prop_size)) { + g_string_append_printf(buf, "%*s%s =3D '%s'\n", + padding, "", propname, prop->data); + } else { + g_string_append_printf(buf, "%*s%s;\n", padding, "", propname); + } } =20 padding -=3D 4; --=20 2.36.1 From nobody Sat Apr 27 00:09:43 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=1659694413; cv=none; d=zohomail.com; s=zohoarc; b=eiDxyi6MbbX9kGvAar6Y1w+BMGCzqE6B6hTTCirIa+pjrbBYBDpyXYtTaDZegpv4Ivb1JrZsLfa+faJZozqQyc/LQFNqZi5zcattDssFQUE9Cnm1ufZDqZWvf/+4RA+lfIgZWq9TsxRR20T6OuEvtYQ3LUk6ub5MdodFIZX731c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659694413; 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=A3eMa96N5+DdIY5wqc8E6Ll1NSx7o7edEN31miUgkfI=; b=KNUWry/xp2yUcnRUdop3hR4R9eZa3cZIuST+c3Uf3DHWeDcEX7T+Z/D4crZ2HYeFutvsBFcpjGqyDhI/frVi0PKWRGcb5pRwlQ+JRnq+kCQ8ZSCCuBQkgqcRwHFcPj10jbL3g0B1GSTJMDWfyHU1m6uGOxEWrgPtxA3HgkOB5t8= 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 16596944136691015.2566878313556; Fri, 5 Aug 2022 03:13:33 -0700 (PDT) Received: from localhost ([::1]:54576 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJuKi-0002kH-Jy for importer@patchew.org; Fri, 05 Aug 2022 06:13:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50252) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtou-0007e8-KA for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:40 -0400 Received: from mail-ua1-x92e.google.com ([2607:f8b0:4864:20::92e]:47058) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtop-0001iP-7P for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:38 -0400 Received: by mail-ua1-x92e.google.com with SMTP id z14so823856uaq.13 for ; Fri, 05 Aug 2022 02:40:30 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40:29 -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=A3eMa96N5+DdIY5wqc8E6Ll1NSx7o7edEN31miUgkfI=; b=cC9nTq5kESxrGWr+0tTKo5M+scNzLDe0k/hHjIwuP/8MDim1lg+tjsd44zy7XJl4fi DICMgVmsKY403lQHrwtxQhX76cYgghurKIEERcDqj3kN4+mj0eD3St3gazPb/ckD7dgc 96chfKKayHXa1mCt0+WzoqMxTXA3UGMCQVRFHu3/em8Nfe35s6vt9Mo30RBR65Xv+PVC xcOqj2fnWLTFwRi/Jlk3RmylOuGJzkBFBp9CchjkDJMqJ00cazOWKg/+AsHY/0JaQw64 9FiHg1uClAc2WbbbOdR7+M3o7y7CPKDauelLOGzRnlR+d/cBU9d1SFG8GwKr7qbrOHf1 GtYA== 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=A3eMa96N5+DdIY5wqc8E6Ll1NSx7o7edEN31miUgkfI=; b=Sj/1rZbW2Rn/OTilVA5pG6ax42SiL4NpAOobTOLCdEDJRbyaU+SA78DQUZSseAjeOT hul1+HHshYfODz5QDDOlFJ9coPCI11LH2qrQhV7bsQeK/QsgXh3frWyD+ZlMXpPArCVI EuGrnXKf3Cir/QbXHHFbQhJdG5FuWsz/yvNJYJ8cLxQTf2HIf+F0KQLMTKeJxEyfy8Sy Nlku8QQfBafikQ/adK1UBjOs9j56FrNsalaOKRyicQx7RomWck/55LiSAxjxhu1R0RLJ 1awtjkm+VBoBqnOaW0ifAwRTUe6eYoyjqa2RpkigwkHnTbOkvpodXRmfY/0iVEzjo6K4 Gh0w== X-Gm-Message-State: ACgBeo22PcaDBwJAI3xW3paFAux1W4/arHs7w8EJ/m2hVhQtqMaWL0Ba sdQKZiQCrfHQItB1mvxRp2KBtHDNPtk= X-Google-Smtp-Source: AA6agR4It1zOZ2EEHy/jEwWwfxmcCQcAFD/fzPPq7lUZCOMbxnbCuOuLCoV9ptFhttLEjrKWyrQzog== X-Received: by 2002:ab0:3bc6:0:b0:381:c4db:ef5 with SMTP id q6-20020ab03bc6000000b00381c4db0ef5mr2937984uaw.81.1659692429834; Fri, 05 Aug 2022 02:40:29 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza Subject: [PATCH for-7.2 v2 17/20] device_tree.c: support remaining FDT prop types Date: Fri, 5 Aug 2022 06:39:45 -0300 Message-Id: <20220805093948.82561-18-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::92e; envelope-from=danielhb413@gmail.com; helo=mail-ua1-x92e.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: 1659694414419100001 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 [0 0] rng-seed =3D <0x5967a270 0x62b0fb4f 0x8262b46a 0xabf48423 0xcce9615 0xf= 9daae64 0x66564790 0x357d1604> 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 | 58 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 8691c3ccc0..9d95e4120b 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -681,6 +681,53 @@ static bool fdt_prop_is_string(const void *data, int s= ize) return true; } =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, "%x", 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; @@ -699,11 +746,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(prop->data, prop_size)) { g_string_append_printf(buf, "%*s%s =3D '%s'\n", padding, "", propname, prop->data); + } 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.36.1 From nobody Sat Apr 27 00:09:43 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=1659694070; cv=none; d=zohomail.com; s=zohoarc; b=VUMHZ6EyDXgJzSUiL6wjCF/vb2V+D9lGy3P3yD5QBVJ8DlpCsOrypzuNycbrfJlfTnkq+Dhr0cVYc1lJ+rhKcow/Ikq+F0Mqys0Z4F3HqzUuIUgR6Xxk0zQDzpMOlxfJD3nKBw5WA8fkP2+ixwxOBjwcYXscduDbaDcg4hqUi6U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659694070; 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=0EH6/SU6+KuKxZ3ZaeY746PUfa8wkEHLaOit3NDDzxk=; b=Mqabvd/h9Pipje+lzqsobCeZpY8h+5ErE8F4CublsRjrDHFdaRBEu/dStJRTJzAQxE4mBfcFfYaSeijp1fpo4TuIzknhxaI/S1/dU5oC3OVUki8XtfYXJSQ9JNbcjvMTM0vF/TjCKZmeWDkbMyqN5QFM+k7llYwdbhKlf2dSDZI= 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 1659694070044516.2525990161835; Fri, 5 Aug 2022 03:07:50 -0700 (PDT) Received: from localhost ([::1]:45868 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJuFA-0004tB-OX for importer@patchew.org; Fri, 05 Aug 2022 06:07:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50200) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtoq-0007bz-T7 for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:38 -0400 Received: from mail-ua1-x932.google.com ([2607:f8b0:4864:20::932]:34387) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoo-0001iX-B3 for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:36 -0400 Received: by mail-ua1-x932.google.com with SMTP id y22so848468uay.1 for ; Fri, 05 Aug 2022 02:40:32 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40:31 -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=0EH6/SU6+KuKxZ3ZaeY746PUfa8wkEHLaOit3NDDzxk=; b=VbeSKg7FQvmJOjfKi0eCowhLdzDWOD8pfvW3apDlAMQfKhMf+C0hmh/XG+0Y6tBPul 7oT+It6AKD9W7xaZ9URFK0FAVbCx4m8v6n9FeVwm3TNExnLWmpkfHmCJ8FHc+zezKTgw +mKblxfF7bAORTw2rW/dLtCkvU5kOS5HPxz/nS616isT9MvNle6N2Mu+E8O9iAtzI24X QNahaEy1KfPtXXRfzmyA0adnXntX9/legm1GHEnIZmrVgth628946fiq2ozSbm3nbQpx 3r2drWEMB6uAuRBrJlKwcn+vkXR3EZqKnn1NIV4eKpyVlWtEdSNFrDmmC64O8/2b7yjz rUvA== 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=0EH6/SU6+KuKxZ3ZaeY746PUfa8wkEHLaOit3NDDzxk=; b=F7IhqnNuDRbmk+fshfKOaw8N/WFa5XMsPYrVpl1O71pDK313TGKUQ7V9jEP8xmhYQJ Yl8DNjHLkEguU+3iOxT7Nr4egExyyXdifld/5Cd5rLkVBEuDaBWaeeY9FTnZYA78Iwpy RnOQL+ce8weYspQGq16P0dwWwHWH7PcD75txo9iAAe/iwPe7D1d1Tg+pLXtBhCcIF9t/ Y1onqX7ORYZ5m78lEux1mwcH5nEG70u1oFAgVctt6vpNW7TDcPrIu7afdx4ajYCdoxAs gBrA/dVIo3oJ7tiCX82Xxn9uVEcf7HNza0Y6U9q/3pQmKtHOxZjsJceaWf5I5+Bsuk+/ RBhA== X-Gm-Message-State: ACgBeo0Ey4hQjmJsLmyEO3sw/8VHuhviWkFHhCzM0PAkmnEv9cDE7QMm zBrlmAqnwBG6rCOcaP2rJ6nIt0cLfXA= X-Google-Smtp-Source: AA6agR7u0xk/ukDsrpv0byIbW4dP6wSdCYoeSqem485u1OtJFdxmzKAYUUeQvXWZjZOtfc3Rzyyk0Q== X-Received: by 2002:ab0:15ed:0:b0:365:f250:7384 with SMTP id j42-20020ab015ed000000b00365f2507384mr2688894uae.44.1659692431963; Fri, 05 Aug 2022 02:40:31 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza Subject: [PATCH for-7.2 v2 18/20] device_node.c: enable 'info fdt' to print subnodes Date: Fri, 5 Aug 2022 06:39:46 -0300 Message-Id: <20220805093948.82561-19-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::932; envelope-from=danielhb413@gmail.com; helo=mail-ua1-x932.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: 1659694071369100001 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 9d95e4120b..99d95c1cb9 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -728,17 +728,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 @@ -763,6 +772,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, ""); } @@ -783,7 +796,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.36.1 From nobody Sat Apr 27 00:09:43 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=1659694688; cv=none; d=zohomail.com; s=zohoarc; b=XTeLnTaHwWYvjlwRDiu2Gp8YkD8KBDy9yuMtXGD8/hjggisHY1PLQZwadLpQjddBIB9LytbV+PyzQBIKn1dr5kO0DOgVAT5oW/nEkgNZdp2LiO2oYEkM2xY+cKCu8bgXAn+UG6E2b+ewNnJc6kbB1QB2bHX3oQFBH9j5M35WcOM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659694688; 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=mXJwJLmcRqnXtZhHoo+MfEnHjgdMdXK2oknrWiQwJuA=; b=NopB+sdDzT3X+Y+vp3OObsWGdjm3OomfIgAhZ2JOQsn/pgA2efYsUcphFZbObUNVZJPc0qhEJ2YSajlU0ymVRF2ZjGLuGnuSCKHL6JQp9/eZAYAQjb1WhB1J5XwsulgbBEBCoQfUaf15wYdo2JkT1XT5PlFYKfHVJSoUrqSXXtw= 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 1659694688309494.8670376099684; Fri, 5 Aug 2022 03:18:08 -0700 (PDT) Received: from localhost ([::1]:35072 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJuP9-0000L4-8C for importer@patchew.org; Fri, 05 Aug 2022 06:18:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50294) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtou-0007fM-OW for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:40 -0400 Received: from mail-vs1-xe2f.google.com ([2607:f8b0:4864:20::e2f]:36546) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtoq-0001fk-Jd for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:39 -0400 Received: by mail-vs1-xe2f.google.com with SMTP id o123so1945708vsc.3 for ; Fri, 05 Aug 2022 02:40:34 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40:33 -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=mXJwJLmcRqnXtZhHoo+MfEnHjgdMdXK2oknrWiQwJuA=; b=P8K75jELNF1Y+m0gSowPvLQNO4NICdiEuAVD9pdWcZSwwa1Te+tAa5+jGS6cRZCvId OOtVqXxmndeJ4sUtCa1WxRZ+5gdtQas96gCymL2g03x4JwlV5DYexX7QZVn3KTNDisi7 Avs5/kT5AArmEo0dDc6xixIVomXjcaCLHSX0PShT3ILMoW+pZRuFuKkQ2p87rm6FZaZt 81Zasf1XKdsTNLGyOdlc0aAKvjmwBrjJMD7w43xONInK2HshctWwqHyBDeSXMqPCDT8+ BTWZrnhfw/lWFxnXAAWo1tLzU59vCkRKu0qesOBpUUc9JigXrggXKfJ6sjfINPH4bp2V aLDw== 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=mXJwJLmcRqnXtZhHoo+MfEnHjgdMdXK2oknrWiQwJuA=; b=GTOSRlfT/6NAbNqYBl1pkGp3+8ThSzRJuX87rkw+MjHUq3ZGvaxYwCxOenQe+Ph6AA nr9bq5rNPzXOXsmPlzOPGhxPSqzm7N1ZAEBT6j0PSEseMNu4/l4Eg5H+UVRxLWl23ecp lwzJGOYrVyWIS1yl/7TmOhrOOb02wTz98yE95iFYfolfylAhcGVBFuVZlKMCW8veli/j b1h9uNQXByDr5ZbF+g9TM5WkodTwYYig1iTY08Pfp7ZmD8wEm1t7B7qRvUpRJQZ0XOl1 qNQsgkmcM8eY1eW1En9ewYjz09/QHbRMkOWFO5eCxW6va6XSbXOA2YCvfdkecsPETZXv B+hg== X-Gm-Message-State: ACgBeo1VgDW8NBAGzSSWHePl4nF+19wK82AHRdeNCT50qGysmK3bpot2 +Rj9/4JhJqMC+bRbPnPFysGooZLC+Cs= X-Google-Smtp-Source: AA6agR5iMTnWRedW/b2lCN9NGrwZvvmh6dL+q4fVm4TuHGjpy3H91W5OMGfK3T5gPlbAeAQNO4l0QA== X-Received: by 2002:a67:fa0f:0:b0:387:de44:b29 with SMTP id i15-20020a67fa0f000000b00387de440b29mr2612056vsq.5.1659692433788; Fri, 05 Aug 2022 02:40:33 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza Subject: [PATCH for-7.2 v2 19/20] device_tree.c: add fdt_format_property() helper Date: Fri, 5 Aug 2022 06:39:47 -0300 Message-Id: <20220805093948.82561-20-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::e2f; envelope-from=danielhb413@gmail.com; helo=mail-vs1-xe2f.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: 1659694690181100001 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 99d95c1cb9..902a7f680b 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -728,6 +728,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(data, prop_size)) { + g_string_append_printf(buf, "%*s%s =3D '%s'\n", padding, "", + propname, (char *)data); + } 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) @@ -755,21 +774,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(prop->data, prop_size)) { - g_string_append_printf(buf, "%*s%s =3D '%s'\n", - padding, "", propname, prop->data); - } 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.36.1 From nobody Sat Apr 27 00:09:43 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=1659693500; cv=none; d=zohomail.com; s=zohoarc; b=DyXV874GvDd87xzcbKlY9oepFEHD+JdQ/0mAircnuAwV6gtiL3+PdmdWkYwEsxDjdV8Kr2pgG2EVW4Z7HYQXLiOcLhTB7RAYI4KyLc9O91S+IKVtiUDfb/PqQwpjXUcsDANbufVdrJ5M9SmXWbjMqIJ/mOWv0AXDnNS2GE1rNrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1659693500; 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=DkCA2spgI+uwLgOuel9849x5d610iHs6nmKGou/9TJE=; b=bKoscVrr1vdZNPphs2ElCD0BJGzVNgX6CdRgDbn15vkiuOCApXcthOIifD/G23EaxDlr9wuo2opuiDLYLH8KLx79vlhRpcTrJELVy2RvSVN3MFHqTJm6vjkH2spFlnqMCNP1Dt4kQuwDgAp1sRf3T/u3Rv8UGe5M6kvulTwSMmY= 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 1659693500066912.732781862559; Fri, 5 Aug 2022 02:58:20 -0700 (PDT) Received: from localhost ([::1]:59354 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oJu5y-0002MY-SV for importer@patchew.org; Fri, 05 Aug 2022 05:58:18 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50302) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oJtov-0007gh-6v for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:41 -0400 Received: from mail-ua1-x929.google.com ([2607:f8b0:4864:20::929]:45847) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oJtor-0001eJ-N8 for qemu-devel@nongnu.org; Fri, 05 Aug 2022 05:40:40 -0400 Received: by mail-ua1-x929.google.com with SMTP id f15so823913uao.12 for ; Fri, 05 Aug 2022 02:40:36 -0700 (PDT) Received: from balboa.COMFAST ([191.19.239.67]) by smtp.gmail.com with ESMTPSA id f9-20020a1f1f09000000b00376f4f93745sm2668496vkf.10.2022.08.05.02.40.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 05 Aug 2022 02:40: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=DkCA2spgI+uwLgOuel9849x5d610iHs6nmKGou/9TJE=; b=GZqYXDcFFrVTiqtZDus2hjOA5JLZL8JzQWiP0ZLMFXIKPR2Y7d/r3FjCitQv8oCuf8 PPwbMdH9HQUTOjQIZtelaOBwnWIQWRrq/vNIw0Uosm579D9Woh2cdAdFHrMTd1ZJu+Cm 0dAEH/5QtcfIsQJ2hRbqeuhjBHlI4IORHVf/VL7qPwU8oadmFdLIxLurAKZmXnDS81E+ VpE87N2vEZ4VjR+sKVhztykDIE/DwiUWk99ny8MnRGCXO2gsvxZBEgzqZ95QcvyJUvk1 HP933+FuQUx0QPeY6qACdqUtk9TMltUGdwzJKc5PM7yM2m943qW9CG6QArYvlMWID6Vp xQ/w== 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=DkCA2spgI+uwLgOuel9849x5d610iHs6nmKGou/9TJE=; b=Ny5IrJgL1fYJw0C6WpSnqYKNSG8qr4GO47VFzxycVzUuSk3KMSrkb9+15PKXec6LFf X2Z2vbxjN9mdHuIncRruFXnIf2diJgho8kO5QG2HMgULgbaMxnzOzJjySB7Cgfw5ZvnA eBlVkcdNXEoATZPGUpfRI+kZ0RxTS21axHOJt6o6BKbJoR56a5EdDy48aUWILnk90X5k A+UIUwrA07fubK1pYRc9IpFTel98v6XCAA9yMP2J7AOTFDMveY1SnChNPQwl1u5xtM1C HGFS8wuo5Yk6sCBQnyaKSq+tqL+MPejZJUix3qqBI5xcnTiWj0rK8bkja9lt9sTe46TR UJkw== X-Gm-Message-State: ACgBeo30yyBpFlRHTFoZoYUMW8EoFP6zj82m5EZans15SYUDXqPZAiyZ 1z1Zj/Al5Ks2SK9lanWmM8y6FsxI8js= X-Google-Smtp-Source: AA6agR4X5GJSrAOCucH/TTAo2OF6X83TcDF3xsYfD3Sqv6hkiSZA7aa++RBrTsWvsJD0TrgRTltvBQ== X-Received: by 2002:ab0:3303:0:b0:384:dd5b:ef55 with SMTP id r3-20020ab03303000000b00384dd5bef55mr2787442uao.27.1659692435844; Fri, 05 Aug 2022 02:40:35 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: alistair.francis@wdc.com, david@gibson.dropbear.id.au, Daniel Henrique Barboza , "Dr . David Alan Gilbert" Subject: [PATCH for-7.2 v2 20/20] hmp, device_tree.c: add 'info fdt ' support Date: Fri, 5 Aug 2022 06:39:48 -0300 Message-Id: <20220805093948.82561-21-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220805093948.82561-1-danielhb413@gmail.com> References: <20220805093948.82561-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::929; envelope-from=danielhb413@gmail.com; helo=mail-ua1-x929.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: 1659693501629100001 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 Signed-off-by: Daniel Henrique Barboza Acked-by: Dr. David Alan Gilbert --- 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 accde90380..df8493adc5 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 902a7f680b..be7b7e297e 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -785,23 +785,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.36.1