A dynamic library bundling the guest payload consumed by libkrun
Go to file
Jake Correnti a70c65d97e Add TDX support
Adds support for a TDX flavor. Additionally adjusts the qboot binary
locations such that SEV has a different binary than TDX.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2025-06-12 11:44:57 +01:00
.github/workflows ci: rename build-aarch64 to cross-build-aarch64 2024-10-08 13:45:44 +02:00
initrd sev: update initrd.gz binary 2023-04-04 17:52:44 +02:00
patches Rebase on a 6.12.20 kernel 2025-03-24 17:02:59 +01:00
patches-tee Add TDX support 2025-06-12 11:44:57 +01:00
qboot Add TDX support 2025-06-12 11:44:57 +01:00
utils utils: Add kernel_size_time.sh to measure size and boot time 2025-02-11 12:42:48 +01:00
.gitignore initial commit 2020-08-13 18:47:26 +02:00
CODEOWNERS Add MatiasVara to CODEOWNERS 2025-01-20 20:03:08 +01:00
LICENSE-GPL-2.0-only initial commit 2020-08-13 18:47:26 +02:00
LICENSE-LGPL-2.1-only initial commit 2020-08-13 18:47:26 +02:00
Makefile Add TDX support 2025-06-12 11:44:57 +01:00
README.md Add krunvm debian environment for macOS build 2025-03-20 13:27:23 +01:00
bin2cbundle.py Rebase on a 6.4.7 kernel 2023-08-10 10:23:10 +02:00
build_on_krunvm.sh Add krunvm debian environment for macOS build 2025-03-20 13:27:23 +01:00
build_on_krunvm_debian.sh Add krunvm debian environment for macOS build 2025-03-20 13:27:23 +01:00
build_on_krunvm_fedora.sh Add krunvm debian environment for macOS build 2025-03-20 13:27:23 +01:00
config-libkrunfw-sev_x86_64 sev: add "acpi=off" to the bundled command line 2025-01-27 13:35:07 -05:00
config-libkrunfw-tdx_x86_64 Add TDX support 2025-06-12 11:44:57 +01:00
config-libkrunfw_aarch64 aarch64: enable IPv6 2024-11-07 11:22:23 +01:00
config-libkrunfw_x86_64 config-libkrunfw_x86_64: Disable process autogrouping feature 2025-02-11 12:42:48 +01:00

README.md

libkrunfw

libkrunfw is a library bundling a Linux kernel in a dynamic library in a way that can be easily consumed by libkrun.

By having the kernel bundled in a dynamic library, libkrun can leave to the linker the work of mapping the sections into the process, and then directly inject those mappings into the guest without any kind of additional work nor processing.

Building

Linux (generic variant)

Requirements

  • The toolchain your distribution needs to build a Linux kernel.
  • Python 3
  • pyelftools (package python3-pyelftools in Fedora and Ubuntu)

Building and installing the library

make
sudo make install

Linux (SEV variant)

Requirements

  • The toolchain your distribution needs to build a Linux kernel.
  • Python 3
  • pyelftools (package python3-pyelftools in Fedora and Ubuntu)

Building and installing the library

make SEV=1
sudo make SEV=1 install

macOS

Requirements

Compiling a Linux kernel natively on macOS is not an easy feat. For this reason, the recommended way for building libkrunfw in this platform is by already having installed a binary version of krunvm and its dependencies (libkrun, and libkrunfw itself), such as the one available in the krunvm Homebrew repo, and then executing the build_on_krunvm.sh script found in this repository.

This will create a lightweight Linux VM using krunvm with the current working directory mapped inside it, and build the kernel on it.

Building the library using krunvm

./build_on_krunvm.sh
make

By default, the build environment is based on a Fedora image. There is also a Debian variant which can be selected by setting the BUILDER environment variable.

BUILDER=debian ./build_on_krunvm.sh

In general, ./build_on_krunvm.sh will always delegate to ./build_on_krunvm_${BUILDER}.sh so additional environments can be added like this if needed.

Known limitations

  • To save memory, the embedded kernel is configured with CONFIG_NR_CPUS=8, which limits the maximum number of supported CPUs to 8. If this kernel runs in a VM with more CPUs, only the first 8 will be initialized and used.

License

This library bundles a Linux kernel but does not execute any code from it, acting as a mere storage format. As a consequence, this library does not constitute a derivative work of the Linux kernel. Thus, the following licenses apply:

  • Linux kernel: GPL-2.0-only

  • Files contained in the patches directory: GPL-2.0-only

  • Library code, including automatically-generated code: LGPL-2.1-only

Therefore, distributions of this library in binary form are required to be accompanied by the source code of the Linux kernel bundled in the binary along with the code of the library itself, but other programs linking against this library are not required to be licensed under the GPL-2.0-only nor the LGPL-2.1-only licenses.