If PcdUse1GPageTable is not enabled restrict the physical address space
used to 1TB, to limit the amount of memory needed for identity mapping
page tables.
The same already happens in case the processor has no support for
gigabyte pages.
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf | 1 +
OvmfPkg/Library/PlatformInitLib/MemDetect.c | 5 +++++
2 files changed, 6 insertions(+)
diff --git a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf
index 86a82ad3e084..5a79d95b689c 100644
--- a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf
+++ b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf
@@ -58,6 +58,7 @@ [LibraryClasses.X64]
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress
+ gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable
[FixedPcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase
diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
index acf90b4e93fd..1102b00ecbf0 100644
--- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c
+++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c
@@ -663,6 +663,11 @@ PlatformAddressWidthFromCpuid (
PhysBits = 40;
}
+ if (!FixedPcdGetBool (PcdUse1GPageTable) && (PhysBits > 40)) {
+ DEBUG ((DEBUG_INFO, "%a: limit PhysBits to 40 (PcdUse1GPageTable is false)\n", __func__));
+ PhysBits = 40;
+ }
+
PlatformInfoHob->PhysMemAddressWidth = PhysBits;
PlatformInfoHob->FirstNonAddress = LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth);
}
--
2.40.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#104970): https://edk2.groups.io/g/devel/message/104970
Mute This Topic: https://groups.io/mt/98944978/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
On Wed, 17 May 2023 at 12:24, Gerd Hoffmann <kraxel@redhat.com> wrote: > > If PcdUse1GPageTable is not enabled restrict the physical address space > used to 1TB, to limit the amount of memory needed for identity mapping > page tables. > > The same already happens in case the processor has no support for > gigabyte pages. > Apologies for the noob question, but does this mean EDK2 maps the entire address space 1:1, not just the region that as any DRAM in it? > Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> > --- > OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf | 1 + > OvmfPkg/Library/PlatformInitLib/MemDetect.c | 5 +++++ > 2 files changed, 6 insertions(+) > > diff --git a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf > index 86a82ad3e084..5a79d95b689c 100644 > --- a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf > +++ b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf > @@ -58,6 +58,7 @@ [LibraryClasses.X64] > > [Pcd] > gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress > + gEfiMdeModulePkgTokenSpaceGuid.PcdUse1GPageTable > > [FixedPcd] > gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase > diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c > index acf90b4e93fd..1102b00ecbf0 100644 > --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c > +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c > @@ -663,6 +663,11 @@ PlatformAddressWidthFromCpuid ( > PhysBits = 40; > } > > + if (!FixedPcdGetBool (PcdUse1GPageTable) && (PhysBits > 40)) { > + DEBUG ((DEBUG_INFO, "%a: limit PhysBits to 40 (PcdUse1GPageTable is false)\n", __func__)); > + PhysBits = 40; > + } > + > PlatformInfoHob->PhysMemAddressWidth = PhysBits; > PlatformInfoHob->FirstNonAddress = LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth); > } > -- > 2.40.1 > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#105110): https://edk2.groups.io/g/devel/message/105110 Mute This Topic: https://groups.io/mt/98944978/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
On Mon, May 22, 2023 at 12:37:51PM +0200, Ard Biesheuvel wrote: > On Wed, 17 May 2023 at 12:24, Gerd Hoffmann <kraxel@redhat.com> wrote: > > > > If PcdUse1GPageTable is not enabled restrict the physical address space > > used to 1TB, to limit the amount of memory needed for identity mapping > > page tables. > > > > The same already happens in case the processor has no support for > > gigabyte pages. > > > > Apologies for the noob question, but does this mean EDK2 maps the > entire address space 1:1, not just the region that as any DRAM in it? I just saw memory usage and boot time go up. Didn't check whenever that was just the 64-bit mmio area (which recent ovmf scales up with the available address space) or all address space. take care, Gerd -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#105113): https://edk2.groups.io/g/devel/message/105113 Mute This Topic: https://groups.io/mt/98944978/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=-=-=-=-=-=-=-=-=-=-=-
© 2016 - 2023 Red Hat, Inc.