* [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit
@ 2018-11-26 22:37 Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size Ard Biesheuvel
` (13 more replies)
0 siblings, 14 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:37 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
The ArmVirtQemu targets currently limit the size of the IPA space to
40 bits because that is all what KVM supports. However, this is about
to change, and so we need to update the code if we want to ensure that
our UEFI firmware builds can keep running on systems that set values
other than 40 (which could be > 40 or < 40)
So refactor the way we deal with this limit, both for bare metal and for
virtual targets, so that
a) the range of the GCD memory map is based directly on the CPU's PA range
b) the range of the 1:1 mapping in the page tables is based on the CPU's PA
range (unless it exceeds what the architecture permits for 4k pages)
c) PcdPrePiCpuMemorySize is no longer needed, and can be removed.
Patch #1 introduces ARM_MMU_IDMAP_RANGE and ArmGetPhysicalAddressBits ()
in ArmLib.
Patch #2 updates the virt targets to replace a local definition of
ArmGetPhysicalAddressBits () with the new ArmLib implementation.
Patch #3 updates the ARM MMU code so that the maximum size of the
virtual address space is based on ArmGetPhysicalAddressBits () or
ARM_MMU_IDMAP_RANGE (whichever produces the smallest result), and
no longer on PcdPrePiCpuMemorySize
Patch #4 - #8 update all invocations of BuildCpuHob() so that the size
of the GCD memory map is based on the CPU's capabilities (and no longer
on PcdPrePiCpuMemorySize)
Patch #9 and #10 drop some unused PCD references from .inf files.
Patch #11 updates QemuVirtMemInfoLib to no longer take PcdPrePiCpuMemorySize
into account.
Patch #12 removes all overrides of PcdPrePiCpuMemorySize
Patch #13 (which should only be merged after edk2-platforms has been updated
as well) removes PcdPrePiCpuMemorySize entirely.
Changes since v1:
- add a define ARM_MMU_IDMAP_RANGE that describes the maximum size of
the virtual address space when running with 4k pages, which may
deviate from the maximum size when running under the OS
- to avoid having to reason in complicated ways between ARM_MMU_IDMAP_RANGE,
the number of physical address bits supported by the CPU and the size
of the GCD memory map, just drop PcdPrePiCpuMemorySize entirely
Note that I dropped a couple of acks (from Laszlo and Philippe) due to the
fact that the code looks rather different now.
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Eric Auger <eric.auger@redhat.com>
Cc: Andrew Jones <drjones@redhat.com>
Cc: Philippe Mathieu-Daude <philmd@redhat.com>
Cc: Julien Grall <julien.grall@linaro.org>
Ard Biesheuvel (13):
ArmPkg/ArmLib: add support for reading the max physical address space
size
ArmVirtPkg: refactor reading of the physical address space size
ArmPkg/ArmMmuLib: take the CPU supported maximum PA space into account
ArmPkg/CpuPei: base GCD memory space size on CPU's PA range
ArmPlatformPkg/PrePi: base GCD memory space size on CPU's PA range
ArmVirtPkg/PrePi: base GCD memory space size on CPU's PA range
BeagleBoardPkg/PrePi: base GCD memory space size on CPU's PA range
EmbeddedPkg/PrePiHobLib: base GCD memory space size on CPU's PA range
ArmPlatformPkg/PlatformPei: drop unused PCD references
EmbeddedPkg/PrePiLib: drop unused PCD reference
ArmVirtPkg/QemuVirtMemInfoLib: ignore PcdPrePiCpuMemorySize
ArmVirtPkg: drop PcdPrePiCpuMemorySize assignments from all platforms
EmbeddedPkg/EmbeddedPkg.dec: drop PcdPrePiCpuMemorySize declarations
EmbeddedPkg/EmbeddedPkg.dec | 4 --
ArmVirtPkg/ArmVirt.dsc.inc | 3 --
ArmVirtPkg/ArmVirtQemu.dsc | 4 --
ArmVirtPkg/ArmVirtQemuKernel.dsc | 4 --
ArmPkg/Drivers/CpuPei/CpuPei.inf | 1 -
ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf | 3 --
ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf | 3 --
ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf | 3 --
ArmPlatformPkg/PlatformPei/PlatformPeim.inf | 3 --
ArmPlatformPkg/PrePi/PeiMPCore.inf | 1 -
ArmPlatformPkg/PrePi/PeiUniCore.inf | 1 -
.../QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf | 7 ----
.../QemuVirtMemInfoPeiLib.inf | 7 ----
.../XenVirtMemInfoLib/XenVirtMemInfoLib.inf | 6 ---
.../PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 -
BeagleBoardPkg/PrePi/PeiUniCore.inf | 1 -
.../Library/PrePiHobLib/PrePiHobLib.inf | 1 -
EmbeddedPkg/Library/PrePiLib/PrePiLib.inf | 1 -
ArmPkg/Include/Library/ArmLib.h | 17 ++++++++
.../Include/Library/ArmVirtMemInfoLib.h | 1 +
ArmPkg/Drivers/CpuPei/CpuPei.c | 2 +-
.../Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 11 +++++-
ArmPlatformPkg/PrePi/PrePi.c | 2 +-
.../ArmVirtMemoryInitPeiLib.c | 5 ++-
.../QemuVirtMemInfoLib/QemuVirtMemInfoLib.c | 11 +-----
.../XenVirtMemInfoLib/XenVirtMemInfoLib.c | 8 +---
ArmVirtPkg/PrePi/PrePi.c | 2 +-
BeagleBoardPkg/PrePi/PrePi.c | 2 +-
EmbeddedPkg/Library/PrePiHobLib/Hob.c | 2 +-
ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S | 16 ++++++++
ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S | 8 ++++
.../QemuVirtMemInfoLib/AArch64/PhysAddrTop.S | 39 -------------------
.../QemuVirtMemInfoLib/Arm/PhysAddrTop.S | 24 ------------
.../XenVirtMemInfoLib/AArch64/PhysAddrTop.S | 39 -------------------
.../XenVirtMemInfoLib/Arm/PhysAddrTop.S | 24 ------------
35 files changed, 64 insertions(+), 203 deletions(-)
delete mode 100644 ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S
delete mode 100644 ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S
delete mode 100644 ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S
delete mode 100644 ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S
--
2.19.1
^ permalink raw reply [flat|nested] 22+ messages in thread
* [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
@ 2018-11-26 22:37 ` Ard Biesheuvel
2018-11-26 22:43 ` Philippe Mathieu-Daudé
` (2 more replies)
2018-11-26 22:37 ` [PATCH v2 02/13] ArmVirtPkg: refactor reading of the " Ard Biesheuvel
` (12 subsequent siblings)
13 siblings, 3 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:37 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
Add a helper function that returns the maximum physical address space
size as supported by the current CPU.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPkg/Include/Library/ArmLib.h | 17 +++++++++++++++++
ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S | 16 ++++++++++++++++
ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S | 8 ++++++++
3 files changed, 41 insertions(+)
diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h
index ffda50e9d767..b22879fe6e94 100644
--- a/ArmPkg/Include/Library/ArmLib.h
+++ b/ArmPkg/Include/Library/ArmLib.h
@@ -29,6 +29,17 @@
#define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | \
EFI_MEMORY_WT | EFI_MEMORY_WB | \
EFI_MEMORY_UCE)
+//
+// ARM_MMU_IDMAP_RANGE defines the maximum size of the identity mapping
+// that covers the entire address space when running in UEFI. This is
+// limited to what can architecturally be mapped using a 4 KB granule,
+// even if the hardware is capable of mapping more using larger pages.
+//
+#ifdef MDE_CPU_ARM
+#define ARM_MMU_IDMAP_RANGE (1ULL << 32)
+#else
+#define ARM_MMU_IDMAP_RANGE (1ULL << 48)
+#endif
/**
* The UEFI firmware must not use the ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_* attributes.
@@ -733,4 +744,10 @@ ArmWriteCntvOff (
UINT64 Val
);
+UINTN
+EFIAPI
+ArmGetPhysicalAddressBits (
+ VOID
+ );
+
#endif // __ARM_LIB__
diff --git a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
index 1ef2f61f5979..7332601241aa 100644
--- a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
+++ b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
@@ -196,4 +196,20 @@ ASM_FUNC(ArmWriteSctlr)
3:msr sctlr_el3, x0
4:ret
+ASM_FUNC(ArmGetPhysicalAddressBits)
+ mrs x0, id_aa64mmfr0_el1
+ adr x1, .LPARanges
+ and x0, x0, #7
+ ldrb w0, [x1, x0]
+ ret
+
+//
+// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
+// physical address space support on this CPU:
+// 0 == 32 bits, 1 == 36 bits, etc etc
+// 6 and 7 are reserved
+//
+.LPARanges:
+ .byte 32, 36, 40, 42, 44, 48, 52, -1
+
ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
index f2a517671f0a..f2f3c9a25991 100644
--- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
+++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
@@ -165,4 +165,12 @@ ASM_FUNC(ArmWriteCpuActlr)
isb
bx lr
+ASM_FUNC (ArmGetPhysicalAddressBits)
+ mrc p15, 0, r0, c0, c1, 4 // MMFR0
+ and r0, r0, #0xf // VMSA [3:0]
+ cmp r0, #5 // >5 implies LPAE support
+ movlt r0, #32 // 32 bits if no LPAE
+ movge r0, #40 // 40 bits if LPAE
+ bx lr
+
ASM_FUNCTION_REMOVE_IF_UNREFERENCED
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 02/13] ArmVirtPkg: refactor reading of the physical address space size
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size Ard Biesheuvel
@ 2018-11-26 22:37 ` Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 03/13] ArmPkg/ArmMmuLib: take the CPU supported maximum PA space into account Ard Biesheuvel
` (11 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:37 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
In preparation of dropping the hardcoded 40-bit limit on the physical
address space when running under virtualization, let's refactor the
code a bit so we read the hardware limit in a single place.
Note that the hardware capabilities may exceed what the architecture
permits when using 4 KB pages, so we need to take ARM_MMU_IDMAP_RANGE
into account as well.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf | 6 ---
ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf | 6 ---
ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf | 6 ---
ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h | 1 +
ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c | 5 ++-
ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c | 8 +---
ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c | 8 +---
ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S | 39 --------------------
ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S | 24 ------------
ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S | 39 --------------------
ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S | 24 ------------
11 files changed, 9 insertions(+), 157 deletions(-)
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
index c72a97f9e78a..f2c461e3b55a 100644
--- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
+++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
@@ -24,12 +24,6 @@ [Defines]
[Sources]
QemuVirtMemInfoLib.c
-[Sources.ARM]
- Arm/PhysAddrTop.S
-
-[Sources.AARCH64]
- AArch64/PhysAddrTop.S
-
[Packages]
ArmPkg/ArmPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf
index e4032d3efb53..f54fb51ee1d4 100644
--- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf
+++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf
@@ -26,12 +26,6 @@ [Sources]
QemuVirtMemInfoLib.c
QemuVirtMemInfoPeiLibConstructor.c
-[Sources.ARM]
- Arm/PhysAddrTop.S
-
-[Sources.AARCH64]
- AArch64/PhysAddrTop.S
-
[Packages]
ArmPkg/ArmPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf
index cd4c805a4db9..ae107810e927 100644
--- a/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf
+++ b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.inf
@@ -24,12 +24,6 @@ [Defines]
[Sources]
XenVirtMemInfoLib.c
-[Sources.ARM]
- Arm/PhysAddrTop.S
-
-[Sources.AARCH64]
- AArch64/PhysAddrTop.S
-
[Packages]
ArmPkg/ArmPkg.dec
ArmVirtPkg/ArmVirtPkg.dec
diff --git a/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
index bdf1c513bc6d..15562b35c730 100644
--- a/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
+++ b/ArmVirtPkg/Include/Library/ArmVirtMemInfoLib.h
@@ -35,6 +35,7 @@
VOID
EFIAPI
ArmVirtGetMemoryMap (
+ IN EFI_PHYSICAL_ADDRESS TopOfAddressSpace,
OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
);
diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
index 05afd1282422..f8c8af987d20 100644
--- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
+++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
@@ -15,6 +15,7 @@
#include <PiPei.h>
+#include <Library/ArmLib.h>
#include <Library/ArmMmuLib.h>
#include <Library/ArmVirtMemInfoLib.h>
#include <Library/DebugLib.h>
@@ -39,7 +40,9 @@ InitMmu (
RETURN_STATUS Status;
// Get Virtual Memory Map from the Platform Library
- ArmVirtGetMemoryMap (&MemoryTable);
+ ArmVirtGetMemoryMap (MIN (LShiftU64 (1ULL, ArmGetPhysicalAddressBits ()),
+ ARM_MMU_IDMAP_RANGE),
+ &MemoryTable);
//Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in
// DRAM (even at the top of DRAM as it is the first permanent memory allocation)
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
index 760bcc169cf4..a80454c4802e 100644
--- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
+++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
@@ -21,11 +21,6 @@
// Number of Virtual Memory Map Descriptors
#define MAX_VIRTUAL_MEMORY_MAP_DESCRIPTORS 5
-EFI_PHYSICAL_ADDRESS
-ArmGetPhysAddrTop (
- VOID
- );
-
/**
Return the Virtual Memory Map of your platform
@@ -41,6 +36,7 @@ ArmGetPhysAddrTop (
**/
VOID
ArmVirtGetMemoryMap (
+ IN EFI_PHYSICAL_ADDRESS TopOfAddressSpace,
OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
)
{
@@ -80,7 +76,7 @@ ArmVirtGetMemoryMap (
// Peripheral space after DRAM
TopOfMemory = MIN (1ULL << FixedPcdGet8 (PcdPrePiCpuMemorySize),
- ArmGetPhysAddrTop ());
+ TopOfAddressSpace);
VirtualMemoryTable[2].PhysicalBase = VirtualMemoryTable[0].Length + VirtualMemoryTable[1].Length;
VirtualMemoryTable[2].VirtualBase = VirtualMemoryTable[2].PhysicalBase;
VirtualMemoryTable[2].Length = TopOfMemory -
diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c
index 88ff3167cbfd..3d4e3e38c3f1 100644
--- a/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c
+++ b/ArmVirtPkg/Library/XenVirtMemInfoLib/XenVirtMemInfoLib.c
@@ -18,11 +18,6 @@
STATIC ARM_MEMORY_REGION_DESCRIPTOR mVirtualMemoryTable[2];
-EFI_PHYSICAL_ADDRESS
-ArmGetPhysAddrTop (
- VOID
- );
-
/**
Return the Virtual Memory Map of your platform
@@ -39,6 +34,7 @@ ArmGetPhysAddrTop (
VOID
EFIAPI
ArmVirtGetMemoryMap (
+ IN EFI_PHYSICAL_ADDRESS TopOfAddressSpace,
OUT ARM_MEMORY_REGION_DESCRIPTOR **VirtualMemoryMap
)
{
@@ -51,7 +47,7 @@ ArmVirtGetMemoryMap (
//
mVirtualMemoryTable[0].PhysicalBase = 0x0;
mVirtualMemoryTable[0].VirtualBase = 0x0;
- mVirtualMemoryTable[0].Length = ArmGetPhysAddrTop ();
+ mVirtualMemoryTable[0].Length = TopOfAddressSpace;
mVirtualMemoryTable[0].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
mVirtualMemoryTable[1].PhysicalBase = 0x0;
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S b/ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S
deleted file mode 100644
index a1f6a194d59b..000000000000
--- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/AArch64/PhysAddrTop.S
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-# Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-
-#include <AsmMacroIoLibV8.h>
-
-//EFI_PHYSICAL_ADDRESS
-//GetPhysAddrTop (
-// VOID
-// );
-ASM_FUNC(ArmGetPhysAddrTop)
- mrs x0, id_aa64mmfr0_el1
- adr x1, .LPARanges
- and x0, x0, #7
- ldrb w1, [x1, x0]
- mov x0, #1
- lsl x0, x0, x1
- ret
-
-//
-// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
-// physical address space support on this CPU:
-// 0 == 32 bits, 1 == 36 bits, etc etc
-// 6 and 7 are reserved
-//
-.LPARanges:
- .byte 32, 36, 40, 42, 44, 48, -1, -1
-
-ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S b/ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S
deleted file mode 100644
index 9cd81529fb3d..000000000000
--- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/Arm/PhysAddrTop.S
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-
-#include <AsmMacroIoLib.h>
-
-//EFI_PHYSICAL_ADDRESS
-//GetPhysAddrTop (
-// VOID
-// );
-ASM_FUNC(ArmGetPhysAddrTop)
- mov r0, #0x00000000
- mov r1, #0x10000
- bx lr
diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S b/ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S
deleted file mode 100644
index a1f6a194d59b..000000000000
--- a/ArmVirtPkg/Library/XenVirtMemInfoLib/AArch64/PhysAddrTop.S
+++ /dev/null
@@ -1,39 +0,0 @@
-#
-# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-# Copyright (c) 2016-2017, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-
-#include <AsmMacroIoLibV8.h>
-
-//EFI_PHYSICAL_ADDRESS
-//GetPhysAddrTop (
-// VOID
-// );
-ASM_FUNC(ArmGetPhysAddrTop)
- mrs x0, id_aa64mmfr0_el1
- adr x1, .LPARanges
- and x0, x0, #7
- ldrb w1, [x1, x0]
- mov x0, #1
- lsl x0, x0, x1
- ret
-
-//
-// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
-// physical address space support on this CPU:
-// 0 == 32 bits, 1 == 36 bits, etc etc
-// 6 and 7 are reserved
-//
-.LPARanges:
- .byte 32, 36, 40, 42, 44, 48, -1, -1
-
-ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S b/ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S
deleted file mode 100644
index 9cd81529fb3d..000000000000
--- a/ArmVirtPkg/Library/XenVirtMemInfoLib/Arm/PhysAddrTop.S
+++ /dev/null
@@ -1,24 +0,0 @@
-#
-# Copyright (c) 2011-2013, ARM Limited. All rights reserved.
-# Copyright (c) 2014-2017, Linaro Limited. All rights reserved.
-#
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-#
-
-#include <AsmMacroIoLib.h>
-
-//EFI_PHYSICAL_ADDRESS
-//GetPhysAddrTop (
-// VOID
-// );
-ASM_FUNC(ArmGetPhysAddrTop)
- mov r0, #0x00000000
- mov r1, #0x10000
- bx lr
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 03/13] ArmPkg/ArmMmuLib: take the CPU supported maximum PA space into account
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 02/13] ArmVirtPkg: refactor reading of the " Ard Biesheuvel
@ 2018-11-26 22:37 ` Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 04/13] ArmPkg/CpuPei: base GCD memory space size on CPU's PA range Ard Biesheuvel
` (10 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:37 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
In preparation of dropping PcdPrePiCpuMemorySize entirely, base the
maximum size of the identity map on the capabilities of the CPU.
Since that may exceed what is architecturally permitted when using
4 KB pages, take ARM_MMU_IDMAP_RANGE into account as well.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf | 3 ---
ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf | 3 ---
ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 11 +++++++++--
3 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
index b9f264de8d26..246963361e45 100644
--- a/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
+++ b/ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
@@ -40,8 +40,5 @@ [LibraryClasses]
CacheMaintenanceLib
MemoryAllocationLib
-[Pcd.AARCH64]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
-
[Pcd.ARM]
gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride
diff --git a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
index ecf13f790734..f689c193b862 100644
--- a/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
+++ b/ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
@@ -35,6 +35,3 @@ [LibraryClasses]
ArmLib
CacheMaintenanceLib
MemoryAllocationLib
-
-[Pcd.AARCH64]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
index 4b62ecb6a476..c1c72358ec8d 100644
--- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
+++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c
@@ -604,8 +604,15 @@ ArmConfigureMmu (
return EFI_INVALID_PARAMETER;
}
- // Cover the entire GCD memory space
- MaxAddress = (1UL << PcdGet8 (PcdPrePiCpuMemorySize)) - 1;
+ //
+ // Limit the virtual address space to what we can actually use: UEFI
+ // mandates a 1:1 mapping, so no point in making the virtual address
+ // space larger than the physical address space. We also have to take
+ // into account the architectural limitations that result from UEFI's
+ // use of 4 KB pages.
+ //
+ MaxAddress = MIN (LShiftU64 (1ULL, ArmGetPhysicalAddressBits ()),
+ ARM_MMU_IDMAP_RANGE) - 1;
// Lookup the Table Level to get the information
LookupAddresstoRootTable (MaxAddress, &T0SZ, &RootTableEntryCount);
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 04/13] ArmPkg/CpuPei: base GCD memory space size on CPU's PA range
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
` (2 preceding siblings ...)
2018-11-26 22:37 ` [PATCH v2 03/13] ArmPkg/ArmMmuLib: take the CPU supported maximum PA space into account Ard Biesheuvel
@ 2018-11-26 22:37 ` Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 05/13] ArmPlatformPkg/PrePi: " Ard Biesheuvel
` (9 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:37 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
Derive the size of the GCD memory space map directly from the CPU's
information registers rather than from the PcdPrePiCpuMemorySize PCD,
which will be removed.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPkg/Drivers/CpuPei/CpuPei.inf | 1 -
ArmPkg/Drivers/CpuPei/CpuPei.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/ArmPkg/Drivers/CpuPei/CpuPei.inf b/ArmPkg/Drivers/CpuPei/CpuPei.inf
index eafccd600983..dcea012fd8f9 100644
--- a/ArmPkg/Drivers/CpuPei/CpuPei.inf
+++ b/ArmPkg/Drivers/CpuPei/CpuPei.inf
@@ -50,7 +50,6 @@ [Guids]
gArmMpCoreInfoGuid
[FixedPcd]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
[Depex]
diff --git a/ArmPkg/Drivers/CpuPei/CpuPei.c b/ArmPkg/Drivers/CpuPei/CpuPei.c
index d54f42acfcc8..e63519ff6481 100644
--- a/ArmPkg/Drivers/CpuPei/CpuPei.c
+++ b/ArmPkg/Drivers/CpuPei/CpuPei.c
@@ -73,7 +73,7 @@ InitializeCpuPeim (
ArmEnableBranchPrediction ();
// Publish the CPU memory and io spaces sizes
- BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
+ BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));
// Only MP Core platform need to produce gArmMpCoreInfoPpiGuid
Status = PeiServicesLocatePpi (&gArmMpCoreInfoPpiGuid, 0, NULL, (VOID**)&ArmMpCoreInfoPpi);
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 05/13] ArmPlatformPkg/PrePi: base GCD memory space size on CPU's PA range
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
` (3 preceding siblings ...)
2018-11-26 22:37 ` [PATCH v2 04/13] ArmPkg/CpuPei: base GCD memory space size on CPU's PA range Ard Biesheuvel
@ 2018-11-26 22:37 ` Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 06/13] ArmVirtPkg/PrePi: " Ard Biesheuvel
` (8 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:37 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
Derive the size of the GCD memory space map directly from the CPU's
information registers rather than from the PcdPrePiCpuMemorySize PCD,
which will be removed.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPlatformPkg/PrePi/PeiMPCore.inf | 1 -
ArmPlatformPkg/PrePi/PeiUniCore.inf | 1 -
ArmPlatformPkg/PrePi/PrePi.c | 2 +-
3 files changed, 1 insertion(+), 3 deletions(-)
diff --git a/ArmPlatformPkg/PrePi/PeiMPCore.inf b/ArmPlatformPkg/PrePi/PeiMPCore.inf
index 242b03175536..7e2ad6fc483d 100644
--- a/ArmPlatformPkg/PrePi/PeiMPCore.inf
+++ b/ArmPlatformPkg/PrePi/PeiMPCore.inf
@@ -97,7 +97,6 @@ [FixedPcd]
gArmPlatformTokenSpaceGuid.PcdCoreCount
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
diff --git a/ArmPlatformPkg/PrePi/PeiUniCore.inf b/ArmPlatformPkg/PrePi/PeiUniCore.inf
index a45cdef4ed91..26328b7e8f67 100644
--- a/ArmPlatformPkg/PrePi/PeiUniCore.inf
+++ b/ArmPlatformPkg/PrePi/PeiUniCore.inf
@@ -90,7 +90,6 @@ [FixedPcd]
gArmPlatformTokenSpaceGuid.PcdCoreCount
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
diff --git a/ArmPlatformPkg/PrePi/PrePi.c b/ArmPlatformPkg/PrePi/PrePi.c
index 02cff7ddc204..245bdded1eb3 100644
--- a/ArmPlatformPkg/PrePi/PrePi.c
+++ b/ArmPlatformPkg/PrePi/PrePi.c
@@ -115,7 +115,7 @@ PrePiMain (
BuildStackHob (StacksBase, StacksSize);
//TODO: Call CpuPei as a library
- BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
+ BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));
if (ArmIsMpCore ()) {
// Only MP Core platform need to produce gArmMpCoreInfoPpiGuid
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 06/13] ArmVirtPkg/PrePi: base GCD memory space size on CPU's PA range
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
` (4 preceding siblings ...)
2018-11-26 22:37 ` [PATCH v2 05/13] ArmPlatformPkg/PrePi: " Ard Biesheuvel
@ 2018-11-26 22:37 ` Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 07/13] BeagleBoardPkg/PrePi: " Ard Biesheuvel
` (7 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:37 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
Derive the size of the GCD memory space map directly from the CPU's
information registers rather than from the PcdPrePiCpuMemorySize PCD,
which will be removed.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf | 1 -
ArmVirtPkg/PrePi/PrePi.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
index 1587bd92f206..034ddb41cb48 100755
--- a/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
+++ b/ArmVirtPkg/PrePi/ArmVirtPrePiUniCoreRelocatable.inf
@@ -85,7 +85,6 @@ [FixedPcd]
gArmPlatformTokenSpaceGuid.PcdCoreCount
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
diff --git a/ArmVirtPkg/PrePi/PrePi.c b/ArmVirtPkg/PrePi/PrePi.c
index f6abe2f2016b..61de6cfd4ae6 100755
--- a/ArmVirtPkg/PrePi/PrePi.c
+++ b/ArmVirtPkg/PrePi/PrePi.c
@@ -80,7 +80,7 @@ PrePiMain (
BuildStackHob (StacksBase, StacksSize);
//TODO: Call CpuPei as a library
- BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
+ BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));
// Set the Boot Mode
SetBootMode (BOOT_WITH_FULL_CONFIGURATION);
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 07/13] BeagleBoardPkg/PrePi: base GCD memory space size on CPU's PA range
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
` (5 preceding siblings ...)
2018-11-26 22:37 ` [PATCH v2 06/13] ArmVirtPkg/PrePi: " Ard Biesheuvel
@ 2018-11-26 22:37 ` Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 08/13] EmbeddedPkg/PrePiHobLib: " Ard Biesheuvel
` (6 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:37 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
Derive the size of the GCD memory space map directly from the CPU's
information registers rather than from the PcdPrePiCpuMemorySize PCD,
which will be removed.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
BeagleBoardPkg/PrePi/PeiUniCore.inf | 1 -
BeagleBoardPkg/PrePi/PrePi.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/BeagleBoardPkg/PrePi/PeiUniCore.inf b/BeagleBoardPkg/PrePi/PeiUniCore.inf
index 3d72bc5b46e1..53c71d8eafc2 100644
--- a/BeagleBoardPkg/PrePi/PeiUniCore.inf
+++ b/BeagleBoardPkg/PrePi/PeiUniCore.inf
@@ -86,7 +86,6 @@ [FixedPcd]
gArmPlatformTokenSpaceGuid.PcdCoreCount
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
diff --git a/BeagleBoardPkg/PrePi/PrePi.c b/BeagleBoardPkg/PrePi/PrePi.c
index 46f63f40c46e..bc9b0c80b84c 100644
--- a/BeagleBoardPkg/PrePi/PrePi.c
+++ b/BeagleBoardPkg/PrePi/PrePi.c
@@ -110,7 +110,7 @@ PrePiMain (
BuildStackHob (StacksBase, StacksSize);
//TODO: Call CpuPei as a library
- BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
+ BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));
// Store timer value logged at the beginning of firmware image execution
Performance.ResetEnd = GetTimeInNanoSecond (StartTimeStamp);
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 08/13] EmbeddedPkg/PrePiHobLib: base GCD memory space size on CPU's PA range
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
` (6 preceding siblings ...)
2018-11-26 22:37 ` [PATCH v2 07/13] BeagleBoardPkg/PrePi: " Ard Biesheuvel
@ 2018-11-26 22:37 ` Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 09/13] ArmPlatformPkg/PlatformPei: drop unused PCD references Ard Biesheuvel
` (5 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:37 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
Derive the size of the GCD memory space map directly from the CPU's
information registers rather than from the PcdPrePiCpuMemorySize PCD,
which will be removed.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf | 1 -
EmbeddedPkg/Library/PrePiHobLib/Hob.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf b/EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf
index 526db4c0d8f9..1ce3546d007d 100644
--- a/EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf
+++ b/EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf
@@ -47,7 +47,6 @@ [Guids]
gEfiHobMemoryAllocStackGuid
[FixedPcd.common]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
diff --git a/EmbeddedPkg/Library/PrePiHobLib/Hob.c b/EmbeddedPkg/Library/PrePiHobLib/Hob.c
index aff8ea05797b..e3d70ae0f9fe 100644
--- a/EmbeddedPkg/Library/PrePiHobLib/Hob.c
+++ b/EmbeddedPkg/Library/PrePiHobLib/Hob.c
@@ -193,7 +193,7 @@ CreateHobList (
Hob = HobConstructor (MemoryBegin,MemoryLength,HobBase,StackBase);
SetHobList (Hob);
- BuildCpuHob (PcdGet8 (PcdPrePiCpuMemorySize), PcdGet8 (PcdPrePiCpuIoSize));
+ BuildCpuHob (ArmGetPhysicalAddressBits (), PcdGet8 (PcdPrePiCpuIoSize));
Attributes =(
EFI_RESOURCE_ATTRIBUTE_PRESENT |
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 09/13] ArmPlatformPkg/PlatformPei: drop unused PCD references
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
` (7 preceding siblings ...)
2018-11-26 22:37 ` [PATCH v2 08/13] EmbeddedPkg/PrePiHobLib: " Ard Biesheuvel
@ 2018-11-26 22:37 ` Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 10/13] EmbeddedPkg/PrePiLib: drop unused PCD reference Ard Biesheuvel
` (4 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:37 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
Drop some PCD references that are not actually referenced from the
PlatformPei code.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf | 3 ---
ArmPlatformPkg/PlatformPei/PlatformPeim.inf | 3 ---
2 files changed, 6 deletions(-)
diff --git a/ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf b/ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
index 314789d0a990..23bb3f37e766 100644
--- a/ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
+++ b/ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
@@ -46,8 +46,5 @@ [FixedPcd]
gArmTokenSpaceGuid.PcdFvBaseAddress
gArmTokenSpaceGuid.PcdFvSize
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
-
[depex]
TRUE
diff --git a/ArmPlatformPkg/PlatformPei/PlatformPeim.inf b/ArmPlatformPkg/PlatformPei/PlatformPeim.inf
index 423b9ab858d1..4934baa838e1 100644
--- a/ArmPlatformPkg/PlatformPei/PlatformPeim.inf
+++ b/ArmPlatformPkg/PlatformPei/PlatformPeim.inf
@@ -57,9 +57,6 @@ [FixedPcd]
gArmTokenSpaceGuid.PcdFvBaseAddress
gArmTokenSpaceGuid.PcdFvSize
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
-
[Depex]
TRUE
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 10/13] EmbeddedPkg/PrePiLib: drop unused PCD reference
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
` (8 preceding siblings ...)
2018-11-26 22:37 ` [PATCH v2 09/13] ArmPlatformPkg/PlatformPei: drop unused PCD references Ard Biesheuvel
@ 2018-11-26 22:37 ` Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 11/13] ArmVirtPkg/QemuVirtMemInfoLib: ignore PcdPrePiCpuMemorySize Ard Biesheuvel
` (3 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:37 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
Drop the reference to gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
which is never used.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
EmbeddedPkg/Library/PrePiLib/PrePiLib.inf | 1 -
1 file changed, 1 deletion(-)
diff --git a/EmbeddedPkg/Library/PrePiLib/PrePiLib.inf b/EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
index de68405098c0..3dba884b1f31 100644
--- a/EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
+++ b/EmbeddedPkg/Library/PrePiLib/PrePiLib.inf
@@ -69,7 +69,6 @@ [Protocols]
[FixedPcd.common]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize
gEmbeddedTokenSpaceGuid.PcdMemoryTypeEfiACPIReclaimMemory
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 11/13] ArmVirtPkg/QemuVirtMemInfoLib: ignore PcdPrePiCpuMemorySize
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
` (9 preceding siblings ...)
2018-11-26 22:37 ` [PATCH v2 10/13] EmbeddedPkg/PrePiLib: drop unused PCD reference Ard Biesheuvel
@ 2018-11-26 22:37 ` Ard Biesheuvel
2018-11-26 22:38 ` [PATCH v2 12/13] ArmVirtPkg: drop PcdPrePiCpuMemorySize assignments from all platforms Ard Biesheuvel
` (2 subsequent siblings)
13 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:37 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
Now that the size of the GCD memory map is based directly on the
CPU's capabilities, we no longer have a need for PcdPrePiCpuMemorySize
and so it will be removed. So drop it from QemuVirtMemInfoLib as well.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf | 1 -
ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf | 1 -
ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c | 5 +----
3 files changed, 1 insertion(+), 6 deletions(-)
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
index f2c461e3b55a..5c5b841051ad 100644
--- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
+++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.inf
@@ -45,4 +45,3 @@ [Pcd]
[FixedPcd]
gArmTokenSpaceGuid.PcdFdSize
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf
index f54fb51ee1d4..d12089760b22 100644
--- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf
+++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoPeiLib.inf
@@ -49,4 +49,3 @@ [Pcd]
[FixedPcd]
gArmTokenSpaceGuid.PcdFdSize
gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize
diff --git a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
index a80454c4802e..815ca145b644 100644
--- a/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
+++ b/ArmVirtPkg/Library/QemuVirtMemInfoLib/QemuVirtMemInfoLib.c
@@ -41,7 +41,6 @@ ArmVirtGetMemoryMap (
)
{
ARM_MEMORY_REGION_DESCRIPTOR *VirtualMemoryTable;
- UINT64 TopOfMemory;
ASSERT (VirtualMemoryMap != NULL);
@@ -75,11 +74,9 @@ ArmVirtGetMemoryMap (
VirtualMemoryTable[1].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
// Peripheral space after DRAM
- TopOfMemory = MIN (1ULL << FixedPcdGet8 (PcdPrePiCpuMemorySize),
- TopOfAddressSpace);
VirtualMemoryTable[2].PhysicalBase = VirtualMemoryTable[0].Length + VirtualMemoryTable[1].Length;
VirtualMemoryTable[2].VirtualBase = VirtualMemoryTable[2].PhysicalBase;
- VirtualMemoryTable[2].Length = TopOfMemory -
+ VirtualMemoryTable[2].Length = TopOfAddressSpace -
VirtualMemoryTable[2].PhysicalBase;
VirtualMemoryTable[2].Attributes = ARM_MEMORY_REGION_ATTRIBUTE_DEVICE;
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 12/13] ArmVirtPkg: drop PcdPrePiCpuMemorySize assignments from all platforms
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
` (10 preceding siblings ...)
2018-11-26 22:37 ` [PATCH v2 11/13] ArmVirtPkg/QemuVirtMemInfoLib: ignore PcdPrePiCpuMemorySize Ard Biesheuvel
@ 2018-11-26 22:38 ` Ard Biesheuvel
2018-11-26 22:38 ` [PATCH v2 13/13] EmbeddedPkg/EmbeddedPkg.dec: drop PcdPrePiCpuMemorySize declarations Ard Biesheuvel
2018-11-27 12:11 ` [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Laszlo Ersek
13 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:38 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
PcdPrePiCpuMemorySize is no longer used so drop the PCD overrides
from all platform descriptions in ArmVirtPkg.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
ArmVirtPkg/ArmVirt.dsc.inc | 3 ---
ArmVirtPkg/ArmVirtQemu.dsc | 4 ----
ArmVirtPkg/ArmVirtQemuKernel.dsc | 4 ----
3 files changed, 11 deletions(-)
diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index 70a0ac4d786c..fbdb5c982604 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -388,9 +388,6 @@ [PcdsFixedAtBuild.common]
#
gEfiMdeModulePkgTokenSpaceGuid.PcdSetNxForStack|TRUE
-[PcdsFixedAtBuild.ARM]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|40
-
[Components.common]
#
# Ramdisk support
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 885c6b14b844..a107b6bb5104 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -143,10 +143,6 @@ [PcdsFixedAtBuild.common]
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16
[PcdsFixedAtBuild.AARCH64]
- # KVM limits it IPA space to 40 bits (1 TB), so there is no need to
- # support anything bigger, even if the host hardware does
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|40
-
# Clearing BIT0 in this PCD prevents installing a 32-bit SMBIOS entry point,
# if the entry point version is >= 3.0. AARCH64 OSes cannot assume the
# presence of the 32-bit entry point anyway (because many AARCH64 systems
diff --git a/ArmVirtPkg/ArmVirtQemuKernel.dsc b/ArmVirtPkg/ArmVirtQemuKernel.dsc
index 434d6861a56f..d8fbf14e8f4e 100644
--- a/ArmVirtPkg/ArmVirtQemuKernel.dsc
+++ b/ArmVirtPkg/ArmVirtQemuKernel.dsc
@@ -157,10 +157,6 @@ [PcdsFixedAtBuild.AARCH64]
#
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16
- # KVM limits it IPA space to 40 bits (1 TB), so there is no need to
- # support anything bigger, even if the host hardware does
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|40
-
[PcdsDynamicDefault.common]
gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut|3
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* [PATCH v2 13/13] EmbeddedPkg/EmbeddedPkg.dec: drop PcdPrePiCpuMemorySize declarations
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
` (11 preceding siblings ...)
2018-11-26 22:38 ` [PATCH v2 12/13] ArmVirtPkg: drop PcdPrePiCpuMemorySize assignments from all platforms Ard Biesheuvel
@ 2018-11-26 22:38 ` Ard Biesheuvel
2018-11-27 12:11 ` [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Laszlo Ersek
13 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 22:38 UTC (permalink / raw)
To: edk2-devel
Cc: Ard Biesheuvel, Laszlo Ersek, Leif Lindholm, Eric Auger,
Andrew Jones, Philippe Mathieu-Daude, Julien Grall
PcdPrePiCpuMemorySize is no longer used so drop the declarations from
the package DEC file.
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
EmbeddedPkg/EmbeddedPkg.dec | 4 ----
1 file changed, 4 deletions(-)
diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec
index 28a143865d0e..ff5aab07d745 100644
--- a/EmbeddedPkg/EmbeddedPkg.dec
+++ b/EmbeddedPkg/EmbeddedPkg.dec
@@ -170,22 +170,18 @@ [PcdsFixedAtBuild.common]
gEmbeddedTokenSpaceGuid.PcdAndroidBootDevicePath|L""|VOID*|0x00000057
[PcdsFixedAtBuild.ARM]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|32|UINT8|0x00000010
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|0|UINT8|0x00000011
# ISP1761 USB OTG Controller
gEmbeddedTokenSpaceGuid.PcdIsp1761BaseAddress|0|UINT32|0x00000021
[PcdsFixedAtBuild.AARCH64]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|48|UINT8|0x00000010
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|0|UINT8|0x00000011
[PcdsFixedAtBuild.IA32]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|36|UINT8|0x00000010
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16|UINT8|0x00000011
[PcdsFixedAtBuild.X64]
- gEmbeddedTokenSpaceGuid.PcdPrePiCpuMemorySize|52|UINT8|0x00000010
gEmbeddedTokenSpaceGuid.PcdPrePiCpuIoSize|16|UINT8|0x00000011
[PcdsFixedAtBuild.common, PcdsDynamic.common]
--
2.19.1
^ permalink raw reply related [flat|nested] 22+ messages in thread
* Re: [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size
2018-11-26 22:37 ` [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size Ard Biesheuvel
@ 2018-11-26 22:43 ` Philippe Mathieu-Daudé
2018-11-26 23:02 ` Philippe Mathieu-Daudé
2018-11-27 12:26 ` Ard Biesheuvel
2018-11-27 14:51 ` Auger Eric
2 siblings, 1 reply; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-26 22:43 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel
Cc: Laszlo Ersek, Leif Lindholm, Eric Auger, Andrew Jones,
Julien Grall
On 26/11/18 23:37, Ard Biesheuvel wrote:
> Add a helper function that returns the maximum physical address space
> size as supported by the current CPU.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> ---
> ArmPkg/Include/Library/ArmLib.h | 17 +++++++++++++++++
> ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S | 16 ++++++++++++++++
> ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S | 8 ++++++++
> 3 files changed, 41 insertions(+)
>
> diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h
> index ffda50e9d767..b22879fe6e94 100644
> --- a/ArmPkg/Include/Library/ArmLib.h
> +++ b/ArmPkg/Include/Library/ArmLib.h
> @@ -29,6 +29,17 @@
> #define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | \
> EFI_MEMORY_WT | EFI_MEMORY_WB | \
> EFI_MEMORY_UCE)
> +//
> +// ARM_MMU_IDMAP_RANGE defines the maximum size of the identity mapping
> +// that covers the entire address space when running in UEFI. This is
> +// limited to what can architecturally be mapped using a 4 KB granule,
> +// even if the hardware is capable of mapping more using larger pages.
> +//
> +#ifdef MDE_CPU_ARM
> +#define ARM_MMU_IDMAP_RANGE (1ULL << 32)
> +#else
> +#define ARM_MMU_IDMAP_RANGE (1ULL << 48)
> +#endif
>
> /**
> * The UEFI firmware must not use the ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_* attributes.
> @@ -733,4 +744,10 @@ ArmWriteCntvOff (
> UINT64 Val
> );
>
> +UINTN
> +EFIAPI
> +ArmGetPhysicalAddressBits (
> + VOID
> + );
> +
> #endif // __ARM_LIB__
> diff --git a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> index 1ef2f61f5979..7332601241aa 100644
> --- a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> +++ b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> @@ -196,4 +196,20 @@ ASM_FUNC(ArmWriteSctlr)
> 3:msr sctlr_el3, x0
> 4:ret
>
> +ASM_FUNC(ArmGetPhysicalAddressBits)
> + mrs x0, id_aa64mmfr0_el1
> + adr x1, .LPARanges
> + and x0, x0, #7
> + ldrb w0, [x1, x0]
> + ret
> +
> +//
> +// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
> +// physical address space support on this CPU:
> +// 0 == 32 bits, 1 == 36 bits, etc etc
> +// 6 and 7 are reserved
> +//
> +.LPARanges:
> + .byte 32, 36, 40, 42, 44, 48, 52, -1
> +
> ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> index f2a517671f0a..f2f3c9a25991 100644
> --- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> +++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> @@ -165,4 +165,12 @@ ASM_FUNC(ArmWriteCpuActlr)
> isb
> bx lr
>
> +ASM_FUNC (ArmGetPhysicalAddressBits)
> + mrc p15, 0, r0, c0, c1, 4 // MMFR0
> + and r0, r0, #0xf // VMSA [3:0]
> + cmp r0, #5 // >5 implies LPAE support
> + movlt r0, #32 // 32 bits if no LPAE
> + movge r0, #40 // 40 bits if LPAE
> + bx lr
> +
> ASM_FUNCTION_REMOVE_IF_UNREFERENCED
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size
2018-11-26 22:43 ` Philippe Mathieu-Daudé
@ 2018-11-26 23:02 ` Philippe Mathieu-Daudé
2018-11-26 23:03 ` Ard Biesheuvel
0 siblings, 1 reply; 22+ messages in thread
From: Philippe Mathieu-Daudé @ 2018-11-26 23:02 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel-01
Cc: Laszlo Ersek, Leif Lindholm, Auger Eric, Andrew Jones,
Julien Grall
On Mon, Nov 26, 2018 at 11:43 PM Philippe Mathieu-Daudé
<philmd@redhat.com> wrote:
>
> On 26/11/18 23:37, Ard Biesheuvel wrote:
> > Add a helper function that returns the maximum physical address space
> > size as supported by the current CPU.
> >
> > Contributed-under: TianoCore Contribution Agreement 1.1
> > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
>
> > ---
> > ArmPkg/Include/Library/ArmLib.h | 17 +++++++++++++++++
> > ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S | 16 ++++++++++++++++
> > ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S | 8 ++++++++
> > 3 files changed, 41 insertions(+)
> >
> > diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h
> > index ffda50e9d767..b22879fe6e94 100644
> > --- a/ArmPkg/Include/Library/ArmLib.h
> > +++ b/ArmPkg/Include/Library/ArmLib.h
> > @@ -29,6 +29,17 @@
> > #define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | \
> > EFI_MEMORY_WT | EFI_MEMORY_WB | \
> > EFI_MEMORY_UCE)
> > +//
> > +// ARM_MMU_IDMAP_RANGE defines the maximum size of the identity mapping
> > +// that covers the entire address space when running in UEFI. This is
> > +// limited to what can architecturally be mapped using a 4 KB granule,
> > +// even if the hardware is capable of mapping more using larger pages.
> > +//
> > +#ifdef MDE_CPU_ARM
> > +#define ARM_MMU_IDMAP_RANGE (1ULL << 32)
> > +#else
> > +#define ARM_MMU_IDMAP_RANGE (1ULL << 48)
> > +#endif
> >
> > /**
> > * The UEFI firmware must not use the ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_* attributes.
> > @@ -733,4 +744,10 @@ ArmWriteCntvOff (
> > UINT64 Val
> > );
> >
> > +UINTN
> > +EFIAPI
> > +ArmGetPhysicalAddressBits (
> > + VOID
> > + );
> > +
> > #endif // __ARM_LIB__
> > diff --git a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> > index 1ef2f61f5979..7332601241aa 100644
> > --- a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> > +++ b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> > @@ -196,4 +196,20 @@ ASM_FUNC(ArmWriteSctlr)
> > 3:msr sctlr_el3, x0
> > 4:ret
> >
> > +ASM_FUNC(ArmGetPhysicalAddressBits)
> > + mrs x0, id_aa64mmfr0_el1
> > + adr x1, .LPARanges
> > + and x0, x0, #7
> > + ldrb w0, [x1, x0]
> > + ret
> > +
> > +//
> > +// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
> > +// physical address space support on this CPU:
> > +// 0 == 32 bits, 1 == 36 bits, etc etc
> > +// 6 and 7 are reserved
Oops the comment is now invalid for the index == 6.
> > +//
> > +.LPARanges:
> > + .byte 32, 36, 40, 42, 44, 48, 52, -1
> > +
> > ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> > diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> > index f2a517671f0a..f2f3c9a25991 100644
> > --- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> > +++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> > @@ -165,4 +165,12 @@ ASM_FUNC(ArmWriteCpuActlr)
> > isb
> > bx lr
> >
> > +ASM_FUNC (ArmGetPhysicalAddressBits)
> > + mrc p15, 0, r0, c0, c1, 4 // MMFR0
> > + and r0, r0, #0xf // VMSA [3:0]
> > + cmp r0, #5 // >5 implies LPAE support
> > + movlt r0, #32 // 32 bits if no LPAE
> > + movge r0, #40 // 40 bits if LPAE
> > + bx lr
> > +
> > ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> >
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size
2018-11-26 23:02 ` Philippe Mathieu-Daudé
@ 2018-11-26 23:03 ` Ard Biesheuvel
0 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-26 23:03 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: edk2-devel@lists.01.org, Laszlo Ersek, Leif Lindholm, Auger Eric,
Andrew Jones, Julien Grall
On Tue, 27 Nov 2018 at 00:02, Philippe Mathieu-Daudé <philmd@redhat.com> wrote:
>
> On Mon, Nov 26, 2018 at 11:43 PM Philippe Mathieu-Daudé
> <philmd@redhat.com> wrote:
> >
> > On 26/11/18 23:37, Ard Biesheuvel wrote:
> > > Add a helper function that returns the maximum physical address space
> > > size as supported by the current CPU.
> > >
> > > Contributed-under: TianoCore Contribution Agreement 1.1
> > > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> >
> > Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> >
> > > ---
> > > ArmPkg/Include/Library/ArmLib.h | 17 +++++++++++++++++
> > > ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S | 16 ++++++++++++++++
> > > ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S | 8 ++++++++
> > > 3 files changed, 41 insertions(+)
> > >
> > > diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h
> > > index ffda50e9d767..b22879fe6e94 100644
> > > --- a/ArmPkg/Include/Library/ArmLib.h
> > > +++ b/ArmPkg/Include/Library/ArmLib.h
> > > @@ -29,6 +29,17 @@
> > > #define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | \
> > > EFI_MEMORY_WT | EFI_MEMORY_WB | \
> > > EFI_MEMORY_UCE)
> > > +//
> > > +// ARM_MMU_IDMAP_RANGE defines the maximum size of the identity mapping
> > > +// that covers the entire address space when running in UEFI. This is
> > > +// limited to what can architecturally be mapped using a 4 KB granule,
> > > +// even if the hardware is capable of mapping more using larger pages.
> > > +//
> > > +#ifdef MDE_CPU_ARM
> > > +#define ARM_MMU_IDMAP_RANGE (1ULL << 32)
> > > +#else
> > > +#define ARM_MMU_IDMAP_RANGE (1ULL << 48)
> > > +#endif
> > >
> > > /**
> > > * The UEFI firmware must not use the ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_* attributes.
> > > @@ -733,4 +744,10 @@ ArmWriteCntvOff (
> > > UINT64 Val
> > > );
> > >
> > > +UINTN
> > > +EFIAPI
> > > +ArmGetPhysicalAddressBits (
> > > + VOID
> > > + );
> > > +
> > > #endif // __ARM_LIB__
> > > diff --git a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> > > index 1ef2f61f5979..7332601241aa 100644
> > > --- a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> > > +++ b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> > > @@ -196,4 +196,20 @@ ASM_FUNC(ArmWriteSctlr)
> > > 3:msr sctlr_el3, x0
> > > 4:ret
> > >
> > > +ASM_FUNC(ArmGetPhysicalAddressBits)
> > > + mrs x0, id_aa64mmfr0_el1
> > > + adr x1, .LPARanges
> > > + and x0, x0, #7
> > > + ldrb w0, [x1, x0]
> > > + ret
> > > +
> > > +//
> > > +// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
> > > +// physical address space support on this CPU:
> > > +// 0 == 32 bits, 1 == 36 bits, etc etc
> > > +// 6 and 7 are reserved
>
> Oops the comment is now invalid for the index == 6.
>
Ah yes, I'll fix that up before adding your R-b.
> > > +//
> > > +.LPARanges:
> > > + .byte 32, 36, 40, 42, 44, 48, 52, -1
> > > +
> > > ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> > > diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> > > index f2a517671f0a..f2f3c9a25991 100644
> > > --- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> > > +++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> > > @@ -165,4 +165,12 @@ ASM_FUNC(ArmWriteCpuActlr)
> > > isb
> > > bx lr
> > >
> > > +ASM_FUNC (ArmGetPhysicalAddressBits)
> > > + mrc p15, 0, r0, c0, c1, 4 // MMFR0
> > > + and r0, r0, #0xf // VMSA [3:0]
> > > + cmp r0, #5 // >5 implies LPAE support
> > > + movlt r0, #32 // 32 bits if no LPAE
> > > + movge r0, #40 // 40 bits if LPAE
> > > + bx lr
> > > +
> > > ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> > >
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
` (12 preceding siblings ...)
2018-11-26 22:38 ` [PATCH v2 13/13] EmbeddedPkg/EmbeddedPkg.dec: drop PcdPrePiCpuMemorySize declarations Ard Biesheuvel
@ 2018-11-27 12:11 ` Laszlo Ersek
2018-11-27 12:13 ` Ard Biesheuvel
13 siblings, 1 reply; 22+ messages in thread
From: Laszlo Ersek @ 2018-11-27 12:11 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel
Cc: Leif Lindholm, Eric Auger, Andrew Jones, Philippe Mathieu-Daude,
Julien Grall
On 11/26/18 23:37, Ard Biesheuvel wrote:
> The ArmVirtQemu targets currently limit the size of the IPA space to
> 40 bits because that is all what KVM supports. However, this is about
> to change, and so we need to update the code if we want to ensure that
> our UEFI firmware builds can keep running on systems that set values
> other than 40 (which could be > 40 or < 40)
>
> So refactor the way we deal with this limit, both for bare metal and for
> virtual targets, so that
> a) the range of the GCD memory map is based directly on the CPU's PA range
> b) the range of the 1:1 mapping in the page tables is based on the CPU's PA
> range (unless it exceeds what the architecture permits for 4k pages)
> c) PcdPrePiCpuMemorySize is no longer needed, and can be removed.
>
> Patch #1 introduces ARM_MMU_IDMAP_RANGE and ArmGetPhysicalAddressBits ()
> in ArmLib.
OK, so the crucial piece of info I missed under v1 was that given the
fixed 4KB page size under UEFI, we might not be able to identity map all
the memory that the CPU would otherwise be capable of addressing
(assuming the OS set up a larger page size).
However... that seems to leave us with a conundrum. (I'm 100% sure it is
nothing new to you, but it is new to me.)
If we size the GCD memory space map exactly to what we can identity map
under UEFI, then the UEFI memmap will not advertize the rest of the RAM
to the OS, and the memory will be unusable.
On the other hand, if we size the GCD to the exact RAM size (part of
which could be out of reach for the CPU *under UEFI*, using 4KB pages),
then the OS will be happy. But, what happens when gBS->AllocatePages()
is served from such a high (>48bits) address range, and then the client
module tries to access the (not mapped) chunk?
Hm... Actually, once this becomes a practical problem, I think we can
take care of it, in a platform PEIM. Namely, just pre-allocate the
entire inaccessible / unmappable range (beyond 48-bits) as Boot Services
Data type memory. That will keep the rest of the firmware out (no
well-behaving module will read or write memory that it didn't allocate),
and the OS will be happy to release and reuse that memory.
Does this make sense?
I'd like to be sure that I understand this right, before starting my v2
review.
Thanks!
Laszlo
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit
2018-11-27 12:11 ` [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Laszlo Ersek
@ 2018-11-27 12:13 ` Ard Biesheuvel
2018-11-27 14:35 ` Laszlo Ersek
0 siblings, 1 reply; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-27 12:13 UTC (permalink / raw)
To: Laszlo Ersek
Cc: edk2-devel@lists.01.org, Leif Lindholm, Auger Eric, Andrew Jones,
Philippe Mathieu-Daudé, Julien Grall
On Tue, 27 Nov 2018 at 13:11, Laszlo Ersek <lersek@redhat.com> wrote:
>
> On 11/26/18 23:37, Ard Biesheuvel wrote:
> > The ArmVirtQemu targets currently limit the size of the IPA space to
> > 40 bits because that is all what KVM supports. However, this is about
> > to change, and so we need to update the code if we want to ensure that
> > our UEFI firmware builds can keep running on systems that set values
> > other than 40 (which could be > 40 or < 40)
> >
> > So refactor the way we deal with this limit, both for bare metal and for
> > virtual targets, so that
> > a) the range of the GCD memory map is based directly on the CPU's PA range
> > b) the range of the 1:1 mapping in the page tables is based on the CPU's PA
> > range (unless it exceeds what the architecture permits for 4k pages)
> > c) PcdPrePiCpuMemorySize is no longer needed, and can be removed.
> >
> > Patch #1 introduces ARM_MMU_IDMAP_RANGE and ArmGetPhysicalAddressBits ()
> > in ArmLib.
>
> OK, so the crucial piece of info I missed under v1 was that given the
> fixed 4KB page size under UEFI, we might not be able to identity map all
> the memory that the CPU would otherwise be capable of addressing
> (assuming the OS set up a larger page size).
>
> However... that seems to leave us with a conundrum. (I'm 100% sure it is
> nothing new to you, but it is new to me.)
>
> If we size the GCD memory space map exactly to what we can identity map
> under UEFI, then the UEFI memmap will not advertize the rest of the RAM
> to the OS, and the memory will be unusable.
>
> On the other hand, if we size the GCD to the exact RAM size (part of
> which could be out of reach for the CPU *under UEFI*, using 4KB pages),
> then the OS will be happy. But, what happens when gBS->AllocatePages()
> is served from such a high (>48bits) address range, and then the client
> module tries to access the (not mapped) chunk?
>
That is an excellent question, given that IA32 and ARM are in exactly
the same boat with [L]PAE.
> Hm... Actually, once this becomes a practical problem, I think we can
> take care of it, in a platform PEIM. Namely, just pre-allocate the
> entire inaccessible / unmappable range (beyond 48-bits) as Boot Services
> Data type memory. That will keep the rest of the firmware out (no
> well-behaving module will read or write memory that it didn't allocate),
> and the OS will be happy to release and reuse that memory.
>
> Does this make sense?
>
I will look into how IA32 and ARM deal with this at the moment. Well spotted!
> I'd like to be sure that I understand this right, before starting my v2
> review.
>
> Thanks!
> Laszlo
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size
2018-11-26 22:37 ` [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size Ard Biesheuvel
2018-11-26 22:43 ` Philippe Mathieu-Daudé
@ 2018-11-27 12:26 ` Ard Biesheuvel
2018-11-27 14:51 ` Auger Eric
2 siblings, 0 replies; 22+ messages in thread
From: Ard Biesheuvel @ 2018-11-27 12:26 UTC (permalink / raw)
To: edk2-devel@lists.01.org
Cc: Laszlo Ersek, Leif Lindholm, Auger Eric, Andrew Jones,
Philippe Mathieu-Daudé, Julien Grall
On Mon, 26 Nov 2018 at 23:38, Ard Biesheuvel <ard.biesheuvel@linaro.org> wrote:
>
> Add a helper function that returns the maximum physical address space
> size as supported by the current CPU.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmPkg/Include/Library/ArmLib.h | 17 +++++++++++++++++
> ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S | 16 ++++++++++++++++
> ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S | 8 ++++++++
> 3 files changed, 41 insertions(+)
>
> diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h
> index ffda50e9d767..b22879fe6e94 100644
> --- a/ArmPkg/Include/Library/ArmLib.h
> +++ b/ArmPkg/Include/Library/ArmLib.h
> @@ -29,6 +29,17 @@
> #define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | \
> EFI_MEMORY_WT | EFI_MEMORY_WB | \
> EFI_MEMORY_UCE)
> +//
> +// ARM_MMU_IDMAP_RANGE defines the maximum size of the identity mapping
> +// that covers the entire address space when running in UEFI. This is
> +// limited to what can architecturally be mapped using a 4 KB granule,
> +// even if the hardware is capable of mapping more using larger pages.
> +//
> +#ifdef MDE_CPU_ARM
> +#define ARM_MMU_IDMAP_RANGE (1ULL << 32)
> +#else
> +#define ARM_MMU_IDMAP_RANGE (1ULL << 48)
> +#endif
>
I just learned that this is essentially the same as MAX_ADDRESS (after
we fix AArch64's definition of it) so this can be dropped.
> /**
> * The UEFI firmware must not use the ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_* attributes.
> @@ -733,4 +744,10 @@ ArmWriteCntvOff (
> UINT64 Val
> );
>
> +UINTN
> +EFIAPI
> +ArmGetPhysicalAddressBits (
> + VOID
> + );
> +
> #endif // __ARM_LIB__
> diff --git a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> index 1ef2f61f5979..7332601241aa 100644
> --- a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> +++ b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> @@ -196,4 +196,20 @@ ASM_FUNC(ArmWriteSctlr)
> 3:msr sctlr_el3, x0
> 4:ret
>
> +ASM_FUNC(ArmGetPhysicalAddressBits)
> + mrs x0, id_aa64mmfr0_el1
> + adr x1, .LPARanges
> + and x0, x0, #7
> + ldrb w0, [x1, x0]
> + ret
> +
> +//
> +// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
> +// physical address space support on this CPU:
> +// 0 == 32 bits, 1 == 36 bits, etc etc
> +// 6 and 7 are reserved
> +//
> +.LPARanges:
> + .byte 32, 36, 40, 42, 44, 48, 52, -1
> +
> ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> index f2a517671f0a..f2f3c9a25991 100644
> --- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> +++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> @@ -165,4 +165,12 @@ ASM_FUNC(ArmWriteCpuActlr)
> isb
> bx lr
>
> +ASM_FUNC (ArmGetPhysicalAddressBits)
> + mrc p15, 0, r0, c0, c1, 4 // MMFR0
> + and r0, r0, #0xf // VMSA [3:0]
> + cmp r0, #5 // >5 implies LPAE support
> + movlt r0, #32 // 32 bits if no LPAE
> + movge r0, #40 // 40 bits if LPAE
> + bx lr
> +
> ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> --
> 2.19.1
>
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit
2018-11-27 12:13 ` Ard Biesheuvel
@ 2018-11-27 14:35 ` Laszlo Ersek
0 siblings, 0 replies; 22+ messages in thread
From: Laszlo Ersek @ 2018-11-27 14:35 UTC (permalink / raw)
To: Ard Biesheuvel
Cc: edk2-devel@lists.01.org, Leif Lindholm, Auger Eric, Andrew Jones,
Philippe Mathieu-Daudé, Julien Grall
On 11/27/18 13:13, Ard Biesheuvel wrote:
> On Tue, 27 Nov 2018 at 13:11, Laszlo Ersek <lersek@redhat.com> wrote:
>>
>> On 11/26/18 23:37, Ard Biesheuvel wrote:
>>> The ArmVirtQemu targets currently limit the size of the IPA space to
>>> 40 bits because that is all what KVM supports. However, this is about
>>> to change, and so we need to update the code if we want to ensure that
>>> our UEFI firmware builds can keep running on systems that set values
>>> other than 40 (which could be > 40 or < 40)
>>>
>>> So refactor the way we deal with this limit, both for bare metal and for
>>> virtual targets, so that
>>> a) the range of the GCD memory map is based directly on the CPU's PA range
>>> b) the range of the 1:1 mapping in the page tables is based on the CPU's PA
>>> range (unless it exceeds what the architecture permits for 4k pages)
>>> c) PcdPrePiCpuMemorySize is no longer needed, and can be removed.
>>>
>>> Patch #1 introduces ARM_MMU_IDMAP_RANGE and ArmGetPhysicalAddressBits ()
>>> in ArmLib.
>>
>> OK, so the crucial piece of info I missed under v1 was that given the
>> fixed 4KB page size under UEFI, we might not be able to identity map all
>> the memory that the CPU would otherwise be capable of addressing
>> (assuming the OS set up a larger page size).
>>
>> However... that seems to leave us with a conundrum. (I'm 100% sure it is
>> nothing new to you, but it is new to me.)
>>
>> If we size the GCD memory space map exactly to what we can identity map
>> under UEFI, then the UEFI memmap will not advertize the rest of the RAM
>> to the OS, and the memory will be unusable.
>>
>> On the other hand, if we size the GCD to the exact RAM size (part of
>> which could be out of reach for the CPU *under UEFI*, using 4KB pages),
>> then the OS will be happy. But, what happens when gBS->AllocatePages()
>> is served from such a high (>48bits) address range, and then the client
>> module tries to access the (not mapped) chunk?
>>
>
> That is an excellent question, given that IA32 and ARM are in exactly
> the same boat with [L]PAE.
And that's an excellent observation too; I should have noticed the
parallel with at least IA32 myself!
I remember the article where Brian explains why vendors ship IA32-only
firmware on 64-bit capable Intel processors. Hm... It's here:
https://software.intel.com/en-us/blogs/2015/07/22/why-cheap-systems-run-32-bit-uefi-on-x64-systems
Obviously Linux people were never happy with that, so they worked around
it, and the kernel switches to 64-bit mode itself, AFAIK... But what
about the RAM that the 32-bit DXE phase (and firmware runtime) can't
see, but the OS can? Maybe Linux can provide some pointers here (as you
say).
[...]
Thank you!
Laszlo
^ permalink raw reply [flat|nested] 22+ messages in thread
* Re: [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size
2018-11-26 22:37 ` [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size Ard Biesheuvel
2018-11-26 22:43 ` Philippe Mathieu-Daudé
2018-11-27 12:26 ` Ard Biesheuvel
@ 2018-11-27 14:51 ` Auger Eric
2 siblings, 0 replies; 22+ messages in thread
From: Auger Eric @ 2018-11-27 14:51 UTC (permalink / raw)
To: Ard Biesheuvel, edk2-devel
Cc: Laszlo Ersek, Leif Lindholm, Andrew Jones, Philippe Mathieu-Daude,
Julien Grall
Hi,
On 11/26/18 11:37 PM, Ard Biesheuvel wrote:
> Add a helper function that returns the maximum physical address space
> size as supported by the current CPU.
>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
> ---
> ArmPkg/Include/Library/ArmLib.h | 17 +++++++++++++++++
> ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S | 16 ++++++++++++++++
> ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S | 8 ++++++++
> 3 files changed, 41 insertions(+)
>
> diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h
> index ffda50e9d767..b22879fe6e94 100644
> --- a/ArmPkg/Include/Library/ArmLib.h
> +++ b/ArmPkg/Include/Library/ArmLib.h
> @@ -29,6 +29,17 @@
> #define EFI_MEMORY_CACHETYPE_MASK (EFI_MEMORY_UC | EFI_MEMORY_WC | \
> EFI_MEMORY_WT | EFI_MEMORY_WB | \
> EFI_MEMORY_UCE)
> +//
> +// ARM_MMU_IDMAP_RANGE defines the maximum size of the identity mapping
> +// that covers the entire address space when running in UEFI. This is
> +// limited to what can architecturally be mapped using a 4 KB granule,
> +// even if the hardware is capable of mapping more using larger pages.
> +//
> +#ifdef MDE_CPU_ARM
> +#define ARM_MMU_IDMAP_RANGE (1ULL << 32)
> +#else
> +#define ARM_MMU_IDMAP_RANGE (1ULL << 48)
> +#endif
>
> /**
> * The UEFI firmware must not use the ARM_MEMORY_REGION_ATTRIBUTE_NONSECURE_* attributes.
> @@ -733,4 +744,10 @@ ArmWriteCntvOff (
> UINT64 Val
> );
>
> +UINTN
> +EFIAPI
> +ArmGetPhysicalAddressBits (
> + VOID
> + );
> +
> #endif // __ARM_LIB__
> diff --git a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> index 1ef2f61f5979..7332601241aa 100644
> --- a/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> +++ b/ArmPkg/Library/ArmLib/AArch64/ArmLibSupport.S
> @@ -196,4 +196,20 @@ ASM_FUNC(ArmWriteSctlr)
> 3:msr sctlr_el3, x0
> 4:ret
>
> +ASM_FUNC(ArmGetPhysicalAddressBits)
> + mrs x0, id_aa64mmfr0_el1
> + adr x1, .LPARanges
> + and x0, x0, #7
> + ldrb w0, [x1, x0]
> + ret
> +
> +//
> +// Bits 0..2 of the AA64MFR0_EL1 system register encode the size of the
> +// physical address space support on this CPU:
> +// 0 == 32 bits, 1 == 36 bits, etc etc
> +// 6 and 7 are reserved
> +//
> +.LPARanges:
> + .byte 32, 36, 40, 42, 44, 48, 52, -1
> +
> ASM_FUNCTION_REMOVE_IF_UNREFERENCED
> diff --git a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> index f2a517671f0a..f2f3c9a25991 100644
> --- a/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> +++ b/ArmPkg/Library/ArmLib/Arm/ArmLibSupport.S
> @@ -165,4 +165,12 @@ ASM_FUNC(ArmWriteCpuActlr)
> isb
> bx lr
>
> +ASM_FUNC (ArmGetPhysicalAddressBits)
> + mrc p15, 0, r0, c0, c1, 4 // MMFR0
> + and r0, r0, #0xf // VMSA [3:0]
> + cmp r0, #5 // >5 implies LPAE support
nit: >= 5 in the comment
Thanks
Eric
> + movlt r0, #32 // 32 bits if no LPAE
> + movge r0, #40 // 40 bits if LPAE
> + bx lr
> +
> ASM_FUNCTION_REMOVE_IF_UNREFERENCED
>
^ permalink raw reply [flat|nested] 22+ messages in thread
end of thread, other threads:[~2018-11-27 14:51 UTC | newest]
Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-26 22:37 [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 01/13] ArmPkg/ArmLib: add support for reading the max physical address space size Ard Biesheuvel
2018-11-26 22:43 ` Philippe Mathieu-Daudé
2018-11-26 23:02 ` Philippe Mathieu-Daudé
2018-11-26 23:03 ` Ard Biesheuvel
2018-11-27 12:26 ` Ard Biesheuvel
2018-11-27 14:51 ` Auger Eric
2018-11-26 22:37 ` [PATCH v2 02/13] ArmVirtPkg: refactor reading of the " Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 03/13] ArmPkg/ArmMmuLib: take the CPU supported maximum PA space into account Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 04/13] ArmPkg/CpuPei: base GCD memory space size on CPU's PA range Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 05/13] ArmPlatformPkg/PrePi: " Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 06/13] ArmVirtPkg/PrePi: " Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 07/13] BeagleBoardPkg/PrePi: " Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 08/13] EmbeddedPkg/PrePiHobLib: " Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 09/13] ArmPlatformPkg/PlatformPei: drop unused PCD references Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 10/13] EmbeddedPkg/PrePiLib: drop unused PCD reference Ard Biesheuvel
2018-11-26 22:37 ` [PATCH v2 11/13] ArmVirtPkg/QemuVirtMemInfoLib: ignore PcdPrePiCpuMemorySize Ard Biesheuvel
2018-11-26 22:38 ` [PATCH v2 12/13] ArmVirtPkg: drop PcdPrePiCpuMemorySize assignments from all platforms Ard Biesheuvel
2018-11-26 22:38 ` [PATCH v2 13/13] EmbeddedPkg/EmbeddedPkg.dec: drop PcdPrePiCpuMemorySize declarations Ard Biesheuvel
2018-11-27 12:11 ` [PATCH v2 00/13] ArmPkg, ArmVirtPkg: lift 40-bit IPA space limit Laszlo Ersek
2018-11-27 12:13 ` Ard Biesheuvel
2018-11-27 14:35 ` Laszlo Ersek
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox