From nobody Wed May 15 21:56:08 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1688356021611166.40561788155514; Sun, 2 Jul 2023 20:47:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qGAW9-00083P-A8; Sun, 02 Jul 2023 23:46:25 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qGAW4-00080J-SM; Sun, 02 Jul 2023 23:46:21 -0400 Received: from mail-qv1-xf29.google.com ([2607:f8b0:4864:20::f29]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qGAW2-00086v-Od; Sun, 02 Jul 2023 23:46:20 -0400 Received: by mail-qv1-xf29.google.com with SMTP id 6a1803df08f44-635e5b06aaeso25639116d6.0; Sun, 02 Jul 2023 20:46:17 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k125-20020a632483000000b0055b149a6db5sm8624718pgk.43.2023.07.02.20.46.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Jul 2023 20:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1688355977; x=1690947977; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:from:to:cc:subject:date:message-id:reply-to; bh=yTWHFPqmsLAr6H0AweQ3FDt2bg8rQrwdv61MLdX7124=; b=HCDvng62tnDj1nq/1DQsh030pmBWB0AINd+s2DQjFAvo94zy43+tYdHJZzdGv8Tg+A n1n2A3U1GrcAImpYu85q8k/v5N83s+p5ne9uUWP5QSpXWl2Pwb1wJyV6iqRXoFWEt0oG UFwN7M0dDV49sC9SwB+B0MUV4yVyGior9DZw8O3B0gzHlBKHycQk38bdmiR2BeM/tV1X 2T8UtUBga1HbLf1xpUmNb0KgTUDZcfvuvcNPMjILoQbyp1I1ocZJtp0lEElJFb5iWal9 jTsAn2IH32vvBiTzrNFbeDR0hbeSySNTJW2suDkr8SJn/NwVGIqQkhcmBMyd2vDBknPg 4eQg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1688355977; x=1690947977; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:sender:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=yTWHFPqmsLAr6H0AweQ3FDt2bg8rQrwdv61MLdX7124=; b=j6pdKdN12IPVUFO71o0k1aWginmp3k3qsvdMDbINNF8lpHJa0fwYkYZ9DzkkHnaZFh q/5ld+wDrjyM6hraSxy9JnHM2b+Pox77ceoBhtV4tqNQ+Mb4uPGN/7HyT71QkMDi8x37 dE4ztcxN05z8GpnIdxpfqZA4bKB7zTG4KGJfYJqolwHvtiWPRFJuaBFKCJ21vOh7ubm3 zK7UWA5qCOmT86xc52NM8n2rDoDbf1q83sMyesCAzQvVyMbN8bJBgVaodtesj2yMvlnx HfnVHCjSge/YKdbzFyZ8GG9xNM/L/BF8DuO0oDD9mK6Ad/LvalOWb8flZYqwAd/gQJij 4kaw== X-Gm-Message-State: ABy/qLZcC1Qgl8aSIwU8zlb3W7U0DcfrDHuq/XukKQM0DNlwFiroFKxs WrH8gwheOR+r36qhX8BFh8c= X-Google-Smtp-Source: APBJJlGFIva9JCWdRQ6zJ94dioIdESE5E4yHOZs261NP7GwMDicil4cFTxtKJfadSaNWML0TcGnqZA== X-Received: by 2002:a05:6214:624:b0:62d:f1b0:1ec with SMTP id a4-20020a056214062400b0062df1b001ecmr10575718qvx.26.1688355977151; Sun, 02 Jul 2023 20:46:17 -0700 (PDT) From: Guenter Roeck To: Palmer Dabbelt Cc: Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , qemu-riscv@nongnu.org, qemu-devel@nongnu.org, Guenter Roeck , Alistair Francis Subject: [PATCH] riscv: Generate devicetree only after machine initialization is complete Date: Sun, 2 Jul 2023 20:46:14 -0700 Message-Id: <20230703034614.3909079-1-linux@roeck-us.net> X-Mailer: git-send-email 2.39.2 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::f29; envelope-from=groeck7@gmail.com; helo=mail-qv1-xf29.google.com X-Spam_score_int: -12 X-Spam_score: -1.3 X-Spam_bar: - X-Spam_report: (-1.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_ENVFROM_END_DIGIT=0.25, FREEMAIL_FORGED_FROMDOMAIN=0.25, FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1688356023611100002 Content-Type: text/plain; charset="utf-8" If the devicetree is created before machine initialization is complete, it misses dynamic devices. Specifically, the tpm device is not added to the devicetree file and is therefore not instantiated in Linux. Create devicetree in virt_machine_done() to solve the problem. Cc: Alistair Francis Fixes: 325b7c4e75 hw/riscv: Enable TPM backends Signed-off-by: Guenter Roeck --- hw/riscv/virt.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c index ed4c27487e..08876284f5 100644 --- a/hw/riscv/virt.c +++ b/hw/riscv/virt.c @@ -1248,6 +1248,11 @@ static void virt_machine_done(Notifier *notifier, vo= id *data) uint64_t kernel_entry =3D 0; BlockBackend *pflash_blk0; =20 + /* create devicetree if not provided */ + if (!machine->dtb) { + create_fdt(s, memmap); + } + /* * Only direct boot kernel is currently supported for KVM VM, * so the "-bios" parameter is not supported when KVM is enabled. @@ -1508,15 +1513,13 @@ static void virt_machine_init(MachineState *machine) } virt_flash_map(s, system_memory); =20 - /* load/create device tree */ + /* load device tree */ if (machine->dtb) { machine->fdt =3D load_device_tree(machine->dtb, &s->fdt_size); if (!machine->fdt) { error_report("load_device_tree() failed"); exit(1); } - } else { - create_fdt(s, memmap); } =20 s->machine_done.notify =3D virt_machine_done; --=20 2.39.2