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.133.124]) by mx.groups.io with SMTP id smtpd.web11.11251.1634225448528116551 for ; Thu, 14 Oct 2021 08:30:48 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VRgHyuER; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1634225447; 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=1120pErrXJc0wBvbjJ0Oyjh8afJ0zyi1WHmy3ZSS8VE=; b=VRgHyuERvrkIZzooEbX6zIrFWzoKRH96UEAcWycy20yxYs0iWgBBku/Gx7s+RCZhCxRvpE UZmQtP++VkXGyoR2Cvs09m2y/5ZxMGzL7PrQnEofjQDSebse+8DazdErleyYF7XXd1bNZY EupxSHmIUc0mItr60IlT8dJT9c3/1a4= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-166-a32II4ajNSukUwoaqojOnA-1; Thu, 14 Oct 2021 11:30:44 -0400 X-MC-Unique: a32II4ajNSukUwoaqojOnA-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0B315100C610; Thu, 14 Oct 2021 15:30:43 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C2C3869CBF; Thu, 14 Oct 2021 15:30:42 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id C632F18009F7; Thu, 14 Oct 2021 17:30:24 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Jordan Justen , Jiewen Yao , Gerd Hoffmann Subject: [PATCH 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg Date: Thu, 14 Oct 2021 17:30:21 +0200 Message-Id: <20211014153024.2318942-3-kraxel@redhat.com> In-Reply-To: <20211014153024.2318942-1-kraxel@redhat.com> References: <20211014153024.2318942-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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" Needed for hardware detection: virtio-mmio devices for now, later also pcie root bridge. Depends on patched qemu which actually provides an fdt: https://gitlab.com/kraxel/qemu/-/commits/sirius/microvm-device-tree https://bugzilla.tianocore.org/show_bug.cgi?id=3689 Signed-off-by: Gerd Hoffmann --- OvmfPkg/PlatformPei/PlatformPei.inf | 1 + OvmfPkg/PlatformPei/Platform.c | 40 +++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf index 67eb7aa7166b..56876184b17a 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -44,6 +44,7 @@ [Packages] [Guids] gEfiMemoryTypeInformationGuid + gFdtHobGuid [LibraryClasses] BaseLib diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index df2d9ad015aa..3c0cdba67c83 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -321,6 +321,45 @@ PciExBarInitialization ( ); } +VOID +MicrovmInitialization ( + VOID + ) +{ + FIRMWARE_CONFIG_ITEM FdtItem; + UINTN FdtSize; + UINTN FdtPages; + EFI_STATUS Status; + UINT64 *FdtHobData; + VOID *NewBase; + + Status = QemuFwCfgFindFile ("etc/fdt", &FdtItem, &FdtSize); + if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_INFO, "%a: no etc/fdt found in fw_cfg\n", __FUNCTION__)); + return; + } + + FdtPages = EFI_SIZE_TO_PAGES (FdtSize); + NewBase = AllocatePages (FdtPages); + if (NewBase == NULL) { + DEBUG ((DEBUG_INFO, "%a: AllocatePages failed\n", __FUNCTION__)); + return; + } + + QemuFwCfgSelectItem (FdtItem); + QemuFwCfgReadBytes (FdtSize, NewBase); + + FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData)); + if (FdtHobData == NULL) { + DEBUG ((DEBUG_INFO, "%a: BuildGuidHob failed\n", __FUNCTION__)); + return; + } + + DEBUG ((DEBUG_INFO, "%a: fdt at 0x%x (size %d)\n", __FUNCTION__, + NewBase, FdtSize)); + *FdtHobData = (UINTN)NewBase; +} + VOID MiscInitialization ( VOID @@ -368,6 +407,7 @@ MiscInitialization ( break; case 0xffff: /* microvm */ DEBUG ((DEBUG_INFO, "%a: microvm\n", __FUNCTION__)); + MicrovmInitialization(); PcdStatus = PcdSet16S (PcdOvmfHostBridgePciDevId, MICROVM_PSEUDO_DEVICE_ID); ASSERT_RETURN_ERROR (PcdStatus); -- 2.31.1