Merge pull request #3651 from devimc/2022-02-11/packaging/supportKernelTDx

kernel: support TDx
This commit is contained in:
Fabiano Fidêncio 2022-02-13 13:13:38 +01:00 committed by GitHub
commit 56c51fba4b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 38 additions and 5 deletions

View File

@ -53,6 +53,8 @@ hypervisor_target=""
arch_target="" arch_target=""
# #
kernel_config_path="" kernel_config_path=""
#
skip_config_checks="false"
# destdir # destdir
DESTDIR="${DESTDIR:-/}" DESTDIR="${DESTDIR:-/}"
#PREFIX= #PREFIX=
@ -92,9 +94,10 @@ Options:
-h : Display this help. -h : Display this help.
-k <path> : Path to kernel to build. -k <path> : Path to kernel to build.
-p <path> : Path to a directory with patches to apply to kernel. -p <path> : Path to a directory with patches to apply to kernel.
-s : Skip .config checks
-t <hypervisor> : Hypervisor_target. -t <hypervisor> : Hypervisor_target.
-v <version> : Kernel version to use if kernel path not provided. -v <version> : Kernel version to use if kernel path not provided.
-x <type> : Confidential guest protection type, such as sev -x <type> : Confidential guest protection type, such as sev and tdx
EOT EOT
exit "$exit_code" exit "$exit_code"
} }
@ -112,6 +115,22 @@ arch_to_kernel() {
esac esac
} }
get_tdx_kernel() {
local version="${1}"
local kernel_path=${2}
mkdir -p ${kernel_path}
kernel_url=$(get_from_kata_deps "assets.kernel.tdx.url")
kernel_tarball="${version}.tar.gz"
if [ ! -f "${kernel_tarball}" ]; then
curl --fail -OL "${kernel_url}/${kernel_tarball}"
fi
tar --strip-components=1 -xf ${kernel_tarball} -C ${kernel_path}
}
get_kernel() { get_kernel() {
local version="${1:-}" local version="${1:-}"
@ -119,7 +138,10 @@ get_kernel() {
[ -n "${kernel_path}" ] || die "kernel_path not provided" [ -n "${kernel_path}" ] || die "kernel_path not provided"
[ ! -d "${kernel_path}" ] || die "kernel_path already exist" [ ! -d "${kernel_path}" ] || die "kernel_path already exist"
if [ "${conf_guest}" == "tdx" ]; then
get_tdx_kernel ${version} ${kernel_path}
return
fi
#Remove extra 'v' #Remove extra 'v'
version=${version#v} version=${version#v}
@ -233,6 +255,8 @@ get_kernel_frag_path() {
# Do not care about options that are in whitelist # Do not care about options that are in whitelist
results=$(grep -v -f ${default_config_whitelist} <<< "$results") results=$(grep -v -f ${default_config_whitelist} <<< "$results")
[[ "${skip_config_checks}" == "true" ]] && echo "${config_path}" && return
# Did we request any entries that did not make it? # Did we request any entries that did not make it?
local missing=$(echo $results | grep -v -q "${not_in_string}"; echo $?) local missing=$(echo $results | grep -v -q "${not_in_string}"; echo $?)
if [ ${missing} -ne 0 ]; then if [ ${missing} -ne 0 ]; then
@ -438,7 +462,7 @@ install_kata() {
} }
main() { main() {
while getopts "a:b:c:defg:hk:p:t:v:x:" opt; do while getopts "a:b:c:defg:hk:p:st:v:x:" opt; do
case "$opt" in case "$opt" in
a) a)
arch_target="${OPTARG}" arch_target="${OPTARG}"
@ -467,11 +491,14 @@ main() {
usage 0 usage 0
;; ;;
k) k)
kernel_path="${OPTARG}" kernel_path="$(realpath ${OPTARG})"
;; ;;
p) p)
patches_path="${OPTARG}" patches_path="${OPTARG}"
;; ;;
s)
skip_config_checks="true"
;;
t) t)
hypervisor_target="${OPTARG}" hypervisor_target="${OPTARG}"
;; ;;
@ -481,7 +508,7 @@ main() {
x) x)
conf_guest="${OPTARG}" conf_guest="${OPTARG}"
case "$conf_guest" in case "$conf_guest" in
sev) ;; sev|tdx) ;;
*) die "Confidential guest type '$conf_guest' not supported" ;; *) die "Confidential guest type '$conf_guest' not supported" ;;
esac esac
;; ;;
@ -498,6 +525,8 @@ main() {
if [ -z "$kernel_version" ]; then if [ -z "$kernel_version" ]; then
if [[ ${build_type} == "experimental" ]]; then if [[ ${build_type} == "experimental" ]]; then
kernel_version=$(get_from_kata_deps "assets.kernel-experimental.tag") kernel_version=$(get_from_kata_deps "assets.kernel-experimental.tag")
elif [[ "${conf_guest}" == "tdx" ]]; then
kernel_version=$(get_from_kata_deps "assets.kernel.tdx.tag")
else else
kernel_version=$(get_from_kata_deps "assets.kernel.version") kernel_version=$(get_from_kata_deps "assets.kernel.version")
fi fi

View File

@ -150,6 +150,10 @@ assets:
description: "Linux kernel optimised for virtual machines" description: "Linux kernel optimised for virtual machines"
url: "https://cdn.kernel.org/pub/linux/kernel/v5.x/" url: "https://cdn.kernel.org/pub/linux/kernel/v5.x/"
version: "v5.10.25" version: "v5.10.25"
tdx:
description: "Linux kernel that supports TDX"
url: "https://github.com/intel/tdx/archive/refs/tags"
tag: "tdx-guest-v5.15-4"
kernel-experimental: kernel-experimental:
description: "Linux kernel with virtio-fs support" description: "Linux kernel with virtio-fs support"