Documentation/x86: explain LINUX_EFI_INITRD_MEDIA_GUID
Subsystems (3)
PATCH v2 1/1 Documentation/x86: explain LINUX_EFI_INITRD_MEDIA_GUID
From: Hugo Osvaldo Barrera <[email protected]>
Since the Handover Protocol was deprecated, the recommended approach is to provide an initrd using a UEFI boot service with the LINUX_EFI_INITRD_MEDIA_GUID device path. Documentation for the new approach has been no more than an admonition with a link to an existing implementation.
Provide a short explanation of this functionality, to ease future implementations without having to reverse engineer existing ones.
[Bagas: Don't use :ref: link to EFI stub documentation and refer to OVMF/edk2 implementation]
---
Changes since v1 [1]:
* Apply wording suggestion (Ard)
* Replace candyboot reference with OVMF (Ard)
* Invert patch subject prefix
[1]: https://lore.kernel.org/linux-doc/[email protected]/
Documentation/admin-guide/efi-stub.rst | 3 ++ Documentation/arch/x86/boot.rst | 38 ++++++++++++++++++++------ 2 files changed, 33 insertions(+), 8 deletions(-)
Documentation/admin-guide/efi-stub.rst +3 -0
@@ -79,6 +79,9 @@ because the image we're executing is interpreted by the EFI shell, which understands relative paths, whereas the rest of the command line is passed to bzImage.efi. +.. hint:: + It is also possible to provide an initrd using a Linux-specific UEFI + protocol at boot time. See :ref:`pe-coff-entry-point` for details. The "dtb=" option -----------------
Documentation/arch/x86/boot.rst +30 -8
@@ -1431,12 +1431,34 @@ The boot loader *must* fill out the following fields in bp:: All other fields should be zero. .. note:: - The EFI Handover Protocol is deprecated in favour of the ordinary PE/COFF - entry point, combined with the LINUX_EFI_INITRD_MEDIA_GUID based initrd - loading protocol (refer to [0] for an example of the bootloader side of - this), which removes the need for any knowledge on the part of the EFI - bootloader regarding the internal representation of boot_params or any - requirements/limitations regarding the placement of the command line - and ramdisk in memory, or the placement of the kernel image itself. + The EFI Handover Protocol is deprecated in favour of the ordinary PE/COFF + entry point described below. -[0] https://github.com/u-boot/u-boot/commit/ec80b4735a593961fe701cc3a5d717d4739b0fd0 +.. _pe-coff-entry-point: + +PE/COFF entry point +=================== + +When compiled with ``CONFIG_EFI_STUB=y``, the kernel can be executed as a +regular PE/COFF binary. See Documentation/admin-guide/efi-stub.rst for +implementation details. + +The stub loader can request the initrd via a UEFI protocol. For this to work, +the firmware or bootloader needs to register a handle which carries +implementations of the ``EFI_LOAD_FILE2`` protocol and the device path +protocol exposing the ``LINUX_EFI_INITRD_MEDIA_GUID`` vendor media device path. +In this case, a kernel booting via the EFI stub will invoke +``LoadFile2::LoadFile()`` method on the registered protocol to instruct the +firmware to load the initrd into a memory location chosen by the kernel/EFI +stub. + +This approach removes the need for any knowledge on the part of the EFI +bootloader regarding the internal representation of boot_params or any +requirements/limitations regarding the placement of the command line and +ramdisk in memory, or the placement of the kernel image itself. + +For sample implementations, refer to `the original u-boot implementation`_ or +`the OVMF implementation`_. + +.. _the original u-boot implementation: https://github.com/u-boot/u-boot/commit/ec80b4735a593961fe701cc3a5d717d4739b0fd0 +.. _the OVMF implementation: https://github.com/tianocore/edk2/blob/1780373897f12c25075f8883e073144506441168/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.c
base-commit: f44a29784f685804d9970cfb0d3439c9e30981d7
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Quoted 76 lines · Bagas Sanjaya
From: Hugo Osvaldo Barrera <[email protected]>
Since the Handover Protocol was deprecated, the recommended approach is to provide an initrd using a UEFI boot service with the
LINUX_EFI_INITRD_MEDIA_GUIDdevice path. Documentation for the new approach has been no more than an admonition with a link to an existing implementation.Provide a short explanation of this functionality, to ease future implementations without having to reverse engineer existing ones.
Signed-off-by Hugo Osvaldo Barrera <[email protected]>[Bagas: Don't use :ref: link to EFI stub documentation and refer to OVMF/edk2 implementation]
Co-developed-by Bagas Sanjaya <[email protected]>Signed-off-by Bagas Sanjaya <[email protected]>---
Changes since v1 [1]:* Apply wording suggestion (Ard)
* Replace candyboot reference with OVMF (Ard)
* Invert patch subject prefix[1]:
https://lore.kernel.org/linux-doc/[email protected]/Documentation/admin-guide/efi-stub.rst | 3 ++ Documentation/arch/x86/boot.rst | 38 ++++++++++++++++++++------ 2 files changed, 33 insertions(+), 8 deletions(-)Documentation/admin-guide/efi-stub.rst +3
-0@@ -79,6 +79,9 @@ because the image we're executing is interpreted by the EFI shell, which understands relative paths, whereas the rest of the command line is passed to bzImage.efi. +.. hint:: + It is also possible to provide an initrd using a Linux-specific UEFI + protocol at boot time. See :ref:`pe-coff-entry-point` for details. The "dtb=" option-----------------
Documentation/arch/x86/boot.rst +0
-0@@ -1431,12 +1431,34 @@ The boot loader *must* fill out the followingfields in bp::
All other fields should be zero... note::
Documentation/arch/x86/boot.rst +2
-8- The EFI Handover Protocol is deprecated in favour of the ordinary PE/COFF - entry point, combined with the LINUX_EFI_INITRD_MEDIA_GUID based initrd - loading protocol (refer to [0] for an example of the bootloader side of - this), which removes the need for any knowledge on the part of the EFI - bootloader regarding the internal representation of boot_params or any - requirements/limitations regarding the placement of the command line - and ramdisk in memory, or the placement of the kernel image itself. + The EFI Handover Protocol is deprecated in favour of the ordinary PE/COFF + entry point described below. -[0]https://github.com/u-boot/u-boot/commit/ec80b4735a593961fe701cc3a5d717d4739b0fd0
+.. _pe-coff-entry-point:Documentation/arch/x86/boot.rst +5
-0+ +PE/COFF entry point +=================== + +When compiled with ``CONFIG_EFI_STUB=y``, the kernel can be executedas a
Documentation/arch/x86/boot.rst The boot loader *must* fill out the following fields in bp:: · line 1444
Quoted 2 lines
Documentation/arch/x86/boot.rst +2
-0+regular PE/COFF binary. See Documentation/admin-guide/efi-stub.rst for +implementation details.
I must insist that it's a terrible idea to replace an actual link with the name of the source file.
This might be (marginally) more convenient for somebody who's editing the documentation, but it becomes completely useless for somebody who's READING the documentation. Documentation needs to target readers.
For someone reading https://www.kernel.org/doc/html/latest/arch/x86/boot.html,
the above filename conveys no useful information.
Quoted 32 lines
Documentation/arch/x86/boot.rst +2
-0+ +The stub loader can request the initrd via a UEFI protocol. For thisto work,
Documentation/arch/x86/boot.rst +3
-0+the firmware or bootloader needs to register a handle which carries +implementations of the ``EFI_LOAD_FILE2`` protocol and the device path +protocol exposing the ``LINUX_EFI_INITRD_MEDIA_GUID`` vendor mediadevice path.
+In this case, a kernel booting via the EFI stub will invoke +``LoadFile2::LoadFile()`` method on the registered protocol to instruct the
+firmware to load the initrd into a memory location chosen by the kernel/EFIDocumentation/arch/x86/boot.rst +5
-0+stub. + +This approach removes the need for any knowledge on the part of the EFI +bootloader regarding the internal representation of boot_params or any +requirements/limitations regarding the placement of the command lineand
Documentation/arch/x86/boot.rst +3
-0+ramdisk in memory, or the placement of the kernel image itself. + +For sample implementations, refer to `the original u-bootimplementation`_ or
+the OVMF implementation_.
+
+.._theoriginal u-boot implementation:
https://github.com/u-boot/u-boot/commit/ec80b4735a593961fe701cc3a5d717d4739b0fd0
+.._theOVMF implementation:
https://github.com/tianocore/edk2/blob/1780373897f12c25075f8883e073144506441168/OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.cbase-commit:
f44a29784f685804d9970cfb0d3439c9e30981d7Signature · 1 line
An old man doll... just what I always wanted! - Clara
Signature · 1 line
Hugo
Jonathan Corbet
maintainerQuoted 8 lines · Hugo Osvaldo Barrera
Documentation/arch/x86/boot.rst The boot loader *must* fill out the following fields in bp:: · line 1444
Quoted 4 lines
+When compiled with ``CONFIG_EFI_STUB=y``, the kernel can be executed as a
Documentation/arch/x86/boot.rst +2
-0+regular PE/COFF binary. See Documentation/admin-guide/efi-stub.rst for +implementation details.I must insist that it's a terrible idea to replace an actual link with the name of the source file.
Quoted 6 lines
This might be (marginally) more convenient for somebody who's editing the documentation, but it becomes completely useless for somebody who's READING the documentation. Documentation needs to target readers.
For someone reading https://www.kernel.org/doc/html/latest/arch/x86/boot.html,
the above filename conveys no useful information.
When the documentation is rendered into HTML, that file reference will be turned into a link automatically, and people reading it on kernel.org will not notice the difference.
Thanks,
jon
Quoted 14 lines · Jonathan Corbet
Quoted 12 lines · Hugo Osvaldo Barrera
Documentation/arch/x86/boot.rst The boot loader *must* fill out the following fields in bp:: · line 1444
Quoted 4 lines
+When compiled with ``CONFIG_EFI_STUB=y``, the kernel can be executed as a
Documentation/arch/x86/boot.rst +2
-0+regular PE/COFF binary. See Documentation/admin-guide/efi-stub.rst for +implementation details.I must insist that it's a terrible idea to replace an actual link with the name of the source file.
This might be (marginally) more convenient for somebody who's editing the documentation, but it becomes completely useless for somebody who's READING the documentation. Documentation needs to target readers.
Quoted 6 lines
Quoted 2 lines
For someone reading https://www.kernel.org/doc/html/latest/arch/x86/boot.html,
the above filename conveys no useful information.When the documentation is rendered into HTML, that file reference will be turned into a link automatically, and people reading it on kernel.org will not notice the difference.
That's why I keep the file cross-reference...
Signature · 1 line
An old man doll... just what I always wanted! - Clara
Quoted 14 lines · Jonathan Corbet
Quoted 12 lines · Hugo Osvaldo Barrera
Documentation/arch/x86/boot.rst The boot loader *must* fill out the following fields in bp:: · line 1444
Quoted 4 lines
+When compiled with ``CONFIG_EFI_STUB=y``, the kernel can be executed as a
Documentation/arch/x86/boot.rst +2
-0+regular PE/COFF binary. See Documentation/admin-guide/efi-stub.rst for +implementation details.I must insist that it's a terrible idea to replace an actual link with the name of the source file.
This might be (marginally) more convenient for somebody who's editing the documentation, but it becomes completely useless for somebody who's READING the documentation. Documentation needs to target readers.
Quoted 7 lines
Quoted 2 lines
For someone reading https://www.kernel.org/doc/html/latest/arch/x86/boot.html,
the above filename conveys no useful information.When the documentation is rendered into HTML, that file reference will be turned into a link automatically, and people reading it on kernel.org will not notice the difference.
Thanks for the clarification.
I mis-interpreted this previously.
Sorry for the noise.
Signature · 1 line
Hugo