x86_64-efi: Ensure that memory is mapped when allocating This is a replacement workaround for EFIs that do not map memory above 4G and allows to increase maximum available address to 128TiB
PATCH 1/2 x86_64-efi: Ensure that memory is mapped when allocating This is a replacement workaround for EFIs that do not map memory above 4G and allows to increase maximum available address to 128TiB
From: Vladimir Serbinenko <[email protected]>
--- grub-core/Makefile.core.def | 1 + grub-core/kern/efi/mm.c | 10 ++++ grub-core/kern/x86_64/efi/mm.c | 84 ++++++++++++++++++++++++++++++++++ include/grub/efi/memory.h | 5 ++ 4 files changed, 100 insertions(+) create mode 100644 grub-core/kern/x86_64/efi/mm.c
grub-core/Makefile.core.def +1 -0
@@ -219,6 +219,7 @@ kernel = { efi = kern/efi/acpi.c; efi = kern/efi/sb.c; efi = kern/lockdown.c; + x86_64_efi = kern/x86_64/efi/mm.c; i386_coreboot = kern/i386/pc/acpi.c; i386_multiboot = kern/i386/pc/acpi.c; i386_coreboot = kern/acpi.c;
grub-core/kern/efi/mm.c +10 -0
@@ -160,6 +160,16 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, } } +#ifdef __x86_64__ + status =grub_efi_arch_ensure_mapping (address, pages); +if (status !=GRUB_EFI_SUCCESS ) + { + b->free_pages (address, pages); +grub_error (GRUB_ERR_OUT_OF_MEMORY ,N_ ("out of memory" )); +return NULL ; + } +#endif +grub_efi_store_alloc (address, pages);return (void *) ((grub_addr_t ) address);
grub-core/kern/x86_64/efi/mm.c new file +84 -0
84 lines not on this page · raw message
include/grub/efi/memory.h +5 -0
@@ -21,6 +21,7 @@#include <grub/err.h> #include <grub/types.h> +#include <grub/efi/api.h> /* The term "page" in UEFI refers only to a 4 KiB-aligned 4 KiB size region of memory. It is not concerned with underlying translation management concepts,
@@ -35,4 +36,8 @@ grub_err_t grub_machine_mmap_register (grub_uint64_t start, grub_uint64_t size, int type, int handle);grub_err_t grub_machine_mmap_unregister (int handle); +grub_efi_status_t +grub_efi_arch_ensure_mapping (grub_efi_physical_address_t address, +grub_efi_uintn_t pages); +#endif /* ! GRUB_MEMORY_MACHINE_HEADER */
Signature · 7 lines
2.49.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
PATCH 2/2 kern/efi/mm: ask for more that 4GB if we need it
earlier version of this didn't count for other archs and actually mapping the unmapped memory above 4GB.
this builds on top of the previous patch (by phcoder) in the series and hopefully will do all of the above.
Signed-off-by Paymon MARANDI <[email protected]>
--- grub-core/kern/efi/mm.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
grub-core/kern/efi/mm.c +12 -3
@@ -178,9 +178,18 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address,void *grub_efi_allocate_any_pages (grub_efi_uintn_t pages) { -return grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS , - pages,GRUB_EFI_ALLOCATE_MAX_ADDRESS , -GRUB_EFI_LOADER_DATA ); +void *ret; + ret =grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS , pages, +GRUB_EFI_ALLOCATE_MAX_ADDRESS , +GRUB_EFI_LOADER_DATA ); +if (ret ==NULL ) + { + grub_errno =GRUB_ERR_NONE ; + ret =grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS , + pages,GRUB_EFI_ALLOCATE_ANY_PAGES , +GRUB_EFI_LOADER_DATA ); + } +return ret; } void *
Signature · 7 lines
2.49.0 _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel
oops! sorry about the mess; please discard.
Signature · 6 lines
Paymon _______________________________________________ Grub-devel mailing list [email protected] https://lists.gnu.org/mailman/listinfo/grub-devel