Acidanthera UEFI Development Kit based on EDK II edk2-stable202311
Go to file
Laszlo Ersek 23d04b58e2 ArmVirtualizationPkg: Intel BDS: load EFI-stubbed Linux kernel from fw_cfg
A number of tools depend on passing the kernel image, the initial ramdisk,
and the kernel command line to the guest on the QEMU command line (options
-kernel, -initrd, -append, respectively). At the moment, these QEMU
options  work, but the guest kernel loaded this way is launched by a
minimal binary firmware that is dynamically composed by QEMU. As a
consequence, such a kernel has no UEFI environment.

This patch enables -kernel, -initrd, -append to work on top of the
ArmVirtualizationQemu firmware build. The approach it takes is different
from how the same functionality is implemented in OvmfPkg.

OvmfPkg contains a full-fledged Linux boot loader (see
"OvmfPkg/Library/PlatformBdsLib/QemuKernel.c" and
"OvmfPkg/Library/LoadLinuxLib/"). OVMF's LoadLinuxLib sets up the required
kernel environment in a sophisticated way (including x86-specific
artifacts like the GDT), calls ExitBootServices() itself (for legacy
kernels without EFI handover protocol), and jumps to the kernel (using x86
assembly).

In ArmVirtualizationPkg's PlatformIntelBdsLib, we require the kernel being
loaded to have an EFI stub -- that is, to be a genuine UEFI application.

(The EFI stub is not an additional burden for guest kernels -- the EFI
stub is a hard requirement anyway because it needs to process the DTB
heavily:
- it removes memory nodes,
- it removes memreserve entries,
- it adds UEFI properties to the "chosen" node,
- it calculates and installs virt-to-phys mappings with
  SetVirtualAddressMap() in a way that enables kexec [planned].

Kudos to Ard Biesheuvel for summarizing the above.)

An EFI-stubbed Linux guest kernel can be loaded with plain
gBS->LoadImage(). The EFI stub will look up its own
EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL instance (ie. the device path where
it has been loaded from), and it will locate the initial ramdisk named by
the "initrd" command line parameter as a *sibling file* on the same
device.

The initrd file is then loaded using the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.

This approach enables the EFI stub to load the initial ramdisk from normal
EFI System Partitions, from remote PXE/TFTP directories -- and it enables
us to provide the initrd from memory as well.

In this patch:

- We download the kernel image, the initrd image, and the kernel command
  line, using QEMU's fw_cfg interface.

- We create a read-only EFI_SIMPLE_FILE_SYSTEM_PROTOCOL instance that has
  just a root directory, with the three downloaded files in it.

- The handle that carries the simple file system has a single-node
  VenHw(...) device path (not counting the terminator node).

- We load the EFI-stubbed kernel (which is a UEFI application) with
  gBS->LoadImage(), passing "VenHw(...)/kernel" as device path. This
  causes gBS->LoadImage() to call back into our filesystem.

- Appended to the downloaded command line, we pass "initrd=initrd" to the
  EFI stub.

- Once the EFI stub is running, it loads the initial ramdisk from the
  "sibling" device path "VenHw(...)/initrd", also calling back into our
  filesystem.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16578 6f19259b-4bc3-4df7-8a09-765794883524
