Commit 27cd5511 authored by Ard Biesheuvel's avatar Ard Biesheuvel

efi/libstub: Use pool allocation for the command line

Now that we removed the memory limit for the allocation of the
command line, there is no longer a need to use the page based
allocator so switch to a pool allocation instead.
Signed-off-by: default avatarArd Biesheuvel <ardb@kernel.org>
parent 80b1bfe1
...@@ -212,8 +212,7 @@ efi_status_t efi_parse_options(char const *cmdline) ...@@ -212,8 +212,7 @@ efi_status_t efi_parse_options(char const *cmdline)
* Size of memory allocated return in *cmd_line_len. * Size of memory allocated return in *cmd_line_len.
* Returns NULL on error. * Returns NULL on error.
*/ */
char *efi_convert_cmdline(efi_loaded_image_t *image, char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len)
int *cmd_line_len, unsigned long max_addr)
{ {
const u16 *s2; const u16 *s2;
unsigned long cmdline_addr = 0; unsigned long cmdline_addr = 0;
...@@ -275,7 +274,8 @@ char *efi_convert_cmdline(efi_loaded_image_t *image, ...@@ -275,7 +274,8 @@ char *efi_convert_cmdline(efi_loaded_image_t *image,
options_bytes++; /* NUL termination */ options_bytes++; /* NUL termination */
status = efi_allocate_pages(options_bytes, &cmdline_addr, max_addr); status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, options_bytes,
(void **)&cmdline_addr);
if (status != EFI_SUCCESS) if (status != EFI_SUCCESS)
return NULL; return NULL;
......
...@@ -198,7 +198,7 @@ efi_status_t efi_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg) ...@@ -198,7 +198,7 @@ efi_status_t efi_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg)
* protocol. We are going to copy the command line into the * protocol. We are going to copy the command line into the
* device tree, so this can be allocated anywhere. * device tree, so this can be allocated anywhere.
*/ */
cmdline_ptr = efi_convert_cmdline(image, &cmdline_size, ULONG_MAX); cmdline_ptr = efi_convert_cmdline(image, &cmdline_size);
if (!cmdline_ptr) { if (!cmdline_ptr) {
efi_err("getting command line via LOADED_IMAGE_PROTOCOL\n"); efi_err("getting command line via LOADED_IMAGE_PROTOCOL\n");
status = EFI_OUT_OF_RESOURCES; status = EFI_OUT_OF_RESOURCES;
...@@ -339,7 +339,7 @@ efi_status_t efi_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg) ...@@ -339,7 +339,7 @@ efi_status_t efi_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg)
fail_free_screeninfo: fail_free_screeninfo:
free_screen_info(si); free_screen_info(si);
fail_free_cmdline: fail_free_cmdline:
efi_free(cmdline_size, (unsigned long)cmdline_ptr); efi_bs_call(free_pool, cmdline_ptr);
fail: fail:
return status; return status;
} }
......
...@@ -708,8 +708,7 @@ __printf(1, 2) int efi_printk(char const *fmt, ...); ...@@ -708,8 +708,7 @@ __printf(1, 2) int efi_printk(char const *fmt, ...);
void efi_free(unsigned long size, unsigned long addr); void efi_free(unsigned long size, unsigned long addr);
char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len, char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len);
unsigned long max_addr);
efi_status_t efi_get_memory_map(struct efi_boot_memmap *map); efi_status_t efi_get_memory_map(struct efi_boot_memmap *map);
......
...@@ -404,7 +404,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle, ...@@ -404,7 +404,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
hdr->type_of_loader = 0x21; hdr->type_of_loader = 0x21;
/* Convert unicode cmdline to ascii */ /* Convert unicode cmdline to ascii */
cmdline_ptr = efi_convert_cmdline(image, &options_size, ULONG_MAX); cmdline_ptr = efi_convert_cmdline(image, &options_size);
if (!cmdline_ptr) if (!cmdline_ptr)
goto fail; goto fail;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment