Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Support PVH boot protocol #1818

Closed
wants to merge 7 commits into from

Conversation

aljimenezb
Copy link

@aljimenezb aljimenezb commented Apr 23, 2020

Reason for This PR

The x86/HVM direct boot ABI is intended for use cases targeted by Firecracker, where legacy hardware and software support within the guest is not needed, and it allows booting guests directly into the uncompressed kernel binary, without the need for firmware.

The ABI is already supported by Linux and FreeBSD:
https://xenbits.xen.org/docs/unstable/misc/pvh.html

Examples of current use of the PVH boot protocol are the latest QEMU microvm machine type, and Intel Cloud Hypervisor/RustVMM. A limitation is that the PVH protocol is not available for aarch64.

The current patches are fully functional, and can coexist with current implementation that uses Linux 64-bit protocol, but the ability to use PVH to launch guests has been configured as an optional feature for this RFC.

If there is interest in adding this functionality to Firecracker, additional changes needed are to expand the integration tests, and provide a new API option to allow specifying the default boot protocol.

Description of Changes

Parse the PVH entry point address encoded in the kernel binary, and return it alongside the default entry point.

If the PVH optional feature is enabled use it as the preferred method to boot the guest. Configure the guest initial state (regs/sregs) as required by the PVH ABI.

Copy the set of boot parameters [hvm_start_info, memory map entries, (optional) initramfs module entry] required by PVH into guest memory.

License Acceptance

By submitting this pull request, I confirm that my contribution is made under
the terms of the Apache 2.0 license.

PR Checklist

  • All commits in this PR are signed (git commit -s).
  • The reason for this PR is clearly provided (issue no. or explanation).
  • The description of changes is clear and encompassing.
  • Any required documentation changes (code and docs) are included in this PR.
  • Any newly added unsafe code is properly documented.
  • Any API changes are reflected in firecracker/swagger.yaml.
  • Any user-facing changes are mentioned in CHANGELOG.md.

Define ELF Note header structure and constants necessary for parsing
the PVH entry point address encoded in kernel ELF header.

Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Acked-by: Liam Merwick <liam.merwick@oracle.com>
Introduce the layout and define the start_info, module
list and memory map table entry structures used by the
PVH boot protocol.

The hvm_start_info structure is akin to bootparams in
Linux boot protocol, specifying the small set of
parameters required by the PVH protocol.

Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Acked-by: Liam Merwick <liam.merwick@oracle.com>
Parse the ELF header looking for a PVH Note section and retrieve
the encoded PVH entry point address if there is one. This PVH entry
point address is returned alongside the typical ELF entry point used
for direct boot. The vmm crate can now determine whether a
PVH entry point is available and choose to configure its guests
to boot using either PVH or Linux 64-bit protocol.

Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Acked-by: Liam Merwick <liam.merwick@oracle.com>
In order to properly configure the initial vCPU register state
and boot parameters in guest memory, we must specify which
boot protocol to use with the kernel entry point address.

Create an EntryPoint struct that contains the required
information. This structure will later be used in the vCPU
configuration methods to set the appropriate initial
conditions for the guest.

Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Acked-by: Liam Merwick <liam.merwick@oracle.com>
Set the initial values of the KVM vCPU registers as specified in
the PVH boot ABI:

https://xenbits.xen.org/docs/unstable/misc/pvh.html

Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Acked-by: Liam Merwick <liam.merwick@oracle.com>
Fill the hvm_start_info and related structures as specified
in the PVH boot protocol. Write the data structures to guest
memory at the GPA that will be stored in %rbx when the guest starts.

Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Acked-by: Liam Merwick <liam.merwick@oracle.com>
Enable the optional "pvh" feature to build a Firecracker binary
that is able to boot Linux guests using the PVH boot protocol.
Build a firecracker binary with the PVH capability by running:

tools/devtool build [--release] -- --features pvh

and the resulting Firecracker binary will use the PVH boot
protocol as the preferred choice for booting a guest, if the
guest kernel supports it.

Signed-off-by: Alejandro Jimenez <alejandro.j.jimenez@oracle.com>
Acked-by: Liam Merwick <liam.merwick@oracle.com>
@lauralt lauralt added the Status: Awaiting review Indicates that a pull request is ready to be reviewed label Apr 27, 2020
@alxiord
Copy link

alxiord commented Apr 30, 2020

Hi @aljimenezb, Firecracker intends to consume linux-loader from rust-vmm in the not so distant future, so any functionality added there will be available here too. For now we don't have a use case for PVH so there's no rush.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Awaiting review Indicates that a pull request is ready to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants