Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
openSUSE:Step:15-SP2
grub2.13247
0002-Remove-grub_efi_allocate_pages.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File 0002-Remove-grub_efi_allocate_pages.patch of Package grub2.13247
From bb4cb6d374625d3716380affda56dc4c20da36db Mon Sep 17 00:00:00 2001 From: Vladimir Serbinenko <phcoder@gmail.com> Date: Mon, 7 Aug 2017 18:33:29 +0200 Subject: [PATCH 2/6] Remove grub_efi_allocate_pages. grub_efi_allocate_pages Essentially does 2 unrelated things: * Allocate at fixed address. * Allocate at any address. To switch between 2 different functions it uses address == 0 as magic value which is wrong as 0 is a perfectly valid fixed adress to allocate at. --- grub-core/kern/arm/efi/misc.c | 4 ++-- grub-core/kern/efi/mm.c | 30 ++++++++++++++---------------- grub-core/loader/arm64/fdt.c | 2 +- grub-core/loader/arm64/linux.c | 7 +++---- grub-core/loader/arm64/xen_boot.c | 7 +++---- grub-core/loader/i386/efi/linux.c | 2 +- grub-core/loader/ia64/efi/linux.c | 10 +++++----- include/grub/autoefi.h | 2 +- include/grub/efi/efi.h | 4 +++- 9 files changed, 33 insertions(+), 35 deletions(-) diff --git a/grub-core/kern/arm/efi/misc.c b/grub-core/kern/arm/efi/misc.c index 7cd41842a..c95e8299d 100644 --- a/grub-core/kern/arm/efi/misc.c +++ b/grub-core/kern/arm/efi/misc.c @@ -146,7 +146,7 @@ grub_efi_allocate_loader_memory (grub_uint32_t min_offset, grub_uint32_t size) continue; grub_dprintf("mm", "%s: let's allocate some (0x%x) pages @ 0x%08x...\n", __FUNCTION__, (size >> PAGE_SHIFT), (grub_addr_t) start); - mem = grub_efi_allocate_pages (start, (size >> PAGE_SHIFT) + 1); + mem = grub_efi_allocate_fixed (start, (size >> PAGE_SHIFT) + 1); grub_dprintf("mm", "%s: retval=0x%08x\n", __FUNCTION__, (grub_addr_t) mem); if (! mem) @@ -189,7 +189,7 @@ grub_efi_prepare_platform (void) mmap_size = find_mmap_size (); if (! mmap_size) return GRUB_ERR_OUT_OF_MEMORY; - mmap_buf = grub_efi_allocate_pages (0, page_align (mmap_size) >> 12); + mmap_buf = grub_efi_allocate_any_pages (page_align (mmap_size) >> 12); if (! mmap_buf) return GRUB_ERR_OUT_OF_MEMORY; diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index a03a44e71..4226f34ec 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -179,20 +179,19 @@ grub_efi_allocate_pages_real (grub_efi_physical_address_t address, } void * -grub_efi_allocate_pages (grub_efi_physical_address_t address, - grub_efi_uintn_t pages) +grub_efi_allocate_any_pages (grub_efi_uintn_t pages) { - grub_efi_allocate_type_t alloctype; - - if (address == 0) - { - alloctype = GRUB_EFI_ALLOCATE_MAX_ADDRESS; - address = GRUB_EFI_MAX_USABLE_ADDRESS; - } - else - alloctype = GRUB_EFI_ALLOCATE_ADDRESS; + return grub_efi_allocate_pages_real (GRUB_EFI_MAX_USABLE_ADDRESS, + pages, GRUB_EFI_ALLOCATE_MAX_ADDRESS, + GRUB_EFI_LOADER_DATA); +} - return grub_efi_allocate_pages_real (address, pages, alloctype, +void * +grub_efi_allocate_fixed (grub_efi_physical_address_t address, + grub_efi_uintn_t pages) +{ + return grub_efi_allocate_pages_real (address, pages, + GRUB_EFI_ALLOCATE_ADDRESS, GRUB_EFI_LOADER_DATA); } @@ -501,7 +500,7 @@ add_memory_regions (grub_efi_memory_descriptor_t *memory_map, pages = required_pages; } - addr = grub_efi_allocate_pages (start, pages); + addr = grub_efi_allocate_fixed (start, pages); if (! addr) grub_fatal ("cannot allocate conventional memory %p with %u pages", (void *) ((grub_addr_t) start), @@ -567,8 +566,7 @@ grub_efi_mm_init (void) int mm_status; /* Prepare a memory region to store two memory maps. */ - memory_map = grub_efi_allocate_pages (0, - 2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); + memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (MEMORY_MAP_SIZE)); if (! memory_map) grub_fatal ("cannot allocate memory"); @@ -586,7 +584,7 @@ grub_efi_mm_init (void) /* Freeing/allocating operations may increase memory map size. */ map_size += desc_size * 32; - memory_map = grub_efi_allocate_pages (0, 2 * BYTES_TO_PAGES (map_size)); + memory_map = grub_efi_allocate_any_pages (2 * BYTES_TO_PAGES (map_size)); if (! memory_map) grub_fatal ("cannot allocate memory"); diff --git a/grub-core/loader/arm64/fdt.c b/grub-core/loader/arm64/fdt.c index db49cf649..368001696 100644 --- a/grub-core/loader/arm64/fdt.c +++ b/grub-core/loader/arm64/fdt.c @@ -50,7 +50,7 @@ grub_fdt_load (grub_size_t additional_size) size += additional_size; grub_dprintf ("linux", "allocating %ld bytes for fdt\n", size); - fdt = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (size)); + fdt = grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (size)); if (!fdt) return NULL; diff --git a/grub-core/loader/arm64/linux.c b/grub-core/loader/arm64/linux.c index 9519d2e4d..ee3fcaa86 100644 --- a/grub-core/loader/arm64/linux.c +++ b/grub-core/loader/arm64/linux.c @@ -148,8 +148,7 @@ grub_arm64_uefi_boot_image (grub_addr_t addr, grub_size_t size, char *args) loaded_image->load_options_size = len = (grub_strlen (args) + 1) * sizeof (grub_efi_char16_t); loaded_image->load_options = - grub_efi_allocate_pages (0, - GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); + grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (loaded_image->load_options_size)); if (!loaded_image->load_options) return grub_errno; @@ -223,7 +222,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_dprintf ("linux", "Loading initrd\n"); initrd_pages = (GRUB_EFI_BYTES_TO_PAGES (initrd_size)); - initrd_mem = grub_efi_allocate_pages (0, initrd_pages); + initrd_mem = grub_efi_allocate_any_pages (initrd_pages); if (!initrd_mem) { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); @@ -277,7 +276,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), grub_loader_unset(); grub_dprintf ("linux", "kernel file size: %lld\n", (long long) kernel_size); - kernel_addr = grub_efi_allocate_pages (0, GRUB_EFI_BYTES_TO_PAGES (kernel_size)); + kernel_addr = grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES (kernel_size)); grub_dprintf ("linux", "kernel numpages: %lld\n", (long long) GRUB_EFI_BYTES_TO_PAGES (kernel_size)); if (!kernel_addr) diff --git a/grub-core/loader/arm64/xen_boot.c b/grub-core/loader/arm64/xen_boot.c index a914eb8e2..ab7c2f850 100644 --- a/grub-core/loader/arm64/xen_boot.c +++ b/grub-core/loader/arm64/xen_boot.c @@ -324,10 +324,9 @@ xen_boot_binary_load (struct xen_boot_binary *binary, grub_file_t file, grub_dprintf ("xen_loader", "Xen_boot file size: 0x%lx\n", binary->size); binary->start - = (grub_addr_t) grub_efi_allocate_pages (0, - GRUB_EFI_BYTES_TO_PAGES - (binary->size + - binary->align)); + = (grub_addr_t) grub_efi_allocate_any_pages (GRUB_EFI_BYTES_TO_PAGES + (binary->size + + binary->align)); if (!binary->start) { grub_error (GRUB_ERR_OUT_OF_MEMORY, N_("out of memory")); diff --git a/grub-core/loader/i386/efi/linux.c b/grub-core/loader/i386/efi/linux.c index 549989d1d..27dea343c 100644 --- a/grub-core/loader/i386/efi/linux.c +++ b/grub-core/loader/i386/efi/linux.c @@ -295,7 +295,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), start = (lh.setup_sects + 1) * 512; len = grub_file_size(file) - start; - kernel_mem = grub_efi_allocate_pages(lh.pref_address, + kernel_mem = grub_efi_allocate_fixed(lh.pref_address, BYTES_TO_PAGES(lh.init_size)); if (!kernel_mem) diff --git a/grub-core/loader/ia64/efi/linux.c b/grub-core/loader/ia64/efi/linux.c index efaa42ccd..750330d45 100644 --- a/grub-core/loader/ia64/efi/linux.c +++ b/grub-core/loader/ia64/efi/linux.c @@ -252,7 +252,7 @@ allocate_pages (grub_uint64_t align, grub_uint64_t size_pages, aligned_start += align; if (aligned_start + size > end) continue; - mem = grub_efi_allocate_pages (aligned_start, size_pages); + mem = grub_efi_allocate_fixed (aligned_start, size_pages); if (! mem) { grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate memory"); @@ -326,7 +326,7 @@ grub_linux_boot (void) mmap_size = find_mmap_size (); if (! mmap_size) return grub_errno; - mmap_buf = grub_efi_allocate_pages (0, page_align (mmap_size) >> 12); + mmap_buf = grub_efi_allocate_any_pages (page_align (mmap_size) >> 12); if (! mmap_buf) return grub_error (GRUB_ERR_IO, "cannot allocate memory map"); err = grub_efi_finish_boot_services (&mmap_size, mmap_buf, &map_key, @@ -422,7 +422,7 @@ grub_load_elf64 (grub_file_t file, void *buffer, const char *filename) relocate = grub_env_get ("linux_relocate"); if (!relocate || grub_strcmp (relocate, "force") != 0) { - kernel_mem = grub_efi_allocate_pages (low_addr, kernel_pages); + kernel_mem = grub_efi_allocate_fixed (low_addr, kernel_pages); reloc_offset = 0; } /* Try to relocate. */ @@ -524,7 +524,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)), len += grub_strlen (argv[i]) + 1; len += sizeof (struct ia64_boot_param) + 512; /* Room for extensions. */ boot_param_pages = page_align (len) >> 12; - boot_param = grub_efi_allocate_pages (0, boot_param_pages); + boot_param = grub_efi_allocate_any_pages (boot_param_pages); if (boot_param == 0) { grub_error (GRUB_ERR_OUT_OF_MEMORY, @@ -589,7 +589,7 @@ grub_cmd_initrd (grub_command_t cmd __attribute__ ((unused)), grub_dprintf ("linux", "Loading initrd\n"); initrd_pages = (page_align (initrd_size) >> 12); - initrd_mem = grub_efi_allocate_pages (0, initrd_pages); + initrd_mem = grub_efi_allocate_any_pages (initrd_pages); if (! initrd_mem) { grub_error (GRUB_ERR_OUT_OF_MEMORY, "cannot allocate pages"); diff --git a/include/grub/autoefi.h b/include/grub/autoefi.h index b75591176..b7a252e07 100644 --- a/include/grub/autoefi.h +++ b/include/grub/autoefi.h @@ -55,7 +55,7 @@ static inline grub_err_t grub_autoefi_prepare (void) # define SYSTEM_TABLE_PTR GRUB_EFIEMU_SYSTEM_TABLE_PTR # define SIZEOF_OF_UINTN GRUB_EFIEMU_SIZEOF_OF_UINTN # define SYSTEM_TABLE GRUB_EFIEMU_SYSTEM_TABLE -# define grub_efi_allocate_pages(x,y) (x) +# define grub_efi_allocate_fixed(x,y) (x) # define grub_efi_free_pages(x,y) GRUB_EFI_SUCCESS # define grub_autoefi_finish_boot_services grub_efiemu_finish_boot_services # define EFI_PRESENT 1 diff --git a/include/grub/efi/efi.h b/include/grub/efi/efi.h index c7f2fe6c3..f68a19de4 100644 --- a/include/grub/efi/efi.h +++ b/include/grub/efi/efi.h @@ -43,9 +43,11 @@ EXPORT_FUNC(grub_efi_allocate_pages_real) (grub_efi_physical_address_t address, grub_efi_allocate_type_t alloctype, grub_efi_memory_type_t memtype); void * -EXPORT_FUNC(grub_efi_allocate_pages) (grub_efi_physical_address_t address, +EXPORT_FUNC(grub_efi_allocate_fixed) (grub_efi_physical_address_t address, grub_efi_uintn_t pages); void * +EXPORT_FUNC(grub_efi_allocate_any_pages) (grub_efi_uintn_t pages); +void * EXPORT_FUNC(grub_efi_allocate_pages_max) (grub_efi_physical_address_t max, grub_efi_uintn_t pages); void EXPORT_FUNC(grub_efi_free_pages) (grub_efi_physical_address_t address, -- 2.16.4
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor