From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web08.8614.1639383426719847747 for ; Mon, 13 Dec 2021 00:17:06 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=K6lxp0Ov; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639383425; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2wvanPeZljqJa/PPwwob8+t40JrnNKkazir1Vm1gQjY=; b=K6lxp0OvNAXX8pbtnTfDFX0qd+0JOgJNK+vV/5Ep8nuPHuc1lTYVTRwS2G1+vtFHIBxS2x J/BNm0qC6yjZRcIEqwDLET+OX/akfSGmmhnRG2VNOjZSwRUg8Y1+ZFTSfPUh5qNONiBy57 aPtn2LeZICrEv/U2JSEMh9rnAv3aWRg= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-463-XDRyt-ieM0CvQwsGIG7wmQ-1; Mon, 13 Dec 2021 03:17:02 -0500 X-MC-Unique: XDRyt-ieM0CvQwsGIG7wmQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 883DD104ECFC; Mon, 13 Dec 2021 08:17:01 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 48EC55BE02; Mon, 13 Dec 2021 08:17:01 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 3DD0A180062C; Mon, 13 Dec 2021 09:16:58 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Jiewen Yao , Pawel Polawski , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , Ard Biesheuvel Subject: [PATCH v3 3/5] OvmfPkg/Microvm/fdt: add empty fdt Date: Mon, 13 Dec 2021 09:16:56 +0100 Message-Id: <20211213081658.3535809-4-kraxel@redhat.com> In-Reply-To: <20211213081658.3535809-1-kraxel@redhat.com> References: <20211213081658.3535809-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" FdtClient is unhappy without a device tree, so add an empty fdt which we can use in case etc/fdt is not present in fw_cfg. On ARM machines a device tree is mandatory for hardware detection, thats why FdtClient fails hard. On microvm the device tree is only used to detect virtio-mmio devices (this patch series) and the pcie host (future series). So edk2 can continue with limited functionality in case no device tree is present: no storage, no network, but serial console and direct kernel boot works. qemu release 6.2 & newer will provide a device tree for microvm. https://bugzilla.tianocore.org/show_bug.cgi?id=3689 Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daude --- OvmfPkg/PlatformPei/Platform.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index c9ec1d7e99fb..d0323c645162 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -16,6 +16,7 @@ // // The Library classes this module consumes // +#include #include #include #include @@ -321,6 +322,18 @@ PciExBarInitialization ( ); } +static const UINT8 EmptyFdt[] = { + 0xd0, 0x0d, 0xfe, 0xed, 0x00, 0x00, 0x00, 0x48, + 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x48, + 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x11, + 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x09, +}; + VOID MicrovmInitialization ( VOID @@ -335,8 +348,9 @@ MicrovmInitialization ( Status = QemuFwCfgFindFile ("etc/fdt", &FdtItem, &FdtSize); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "%a: no etc/fdt found in fw_cfg\n", __FUNCTION__)); - return; + DEBUG ((DEBUG_INFO, "%a: no etc/fdt found in fw_cfg, using dummy\n", __FUNCTION__)); + FdtItem = 0; + FdtSize = sizeof (EmptyFdt); } FdtPages = EFI_SIZE_TO_PAGES (FdtSize); @@ -346,8 +360,12 @@ MicrovmInitialization ( return; } - QemuFwCfgSelectItem (FdtItem); - QemuFwCfgReadBytes (FdtSize, NewBase); + if (FdtItem) { + QemuFwCfgSelectItem (FdtItem); + QemuFwCfgReadBytes (FdtSize, NewBase); + } else { + CopyMem (NewBase, EmptyFdt, FdtSize); + } FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData)); if (FdtHobData == NULL) { -- 2.33.1