From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: redhat.com, ip: 209.132.183.28, mailfrom: lersek@redhat.com) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by groups.io with SMTP; Fri, 16 Aug 2019 11:54:27 -0700 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 84D0F859FB; Fri, 16 Aug 2019 18:54:26 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-63.ams2.redhat.com [10.36.116.63]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5F9C1001959; Fri, 16 Aug 2019 18:54:24 +0000 (UTC) Subject: Re: [edk2-devel] [Patch] MdeModulePkg DxeCore: Fix for missing MAT update To: "Gao, Liming" , "devel@edk2.groups.io" , "Kinney, Michael D" Cc: Mike Turner , "Wang, Jian J" , "Wu, Hao A" , "Bi, Dandan" References: <20190810141022.18228-1-liming.gao@intel.com> <66665886-fff1-248a-77e5-6b8fb6966f86@redhat.com> <96f6e8a3-7049-478a-a8f2-4389c06f0e12@redhat.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14E4D0EE7@SHSMSX104.ccr.corp.intel.com> <28d0e7fa-35c8-ca4b-a476-3afdd5d1c3a2@redhat.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14E4D101F@SHSMSX104.ccr.corp.intel.com> <684cdd50-88d7-500e-ca56-c59f11e0e615@redhat.com> <4A89E2EF3DFEDB4C8BFDE51014F606A14E4D28C7@SHSMSX104.ccr.corp.intel.com> From: "Laszlo Ersek" Message-ID: <5e9663fa-7f62-d510-ae4a-389554a578e8@redhat.com> Date: Fri, 16 Aug 2019 20:54:23 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <4A89E2EF3DFEDB4C8BFDE51014F606A14E4D28C7@SHSMSX104.ccr.corp.intel.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Fri, 16 Aug 2019 18:54:26 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit On 08/16/19 17:24, Gao, Liming wrote: > Laszlo: > >> -----Original Message----- >> From: devel@edk2.groups.io [mailto:devel@edk2.groups.io] On Behalf Of >> Laszlo Ersek >> Sent: Friday, August 16, 2019 11:18 PM >> To: Gao, Liming ; devel@edk2.groups.io; Kinney, >> Michael D >> Cc: Mike Turner ; Wang, Jian J >> ; Wu, Hao A ; Bi, Dandan >> >> Subject: Re: [edk2-devel] [Patch] MdeModulePkg DxeCore: Fix for >> missing MAT update >> >> On 08/14/19 17:55, Gao, Liming wrote: >> >>> If Platform PEIM doesn't build HOB, DxeIpl will not build HOB, >> >> My reading of the code is the opposite. If the platform PEIM does not >> build the HOB, then the DXE IPL PEIM will attempt to build the HOB, >> from the UEFI variable. >> >> At commit caa7d3a896f6, in file >> "MdeModulePkg/Core/DxeIplPeim/DxeLoad.c", function DxeLoadCore(), we >> have: >> >> 363 if (GetFirstGuidHob ((CONST EFI_GUID *)&gEfiMemoryTypeInformationGuid) == NULL) { >> 364 // >> 365 // Don't build GuidHob if GuidHob has been installed. >> 366 // >> 367 Status = PeiServicesLocatePpi ( >> 368 &gEfiPeiReadOnlyVariable2PpiGuid, >> 369 0, >> 370 NULL, >> 371 (VOID **)&Variable >> 372 ); >> 373 if (!EFI_ERROR (Status)) { >> 374 DataSize = sizeof (MemoryData); >> 375 Status = Variable->GetVariable ( >> 376 Variable, >> 377 EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME, >> 378 &gEfiMemoryTypeInformationGuid, >> 379 NULL, >> 380 &DataSize, >> 381 &MemoryData >> 382 ); >> 383 if (!EFI_ERROR (Status) && ValidateMemoryTypeInfoVariable(MemoryData, DataSize)) { > > Only when this variable exists, Hob will be built. But, if no PEIM > builds Hob, BDS will not set the variable. > So, there is still no HOB. So how is a platform supposed to enable this feature? If PlatformPei never builds the HOB, the variable will never be created, so the DXE IPL PEIM will also not build the HOB, ever. If PlatformPei builds the HOB with static data, then BDS will set (update) the variable, yes, but the DXE IPL PEIM will ignore the variable, because PlatformPei already built the HOB. So... Is PlatformPei supposed to use the Variable PPI, check if the variable exists, and create the static HOB only if the variable is absent? ... Ugh, wait. I've actually implemented this for OVMF almost 2 years ago! And the answer to my question is "yes": https://bugzilla.tianocore.org/show_bug.cgi?id=386 https://lists.01.org/pipermail/edk2-devel/2017-November/018312.html See the OnReadOnlyVariable2Available() function: + // + // Check if the "MemoryTypeInformation" variable exists, in the + // gEfiMemoryTypeInformationGuid namespace. + // + ReadOnlyVariable2 = Ppi; + DataSize = 0; + Status = ReadOnlyVariable2->GetVariable ( + ReadOnlyVariable2, + EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME, + &gEfiMemoryTypeInformationGuid, + NULL, + &DataSize, + NULL + ); + if (Status == EFI_BUFFER_TOO_SMALL) { + // + // The variable exists; the DXE IPL PEIM will build the HOB from it. + // + return EFI_SUCCESS; + } + // + // Install the default memory type information HOB. + // + BuildMemTypeInfoHob (); Apologies for forgetting about this; you are right. Too bad my work for TianoCore#386 was rejected. :( Thanks Laszlo