Message ID | 20181207112304.19765-2-ard.biesheuvel@linaro.org |
---|---|
State | New |
Headers | show |
Series | introduce MAX_ALLOC_ADDRESS to limit boot time allocations | expand |
On 12/07/18 12:22, Ard Biesheuvel wrote: > 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. Initially, > it just defaults to MAX_ADDRESS, but later on, architectures may elect > to override it to a smaller number. > > This means that all replacements of MAX_ADDRESS with MAX_ALLOC_ADDRESS > are functional no-ops unless an architecture sets a value for the latter. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> > --- > MdePkg/Include/Base.h | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h > index bc877d8125a5..618f8ea85ce7 100644 > --- a/MdePkg/Include/Base.h > +++ b/MdePkg/Include/Base.h > @@ -404,6 +404,10 @@ struct _LIST_ENTRY { > #define MIN_INT32 (((INT32) -2147483647) - 1) > #define MIN_INT64 (((INT64) -9223372036854775807LL) - 1) > > +#ifndef MAX_ALLOC_ADDRESS > +#define MAX_ALLOC_ADDRESS MAX_ADDRESS > +#endif > + > #define BIT0 0x00000001 > #define BIT1 0x00000002 > #define BIT2 0x00000004 > Given that the page size is dictated by the spec, I think adding MAX_ALLOC_ADDRESS as a macro, and doing it here, is appropriate. Reviewed-by: Laszlo Ersek <lersek@redhat.com> _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel
diff --git a/MdePkg/Include/Base.h b/MdePkg/Include/Base.h index bc877d8125a5..618f8ea85ce7 100644 --- a/MdePkg/Include/Base.h +++ b/MdePkg/Include/Base.h @@ -404,6 +404,10 @@ struct _LIST_ENTRY { #define MIN_INT32 (((INT32) -2147483647) - 1) #define MIN_INT64 (((INT64) -9223372036854775807LL) - 1) +#ifndef MAX_ALLOC_ADDRESS +#define MAX_ALLOC_ADDRESS MAX_ADDRESS +#endif + #define BIT0 0x00000001 #define BIT1 0x00000002 #define BIT2 0x00000004
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. Initially, it just defaults to MAX_ADDRESS, but later on, architectures may elect to override it to a smaller number. This means that all replacements of MAX_ADDRESS with MAX_ALLOC_ADDRESS are functional no-ops unless an architecture sets a value for the latter. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- MdePkg/Include/Base.h | 4 ++++ 1 file changed, 4 insertions(+) -- 2.19.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel