From: Jonathan Marek <jonathan@marek.ca>
To: Ard Biesheuvel <ardb@kernel.org>
Cc: linux-efi@vger.kernel.org, open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH 3/3] efi/libstub: consider CONFIG_CMDLINE for initrd= and dtb= options
Date: Sat, 12 Oct 2024 11:00:49 -0400 [thread overview]
Message-ID: <149af6cb-300c-af5e-2a91-161be0dd4d43@marek.ca> (raw)
In-Reply-To: <CAMj1kXH_YbTR9xe7G=ZfqhZ6aBFE8O-ghUe8asd3qqEUN7vdUw@mail.gmail.com>
On 10/12/24 10:50 AM, Ard Biesheuvel wrote:
...
>
> Right.
>
> Would the below work for you? It's not the prettiest code in the
> world, but at least it keeps the weird local to the function.
>
Its missing the "load_options_size == 0" case, then CONFIG_CMDLINE
should be used even if FORCE/etc. are not set. Otherwise it looks OK.
(cmdline_len also shouldn't include the NUL character, but I don't think
that matters)
> --- a/drivers/firmware/efi/libstub/file.c
> +++ b/drivers/firmware/efi/libstub/file.c
> @@ -189,26 +189,48 @@
> unsigned long *load_addr,
> unsigned long *load_size)
> {
> - const efi_char16_t *cmdline = efi_table_attr(image, load_options);
> - u32 cmdline_len = efi_table_attr(image, load_options_size);
> unsigned long efi_chunk_size = ULONG_MAX;
> efi_file_protocol_t *volume = NULL;
> + const efi_char16_t *cmdline;
> efi_file_protocol_t *file;
> unsigned long alloc_addr;
> unsigned long alloc_size;
> efi_status_t status;
> + bool again = false;
> + u32 cmdline_len;
> int offset;
>
> if (!load_addr || !load_size)
> return EFI_INVALID_PARAMETER;
>
> - efi_apply_loadoptions_quirk((const void **)&cmdline, &cmdline_len);
> - cmdline_len /= sizeof(*cmdline);
> -
> if (IS_ENABLED(CONFIG_X86) && !efi_nochunk)
> efi_chunk_size = EFI_READ_CHUNK_SIZE;
>
> alloc_addr = alloc_size = 0;
> +
> +#ifdef CONFIG_CMDLINE
> + if (IS_ENABLED(CONFIG_CMDLINE_FORCE) ||
> + IS_ENABLED(CONFIG_CMDLINE_OVERRIDE) ||
> + (again = (IS_ENABLED(CONFIG_X86) ||
> + IS_ENABLED(CONFIG_CMDLINE_EXTEND)))) {
> + static const efi_char16_t builtin_cmdline[] = L""
> CONFIG_CMDLINE;
> +
> + cmdline = builtin_cmdline;
> + cmdline_len = sizeof(builtin_cmdline);
> + } else
> +#endif
> + {
> +do_load_options:
> + cmdline = efi_table_attr(image, load_options);
> + cmdline_len = efi_table_attr(image, load_options_size);
> +
> + efi_apply_loadoptions_quirk((const void **)&cmdline,
> + &cmdline_len);
> +
> + again = false;
> + }
> + cmdline_len /= sizeof(*cmdline);
> +
> do {
> struct finfo fi;
> unsigned long size;
> @@ -290,6 +312,9 @@
> efi_call_proto(volume, close);
> } while (offset > 0);
>
> + if (again)
> + goto do_load_options;
> +
> *load_addr = alloc_addr;
> *load_size = alloc_size;
>
next prev parent reply other threads:[~2024-10-12 15:04 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-11 22:48 [PATCH 1/3] efi/libstub: fix efi_parse_options() ignoring the default command line Jonathan Marek
2024-10-11 22:48 ` [PATCH 2/3] efi/libstub: remove uneccessary cmdline_size init/check Jonathan Marek
2024-10-12 7:49 ` Ard Biesheuvel
2024-10-11 22:48 ` [PATCH 3/3] efi/libstub: consider CONFIG_CMDLINE for initrd= and dtb= options Jonathan Marek
2024-10-12 7:54 ` Ard Biesheuvel
2024-10-12 12:00 ` Jonathan Marek
2024-10-12 13:36 ` Ard Biesheuvel
2024-10-12 14:07 ` Jonathan Marek
2024-10-12 14:50 ` Ard Biesheuvel
2024-10-12 15:00 ` Jonathan Marek [this message]
2024-10-15 0:13 ` kernel test robot
2024-10-15 2:08 ` kernel test robot
2024-10-12 7:46 ` [PATCH 1/3] efi/libstub: fix efi_parse_options() ignoring the default command line Ard Biesheuvel
2024-10-12 11:55 ` Jonathan Marek
2024-10-12 13:15 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=149af6cb-300c-af5e-2a91-161be0dd4d43@marek.ca \
--to=jonathan@marek.ca \
--cc=ardb@kernel.org \
--cc=linux-efi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox