From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.groups.io with SMTP id smtpd.web11.11242.1613753270579275576 for ; Fri, 19 Feb 2021 08:47:50 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=KWaUYTCq; spf=pass (domain: redhat.com, ip: 63.128.21.124, mailfrom: lersek@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613753269; 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=mZVMSfVT5dHyMiJujI7vsD3+Crn15QXAvNk4CwCZDMc=; b=KWaUYTCq9HeSDmN0ekNdk3rkCA3MYpCiZ7UIAFGToqpk+tt4Ol2zcIXe8yXikvkRmHiNsf Ii7zX8MVw1XKDFvvaFfxxcw48qFdfpuyfyP+psVjWRnNJTW7JUa8lapBMp+paDAV24QboN 3hhIf2hHX6USmei+wS6TY913qCY6qnk= 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-228-tNitUbHuMY64QfeJ6gorqg-1; Fri, 19 Feb 2021 11:47:44 -0500 X-MC-Unique: tNitUbHuMY64QfeJ6gorqg-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 55300C28A; Fri, 19 Feb 2021 16:47:43 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-113-87.ams2.redhat.com [10.36.113.87]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B2B25D9C2; Fri, 19 Feb 2021 16:47:41 +0000 (UTC) Subject: Re: [edk2-devel] [PATCH 1/2] MdeModulePkg/Core/Dxe: Allow to force runtime allocations at separate range To: Alexander Graf , "Kinney, Michael D" , "devel@edk2.groups.io" Cc: Leif Lindholm , Ard Biesheuvel , "Justen, Jordan L" , "Woodhouse, David" , Hendrik Borghorst References: <20210218200953.20943-1-graf@amazon.com> <20210218200953.20943-2-graf@amazon.com> <5efeedb0-d0de-8428-3a88-190ccf02707e@amazon.com> From: "Laszlo Ersek" Message-ID: <51844c5a-aedf-9a0a-10e5-7a06b2073a8c@redhat.com> Date: Fri, 19 Feb 2021 17:47:40 +0100 MIME-Version: 1.0 In-Reply-To: <5efeedb0-d0de-8428-3a88-190ccf02707e@amazon.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=lersek@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Hello Alex, On 02/19/21 15:10, Alexander Graf wrote: > Hi Mike, > > Thanks a lot for the pointer! In my case, the defaults for the > preallocated memory regions was just not big enough to prevent > hibernation breakage. I increased them now as intended and everything > works like a charm. The most recent related OVMF commits are, for reference (merged on 2020-May-08): 1 2c06e76bba06 OvmfPkg/PlatformPei: don't track BS Code/Data in default MemTypeInfo HOB 2 356b96b3a2dc OvmfPkg/PlatformPei: rewrite MemTypeInfo HOB production logic 3 8db87f98357b OvmfPkg/PlatformPei: extract memory type info defaults to PCDs 4 7b6327ff03bb OvmfPkg/PlatformPei: increase memory type info defaults The commit messages hopefully explain how OVMF utilizes the pattern described by Mike, and what PCDs to tweak if you need larger bins. If you think your PCD updates are upstreamable, please feel free to submit those as a patch! Thanks! Laszlo > > Please ignore this patch set, the existing mechanism is definitely > superior :) > > > Thanks! > > Alex > > > On 18.02.21 23:28, Kinney, Michael D wrote: >> >> Hi Alex, >> >> This feature is already available from the DXE Core using the >> MemoryTypeInformation and was >> specifically added to support hibernation use case. >> >> There is an optional HOB that is passed into DXE Core that can provide >> bin sizes for any supported memory types.  Not just Runtime and ACPI. >> >> This feature can use a fixed HOB or use a dynamic HOB from a UEFI >> Variable, so that changes in the memory usage of >> the critical memory types for hibernation can be tracked and stored in >> the UEFI Variables and be used to populate >> the HOB.  It is a platform choice to use fixed or dynamic HOB. >> >> https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Include/Guid/MemoryTypeInformation.h >> >> >> https://github.com/tianocore/edk2/blob/978b9d511f5b9cb7bc5b09749f86c39bec51525d/MdeModulePkg/Core/Dxe/Gcd/Gcd.c#L2233 >> >> >> https://github.com/tianocore/edk2/blob/978b9d511f5b9cb7bc5b09749f86c39bec51525d/MdeModulePkg/Core/Dxe/Mem/Page.c#L45 >> >> >> The DXE Core use the HOB to pre-allocate bins for the memory types and >> do allocations from those bins. >> >> The UEFI Memory Map provides an entry for the entire bin (no just the >> allocated space), so small >> differences in allocations from boot to boot do not change the UEFI >> memory map.  This also >> reduces the total number of memory map entries in the UEFI memory map. >> >> If dynamic HOB is used, then the Boot Manager compares the actual >> memory usage to the HOB. >> If the usage is larger or smaller by more than a threshold, then the >> UEFI Variable is >> updated.  The platform has the choice to reboot or continue booting >> after this UEIF Variable >> update based on a PCD.  The reboot can help make sure the first boot >> to the OS has the right >> bin sizes to support future hibernate boot flows.