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

runtime: packaging: Use confidential kernel instead of the TDX one #8978

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 0 additions & 2 deletions .github/workflows/build-kata-static-tarball-amd64.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ jobs:
- kata-ctl
- kernel
- kernel-confidential
- kernel-sev
- kernel-dragonball-experimental
- kernel-tdx-experimental
- kernel-nvidia-gpu
- kernel-nvidia-gpu-confidential
- nydus
Expand Down
31 changes: 6 additions & 25 deletions src/runtime/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -378,17 +378,9 @@ ifneq (,$(QEMUCMD))
KERNELNAME = $(call MAKE_KERNEL_NAME,$(KERNELTYPE))
KERNELPATH = $(KERNELDIR)/$(KERNELNAME)

KERNELSEVTYPE = compressed
KERNELSEVNAME = $(call MAKE_KERNEL_SEV_NAME,$(KERNELSEVTYPE))
KERNELSEVPATH = $(KERNELDIR)/$(KERNELSEVNAME)

KERNELTDXTYPE = compressed
KERNELTDXNAME = $(call MAKE_KERNEL_TDX_NAME,$(KERNELTDXTYPE))
KERNELTDXPATH = $(KERNELDIR)/$(KERNELTDXNAME)

KERNELSNPTYPE = compressed
KERNELSNPNAME = $(call MAKE_KERNEL_SNP_NAME,$(KERNELSNPTYPE))
KERNELSNPPATH = $(KERNELDIR)/$(KERNELSNPNAME)
KERNELCONFIDENTIALTYPE = compressed
KERNELCONFIDENTIALNAME = $(call MAKE_KERNEL_CONFIDENTIAL_NAME,$(KERNELCONFIDENTIALTYPE))
KERNELCONFIDENTIALPATH = $(KERNELDIR)/$(KERNELCONFIDENTIALNAME)

KERNELSENAME = kata-containers-se.img
KERNELSEPATH = $(KERNELDIR)/$(KERNELSENAME)
Expand Down Expand Up @@ -585,9 +577,7 @@ USER_VARS += KERNELTYPE_ACRN
USER_VARS += KERNELTYPE_CLH
USER_VARS += KERNELPATH_ACRN
USER_VARS += KERNELPATH
USER_VARS += KERNELSEVPATH
USER_VARS += KERNELTDXPATH
USER_VARS += KERNELSNPPATH
USER_VARS += KERNELCONFIDENTIALPATH
USER_VARS += KERNELSEPATH
USER_VARS += KERNELPATH_CLH
USER_VARS += KERNELPATH_FC
Expand Down Expand Up @@ -773,17 +763,8 @@ define MAKE_KERNEL_VIRTIOFS_NAME
$(if $(findstring uncompressed,$1),vmlinux-virtiofs.container,vmlinuz-virtiofs.container)
endef

define MAKE_KERNEL_SEV_NAME
$(if $(findstring uncompressed,$1),vmlinux-sev.container,vmlinuz-sev.container)
endef

define MAKE_KERNEL_TDX_NAME
$(if $(findstring uncompressed,$1),vmlinux-tdx.container,vmlinuz-tdx.container)
endef

# SNP configuration uses the SEV kernel
define MAKE_KERNEL_SNP_NAME
$(if $(findstring uncompressed,$1),vmlinux-sev.container,vmlinuz-sev.container)
define MAKE_KERNEL_CONFIDENTIAL_NAME
$(if $(findstring uncompressed,$1),vmlinux-confidential.container,vmlinuz-confidential.container)
endef

GENERATED_FILES += pkg/katautils/config-settings.go
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/config/configuration-qemu-sev.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

[hypervisor.qemu]
path = "@QEMUPATH@"
kernel = "@KERNELSEVPATH@"
kernel = "@KERNELCONFIDENTIALPATH@"
initrd = "@INITRDSEVPATH@"
machine_type = "@MACHINETYPE@"

Expand Down
2 changes: 1 addition & 1 deletion src/runtime/config/configuration-qemu-snp.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

[hypervisor.qemu]
path = "@QEMUSNPPATH@"
kernel = "@KERNELSNPPATH@"
kernel = "@KERNELCONFIDENTIALPATH@"
#image = "@IMAGEPATH@"
initrd = "@INITRDSEVPATH@"
machine_type = "@MACHINETYPE@"
Expand Down
2 changes: 1 addition & 1 deletion src/runtime/config/configuration-qemu-tdx.toml.in
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

