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

Implement an EFI flavor #161

Merged
merged 24 commits into from
Feb 9, 2024
Merged

Implement an EFI flavor #161

merged 24 commits into from
Feb 9, 2024

Conversation

slp
Copy link
Contributor

@slp slp commented Feb 6, 2024

This (draft) PR adds a new feature, "efi", that will be used to produce a new flavor (libkrun-efi.so) of the library (in the same way we have libkrun.so and libkrun-sev.so now).

Initially, only aarch64 will be supported, as the initial goal is to be able to act as an open replacement for Virtualization.framework for Apple Silicon devices running macOS.

slp added 7 commits February 7, 2024 13:45
Use our wrapper for EFD_NONBLOCK instead of the one in libc for
compatiblity with macOS.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Use a build-time conditional to import the right MetadataExt for current
the target OS.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Up to this point virtio-blk was gated behind the "tee" feature. Since we
now will be wanting to enable it too for the future "efi" flavor (and
perhaps even for the regular one), move it behind its own feature.

Signed-off-by: Sergio Lopez <slp@redhat.com>
We were generating a non-page-aligned size that was confusing EDK2.

Signed-off-by: Sergio Lopez <slp@redhat.com>
We were using "arm,gic-400" which Linux understood but confuses EDK2.
Use "arm,cortex-a15-gic" instead.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Add a prebuilt EDK2 binary to be bundled and used as firmware with the
"efi" flavor of the library.

Signed-off-by: Sergio Lopez <slp@redhat.com>
The "efi" feature will enable us to produce an EFI flavor the library,
that will be targeted towards running full VMs using EDK2 as firmware.
This was we sacrifice the ultra-fast boot time of the regular flavor in
favor of being able to boot regular disk images, with their own kernel
and initrd, as long they have an EFI layout.

This commit introduces just lays the foundations for this feature. Don't
expect EDK2 to boot properly just from this commit.

Signed-off-by: Sergio Lopez <slp@redhat.com>
slp added 2 commits February 7, 2024 16:09
The legacy serial port is useful for debugging and pretty much
compulsory for booting EDK2. Enable an output-only serial port for the
"efi" feature.

Signed-off-by: Sergio Lopez <slp@redhat.com>
The EDK2 build for QEMU always expects to find the FDT at the start of
DRAM. Do the same thing for simplicity.

Signed-off-by: Sergio Lopez <slp@redhat.com>
@slp slp force-pushed the efi-flavor branch 4 times, most recently from db81c28 to b8b6c3d Compare February 7, 2024 15:34
slp added 15 commits February 7, 2024 16:41
Relax queue restrictions to allow EDK2 to operate them properly.

Signed-off-by: Sergio Lopez <slp@redhat.com>
On PORT_READY, EDK2 expects the console port to be open in addition be
marked as console, so do it accordingly.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Simplify reset method to just return a boolean to indicate whether the
reset was successful or not.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Implement reset method by just returning "true" without doing anything.
Strictly speaking it's not enough, but we don't support any scenario
where more work is actually required.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Implement reset method by just returning "true" without doing anything.
Strictly speaking it's not enough, but we don't support any scenario
where more work is actually required.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Implement reset method by shutting down all ports and stopping their
respective threads. This required extending the functionality a bit to
ensure we can issue an ordered shut down of each spawned thread.

Signed-off-by: Sergio Lopez <slp@redhat.com>
The efi flavor doesn't need a bundled kernel, so allow it to be built
without linking against libkrunfw.

Signed-off-by: Sergio Lopez <slp@redhat.com>
In the efi flavor the guest will spawn its own init instead of ours, so
don't bundle it.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Introduce the EFI variable to trigger building the efi flavor of the
library this way:

make EFI=1

Signed-off-by: Sergio Lopez <slp@redhat.com>
Add "boot_efi.c", an example of using libkrun to boot a guest disk image
using EFI.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Using EV_ONESHOT to simulate epoll's EDGE_TRIGGERED semantics was wrong.
Let's use EV_CLEAR instead.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Propagate interrupt controller into the virtio-net device. Without this,
virtio-net can't send interrupts in macOS/hvf.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Extend the workflow for the darwin target to run clippy checks on the
EFI feature.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Avoid unnecesary cast to please clippy.

Signed-off-by: Sergio Lopez <slp@redhat.com>
AsRawFd is only used on Linux, gate it behind a build-time conditional.

Signed-off-by: Sergio Lopez <slp@redhat.com>
@slp slp marked this pull request as ready for review February 7, 2024 15:44
@slp slp requested a review from mtjhrc February 7, 2024 18:35
@slp slp merged commit 973d11c into containers:main Feb 9, 2024
5 checks passed
@slp slp deleted the efi-flavor branch February 9, 2024 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant