audk/ArmPlatformPkg
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
..
ArmJunoPkg ArmPlatformPkg/ArmJunoPkg: Move the watchdog generic driver to ArmPkg/Drivers 2014-12-12 19:09:24 +00:00
ArmRealViewEbPkg ArmPlatformPkg: Increase more ARM address Pcd entries to 64-bit. 2014-11-11 00:43:03 +00:00
ArmVExpressPkg ArmPlatformPkg: Fixed build 2014-12-15 11:13:44 +00:00
ArmVirtualizationPkg ArmVirtualizationPkg: Intel BDS: load EFI-stubbed Linux kernel from fw_cfg 2015-01-02 12:08:33 +00:00
Bds ArmPkg/BdsLib: Rework TFTP boot 2014-12-12 19:14:22 +00:00
Documentation ArmPlatformPkg/Documentation: Removed BaseTools-Pending-Patches.patch 2014-10-29 18:55:29 +00:00
Drivers EmbeddedPkg: Clarify the declaration of SerialPortGetControl() 2014-10-27 15:38:20 +00:00
FileSystem/BootMonFs ArmPlatformPkg: Fixed build 2014-12-15 11:13:44 +00:00
Include EmbeddedPkg: Clarify the declaration of SerialPortGetControl() 2014-10-27 15:38:20 +00:00
Library ArmPlatformPkg: fix undefined reference to memcpy 2014-11-12 10:01:41 +00:00
MemoryInitPei ArmPlatformPkg: Increase more ARM address Pcd entries to 64-bit. 2014-11-11 00:43:03 +00:00
PlatformPei ArmPlatformPkg: Increase more ARM address Pcd entries to 64-bit. 2014-11-11 00:43:03 +00:00
PrePeiCore ArmPlatformPkg: Increase more ARM address Pcd entries to 64-bit. 2014-11-11 00:43:03 +00:00
PrePi ArmPkg,ArmPlatformPkg: Allow dynamic PCDs for memory base and size 2014-09-09 16:11:30 +00:00
Scripts ArmPlatformPkg/Scripts: Update the profiling script to work on AArch64 with the latest DS-5 2014-08-19 13:36:00 +00:00
Sec ArmPlatformPkg: Increase more ARM address Pcd entries to 64-bit. 2014-11-11 00:43:03 +00:00
ArmPlatformPkg-2ndstage.dsc ARM Packages: Added support for GCC stack protector 2014-08-20 18:01:50 +00:00
ArmPlatformPkg-2ndstage.fdf ARM Packages: Removed malicious trailing spaces 2014-08-20 11:38:45 +00:00
ArmPlatformPkg.dec ArmPlatformPkg: Increase more ARM address Pcd entries to 64-bit. 2014-11-11 00:43:03 +00:00
ArmPlatformPkg.dsc ArmPlatformPkg: separate PlatformPei and PlatformPeiLib 2014-09-16 00:56:50 +00:00
ArmPlatformPkg.fdf ARM Packages: Removed malicious trailing spaces 2014-08-20 11:38:45 +00:00
Contributions.txt EDK II Contributions.txt: Update patch format information 2014-10-31 22:05:50 +00:00
License.txt EDK II Packages: Added License.txt files 2012-04-12 16:40:32 +00:00