From: Glenn Washburn <development@efficientek.com>
To: grub-devel@gnu.org, Daniel Kiper <dkiper@net-space.pl>
Cc: Ard Biesheuvel <ardb@kernel.org>,
Glenn Washburn <development@efficientek.com>
Subject: [PATCH v2 0/2] EFI chainloader improvement
Date: Wed, 31 May 2023 23:16:24 -0500 [thread overview]
Message-ID: <cover.1685592596.git.development@efficientek.com> (raw)
Changes since v1:
* Rebase onto latest master
* Change logic: The device path argument to image load changed back to the way
it was originally where the argument is set to the device path that $root
resolves to. If $root does not resolve or is not a device, the argument
will be NULL as allowed for in the spec. By setting $root to the device of
the chainloaded file, v1 behavior can be had. So this is more versatile
behavior.
* Minor rewording of metadata.
This series improves the EFI chainloader. I've noticed for a while now that
chainloading would fail when root=memdisk. It didn't really make sense because
I was specifying the image to chainload as device+path, so why would it care
about what my root was. But I noticed that if I changed the root to the device
the image file was located on, then chainloading worked. The second patch
fixes this by removing some previous assumptions that I don't believe are
valid (eg. that LoadImage needs a valid device path).
Glenn
Glenn Washburn (2):
docs: Document extra arguments to chainloader on EFI
efi/chainloader: Do not require a $root visible to EFI firmware when
chainloading
docs/grub.texi | 7 +++++--
grub-core/loader/efi/chainloader.c | 28 +++++++++++++---------------
2 files changed, 18 insertions(+), 17 deletions(-)
Range-diff against v1:
2: 04edeb1d7fd0 ! 1: d1fc25518bfc docs: Document that extra arguments to chainloader on EFI
@@ Metadata
Author: Glenn Washburn <development@efficientek.com>
## Commit message ##
- docs: Document that extra arguments to chainloader on EFI
+ docs: Document extra arguments to chainloader on EFI
Extra arguments given to chainloader on EFI platforms will be sent to
the chainloaded application. Also, minor edit in the chainloading section
@@ Commit message
necessarily in real mode (which does not exist on some achitectures).
## docs/grub.texi ##
-@@ docs/grub.texi: information.
+@@ docs/grub.texi: invoke shutdown machinery.
Operating systems that do not support Multiboot and do not have specific
support in GRUB (specific support is available for Linux, FreeBSD, NetBSD
and OpenBSD) must be chain-loaded, which involves loading another boot
1: eed74ee4b128 ! 2: c17d3a8a0fe0 efi/chainloader: Do not require a valid $root when chainloading
@@ Metadata
Author: Glenn Washburn <development@efficientek.com>
## Commit message ##
- efi/chainloader: Do not require a valid $root when chainloading
+ efi/chainloader: Do not require a $root visible to EFI firmware when chainloading
The EFI chainloader checks that a device path can be created for the $root
device before allowing chainloading to a given file. This is probably to
@@ Commit message
that is accessible by the firmware, eg. (hd0,1)/efi/boot.efi, would
fail when root is a location inaccessible by the firmware, eg. memdisk.
- Use GRUB_EFI_BYTES_TO_PAGES() instead of donig the calculation explicitly.
+ Use GRUB_EFI_BYTES_TO_PAGES() instead of doing the calculation explicitly.
Add comment noting the section where the load options for the chainloaded
EFI application is constructed.
@@ grub-core/loader/efi/chainloader.c
#include <grub/i18n.h>
#include <grub/net.h>
@@ grub-core/loader/efi/chainloader.c: grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
- if (! file)
- goto fail;
-- /* Get the root device's device path. */
-- dev = grub_device_open (0);
+ /* Get the root device's device path. */
+ dev = grub_device_open (0);
- if (! dev)
- goto fail;
-
-+ dev = file->device;
- if (dev->disk)
+- if (dev->disk)
++ if (dev == NULL)
++ ;
++ else if (dev->disk)
dev_handle = grub_efidisk_get_device_handle (dev->disk);
else if (dev->net && dev->net->server)
+ {
@@ grub-core/loader/efi/chainloader.c: grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
if (dev_handle)
dp = grub_efi_get_device_path (dev_handle);
@@ grub-core/loader/efi/chainloader.c: grub_cmd_chainloader (grub_command_t cmd __a
- pages = (((grub_efi_uintn_t) size + ((1 << 12) - 1)) >> 12);
+ pages = (grub_efi_uintn_t) GRUB_EFI_BYTES_TO_PAGES (size);
- status = efi_call_4 (b->allocate_pages, GRUB_EFI_ALLOCATE_ANY_PAGES,
+ status = b->allocate_pages (GRUB_EFI_ALLOCATE_ANY_PAGES,
GRUB_EFI_LOADER_CODE,
@@ grub-core/loader/efi/chainloader.c: grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
}
@@ grub-core/loader/efi/chainloader.c: grub_cmd_chainloader (grub_command_t cmd __a
if (argc > 1)
{
int i, len;
-@@ grub-core/loader/efi/chainloader.c: grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
- }
-
- grub_file_close (file);
-- grub_device_close (dev);
-
- /* We're finished with the source image buffer and file path now. */
- efi_call_2 (b->free_pages, address, pages);
-@@ grub-core/loader/efi/chainloader.c: grub_cmd_chainloader (grub_command_t cmd __attribute__ ((unused)),
-
- fail:
-
-- if (dev)
-- grub_device_close (dev);
--
- if (file)
- grub_file_close (file);
-
--
2.34.1
next reply other threads:[~2023-06-01 4:17 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-01 4:16 Glenn Washburn [this message]
2023-06-01 4:16 ` [PATCH v2 1/2] docs: Document extra arguments to chainloader on EFI Glenn Washburn
2023-06-01 4:16 ` [PATCH v2 2/2] efi/chainloader: Do not require a $root visible to EFI firmware when chainloading Glenn Washburn
2023-06-01 7:33 ` [PATCH v2 0/2] EFI chainloader improvement Ard Biesheuvel
2023-06-01 9:53 ` Daniel Kiper
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=cover.1685592596.git.development@efficientek.com \
--to=development@efficientek.com \
--cc=ardb@kernel.org \
--cc=dkiper@net-space.pl \
--cc=grub-devel@gnu.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.