[hypervisor.qemu]
path = "@QEMUTDXPATH@"
kernel = "@KERNELTDXPATH@"
kernel = "@KERNELCONFIDENTIALPATH@"
image = "@IMAGETDXPATH@"
# initrd = "@INITRDPATH@"
machine_type = "@MACHINETYPE@"
Expand Down
4 changes: 2 additions & 2 deletions tools/packaging/kata-deploy/local-build/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -160,13 +160,13 @@ stratovirt-tarball:
rootfs-image-tarball: agent-tarball
${MAKE} $@-build

rootfs-image-tdx-tarball: agent-opa-tarball kernel-tdx-experimental-tarball
rootfs-image-tdx-tarball: agent-opa-tarball kernel-confidential-tarball
${MAKE} $@-build

rootfs-initrd-mariner-tarball: agent-opa-tarball
${MAKE} $@-build

rootfs-initrd-sev-tarball: agent-opa-tarball kernel-sev-tarball
rootfs-initrd-sev-tarball: agent-opa-tarball kernel-confidential-tarball
${MAKE} $@-build

rootfs-initrd-tarball: agent-tarball
Expand Down
35 changes: 34 additions & 1 deletion tools/packaging/kata-deploy/local-build/kata-deploy-binaries.sh
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,16 @@ get_kernel_modules_dir() {
local dots=$(echo ${version} | grep -o '\.' | wc -l)
[ "${dots}" == "1" ] && numeric_final_version="${version}.0"

echo "${repo_root_dir}/tools/packaging/kata-deploy/local-build/build/${kernel_name}/builddir/kata-linux-${version}-${kernel_kata_config_version}/lib/modules/${numeric_final_version}"
local kernel_modules_dir="${repo_root_dir}/tools/packaging/kata-deploy/local-build/build/${kernel_name}/builddir/kata-linux-${version}-${kernel_kata_config_version}/lib/modules/${numeric_final_version}"
case ${kernel_name} in
kernel-nvidia-gpu-confidential)
kernel_modules_dir+="-nvidia-gpu-confidential"
;;
*)
;;
esac

echo ${kernel_modules_dir}
}

cleanup_and_fail() {
Expand Down Expand Up @@ -213,6 +222,15 @@ get_agent_tarball_path() {
echo "${agent_local_build_dir}/${agent_tarball_name}"
}

get_latest_kernel_confidential_artefact_and_builder_image_version() {
local kernel_version=$(get_from_kata_deps "assets.kernel.confidential.version")
local kernel_kata_config_version="$(cat ${repo_root_dir}/tools/packaging/kernel/kata_config_version)"
local latest_kernel_artefact="${kernel_version}-${kernel_kata_config_version}-$(get_last_modification $(dirname $kernel_builder))"
local latest_kernel_builder_image="$(get_kernel_image_name)"

echo "${latest_kernel_artefact}-${latest_kernel_builder_image}"
}

#Install guest image
install_image() {
local variant="${1:-}"
Expand All @@ -234,7 +252,14 @@ install_image() {
"$(get_last_modification "${repo_root_dir}/src/agent")" \
"$(get_last_modification "${repo_root_dir}/tools/packaging/static-build/agent")")


latest_artefact="${osbuilder_last_commit}-${guest_image_last_commit}-${agent_last_commit}-${libs_last_commit}-${gperf_version}-${libseccomp_version}-${rust_version}-${image_type}"
if [ "${variant}" == "tdx" ]; then
# For the TDX image we depend on the kernel built in order to ensure that
# measured boot is used
latest_artefacts+="-$(get_latest_kernel_confidential_artefact_and_builder_image_version)"
fi

latest_builder_image=""

install_cached_tarball_component \
Expand Down Expand Up @@ -287,6 +312,12 @@ install_initrd() {
"$(get_last_modification "${repo_root_dir}/tools/packaging/static-build/agent")")

latest_artefact="${osbuilder_last_commit}-${guest_image_last_commit}-${agent_last_commit}-${libs_last_commit}-${gperf_version}-${libseccomp_version}-${rust_version}-${initrd_type}"
if [ "${variant}" == "tdx" ]; then
# For the TDX image we depend on the kernel built in order to ensure that
# measured boot is used
latest_artefacts+="-$(get_latest_kernel_confidential_artefact_and_builder_image_version)"
fi

latest_builder_image=""

[[ "${ARCH}" == "aarch64" && "${CROSS_BUILD}" == "true" ]] && echo "warning: Don't cross build initrd for aarch64 as it's too slow" && exit 0
Expand Down Expand Up @@ -400,6 +431,8 @@ install_kernel() {
install_kernel_confidential() {
local kernel_url="$(get_from_kata_deps assets.kernel.confidential.url)"

export MEASURED_ROOTFS=yes

install_kernel_helper \
"assets.kernel.confidential.version" \
"kernel-confidential" \
Expand Down
2 changes: 1 addition & 1 deletion tools/packaging/kernel/kata_config_version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
123
124