Message ID | 20181219205640.4704-2-ard.biesheuvel@linaro.org |
---|---|
State | New |
Headers | show |
Series | introduce MAX_ALLOC_ADDRESS to limit boot time allocations | expand |
Reviewed-by: Liming Gao <liming.gao@intel.com> >-----Original Message----- >From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Ard >Biesheuvel >Sent: Thursday, December 20, 2018 4:57 AM >To: edk2-devel@lists.01.org >Cc: Andrew Jones <drjones@redhat.com>; Wu, Hao A <hao.a.wu@intel.com>; >Gao, Liming <liming.gao@intel.com>; Kinney, Michael D ><michael.d.kinney@intel.com>; Laszlo Ersek <lersek@redhat.com> >Subject: [edk2] [PATCH v2 1/6] MdePkg/Base: introduce >MAX_ALLOC_ADDRESS > >On some architectures, the maximum representable address deviates from >the virtual address range that is accessible by the firmware at boot >time. For instance, on AArch64, UEFI mandates a 4 KB page size, which >limits the address space to 48 bits, while more than that may be >populated on a particular platform, for use by the OS. > >So introduce a new macro MAX_ALLOC_ADDRESS, which represent the >maximum >address the firmware should take into account when allocating memory >ranges that need to be accessible by the CPU at boot time. > >Contributed-under: TianoCore Contribution Agreement 1.1 >Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> >--- > MdePkg/Include/AArch64/ProcessorBind.h | 5 +++++ > MdePkg/Include/Arm/ProcessorBind.h | 5 +++++ > MdePkg/Include/Ebc/ProcessorBind.h | 5 +++++ > MdePkg/Include/Ia32/ProcessorBind.h | 5 +++++ > MdePkg/Include/X64/ProcessorBind.h | 5 +++++ > 5 files changed, 25 insertions(+) > >diff --git a/MdePkg/Include/AArch64/ProcessorBind.h >b/MdePkg/Include/AArch64/ProcessorBind.h >index 968c18f915ae..f4a544b34d78 100644 >--- a/MdePkg/Include/AArch64/ProcessorBind.h >+++ b/MdePkg/Include/AArch64/ProcessorBind.h >@@ -142,6 +142,11 @@ typedef INT64 INTN; > /// > #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL > >+/// >+/// Maximum usable address at boot time (48 bits using 4 KB pages) >+/// >+#define MAX_ALLOC_ADDRESS 0xFFFFFFFFFFFFULL >+ > /// > /// Maximum legal AArch64 INTN and UINTN values. > /// >diff --git a/MdePkg/Include/Arm/ProcessorBind.h >b/MdePkg/Include/Arm/ProcessorBind.h >index 8cca0f3bb050..16a61fc7a325 100644 >--- a/MdePkg/Include/Arm/ProcessorBind.h >+++ b/MdePkg/Include/Arm/ProcessorBind.h >@@ -148,6 +148,11 @@ typedef INT32 INTN; > /// > #define MAX_ADDRESS 0xFFFFFFFF > >+/// >+/// Maximum usable address at boot time >+/// >+#define MAX_ALLOC_ADDRESS MAX_ADDRESS >+ > /// > /// Maximum legal ARM INTN and UINTN values. > /// >diff --git a/MdePkg/Include/Ebc/ProcessorBind.h >b/MdePkg/Include/Ebc/ProcessorBind.h >index 5217cfd97eac..45beb7572817 100644 >--- a/MdePkg/Include/Ebc/ProcessorBind.h >+++ b/MdePkg/Include/Ebc/ProcessorBind.h >@@ -103,6 +103,11 @@ typedef unsigned long UINTN; > /// > #define MAX_ADDRESS ((UINTN)(~0ULL >> (64 - sizeof (INTN) * 8))) > >+/// >+/// Maximum usable address at boot time (48 bits using 4 KB pages) >+/// >+#define MAX_ALLOC_ADDRESS MAX_ADDRESS >+ > /// > /// Maximum legal EBC INTN and UINTN values. > /// >diff --git a/MdePkg/Include/Ia32/ProcessorBind.h >b/MdePkg/Include/Ia32/ProcessorBind.h >index 8e4de7029cfc..71d53e2543bb 100644 >--- a/MdePkg/Include/Ia32/ProcessorBind.h >+++ b/MdePkg/Include/Ia32/ProcessorBind.h >@@ -246,6 +246,11 @@ typedef INT32 INTN; > /// > #define MAX_ADDRESS 0xFFFFFFFF > >+/// >+/// Maximum usable address at boot time >+/// >+#define MAX_ALLOC_ADDRESS MAX_ADDRESS >+ > /// > /// Maximum legal IA-32 INTN and UINTN values. > /// >diff --git a/MdePkg/Include/X64/ProcessorBind.h >b/MdePkg/Include/X64/ProcessorBind.h >index e4254285877b..1c04090c7d03 100644 >--- a/MdePkg/Include/X64/ProcessorBind.h >+++ b/MdePkg/Include/X64/ProcessorBind.h >@@ -260,6 +260,11 @@ typedef INT64 INTN; > /// > #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL > >+/// >+/// Maximum usable address at boot time >+/// >+#define MAX_ALLOC_ADDRESS MAX_ADDRESS >+ > /// > /// Maximum legal x64 INTN and UINTN values. > /// >-- >2.19.2 > >_______________________________________________ >edk2-devel mailing list >edk2-devel@lists.01.org >https://lists.01.org/mailman/listinfo/edk2-devel _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
diff --git a/MdePkg/Include/AArch64/ProcessorBind.h b/MdePkg/Include/AArch64/ProcessorBind.h index 968c18f915ae..f4a544b34d78 100644 --- a/MdePkg/Include/AArch64/ProcessorBind.h +++ b/MdePkg/Include/AArch64/ProcessorBind.h @@ -142,6 +142,11 @@ typedef INT64 INTN; /// #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL +/// +/// Maximum usable address at boot time (48 bits using 4 KB pages) +/// +#define MAX_ALLOC_ADDRESS 0xFFFFFFFFFFFFULL + /// /// Maximum legal AArch64 INTN and UINTN values. /// diff --git a/MdePkg/Include/Arm/ProcessorBind.h b/MdePkg/Include/Arm/ProcessorBind.h index 8cca0f3bb050..16a61fc7a325 100644 --- a/MdePkg/Include/Arm/ProcessorBind.h +++ b/MdePkg/Include/Arm/ProcessorBind.h @@ -148,6 +148,11 @@ typedef INT32 INTN; /// #define MAX_ADDRESS 0xFFFFFFFF +/// +/// Maximum usable address at boot time +/// +#define MAX_ALLOC_ADDRESS MAX_ADDRESS + /// /// Maximum legal ARM INTN and UINTN values. /// diff --git a/MdePkg/Include/Ebc/ProcessorBind.h b/MdePkg/Include/Ebc/ProcessorBind.h index 5217cfd97eac..45beb7572817 100644 --- a/MdePkg/Include/Ebc/ProcessorBind.h +++ b/MdePkg/Include/Ebc/ProcessorBind.h @@ -103,6 +103,11 @@ typedef unsigned long UINTN; /// #define MAX_ADDRESS ((UINTN)(~0ULL >> (64 - sizeof (INTN) * 8))) +/// +/// Maximum usable address at boot time (48 bits using 4 KB pages) +/// +#define MAX_ALLOC_ADDRESS MAX_ADDRESS + /// /// Maximum legal EBC INTN and UINTN values. /// diff --git a/MdePkg/Include/Ia32/ProcessorBind.h b/MdePkg/Include/Ia32/ProcessorBind.h index 8e4de7029cfc..71d53e2543bb 100644 --- a/MdePkg/Include/Ia32/ProcessorBind.h +++ b/MdePkg/Include/Ia32/ProcessorBind.h @@ -246,6 +246,11 @@ typedef INT32 INTN; /// #define MAX_ADDRESS 0xFFFFFFFF +/// +/// Maximum usable address at boot time +/// +#define MAX_ALLOC_ADDRESS MAX_ADDRESS + /// /// Maximum legal IA-32 INTN and UINTN values. /// diff --git a/MdePkg/Include/X64/ProcessorBind.h b/MdePkg/Include/X64/ProcessorBind.h index e4254285877b..1c04090c7d03 100644 --- a/MdePkg/Include/X64/ProcessorBind.h +++ b/MdePkg/Include/X64/ProcessorBind.h @@ -260,6 +260,11 @@ typedef INT64 INTN; /// #define MAX_ADDRESS 0xFFFFFFFFFFFFFFFFULL +/// +/// Maximum usable address at boot time +/// +#define MAX_ALLOC_ADDRESS MAX_ADDRESS + /// /// Maximum legal x64 INTN and UINTN values. ///
On some architectures, the maximum representable address deviates from the virtual address range that is accessible by the firmware at boot time. For instance, on AArch64, UEFI mandates a 4 KB page size, which limits the address space to 48 bits, while more than that may be populated on a particular platform, for use by the OS. So introduce a new macro MAX_ALLOC_ADDRESS, which represent the maximum address the firmware should take into account when allocating memory ranges that need to be accessible by the CPU at boot time. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- MdePkg/Include/AArch64/ProcessorBind.h | 5 +++++ MdePkg/Include/Arm/ProcessorBind.h | 5 +++++ MdePkg/Include/Ebc/ProcessorBind.h | 5 +++++ MdePkg/Include/Ia32/ProcessorBind.h | 5 +++++ MdePkg/Include/X64/ProcessorBind.h | 5 +++++ 5 files changed, 25 insertions(+) -- 2.19.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel