From nobody Thu May 16 09:28:55 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=1658520222; cv=none; d=zohomail.com; s=zohoarc; b=YQWqWSUNTABjbbAOKTW2XRoAKhkZL9ynQCwQJHovGYRIF8NhP55mb69VsQGXRJVQZMhYBWFnM8moqBTLLAZFBf5WSotkP0fzFa4k99g/n+1JQWyGO6+94AU9Q2p1acQJ+2lIO0njvtM1O+CYfDCY46yflDg0OCjsKZ3AW8+1Emc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658520222; 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=9JxcmPY5cRnsfdU9CxHMKESf5qPzNpvz9n+hCJIAKF8=; b=dRq2Bu2TARcMZXqcJL/z3ieEsCN5kpW0G/0zfMolm9HhEuvgLK1/UxKfpSUESqhZofXrWuf10O2vVJHKAX9euAdqB9c1LMk7+yVDx/t2mBZh1/xhL7wW52vyd2RDF9DfKoZFCkSpqX7U7NTsNwY8M5LvWeRcDhAOhHmqe/ChbdQ= 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 1658520222129860.2415278213174; Fri, 22 Jul 2022 13:03:42 -0700 (PDT) Received: from localhost ([::1]:46076 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEys7-0005fZ-JL for importer@patchew.org; Fri, 22 Jul 2022 16:03:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51420) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEyov-0002sE-DV; Fri, 22 Jul 2022 16:00:21 -0400 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:45996) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEyor-0005C9-OB; Fri, 22 Jul 2022 16:00:20 -0400 Received: by mail-ot1-x331.google.com with SMTP id r22-20020a056830419600b0061c6edc5dcfso4092028otu.12; Fri, 22 Jul 2022 13:00:15 -0700 (PDT) Received: from balboa.COMFAST ([152.254.206.198]) by smtp.gmail.com with ESMTPSA id n14-20020a9d740e000000b0061cae62aafcsm2388218otk.20.2022.07.22.13.00.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=9JxcmPY5cRnsfdU9CxHMKESf5qPzNpvz9n+hCJIAKF8=; b=hlFpPKGLj+MpDBYY6Vo8KeLXGsG10xnociaYKgpxAeZp+lxEu4lQleNhHDCeRj1WVn /b7GlWV5ycqiJ9wHHG1JeoaW3oUC1Xp6gHvLcA1UFlDKKEZbOeAeBQojYcwspXdqdmT6 Ap3etde7fuQHGaxqYXS2iu7Lqen7zx/fNJx+vAvItSJOU3fDHHPNoeiyoOQSg42LyQCv WamVgZI9Av6QLcl5EgiSEHBc1OQHmeI+FqdWh9gsQZTWbZXOUHbAwNpTUiRxZL+Q2now pq7JSqslhKcDxRSS+Rrwrnm29wh90XX2QDaX35GSfNB9kPrRGC78+ORwZaFAvxg3F+be 96rA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9JxcmPY5cRnsfdU9CxHMKESf5qPzNpvz9n+hCJIAKF8=; b=3XHmpcLz8KWqNNlFEk0B/86EKI0qJGWfPfX3TYi3uAFi0ogM4DYBpEDDuLxzC7QAcF QQmYmQBzlYff9O3l4iWEQHzAaaFjjFAhU2MCZWC6BtHpxEpRi/k0kJY3QBKBc1bQg3UC ZfvwZ18wfCmNoBvK5DeRnT1AxWDuqssAmSGtCTCltKPd548NH7tL1p5Es7JqBcZbnd9P uaEh4IG9LajYpv6y4xgGwAuv+1Ljg4QyOVrPVHIyYadCD88yo6pfkEQ6Hwvxo/60QrPj sM/4r1eopfAnwv1/Ujb7uDt5x3XLhfrylEMxpvrQASNeROPpDneD1xnj+eMfcDXvWPhL y5Eg== X-Gm-Message-State: AJIora9ibHfISAvMhbcGKBhDfhc6fh1hJ1uhZrusoDArVHJR+uw2YlFo hdiOMNQ4AEidFuCJxMCFvh/MS0iqoGY= X-Google-Smtp-Source: AGRyM1vviHyHF0k+Y92kY/EXlekhqmbp7lodeTnHmsRttGeyjgFFMvcxIU4aarCjfKcfRqkgsw/xgw== X-Received: by 2002:a05:6830:4188:b0:60b:83f8:e8d0 with SMTP id r8-20020a056830418800b0060b83f8e8d0mr615946otu.32.1658520014778; Fri, 22 Jul 2022 13:00:14 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: Alistair Francis , David Gibson , Daniel Henrique Barboza , Peter Maydell , qemu-arm@nongnu.org Subject: [PATCH for-7.2 01/10] hw/arm/boot.c: do not free machine->fdt in arm_load_dtb() Date: Fri, 22 Jul 2022 16:59:58 -0300 Message-Id: <20220722200007.1602174-2-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722200007.1602174-1-danielhb413@gmail.com> References: <20220722200007.1602174-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::331; envelope-from=danielhb413@gmail.com; helo=mail-ot1-x331.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: 1658520224216100001 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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index ada2717f76..1d9c6047b1 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -684,7 +684,8 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_inf= o *binfo, */ rom_add_blob_fixed_as("dtb", fdt, size, addr, as); =20 - g_free(fdt); + /* Update ms->fdt pointer */ + ms->fdt =3D fdt; =20 return size; =20 --=20 2.36.1 From nobody Thu May 16 09:28:55 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=1658520400; cv=none; d=zohomail.com; s=zohoarc; b=Lpl0vwbLmjx7kxvFAHSD805X7EvmsUyZQolS6eIJrn0xy0v1ZVv5JVFcQB91f0FCQMIYti7w7qsAR1cKylVJCaGoHYV641N6wC3JmU6RQMIu+N5cldcFvKToFXsqUhHgsU8F5h+YrOpRIqxiMY+VJao40F+MaURcAWRZ6E41V+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658520400; 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=ix0V0IY8A5Ri9rM6kmEs+/lX0f+nUh1CsW4T8Bh8oSg=; b=BGNmQbv6gJAKfY0boirv09Xhbr+FEA/MbMtlEk4+mLFs8hOFUhlLfht+FvY5t3uhAiuLKEIC9hTXcvCBX+4vinmkFQ/FAex6NAlqWMQX0cNySlXFDQYkuZO+ejxmxedq91UsiV34cKvZUMheN1OOOL8rNUKlSoZ1dUp66E39OHI= 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 1658520400303279.07259071372766; Fri, 22 Jul 2022 13:06:40 -0700 (PDT) Received: from localhost ([::1]:54410 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEyv1-0002tG-8y for importer@patchew.org; Fri, 22 Jul 2022 16:06:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51418) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEyov-0002sD-D0; Fri, 22 Jul 2022 16:00:21 -0400 Received: from mail-ot1-x331.google.com ([2607:f8b0:4864:20::331]:33622) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEyos-0005CN-9b; Fri, 22 Jul 2022 16:00:20 -0400 Received: by mail-ot1-x331.google.com with SMTP id y10-20020a9d634a000000b006167f7ce0c5so4129079otk.0; Fri, 22 Jul 2022 13:00:17 -0700 (PDT) Received: from balboa.COMFAST ([152.254.206.198]) by smtp.gmail.com with ESMTPSA id n14-20020a9d740e000000b0061cae62aafcsm2388218otk.20.2022.07.22.13.00.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ix0V0IY8A5Ri9rM6kmEs+/lX0f+nUh1CsW4T8Bh8oSg=; b=HrAoja/x6XtOQtqYXUvC6Qr/Fibby1uPdEpUHqCEibqwb26QnWWdANUsgo1pHd/Tpz G1nkKX6Roe6BlY1mRa622mN4ny3Apr90Cn2nYYLFSq/4gKHoGG64E4sTg6DA/3XdLwKx NRdpdC9WkvdTS85dbJ8yJyZCmWBOtyYY6FtMnhAD1m91TTXFVf4/00s6jnpc+MpNCcO7 r43nUOFAMLijnbb1vjrXSSj5GglIvmo4rMp9BAxhHNHZ0dgv4aPvEfidpj4OLhOaVMGX ljTCdLJRAFCPuj4gfU42IEnUzt9JvfxztXV+hVhp6SKLExCqfz3v8xS7PFfDHPLsQo+w WjuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ix0V0IY8A5Ri9rM6kmEs+/lX0f+nUh1CsW4T8Bh8oSg=; b=MQdT6nKuH4Ig1mmBhDOYCj6GcLVjdPVMgU6zCd0J7fk+T4dmgv4UxuF8DBzF8G5Req aCO9DLRV3cSN9Se/a9nsOIHtRDP5IqbCeajXqRsJTw2jLTsV1Cy7QYquJpCPZ7ZaAmMj UGA1d4ibKG97QgaPZfCjCK328PfAs6AWwbLV4GNapeKYEp+CmFIH/VtH1G4wThFiSZV8 A2gnrHUMlWgG+wMDTU8WcCAHs/mwesetL/aliBpkkDUH3ZTK5yrecC6i5g1hbWN7BgqO RrjFPTiO3pbYpakxLNW6kQj8FzEujuW2Py0Y7ZnctmyC6mwelIouykvprEcNkS/dQPnu pN/w== X-Gm-Message-State: AJIora/iQPzacaht0Igei2GQpYMtNURG82Vc5N81HZzn8gdz3iPHwupJ 8pERzkROz8qSrrrUkZykwp09oQmVJJ8= X-Google-Smtp-Source: AGRyM1skiz4jsQfHCuBJS/SEh2zktbueTIinurDQIjutZY3RslonQe9irbHYhmh9eeHGw2F7/JYiSA== X-Received: by 2002:a05:6830:43a0:b0:61c:c25b:eb88 with SMTP id s32-20020a05683043a000b0061cc25beb88mr641398otv.111.1658520016882; Fri, 22 Jul 2022 13:00:16 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: Alistair Francis , David Gibson , Daniel Henrique Barboza , BALATON Zoltan , qemu-ppc@nongnu.org Subject: [PATCH for-7.2 02/10] hw/ppc/pegasos2.c: set machine->fdt in machine_reset() Date: Fri, 22 Jul 2022 16:59:59 -0300 Message-Id: <20220722200007.1602174-3-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722200007.1602174-1-danielhb413@gmail.com> References: <20220722200007.1602174-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::331; envelope-from=danielhb413@gmail.com; helo=mail-ot1-x331.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: 1658520402299100001 Content-Type: text/plain; charset="utf-8" We'll introduce HMP commands that requires machine->fdt to be set properly. Cc: BALATON Zoltan Cc: qemu-ppc@nongnu.org Signed-off-by: Daniel Henrique Barboza Acked-by: BALATON Zoltan --- hw/ppc/pegasos2.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index 61f4263953..9827c3b4c2 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -329,6 +329,9 @@ static void pegasos2_machine_reset(MachineState *machin= e) g_free(pm->fdt_blob); pm->fdt_blob =3D fdt; =20 + /* Set common MachineState->fdt */ + machine->fdt =3D fdt; + vof_build_dt(fdt, pm->vof); vof_client_open_store(fdt, pm->vof, "/chosen", "stdout", "/failsafe"); pm->cpu->vhyp =3D PPC_VIRTUAL_HYPERVISOR(machine); --=20 2.36.1 From nobody Thu May 16 09:28:55 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=1658520235; cv=none; d=zohomail.com; s=zohoarc; b=LCwEWGRVRU9lZ46KZz+sTnofItlAzdFkHfI5JeOVn4nBu1+LEsjFQgG7q3s0/8me6yfQHjvCUBcgdAN805+ID7I7WEarCYlUZ60CUAwjZQkuEnrfVdvajM424vwTFOLGEN1Zned3ws2PB2Ye90XRYPuzqxsTX+nE6a9+kER3+zE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658520235; 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=pES3OUwSggunbQU+tmgNIZG7n8J8b5Ja341if3roq2Y=; b=nGKLQrS9bPQaJz2QNnylb25BDN156CFBWG7JgHOqVfiGhdBHV7EVIfWnVP6Azb3Ehy7C6IGFWa8i5ozIMtxWvih8PF+ayEwtZkh43HWDNkWK73nOCBRJPGaZv0yQUKQJ6YmFNUo3kJo8qSip4ppcAmkSEeH8dpySYQBq6lee3Gw= 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 1658520235645613.6127452657254; Fri, 22 Jul 2022 13:03:55 -0700 (PDT) Received: from localhost ([::1]:47234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEysL-0006Qr-Lz for importer@patchew.org; Fri, 22 Jul 2022 16:03:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51434) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEyow-0002sp-LS; Fri, 22 Jul 2022 16:00:22 -0400 Received: from mail-oo1-xc32.google.com ([2607:f8b0:4864:20::c32]:45734) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEyov-0005Ch-1P; Fri, 22 Jul 2022 16:00:22 -0400 Received: by mail-oo1-xc32.google.com with SMTP id v5-20020a4aa505000000b00435b0bb4227so1019258ook.12; Fri, 22 Jul 2022 13:00:20 -0700 (PDT) Received: from balboa.COMFAST ([152.254.206.198]) by smtp.gmail.com with ESMTPSA id n14-20020a9d740e000000b0061cae62aafcsm2388218otk.20.2022.07.22.13.00.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pES3OUwSggunbQU+tmgNIZG7n8J8b5Ja341if3roq2Y=; b=RhoQAtl8B3raRMcLKceRL8muFdTnFFb6yRxb5OdK/a56edKowub/AWYB53NHb9pnCN CEiGrR24BzNPDW5mKWnyW8uRb6Nay+n3aDN4yirYwQpLw9I6n2clDgX2705OeJ2R1Q0n dYl/I8t3VKYmkWlHfHYNWeE8dlBEF72qLhvWAUTrm2q///nV/P3bkKIuqYspyBFcDUD7 185xRcftw3hw+oGdaVv5/HNAzPSpxLFMKrSy9j9VF7KCycor+yPtwwBK08xbe9WoVyNU p/jV4Agld/8WaQ44GjvVR9Ll3+oteOWluEUkyt97e+enorADQU6dlzb34hG39hGNrv8A dNLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pES3OUwSggunbQU+tmgNIZG7n8J8b5Ja341if3roq2Y=; b=xQ+XsCpm47L50qT5dieTp9iMI3Vfn67Wi0jTnRuVPQRud2YpIyK8PvDEEt6r3CkxnC MwPFc0vltR0fY4bqnVG1R+0xCOSK7oRsgRG+39fNS01Mg0OMbDSOnkzB9PRZa9Ja7Iko ieJ3A88GlPTn+Nc772emY7gmvRCTPwgOV+28lejT770Fhuv4e24DTqbTCy9fUfxScIL+ MQBvIDUUfHPYX1Zfp2gZi8cefUqHnrZfywiKYXbNYcqbXBMeflft+Hxomo5/PGhpHOjY ZUsNtrupdt/EfBosxDWt1UJlfG3475bwRObS1gYnBufKCMIIl5+US+XNQqhlz3Z1UFvw c9Fg== X-Gm-Message-State: AJIora+rdI49l2GDUeUQuf7woqF3AVVsP7vVhgGQ/gkij/KdrYHBnO2o URIq2fHcN92aV/OvyP/NbZa5TkmB22I= X-Google-Smtp-Source: AGRyM1tWdDErTuYYhL/DJl2SsBM4dPhc9i4dR5sgpOzjka3/ZBy1T+Ywyl7VHDTRS9jqqaOpxo23mg== X-Received: by 2002:a4a:ac89:0:b0:42c:7331:a110 with SMTP id b9-20020a4aac89000000b0042c7331a110mr589289oon.40.1658520019018; Fri, 22 Jul 2022 13:00:19 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: Alistair Francis , David Gibson , Daniel Henrique Barboza , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , qemu-ppc@nongnu.org Subject: [PATCH for-7.2 03/10] hw/ppc: set machine->fdt in spapr machine Date: Fri, 22 Jul 2022 17:00:00 -0300 Message-Id: <20220722200007.1602174-4-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722200007.1602174-1-danielhb413@gmail.com> References: <20220722200007.1602174-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::c32; envelope-from=danielhb413@gmail.com; helo=mail-oo1-xc32.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: 1658520237337100001 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 | 3 +++ hw/ppc/spapr_hcall.c | 3 +++ 2 files changed, 6 insertions(+) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index bc9ba6e6dc..7279583a4d 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1713,6 +1713,9 @@ static void spapr_machine_reset(MachineState *machine) spapr->fdt_initial_size =3D spapr->fdt_size; spapr->fdt_blob =3D fdt; =20 + /* Set common MachineState->fdt */ + 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..e6b960577d 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -1256,6 +1256,9 @@ target_ulong do_client_architecture_support(PowerPCCP= U *cpu, spapr->fdt_initial_size =3D spapr->fdt_size; spapr->fdt_blob =3D fdt; =20 + /* Set common MachineState->fdt */ + MACHINE(spapr)->fdt =3D fdt; + return H_SUCCESS; } =20 --=20 2.36.1 From nobody Thu May 16 09:28:55 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=1658520447; cv=none; d=zohomail.com; s=zohoarc; b=CSqaUATQM07n61Vz/m54kiIViVuAqrHp9u5U7xfuG4jP8NNiGUKsR/jZ9gPaLLHhaZAYiE7nAtyEV36LV3o1ALsm3gORjC7EpM/r1/eh1xbZqQMxVbp6ESGlsegVwImOKdPalcIEAtUMQ/SCRqMZsX5PbAYM+Md5Ug2guCKebCk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658520447; 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=4UvK2EXKYd/bzx1pqiGuSOb3EJViIu85WwNJvp0REWk=; b=NSf93KjpsAycDZaEpbcb3Oq1GtKKHIKadbSuVYWjfS7X3BPQW2c3EH4OPhEZu9jT7ytD+VfVN/96HnsgGCMvSZq7DEamJdPWUO+yc8wIS2rAiS4ZopZSUWdMq71oRk9W9yGrbNeXvch1TlAX7+YW9UbbpMPT7JrjwRZ8Px8u57s= 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 1658520447642644.4505334952944; Fri, 22 Jul 2022 13:07:27 -0700 (PDT) Received: from localhost ([::1]:55960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEyvl-0003tb-2O for importer@patchew.org; Fri, 22 Jul 2022 16:07:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51444) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEyox-0002tS-U0 for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:23 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]:42571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEyow-0005D4-9B for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:23 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-f2a4c51c45so7547434fac.9 for ; Fri, 22 Jul 2022 13:00:21 -0700 (PDT) Received: from balboa.COMFAST ([152.254.206.198]) by smtp.gmail.com with ESMTPSA id n14-20020a9d740e000000b0061cae62aafcsm2388218otk.20.2022.07.22.13.00.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4UvK2EXKYd/bzx1pqiGuSOb3EJViIu85WwNJvp0REWk=; b=cQdEDDMsz2zg8RSUSXWvSIx32k4ChjPblmDl+w0UthjSMKp7j40VohhyHeibgfmYUl HArzG5KJ1OH++ss6ef53qvHCgycgYnH71MjdGc+1u7i/mZXsw/zX+mbb3DxKcLFfRaj9 eeK1KqqQJHQ3jkRPE4VkBknN8WL65g5b6V5ztHZgfyRzo2BBgFrTuW2qIgSAHtbcC/GP GTLDn6fSO03MCsUr6Erda8PxZf7tiAh9N12/GgtIO9XgXInCeLwiLOBZwx5BPMVVvpCU m7Ajca8YX1clXwMnDrno4WgLYKc9vb5jNuhEgnXDCCPzeeDcIWUq9ksNGCE67G6YhhSa yVEA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4UvK2EXKYd/bzx1pqiGuSOb3EJViIu85WwNJvp0REWk=; b=mer/TUaM0M9YYcboWKJBKddY1nVv6FuhG55sbKLLemCFcIuMIrXQZSdI+n0751PFXr yeOkz+Hg0P1BGzWHV8xWub+Ql+dtrqpZuv1sQjeIHdFVQo0om5NZeTxJZi9AGZMjRoZa l0nmrtm3+z1/Oulz4k+Mc5BavB9Srs3YAwTMV8htFGuCCpB1kq53DGR2rkWleRrQqLYb o/TVHu2EGo4mSM//SLEZ42XzCfrZ874VyNrJvIDc7J1En9Jrhn1KOPKnTV/cN2IVR1DG viPpBtJrJViqsnpS7WvpGQo2cJOkYP9qJcsLaXpbS/w/LNkgcgrUeVvZiNLgJnPFvypz O3Bw== X-Gm-Message-State: AJIora+5ZQAArheEpMWsGAaksTrzML/oRxN3FJkFCN4yetRJaDJjuRnn Nfpqr2Sf/S05kWkNdSujVUZAyTdzGnE= X-Google-Smtp-Source: AGRyM1u1oY6aDIG1D6KC7RQrzmkqijRyPXBREvFrbk5fAYNmKHVsXz3zrRPI6TUbWxSKOxMxQGqdfA== X-Received: by 2002:a05:6870:8183:b0:10c:d04a:53e8 with SMTP id k3-20020a056870818300b0010cd04a53e8mr8404277oae.14.1658520020962; Fri, 22 Jul 2022 13:00:20 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: Alistair Francis , David Gibson , Daniel Henrique Barboza , "Dr . David Alan Gilbert" Subject: [PATCH for-7.2 04/10] hmp, device_tree.c: introduce fdt-save Date: Fri, 22 Jul 2022 17:00:01 -0300 Message-Id: <20220722200007.1602174-5-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722200007.1602174-1-danielhb413@gmail.com> References: <20220722200007.1602174-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::29; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x29.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1658520448406100001 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 'fdt-save' 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 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 --- hmp-commands.hx | 13 +++++++++++++ include/sysemu/device_tree.h | 2 ++ monitor/misc.c | 13 +++++++++++++ softmmu/device_tree.c | 18 ++++++++++++++++++ 4 files changed, 46 insertions(+) diff --git a/hmp-commands.hx b/hmp-commands.hx index c9d465735a..3c134cf652 100644 --- a/hmp-commands.hx +++ b/hmp-commands.hx @@ -1768,3 +1768,16 @@ ERST "\n\t\t\t -b to specify dirty bitmap as method of ca= lculation)", .cmd =3D hmp_calc_dirty_rate, }, + + { + .name =3D "fdt-save", + .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_fdt_save, + }, + +SRST +``fdt-save`` *filename* + Save the FDT in the 'filename' file to be decoded using dtc +ERST diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h index ef060a9759..1397adb21c 100644 --- a/include/sysemu/device_tree.h +++ b/include/sysemu/device_tree.h @@ -123,6 +123,8 @@ int qemu_fdt_nop_node(void *fdt, const char *node_path); int qemu_fdt_add_subnode(void *fdt, const char *name); int qemu_fdt_add_path(void *fdt, const char *path); =20 +void fdt_save(const char *filename, Error **errp); + #define qemu_fdt_setprop_cells(fdt, node_path, property, ...) = \ do { = \ uint32_t qdt_tmp[] =3D { __VA_ARGS__ }; = \ diff --git a/monitor/misc.c b/monitor/misc.c index 3d2312ba8d..145285cec0 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -78,6 +78,7 @@ #include "qapi/qmp-event.h" #include "sysemu/cpus.h" #include "qemu/cutils.h" +#include "sysemu/device_tree.h" =20 #if defined(TARGET_S390X) #include "hw/s390x/storage-keys.h" @@ -936,6 +937,18 @@ static void hmp_boot_set(Monitor *mon, const QDict *qd= ict) } } =20 +static void hmp_fdt_save(Monitor *mon, const QDict *qdict) +{ + const char *path =3D qdict_get_str(qdict, "filename"); + Error *local_err =3D NULL; + + fdt_save(path, &local_err); + + if (local_err) { + error_report_err(local_err); + } +} + static void hmp_info_mtree(Monitor *mon, const QDict *qdict) { bool flatview =3D qdict_get_try_bool(qdict, "flatview", false); diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 6ca3fad285..eeab6a5ef0 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -643,3 +643,21 @@ out: g_free(propcells); return ret; } + +void fdt_save(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 Thu May 16 09:28:55 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=1658520230; cv=none; d=zohomail.com; s=zohoarc; b=QdzYTbbz+YGRCdcC3BwbAdpLGuLLF7oPhfizGXgTJJloc0XiTCZumH8ecJ9SL1FusSJmdpm+k4kqA65OCQgYdwJA9h1cL306yf2SgcAVZrekJQ1Bb4p40P7KO7c0r9Q1FzrpBlskMY1a1g9hNHstqeeaAopmSffjN9TsgzUWPrU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658520230; 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=vvTscm4jE/pQADjzilhvEGolDLXNnxRwXsi8fxpaEv0=; b=NSBWo4j8AIunlyxdTRhjgJMgKYxzz4VSkAWjJfF0ANyt1KEHNHZi2tD+qCmC4v6bNXNl9IS3gnjJKI1tW0S1cuYddJRW/uuw0zv5fJbgLKDTw0xDKzPDplfFzoxcrSTlIdyBgtYd80JE6yVJ4lHIQx0cqBH/ck21AOy6Qv2UXu0= 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 1658520230756400.49986455491364; Fri, 22 Jul 2022 13:03:50 -0700 (PDT) Received: from localhost ([::1]:46944 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEysH-0006FT-MN for importer@patchew.org; Fri, 22 Jul 2022 16:03:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51466) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEyoz-0002yy-Tw for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:25 -0400 Received: from mail-oa1-x34.google.com ([2001:4860:4864:20::34]:41845) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEyoy-0005Dn-3B for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:25 -0400 Received: by mail-oa1-x34.google.com with SMTP id 586e51a60fabf-10d8880d055so7549225fac.8 for ; Fri, 22 Jul 2022 13:00:23 -0700 (PDT) Received: from balboa.COMFAST ([152.254.206.198]) by smtp.gmail.com with ESMTPSA id n14-20020a9d740e000000b0061cae62aafcsm2388218otk.20.2022.07.22.13.00.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vvTscm4jE/pQADjzilhvEGolDLXNnxRwXsi8fxpaEv0=; b=ZLECyn1x95EjHziMxhbk8B9DEvhBAe16RHNpYGVTVFqUHX29o/uSYdDX90fk5CbPzo c3dIFc0nc2ORS5e8VDiudOXAw3xDGRUseh0wVJCWcDEVkinEXb+eyd87hi1yD7Ityj+i wS42Ks7bDTrfQG7oJGiDs/P1gYQzSCIK2uTUbWDWWpfPKLXbJficW5+zLMRdMXFAMfaF zIiiWv4MWEwnU3nzjQCOdojWTVj2pebvKDMvwtu+rlv76odrjhP30/lfcKXijlPvxKnW Evcytv09ZUYwJlE5JGO15P+YJprULSv68vPL3Y0YJgzJHMgx6JN7nFf/HEJIx9LcsyIY j11w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vvTscm4jE/pQADjzilhvEGolDLXNnxRwXsi8fxpaEv0=; b=Hu5TtzfCqY9Jd4Lz1gXxx9ssZ7XISgPqYYgslQNtG+b5G42C4d2sLoSEDoEhoOI249 OiRNT7ecgQ+e2ALq2QaKdO8WMULOn/W/lcJxan6y3MmVaFznZN/aByB18mNcOUXOaZy9 OlAUOJfm7zZjGOqOQYHYWIKhMgXOhlhggob8ZRyzpDNj1+da2D0utWf0Z0B/yXOCK1mq pzR7xVMdvAyNpLeMNE3YmczPd8W8bWSc09NQx759UY2ZNGLvl2hBvNHL82hH3uxzU1ve nRQxyZpZyATJyMbJErQL0Xa77WBe1LWdaGOHMJLpmRvyz9Qxuz0Umf/AHDbx90EqR51l hdyw== X-Gm-Message-State: AJIora+dx4RvvLFV6O+ok0jkbKsUYZm9MxBQ1PhOAfG6CYgAt4UUY+4K ma/FCLonow/AkXP3cI44xeASjFEOKC8= X-Google-Smtp-Source: AGRyM1vsRyTEnJWoiv6XK8PqC+TwzEVK8xzEXxB3k3VgEWVpYzK+BxX8pmc84kwgItBrXEWCTgc/xA== X-Received: by 2002:a05:6870:8925:b0:101:fbdd:765d with SMTP id i37-20020a056870892500b00101fbdd765dmr881512oao.194.1658520022775; Fri, 22 Jul 2022 13:00:22 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: Alistair Francis , David Gibson , Daniel Henrique Barboza , "Dr . David Alan Gilbert" Subject: [PATCH for-7.2 05/10] hmp, device_tree.c: introduce 'info fdt' command Date: Fri, 22 Jul 2022 17:00:02 -0300 Message-Id: <20220722200007.1602174-6-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722200007.1602174-1-danielhb413@gmail.com> References: <20220722200007.1602174-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::34; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x34.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1658520231380100001 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 attribute. '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 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. 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/sysemu/device_tree.h | 1 + monitor/misc.c | 12 ++++++++++ softmmu/device_tree.c | 43 ++++++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index 3ffa24bd67..abf277be7d 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -908,3 +908,16 @@ SRST ``stats`` Show runtime-collected statistics ERST + + { + .name =3D "fdt", + .args_type =3D "fullpath:s", + .params =3D "fullpath", + .help =3D "show firmware device tree node given its full pat= h", + .cmd =3D hmp_info_fdt, + }, + +SRST + ``info fdt`` + Show firmware device tree (fdt). +ERST diff --git a/include/sysemu/device_tree.h b/include/sysemu/device_tree.h index 1397adb21c..c0f98b1c88 100644 --- a/include/sysemu/device_tree.h +++ b/include/sysemu/device_tree.h @@ -124,6 +124,7 @@ int qemu_fdt_add_subnode(void *fdt, const char *name); int qemu_fdt_add_path(void *fdt, const char *path); =20 void fdt_save(const char *filename, Error **errp); +void fdt_info(const char *fullpath, Error **errp); =20 #define qemu_fdt_setprop_cells(fdt, node_path, property, ...) = \ do { = \ diff --git a/monitor/misc.c b/monitor/misc.c index 145285cec0..e709a7de91 100644 --- a/monitor/misc.c +++ b/monitor/misc.c @@ -973,6 +973,18 @@ static void hmp_info_capture(Monitor *mon, const QDict= *qdict) } } =20 +static void hmp_info_fdt(Monitor *mon, const QDict *qdict) +{ + const char *fullpath =3D qdict_get_str(qdict, "fullpath"); + Error *local_err =3D NULL; + + fdt_info(fullpath, &local_err); + + if (local_err) { + error_report_err(local_err); + } +} + static void hmp_stopcapture(Monitor *mon, const QDict *qdict) { int i; diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index eeab6a5ef0..899c239c5c 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -26,6 +26,7 @@ #include "hw/loader.h" #include "hw/boards.h" #include "qemu/config-file.h" +#include "qemu/qemu-print.h" =20 #include =20 @@ -661,3 +662,45 @@ void fdt_save(const char *filename, Error **errp) =20 error_setg(errp, "Error when saving machine FDT to file %s", filename); } + +static void fdt_print_node(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; + + qemu_printf("%*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)); + + qemu_printf("%*s%s;\n", padding, "", propname); + } + + padding -=3D 4; + qemu_printf("%*s}\n", padding, ""); +} + +void fdt_info(const char *fullpath, Error **errp) +{ + int node; + + if (!current_machine->fdt) { + error_setg(errp, "Unable to find the machine FDT"); + return; + } + + node =3D fdt_path_offset(current_machine->fdt, fullpath); + if (node < 0) { + error_setg(errp, "node '%s' not found in FDT", fullpath); + return; + } + + fdt_print_node(node, 0); +} --=20 2.36.1 From nobody Thu May 16 09:28:55 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=1658520410; cv=none; d=zohomail.com; s=zohoarc; b=cv00aiAbEi60TR0hBpAh2wGZgAQVlNKgxmOojwGShF0X4K4waPjD3pWjY8enjDPDp0TLsDgaP/N4AbZYC6PINjKtl/hGb4evegHPW9NX/G9KMTDD34GeLrRxXTFOYatVLSOwBhD0vkTbtz8qqRvZ6lVIGzwpvq/1LhUmQXuuhws= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658520410; 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=sKtgH6N152/Ky0OYbTdVV9FFZLyxA0EDEz3bCdDiuZQ=; b=cMeb0XOBW7QhMHglobCfmjpfEJDHIhnGGbzL4pgA+DFnws5v2S5Tcnf5U1X8N3VWhv6eGkRm3sNtK7/PNxHA/ayp7togYunLMobFq+MFsWeNmDsczK2fBIBe+cy6BtOfRDApk1AgdQ6SFqW2r0Xrg1QVKYx3ZBJyEFU9IsKxLZo= 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 1658520410144478.77873039148415; Fri, 22 Jul 2022 13:06:50 -0700 (PDT) Received: from localhost ([::1]:54998 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEyvB-0003GY-4S for importer@patchew.org; Fri, 22 Jul 2022 16:06:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51472) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEyp0-00031z-Tg for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:26 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]:42571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEyoz-0005D4-92 for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:26 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-f2a4c51c45so7547627fac.9 for ; Fri, 22 Jul 2022 13:00:24 -0700 (PDT) Received: from balboa.COMFAST ([152.254.206.198]) by smtp.gmail.com with ESMTPSA id n14-20020a9d740e000000b0061cae62aafcsm2388218otk.20.2022.07.22.13.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=sKtgH6N152/Ky0OYbTdVV9FFZLyxA0EDEz3bCdDiuZQ=; b=gcmC7zlDFZg5TN+DMQ9F9lTHJWmYGJ1LxVApfunk+KdAE+V+7m+mfxkThaA7Z4G6X7 7ZR7gY0SiGHPcZhfda0DqoiQw5eG6Qt60ZX3Rg4mDULdLRYzMKFr7lrzYlpNmqxd6xUI 4EAs04GxcOrGbdDtPcC2u59cruHID7kla5Gh3sCJpHINoDGwum7ZCzbSlXxLlxtnu8K0 TAEF8qREolECDZmwZUOK2HyVGZuVt/0Z1odI53NH5K9jLJiERoMGeYyRxeTr/bNmjpiM EH2uUZ0cuB09vrVi9PQArOTx7cTudDH8/HWUAvEiD8vGJdvR6CPoYGLiDcNuuL8+MYYm Nv5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=sKtgH6N152/Ky0OYbTdVV9FFZLyxA0EDEz3bCdDiuZQ=; b=gR2wojzzFcB7RGVUn4TGmMR440WBmwFrgoRsIarnc7Uj7XB1clEtGgvW9bi2QzaY91 7q1sJmef2Ho3E4Q1rJ0999yFT3a2Qaz1rjC4PtnPRJs8mhpCOqIDVtYbz+k6/N27DLm8 YvScnZDGaa3T5NE+dBugTwnAaernIBBv8IwSoRKu8paYm8uOvD2Jf4sjkr+Z8qlzthvd mY7WdUyScRqHje+7Y8fRbgbQBokwtzObQp6hpHu4BTkQUSW8uG0ltTfNJuqbMihhnHiX YInzu86a5uWUszkD1JCUcu4wVohl8CSoSKgvMSLh58AT1zlJGYA3MnPYIsrvKh6IqJq8 QeSg== X-Gm-Message-State: AJIora9WoxP5BhzsMFBFkzarjGVmW3U2Sr3gmQqZTeJj4RvFebXdtRz1 AHBW431OEjiegGczuOtT4CaBNx3RuY0= X-Google-Smtp-Source: AGRyM1uF68HNVztTRcubA755ydDHemi7PC7o/hR73TcrMI4iPu7pIZt5nEGTSzC6vYU2UXb37tzTIw== X-Received: by 2002:a05:6870:15c9:b0:101:e18b:d12d with SMTP id k9-20020a05687015c900b00101e18bd12dmr8506716oad.51.1658520024480; Fri, 22 Jul 2022 13:00:24 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: Alistair Francis , David Gibson , Daniel Henrique Barboza Subject: [PATCH for-7.2 06/10] device_tree.c: support printing of strings props Date: Fri, 22 Jul 2022 17:00:03 -0300 Message-Id: <20220722200007.1602174-7-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722200007.1602174-1-danielhb413@gmail.com> References: <20220722200007.1602174-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::29; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x29.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1658520412186100001 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 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 899c239c5c..3c070acc0d 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -663,6 +663,24 @@ void fdt_save(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_print_node(int node, int depth) { const struct fdt_property *prop =3D NULL; @@ -680,7 +698,11 @@ static void fdt_print_node(int node, int depth) prop =3D fdt_get_property_by_offset(fdt, property, &prop_size); propname =3D fdt_string(fdt, fdt32_to_cpu(prop->nameoff)); =20 - qemu_printf("%*s%s;\n", padding, "", propname); + if (fdt_prop_is_string(prop->data, prop_size)) { + qemu_printf("%*s%s =3D '%s'\n", padding, "", propname, prop->d= ata); + } else { + qemu_printf("%*s%s;\n", padding, "", propname); + } } =20 padding -=3D 4; --=20 2.36.1 From nobody Thu May 16 09:28:55 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=1658520569; cv=none; d=zohomail.com; s=zohoarc; b=Gk9G4lDMNhYtt5odTjktLTLujjsf8u+mixNHCfRD877Wl+fQEZvtS4IBz+Ii8RDkY8YzM71p7hP6cZsyKT7LzvEFLrA9YJEZzbCtj/48yuy9VXQYYmpYzFDQrLfto/Wx+E/TjMmR+vQKQgyBKN8UWuE8PGHv4q5KEclZQOvH6aQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658520569; 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=ynwsvdFe45St3WK2+5YgYIPrTLY4PoonLky5nrdFajI=; b=AyWiFWVJPCXyxNMrG8W+MA7Xc07RCv9eM+T77m2qdD7n0isQkYlFz6IPIlRHIDcsGBXQ6LVSdV0YtHFMjea+JTLV4EUGM339klfpOUdEvV99pKG93di+tlYP930kvmL0+p6y+juK+0pl442vC536tLiqUlQLvRSLxDmc/A3vAaw= 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 1658520569765231.7591381057257; Fri, 22 Jul 2022 13:09:29 -0700 (PDT) Received: from localhost ([::1]:33950 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEyxk-00083V-Lr for importer@patchew.org; Fri, 22 Jul 2022 16:09:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51500) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEyp3-00037F-TY for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:29 -0400 Received: from mail-oa1-x2d.google.com ([2001:4860:4864:20::2d]:37693) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEyp2-0005G4-4h for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:29 -0400 Received: by mail-oa1-x2d.google.com with SMTP id 586e51a60fabf-10dc6e9f500so1605625fac.4 for ; Fri, 22 Jul 2022 13:00:27 -0700 (PDT) Received: from balboa.COMFAST ([152.254.206.198]) by smtp.gmail.com with ESMTPSA id n14-20020a9d740e000000b0061cae62aafcsm2388218otk.20.2022.07.22.13.00.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ynwsvdFe45St3WK2+5YgYIPrTLY4PoonLky5nrdFajI=; b=fXzVXTzk6GDjtZPVXPM3kk69Gk8+2hoiKeUFG0NiF8po6q3xnqvVgN0ihyjiDZxBmT pHIaTJNT+iUapzBhBV+x4JZI5exBE53cGazcVYS8IGLMrGSyd1g7JohhIvC7OG/b5Mwp wBt2019Y7u3W9TfisQv+GnPKnx6CIRHH+O/6nLTKUCCRLsxU7lB4cIOKi5islxYO91cu wsDkVU7kafscjPizplinCh88mwakgRMAw+t5LnAUXy9vBe2uL/Wr5Wrd2l7GCBMQ2iim KWVFK/nuNk/FOkDxPFaLXzOdTzP8O17ptn+5sYs62NbxiEINY5xUeYyHmZGpoTuJ/y9d /6Mw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ynwsvdFe45St3WK2+5YgYIPrTLY4PoonLky5nrdFajI=; b=mAhNpZBCyIUTfaaXqg704n7EQQwNA+kFaSAxxxbw5PIfMqctty9pZTBnmxhsEPI+b6 sKHb3cGIFGplnw5BE9ZXv4i9+wWkF7aXopIR/EsgFtHc3v6PfwaV+qyCZ3Voaqxdh57w CoN27ZvzCBMZPkBLK9h01Y0LP62ilViwHM2CbKuJkui6pLf+TGWP1IGUKGQzNipFN2An s6nSY3FO3bcl1q3dsxLxmKmyNfmxU5L2bDuYZjrk6HiirrzVoE+HKvUnD2kls1XastjA /M1yz6W5rM/AfgZegQxzpJdbbbcTKPZ2chla6QQ+97jsl5jnbTpu4H1EZ+PHhufg1hqR /R2A== X-Gm-Message-State: AJIora845Tb339NF7ndmqoYpSiJdWt0cinTnr4/qtDYKhsr4Ms7eqzYn mw7dF7hHlPFDA6ESdGvoluwzSyyazo8= X-Google-Smtp-Source: AGRyM1t+5YIqFG6R/UhlZrCX7/MPTAWZuBO2zt6VTfOzBjts4Rap7ujpW4Z1WA1cJt7R2mnUKtFZyQ== X-Received: by 2002:a05:6870:b613:b0:10b:db5f:6026 with SMTP id cm19-20020a056870b61300b0010bdb5f6026mr875790oab.159.1658520026447; Fri, 22 Jul 2022 13:00:26 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: Alistair Francis , David Gibson , Daniel Henrique Barboza Subject: [PATCH for-7.2 07/10] device_tree.c: support remaining FDT prop types Date: Fri, 22 Jul 2022 17:00:04 -0300 Message-Id: <20220722200007.1602174-8-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722200007.1602174-1-danielhb413@gmail.com> References: <20220722200007.1602174-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::2d; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x2d.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1658520571126100001 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 | 53 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 3c070acc0d..3a4d09483b 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -681,6 +681,46 @@ 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_print_uint32_array(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; + + qemu_printf("%*s%s =3D <", padding, "", propname); + for (i =3D 0; i < array_len; i++) { + qemu_printf("0x%" PRIx32, fdt32_to_cpu(array[i])); + + if (i < array_len - 1) { + qemu_printf(" "); + } + } + qemu_printf(">\n"); +} + +static void fdt_prop_print_val(const char *propname, const void *data, + int prop_size, int padding) +{ + const char *val =3D data; + int i; + + qemu_printf("%*s%s =3D [", padding, "", propname); + for (i =3D 0; i < prop_size; i++) { + qemu_printf("%x", val[i]); + + if (i < prop_size - 1) { + qemu_printf(" "); + } + } + qemu_printf("]\n"); +} + static void fdt_print_node(int node, int depth) { const struct fdt_property *prop =3D NULL; @@ -698,10 +738,19 @@ static void fdt_print_node(int node, int 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) { + qemu_printf("%*s%s;\n", padding, "", propname); + continue; + } + if (fdt_prop_is_string(prop->data, prop_size)) { - qemu_printf("%*s%s =3D '%s'\n", padding, "", propname, prop->d= ata); + qemu_printf("%*s%s =3D '%s'\n", padding, "", + propname, (char *)prop->data); + } else if (fdt_prop_is_uint32_array(prop_size)) { + fdt_prop_print_uint32_array(propname, prop->data, prop_size, + padding); } else { - qemu_printf("%*s%s;\n", padding, "", propname); + fdt_prop_print_val(propname, prop->data, prop_size, padding); } } =20 --=20 2.36.1 From nobody Thu May 16 09:28:55 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=1658520225; cv=none; d=zohomail.com; s=zohoarc; b=blPGrivGLR90Gq6dT8kyB3ih2eEeEihXTrvCUia7N6L/6486nkKq1mVWQuC/XDgb9tYVHI1kBGf5fi0DY0yhM+//R86c5p9g/Gd10m7RlYJpuoH9ksRWFhFrjrVMSnfg8KJF+iE1XvgORqgak0JwHAV54B+zmxw4WNQwg9yGcvg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658520225; 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=6H1vwOGrBVg5tfAahc7TWhOpLEIjth6n4BeX2NpIabU=; b=jE1h3dm9U4LExBGS2f9yo4wwRcuTzzu29gQp6PKns82y3QkpVDhztuk3MrC+dk1WSoqoHaVAdKTFfJ7Jx+c8QnwoG4OtHyoaTxptA6khwsiM0UWSzMAkPjgpvaVF98Bx2ZnfgWsR4F+BCMxVNUVgHznU9rztp78x/Meph372ppw= 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 1658520225630426.17523165020793; Fri, 22 Jul 2022 13:03:45 -0700 (PDT) Received: from localhost ([::1]:46592 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEysB-00061D-M5 for importer@patchew.org; Fri, 22 Jul 2022 16:03:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51512) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEyp4-000389-Tw for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:30 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]:40723) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEyp3-0005Gl-BZ for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:30 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-10d6e8990b9so7547659fac.7 for ; Fri, 22 Jul 2022 13:00:28 -0700 (PDT) Received: from balboa.COMFAST ([152.254.206.198]) by smtp.gmail.com with ESMTPSA id n14-20020a9d740e000000b0061cae62aafcsm2388218otk.20.2022.07.22.13.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6H1vwOGrBVg5tfAahc7TWhOpLEIjth6n4BeX2NpIabU=; b=UMa18Az1uShjRtVCu9TM/5aBnT3hI9cyUcFR8ruqC3AbVyyHBnJtX71W1LGSD2WULO gUHrYxX9+EgfcdQK1rVdnmwpEBBsFYzO3V1g0+QSvfOpk+mgJhY/Hkyrsy7QIQGbJOXo NnY8qM2lvKPHYnYKrzkkcZGNOrhhEnxJJwxtR0obrT1LYf0cWD4ybw/otlanDwG0BlJ0 VjVQq068O3ut82U2ntuxBNZzPdezFESXvYJ0wGpWU8C5qzrxPRVfJPBqwnQsxe3AFX4e jJ9357AWqRh6DwNJ1GC6xudpEAF4217NIlYFotUIJowSnbeykDZRmivd7MZRvf4Gx+63 ou/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6H1vwOGrBVg5tfAahc7TWhOpLEIjth6n4BeX2NpIabU=; b=3wPEyPAKmpzqYWoN7f5A1crSKQpEKdvHnqXsDkeNrvXlNpY2zTxAA4lrRelBaysnhY z+k2JH8vEY427j2iVwL9nlvO1u4rlIJGfTgVP/wnzpbTYNZU24E0deGrxap0v5ApMT0Y Y/YTeT3oJxpJHcdo6cEN9d4ql1g+zq3WqzVIr6EBRpSlWVDS551WjxE6hR81f4FrsAwX wNXBoDNRVhXlzSwMwHRwwaMq3amhAUGPBp5oZ7w50i/uEmJ0nFI/fW8HHG6pvorhJpnD t6HE2fjp13BAtnp93Mwx1quEu7Dkh91OClrQYyfaVrrc1kqJXSsVEoVcZuDMmSOymkYL bIxg== X-Gm-Message-State: AJIora+pO3RU2Tv5x1WFYixU9gACQDzMnHpxTMdGG3Vc+Kl07PazcmHA lQc+OoKBUPfyP5+mQx3L5U477JFJ74k= X-Google-Smtp-Source: AGRyM1s9Hmw/Njzptw0G5l207V0ygJovfpp4C1Zm1xvdLKSL0RVJsrBFYSeCZA5P//yRe8AOH/4b9w== X-Received: by 2002:a05:6870:51ce:b0:10d:4691:7bd9 with SMTP id b14-20020a05687051ce00b0010d46917bd9mr8272548oaj.185.1658520028230; Fri, 22 Jul 2022 13:00:28 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: Alistair Francis , David Gibson , Daniel Henrique Barboza Subject: [PATCH for-7.2 08/10] device_node.c: enable 'info fdt' to print subnodes Date: Fri, 22 Jul 2022 17:00:05 -0300 Message-Id: <20220722200007.1602174-9-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722200007.1602174-1-danielhb413@gmail.com> References: <20220722200007.1602174-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::29; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x29.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1658520227576100001 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 | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 3a4d09483b..88b6a0c902 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -721,16 +721,24 @@ static void fdt_prop_print_val(const char *propname, = const void *data, qemu_printf("]\n"); } =20 -static void fdt_print_node(int node, int depth) +static void fdt_print_node(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 - qemu_printf("%*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); + } + + qemu_printf("%*s%s {\n", padding, "", nodename); =20 padding +=3D 4; =20 @@ -754,6 +762,10 @@ static void fdt_print_node(int node, int depth) } } =20 + fdt_for_each_subnode(node, fdt, parent) { + fdt_print_node(node, depth + 1, NULL); + } + padding -=3D 4; qemu_printf("%*s}\n", padding, ""); } @@ -773,5 +785,5 @@ void fdt_info(const char *fullpath, Error **errp) return; } =20 - fdt_print_node(node, 0); + fdt_print_node(node, 0, fullpath); } --=20 2.36.1 From nobody Thu May 16 09:28:55 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=1658520563; cv=none; d=zohomail.com; s=zohoarc; b=WQtGgBpeuwvnzGf2N2HToHT26kgg2HyAAdp7OTAyvRFz9s4jnWk/pu+miBZ1pkc3+otmOvCcrPQ11MO6Rll2mxiW5TcGGexu/+OwWtRwm46ekvpThko1rBbXOXFC5/+d2u+Bs/t8o7lsWSwmxTit2XFksxJIoCnrenlVrBd1p3Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658520563; 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=vDH8WQM1CcrQ7MWlTwywWT5aGC6JfLPqlVYbl6HwG28=; b=lyw6rNnkHAz/H1eZ+gvbMIXZehXK+UPUUP12BDNPr6d9gyqIi1XVQUjiDt47n9xgHyZLiGci5JW40JnFHpec3EOvWngbj/FZ8r1O+BngFeQ/TVmADNEj82pHvSb946TMTaEXLmgjSL3YF5K3XFGoajoHrtTbal41/rxMlRqgRXs= 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 1658520563193868.617783075663; Fri, 22 Jul 2022 13:09:23 -0700 (PDT) Received: from localhost ([::1]:33562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEyxd-0007nf-HW for importer@patchew.org; Fri, 22 Jul 2022 16:09:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEyp6-0003Bt-9E for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:32 -0400 Received: from mail-oa1-x29.google.com ([2001:4860:4864:20::29]:42571) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEyp4-0005D4-Js for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:31 -0400 Received: by mail-oa1-x29.google.com with SMTP id 586e51a60fabf-f2a4c51c45so7547917fac.9 for ; Fri, 22 Jul 2022 13:00:30 -0700 (PDT) Received: from balboa.COMFAST ([152.254.206.198]) by smtp.gmail.com with ESMTPSA id n14-20020a9d740e000000b0061cae62aafcsm2388218otk.20.2022.07.22.13.00.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vDH8WQM1CcrQ7MWlTwywWT5aGC6JfLPqlVYbl6HwG28=; b=WUm0Ny22YPMID7ejz/czDudkXkIMyInJtINW8CWFgaLKok35tCNd9KdGD3Q+U7wVpP U8dVniq7Ar0dxg7c9AmVeL6bIEJPPtc+jGyQ7m9UUiRMYB8icM6RLEdtObq4WxIThfj3 9YjmX6n8o3Y+j2jLvdod2uoJrZTUrJfA6bQVIzpIhbN/aI8t/hFtTVXkYZ1azi2pQvdH ZZsZiw16uS4TmT5QPhbRy4rTC7UhzVbPm1MqWF+teHBRnHpGq4jiZhtKVN3VHvwgISTq ikVH1uZeh+Tl4XDlZptH9Nvu1QwwbX7hmvvqGFBHa/nLbe9+C2DHtxGQVVa9186k69oI 9vFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vDH8WQM1CcrQ7MWlTwywWT5aGC6JfLPqlVYbl6HwG28=; b=PUAopAkRnSwTaHasKWbspnP+G2sK6TGVgdCF/vduLZzjUIHsWvmkXCsOdvN5WA8N9y ClepN5SjVsGH1Gecnq7H1PQvv4Lx8+uDQERW0qPbfoaMqXFilcppjX1wAXaTDsYAE2e1 TP0W1lPfYkhQQDdr+CcDr7W9oVm9ZbB8XntGvE+7rQosMk38ZvbWAcNb+bQ36c+aNffs jFnfjDDQkeKl43ychzRK6dnTM4O0t0jOQDY0w+JzmlF1LhUSWs6mNk3+wZsy9Wk6vbMX KkU8EGnA6inMUHuuS8GGCw+Q1hlqPAUJxaMOBTWdXm5xk5vELUX1O6M7DAWvdDGyle4y THlA== X-Gm-Message-State: AJIora/AhF/pY77bLJbdw25L48q7tqxKjS2Td9l5ygl/r5eKgpChdXus dup0SrPStkf+oVnxMoB/QBwx7ylQQk0= X-Google-Smtp-Source: AGRyM1ts8tbC6RKHpn7A52qWkYuoJKDYKc5QwcX+HZ1zq85shA3rdqvIXcU4ka4IONoAg2GFaFWk4w== X-Received: by 2002:a05:6870:1601:b0:108:2d92:5494 with SMTP id b1-20020a056870160100b001082d925494mr8760499oae.109.1658520029910; Fri, 22 Jul 2022 13:00:29 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: Alistair Francis , David Gibson , Daniel Henrique Barboza Subject: [PATCH for-7.2 09/10] device_tree.c: add fdt_print_property() helper Date: Fri, 22 Jul 2022 17:00:06 -0300 Message-Id: <20220722200007.1602174-10-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722200007.1602174-1-danielhb413@gmail.com> References: <20220722200007.1602174-1-danielhb413@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:4860:4864:20::29; envelope-from=danielhb413@gmail.com; helo=mail-oa1-x29.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1658520565170100001 Content-Type: text/plain; charset="utf-8" We want to be able to also print properties with 'info fdt'. Create a helper to print properties based on the already existing code from fdt_print_node(). Signed-off-by: Daniel Henrique Barboza --- softmmu/device_tree.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index 88b6a0c902..e41894fbef 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -721,6 +721,23 @@ static void fdt_prop_print_val(const char *propname, c= onst void *data, qemu_printf("]\n"); } =20 +static void fdt_print_property(const char *propname, const void *data, + int prop_size, int padding) +{ + if (prop_size =3D=3D 0) { + qemu_printf("%*s%s;\n", padding, "", propname); + return; + } + + if (fdt_prop_is_string(data, prop_size)) { + qemu_printf("%*s%s =3D '%s'\n", padding, "", propname, (char *)dat= a); + } else if (fdt_prop_is_uint32_array(prop_size)) { + fdt_prop_print_uint32_array(propname, data, prop_size, padding); + } else { + fdt_prop_print_val(propname, data, prop_size, padding); + } +} + static void fdt_print_node(int node, int depth, const char *fullpath) { const struct fdt_property *prop =3D NULL; @@ -746,20 +763,7 @@ static void fdt_print_node(int node, int depth, const = char *fullpath) 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) { - qemu_printf("%*s%s;\n", padding, "", propname); - continue; - } - - if (fdt_prop_is_string(prop->data, prop_size)) { - qemu_printf("%*s%s =3D '%s'\n", padding, "", - propname, (char *)prop->data); - } else if (fdt_prop_is_uint32_array(prop_size)) { - fdt_prop_print_uint32_array(propname, prop->data, prop_size, - padding); - } else { - fdt_prop_print_val(propname, prop->data, prop_size, padding); - } + fdt_print_property(propname, prop->data, prop_size, padding); } =20 fdt_for_each_subnode(node, fdt, parent) { --=20 2.36.1 From nobody Thu May 16 09:28:55 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=1658520673; cv=none; d=zohomail.com; s=zohoarc; b=K0Tbpo9/WI0LV+KfVksDdgskLg85MUdEonZG5HKvBOkkI8NWjVUEFyMD4PUTGJCGRhIvInvuPUe0kxpdHROzuOnAfUu5Ztn3b+2TQXNglpHm4hMlO730U+S2bVVRArRIkXyxrjsyIKLA9Xlf8zAK3UoumINX9gxgJ5IWR7oISkA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1658520673; 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=pLNDvNY4vqIyBPGAJJxTjC/HuMR6ZJpJbU+/fAAfUaE=; b=OZOqPe8ZR3zdkdVpW/OKyYulJ2sgrc1XUVRZtcEvdiYoyerbrY0CNqU/VaZM7UYKCKiXQyds9Y1qh6pZryekwTO559kLu8Vs1YR6v6L8BHxPDiGAOHd79v82il3BV0Olsx2lcsN92RUDulVUu2txCLj6QG2Q1KzRcycBo3CviaI= 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 165852067323447.071705814750544; Fri, 22 Jul 2022 13:11:13 -0700 (PDT) Received: from localhost ([::1]:38300 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oEyzP-0002YT-89 for importer@patchew.org; Fri, 22 Jul 2022 16:11:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51542) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oEyp9-0003GE-68 for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:36 -0400 Received: from mail-oi1-x22d.google.com ([2607:f8b0:4864:20::22d]:35477) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oEyp7-0005JG-3S for qemu-devel@nongnu.org; Fri, 22 Jul 2022 16:00:34 -0400 Received: by mail-oi1-x22d.google.com with SMTP id r82so6698878oig.2 for ; Fri, 22 Jul 2022 13:00:32 -0700 (PDT) Received: from balboa.COMFAST ([152.254.206.198]) by smtp.gmail.com with ESMTPSA id n14-20020a9d740e000000b0061cae62aafcsm2388218otk.20.2022.07.22.13.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 13:00:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pLNDvNY4vqIyBPGAJJxTjC/HuMR6ZJpJbU+/fAAfUaE=; b=doBJUWO3G3KBORNroKbu6VLzepOgXt62ZkOSVf2ddzQkWnntQMr8/GipuZxc1yWfos Lo83DQy8Rb7mzscR1plqsTWwJtjJhdbxuZtHU5G/QBMKINgCSJU69vH+nns8+r27mbVq TQhtd5z2Qnb14L1qDdjwOtkxBrGhG0MvT/ZcYKq+CEzTFY1PSi5++dCnea60lM7+IOZ7 YspIXmXCRLHgro4CA6ivQIgL5QCdGiZ7Ctr1hpB6yU9IOlhLKeAV7lZWAuyc7fIG+SRE 1ejXWnGVngI27aO846PUrGEI7FBGkbfVklmLdO2GKSVJ6F9M15s0u+xS4icu2yPWnzTl kriQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pLNDvNY4vqIyBPGAJJxTjC/HuMR6ZJpJbU+/fAAfUaE=; b=v9RZaKIjOtEKB+KFL82xCQk642wA+NTInc7mBKJ02MH5iTmt26bWLVeWxvx9OiLxxL RZb8K0NvoBNqBx7JRAp1QI0Y3Jx97eZuCwnzb2iCEil+c0v8MJQiW9InGZ/wWfugDBLu +hy02EYanesuKh9fhwI5V6IyJ26lLTkUx0bR+CemfJV+WjEpNhlMkPVKvTY1UGemNOTy JURtLZOZiAV3ZIDcaSxaQmqgWaHIb9MgP5/bU0S1CoGH2JDiEcXkDbyB2TPBPh2xDq2l QUXaczLAVK4DAhZHuYSQM8CKkc2lWc5SyUCRoc4rqD1kcqdAJUrSUVBHgPS+OdOdlF3i r8PQ== X-Gm-Message-State: AJIora+qZb44yVvMaQyUz/tbVHrujYKXDm77ZEVczDt0xmlj8N67BqxY VGuQpfAbj/JN6xHhS8FjVeY/3eJMDEA= X-Google-Smtp-Source: AGRyM1uxCugj6fXUrmGOIziSZ7h/dNOTobFQbUXYTi8ML5JaSnBi8Rfg+6/YD2ykFquHnfjE6WlYsg== X-Received: by 2002:aca:90c:0:b0:33a:768b:50d5 with SMTP id 12-20020aca090c000000b0033a768b50d5mr7647173oij.294.1658520031840; Fri, 22 Jul 2022 13:00:31 -0700 (PDT) From: Daniel Henrique Barboza To: qemu-devel@nongnu.org Cc: Alistair Francis , David Gibson , Daniel Henrique Barboza , "Dr . David Alan Gilbert" Subject: [PATCH for-7.2 10/10] hmp, device_tree.c: add 'info fdt ' support Date: Fri, 22 Jul 2022 17:00:07 -0300 Message-Id: <20220722200007.1602174-11-danielhb413@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220722200007.1602174-1-danielhb413@gmail.com> References: <20220722200007.1602174-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::22d; envelope-from=danielhb413@gmail.com; helo=mail-oi1-x22d.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: 1658520673812100001 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. This is how we're going to support it: - given the same fullpath parameter, assume it's a node. If we have a match with an existing node, print it. If not, assume it's a property; - in fdt_find_property() we're going to split 'fullpath' into node and property. Unfortunately we can't use g_path_get_basename() to helps us because, although the device tree path format is similar to Linux, it'll not work when trying to run QEMU under Windows where the path format is different; - after spliiting into node + property, try to find the node in the FDT. If we have a match, use fdt_get_property() to retrieve fdt_property. Return it if found; - using the fdt_print_property() created previously, print the property. 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> (qemu) 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> (qemu) Cc: Dr. David Alan Gilbert Signed-off-by: Daniel Henrique Barboza --- hmp-commands-info.hx | 2 +- softmmu/device_tree.c | 79 ++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 76 insertions(+), 5 deletions(-) diff --git a/hmp-commands-info.hx b/hmp-commands-info.hx index abf277be7d..8891c2918a 100644 --- a/hmp-commands-info.hx +++ b/hmp-commands-info.hx @@ -913,7 +913,7 @@ ERST .name =3D "fdt", .args_type =3D "fullpath:s", .params =3D "fullpath", - .help =3D "show firmware device tree node given its full pat= h", + .help =3D "show firmware device tree node or property given = its full path", .cmd =3D hmp_info_fdt, }, =20 diff --git a/softmmu/device_tree.c b/softmmu/device_tree.c index e41894fbef..f6eb060acc 100644 --- a/softmmu/device_tree.c +++ b/softmmu/device_tree.c @@ -774,9 +774,74 @@ static void fdt_print_node(int node, int depth, const = char *fullpath) qemu_printf("%*s}\n", padding, ""); } =20 +static const struct fdt_property *fdt_find_property(const char *fullpath, + int *prop_size, + Error **errp) +{ + const struct fdt_property *prop =3D NULL; + void *fdt =3D current_machine->fdt; + g_autoptr(GString) nodename =3D NULL; + const char *propname =3D NULL; + int path_len =3D strlen(fullpath); + int node =3D 0; /* default to root node '/' */ + int i, idx =3D -1; + + /* + * We'll assume that we're dealing with a property. libfdt + * does not have an API to find a property given the full + * path, but it does have an API to find a property inside + * a node. + */ + nodename =3D g_string_new(""); + + for (i =3D path_len - 1; i >=3D 0; i--) { + if (fullpath[i] =3D=3D '/') { + idx =3D i; + break; + } + } + + if (idx =3D=3D -1) { + error_setg(errp, "FDT paths must contain at least one '/' characte= r"); + return NULL; + } + + if (idx =3D=3D path_len - 1) { + error_setg(errp, "FDT paths can't end with a '/' character"); + return NULL; + } + + propname =3D &fullpath[idx + 1]; + + if (idx !=3D 0) { + g_string_append_len(nodename, fullpath, idx); + + node =3D fdt_path_offset(fdt, nodename->str); + if (node < 0) { + error_setg(errp, "node '%s' of property '%s' not found in FDT", + nodename->str, propname); + return NULL; + } + } else { + /* idx =3D 0 means that it's a property of the root node */ + g_string_append(nodename, "/"); + } + + 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, nodename->str); + return NULL; + } + + return prop; +} + void fdt_info(const char *fullpath, Error **errp) { - int node; + const struct fdt_property *prop =3D NULL; + Error *local_err =3D NULL; + int node, prop_size; =20 if (!current_machine->fdt) { error_setg(errp, "Unable to find the machine FDT"); @@ -784,10 +849,16 @@ void fdt_info(const char *fullpath, Error **errp) } =20 node =3D fdt_path_offset(current_machine->fdt, fullpath); - if (node < 0) { - error_setg(errp, "node '%s' not found in FDT", fullpath); + if (node >=3D 0) { + fdt_print_node(node, 0, fullpath); + return; + } + + prop =3D fdt_find_property(fullpath, &prop_size, &local_err); + if (local_err) { + error_propagate(errp, local_err); return; } =20 - fdt_print_node(node, 0, fullpath); + fdt_print_property(fullpath, prop->data, prop_size, 0); } --=20 2.36.1