Skip to content

Commit 27cd551

Browse files
committed
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: Ard Biesheuvel <[email protected]>
1 parent 80b1bfe commit 27cd551

File tree

4 files changed

+7
-8
lines changed

4 files changed

+7
-8
lines changed

drivers/firmware/efi/libstub/efi-stub-helper.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,7 @@ efi_status_t efi_parse_options(char const *cmdline)
212212
* Size of memory allocated return in *cmd_line_len.
213213
* Returns NULL on error.
214214
*/
215-
char *efi_convert_cmdline(efi_loaded_image_t *image,
216-
int *cmd_line_len, unsigned long max_addr)
215+
char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len)
217216
{
218217
const u16 *s2;
219218
unsigned long cmdline_addr = 0;
@@ -275,7 +274,8 @@ char *efi_convert_cmdline(efi_loaded_image_t *image,
275274

276275
options_bytes++; /* NUL termination */
277276

278-
status = efi_allocate_pages(options_bytes, &cmdline_addr, max_addr);
277+
status = efi_bs_call(allocate_pool, EFI_LOADER_DATA, options_bytes,
278+
(void **)&cmdline_addr);
279279
if (status != EFI_SUCCESS)
280280
return NULL;
281281

drivers/firmware/efi/libstub/efi-stub.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ efi_status_t efi_entry(efi_handle_t handle, efi_system_table_t *sys_table_arg)
198198
* protocol. We are going to copy the command line into the
199199
* device tree, so this can be allocated anywhere.
200200
*/
201-
cmdline_ptr = efi_convert_cmdline(image, &cmdline_size, ULONG_MAX);
201+
cmdline_ptr = efi_convert_cmdline(image, &cmdline_size);
202202
if (!cmdline_ptr) {
203203
efi_err("getting command line via LOADED_IMAGE_PROTOCOL\n");
204204
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)
339339
fail_free_screeninfo:
340340
free_screen_info(si);
341341
fail_free_cmdline:
342-
efi_free(cmdline_size, (unsigned long)cmdline_ptr);
342+
efi_bs_call(free_pool, cmdline_ptr);
343343
fail:
344344
return status;
345345
}

drivers/firmware/efi/libstub/efistub.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -708,8 +708,7 @@ __printf(1, 2) int efi_printk(char const *fmt, ...);
708708

709709
void efi_free(unsigned long size, unsigned long addr);
710710

711-
char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len,
712-
unsigned long max_addr);
711+
char *efi_convert_cmdline(efi_loaded_image_t *image, int *cmd_line_len);
713712

714713
efi_status_t efi_get_memory_map(struct efi_boot_memmap *map);
715714

drivers/firmware/efi/libstub/x86-stub.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ efi_status_t __efiapi efi_pe_entry(efi_handle_t handle,
404404
hdr->type_of_loader = 0x21;
405405

406406
/* Convert unicode cmdline to ascii */
407-
cmdline_ptr = efi_convert_cmdline(image, &options_size, ULONG_MAX);
407+
cmdline_ptr = efi_convert_cmdline(image, &options_size);
408408
if (!cmdline_ptr)
409409
goto fail;
410410

0 commit comments

Comments
 (0)