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.9079.1639388042581545558 for ; Mon, 13 Dec 2021 01:34:02 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Y+1QTbAt; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1639388041; 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=huZiCGdqtLBbRNNTqWEPNRkyAXXBj7+9XLhbfRl9raM=; b=Y+1QTbAtvzB8m5+eIUe6edn36sfk4/fJCkXxyh4ZVXwStAlD+f8M+6lJ+0LDgd0mjg0Fjc Qwgn7kSlAVMerqEk5L8WMtSHz3ftd7iiHbt/q+Pz7v16wbuSLbuMPGNT2iI4Ha7dRLZ8au YvmhvuvSAn5orc+Z1870ozFc3JqZE+M= Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-171-hhAzlHl6PsaAm_lXAZEOpQ-1; Mon, 13 Dec 2021 04:33:58 -0500 X-MC-Unique: hhAzlHl6PsaAm_lXAZEOpQ-1 Received: by mail-wr1-f70.google.com with SMTP id q7-20020adff507000000b0017d160d35a8so3659995wro.4 for ; Mon, 13 Dec 2021 01:33:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=huZiCGdqtLBbRNNTqWEPNRkyAXXBj7+9XLhbfRl9raM=; b=sxqMuMcmIZIBSZdxw56pYlUOoH+y2rzSVZ2u8sceImB/cRk7lEANtHGWYKc6+AM9Jh n6HFkKny7liLtvxczYnXwD6upp80VTYO126lI/Q9BBTs8et3yUTyRUNUTth+uxqWwk3l Vy2kSSl/vz72ldL1HZtQUgeH8DVpz2hwb5GyGf1Xaj2OFTullQ9xikSHfkprv7JzzZ5l YUYcQopZnqPlbGo7X+yyLWUxrkXFG8ByKSp/L3tXPyFkp5NIrQZQx6N8lO8w5NippZOM oxR7oUOWH6wRJXbZDMxzivwJkdbqXCtrs9aI5Zxb0bSFaFQ2Dffm7KncySf/J9ZztBgQ lOMA== X-Gm-Message-State: AOAM533nZXUBhF3j8jjq48iYm4FDceSKioFX/6hsXEto4CAG1HM/MeCQ E7tkDF2qLeu10VGlLUed/V3IG/Nlv9niNbkjHlGz6n1SaMfMzVQZW3czTlgjMynvLDQyRcfWNb2 0ohe9QatBBWFt6Q== X-Received: by 2002:adf:8b8a:: with SMTP id o10mr30784963wra.569.1639388037332; Mon, 13 Dec 2021 01:33:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJwu72NF1l1SmDQrenQQJQZtrwzYr67ibY8cORn2L0CGeC9A51u06jrcysOJLDRQVdeh1pvNgA== X-Received: by 2002:adf:8b8a:: with SMTP id o10mr30784934wra.569.1639388037116; Mon, 13 Dec 2021 01:33:57 -0800 (PST) Return-Path: Received: from [192.168.1.36] (174.red-83-50-185.dynamicip.rima-tde.net. [83.50.185.174]) by smtp.gmail.com with ESMTPSA id g18sm7567487wmq.4.2021.12.13.01.33.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Dec 2021 01:33:56 -0800 (PST) Message-ID: <8f133fbe-34ae-bd0a-3dd0-b249b3ce215b@redhat.com> Date: Mon, 13 Dec 2021 10:33:55 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.3.0 Subject: Re: [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg To: Gerd Hoffmann , devel@edk2.groups.io Cc: Jordan Justen , Jiewen Yao , Pawel Polawski , Ard Biesheuvel References: <20211213081658.3535809-1-kraxel@redhat.com> <20211213081658.3535809-3-kraxel@redhat.com> From: =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= In-Reply-To: <20211213081658.3535809-3-kraxel@redhat.com> Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 12/13/21 09:16, Gerd Hoffmann wrote: > 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 Link returns 404. > > https://bugzilla.tianocore.org/show_bug.cgi?id=3689 > Signed-off-by: Gerd Hoffmann > --- > OvmfPkg/PlatformPei/PlatformPei.inf | 1 + > OvmfPkg/PlatformPei/Platform.c | 45 +++++++++++++++++++++++++++++ > 2 files changed, 46 insertions(+) > > diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf > index 1c56ba275835..8ef404168c45 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 906f64615de7..c9ec1d7e99fb 100644 > --- a/OvmfPkg/PlatformPei/Platform.c > +++ b/OvmfPkg/PlatformPei/Platform.c > @@ -321,6 +321,50 @@ 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__)); FreePages (NewBase)? Otherwise: Reviewed-by: Philippe Mathieu-Daude > + return; > + } > + > + DEBUG (( > + DEBUG_INFO, > + "%a: fdt at 0x%x (size %d)\n", > + __FUNCTION__, > + NewBase, > + FdtSize > + )); > + *FdtHobData = (UINTN)NewBase; > +} > + > VOID > MiscInitialization ( > VOID > @@ -368,6 +412,7 @@ MiscInitialization ( > break; > case 0xffff: /* microvm */ > DEBUG ((DEBUG_INFO, "%a: microvm\n", __FUNCTION__)); > + MicrovmInitialization (); > PcdStatus = PcdSet16S ( > PcdOvmfHostBridgePciDevId, > MICROVM_PSEUDO_DEVICE_ID >