2015-01-02 12:08:33 +00:00
AppPkg AppPkg: Disable Lua builds by default. Update the ReadMe file. 2014-11-11 23:15:32 +00:00
ArmPkg ArmPkg/AsmMacroIoLib: Fixed the global variables initialization 2014-12-12 19:32:50 +00:00
ArmPlatformPkg ArmVirtualizationPkg: Intel BDS: load EFI-stubbed Linux kernel from fw_cfg 2015-01-02 12:08:33 +00:00
BaseTools Rollback change 16544. 2014-12-30 03:03:37 +00:00
BeagleBoardPkg ArmPlatformPkg: Increase more ARM address Pcd entries to 64-bit. 2014-11-11 00:43:03 +00:00
Conf EDK II: Add .gitignore 2014-10-14 16:08:15 +00:00
CryptoPkg Correct the Hash Calculation for Revoked X.509 Certificate to align with RFC3280 and UEFI 2.4 Spec. 2014-12-25 08:37:08 +00:00
DuetPkg Change NT32 and DUET to use UEFI Shell by default. Use "-D USE_OLD_SHELL" for NT32 to use EDK Shell. 2014-11-25 08:53:33 +00:00
EdkCompatibilityPkg EdkCompatibilityPkg: Make this field name match the name in the spec. 2014-11-26 01:22:15 +00:00
EdkShellBinPkg EDK II Contributions.txt: Update patch format information 2014-10-31 22:05:50 +00:00
EdkShellPkg EDK II Contributions.txt: Update patch format information 2014-10-31 22:05:50 +00:00
EmbeddedPkg EmbeddedPkg/Lan9118Dxe: Remove link check in SNP initialization 2014-11-11 00:49:50 +00:00
EmulatorPkg EmulatorPkg/MpService: add enabled processor check for startupThisAP 2014-11-21 22:46:49 +00:00
FatBinPkg EDK II Contributions.txt: Update patch format information 2014-10-31 22:05:50 +00:00
IntelFrameworkModulePkg Address the potential system TPL does not been restore. 2014-12-24 00:53:11 +00:00
IntelFrameworkPkg IntelFrameworkPkg: fix mixed dos and linux EOL format issue 2014-12-23 08:31:24 +00:00
IntelFspPkg Move EndOfPei signal earlier before giving control back to FspInitDone. 2014-12-06 01:05:19 +00:00
IntelFspWrapperPkg Fix typo. 2014-12-04 06:03:58 +00:00
MdeModulePkg Remove the FV header assumption in variable driver. 2014-12-31 01:46:50 +00:00
MdePkg Do not assert when the device path node length is invalid. 2014-12-23 09:56:33 +00:00
NetworkPkg Code refine. Check the original length of array to avoid buffer over flow. 2014-12-19 02:37:53 +00:00
Nt32Pkg Change NT32 and DUET to use UEFI Shell by default. Use "-D USE_OLD_SHELL" for NT32 to use EDK Shell. 2014-11-25 08:53:33 +00:00
Omap35xxPkg EDK II Contributions.txt: Update patch format information 2014-10-31 22:05:50 +00:00
OptionRomPkg EDK II Contributions.txt: Update patch format information 2014-10-31 22:05:50 +00:00
OvmfPkg OvmfPkg: QemuBootOrderLib: OFW-to-UEFI translation for virtio-mmio 2015-01-02 12:08:19 +00:00
PcAtChipsetPkg Initialize alarm register in PcRtc module entrypoint to make UEFI SCT GetWakeupTime pass. 2014-11-25 03:38:20 +00:00
PerformancePkg PerformancePkg: Update comments on TscTimerLib 2014-12-01 08:17:51 +00:00
SecurityPkg Remove the FV header assumption in variable driver. 2014-12-31 01:47:39 +00:00
ShellBinPkg ShellBinPkg: Ia32/X64 Shell binary update. 2014-12-05 02:33:45 +00:00
ShellPkg ShellPkg: Check the unrecognized environment variable name before it is removed from command line. 2014-12-31 01:31:00 +00:00
SourceLevelDebugPkg SourceLevelDebugPkg DebugAgentLib: Fix build error with GNU assembler 2014-12-17 05:31:42 +00:00
StdLib StdLib/BsdSocketLib: Fix function declaration mismatch with definition. 2014-12-02 21:30:41 +00:00
StdLibPrivateInternalFiles EDK II Contributions.txt: Update patch format information 2014-10-31 22:05:50 +00:00
UefiCpuPkg UefiCpuPkg CpuExceptionHandlerLib: Use %rax instead of %eax to make code consistence. 2014-12-17 05:30:33 +00:00
UnixPkg UnixPkg: Remove UnixPkg files (It is replaced by EmulatorPkg) 2013-07-29 21:09:55 +00:00
.gitignore EDK II: Add .gitignore 2014-10-14 16:08:15 +00:00
BuildNotes2.txt Update to new SVN URL in readme.txt 2013-06-08 05:26:39 +00:00
Edk2Setup.bat Updated version, missed the last two commits and to add the SVN Revision property (last part of the version value). 2014-08-22 16:08:47 +00:00
Maintainers.txt Update some package owners 2014-10-23 01:35:44 +00:00
edksetup.bat Update edksetup.bat to support Microsoft Visual Studio 2013 when building the Nt32Pkg emulation platform (enabled using the --nt32 flag). 2014-10-30 17:09:25 +00:00
edksetup.sh edksetup.sh: Ensure that WORKSPACE points to the top of an edk2 checkout 2014-07-28 17:37:40 +00:00