Skip to content

Commit

Permalink
Merge pull request #24 from dongx1x/build-version
Browse files Browse the repository at this point in the history
tools: update build script and add version for ubuntu kernel
  • Loading branch information
ruomengh authored Mar 28, 2024
2 parents c15dcff + 5c359b3 commit 8fcb3ad
Show file tree
Hide file tree
Showing 20 changed files with 44 additions and 20 deletions.
20 changes: 18 additions & 2 deletions tools/build/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ is available on Ubuntu 23.10, and [this Github repository](https://github.com/ca
provides guidance and straightforward instructions on how to get started.
Please follow the instructions to create a guest image and set up the TDX environment.

Some additional patches are provided in [kernel](kernel/) directory for CCNP container measurement,
Some additional patches are provided in [kernel/patches](kernel/patches) directory for CCNP container measurement,
here is the information about the patches:

| Patch Number | Comments |
Expand All @@ -23,4 +23,20 @@ Install the build dependencies and build the packages

```Shell
sudo ./build.sh
```
```

*Note: this build script is based on Ubuntu 23.10 TDX early preview kernel, please make sure this kernel has been installed.*

## Install

All the packages are built in `output` directory, please follow [cvm-image-rewriter plugin](../cvm-image-rewriter/plugins/06-install-tdx-guest-kernel/README.md) or install them by `apt`/`dpkg`

```Shell
sudo apt install -y ./output/*.deb
```

or

```Shell
sudo dpkg -i ./output/*.deb
```
27 changes: 9 additions & 18 deletions tools/build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,15 @@

set -e

BASE_KERNEL_VERSION="6.5.0-1003-intel-opt"

CUR_DIR=$(dirname "$(readlink -f "$0")")
KERNEL_PATCHES_DIR=${CUR_DIR}/kernel
KERNEL_DIR=${CUR_DIR}/kernel
TMP_DIR=$(mktemp -d /tmp/ccnp_build.XXXXXX)
OUT_DIR=${CUR_DIR}/output

KERNEL_CONFIG_ANNOTATIONS=$(cat << EOF
CONFIG_TSM_REPORTS policy<{'amd64': 'm'}>
CONFIG_TSM_REPORTS note<'Required for ConfigFS TSM support'>
CONFIG_IMA_CGPATH_TEMPLATE policy<{'amd64': 'n'}>
CONFIG_IMA_CGPATH_TEMPLATE note<'CGPATH for CCNP container measurement'>
CONFIG_IMA_DEP_CGN_TEMPLATE policy<{'amd64': 'n'}>
CONFIG_IMA_DEP_CGN_TEMPLATE note<'CGN for CCNP container measurement'>
EOF
)

patch_kernel() {
for p in "${KERNEL_PATCHES_DIR}"/*
for p in "${KERNEL_DIR}"/patches/*
do
patch -p1 -F1 -s < "${p}"
done
Expand All @@ -32,18 +21,20 @@ build_ubuntu_kernel() {
add-apt-repository -s -y ppa:kobuk-team/tdx-release
# Install the build dependencies
DEBIAN_FRONTEND=noninteractive apt update && apt install -y devscripts && \
apt build-dep -y linux-image-unsigned-"$(uname -r)"
apt build-dep -y linux-image-unsigned-"${BASE_KERNEL_VERSION}"
# Download the source codes
apt source linux-image-unsigned-"$(uname -r)"
apt source linux-image-unsigned-"${BASE_KERNEL_VERSION}"
# A workaround to fix build issue of DKMS
mv /lib/modules/"$(uname -r)"/modules.dep /lib/modules/"$(uname -r)"/modules.dep.bk
touch /lib/modules/"$(uname -r)"/modules.dep

pushd linux-*/
patch_kernel
# Add new configs in the patch
echo "${KERNEL_CONFIG_ANNOTATIONS}" | sed -i "/CONFIG_TDX_GUEST_DRIVER *note.*/ r /dev/stdin" \
sed -i "/CONFIG_TDX_GUEST_DRIVER *note.*/ r ${KERNEL_DIR}/ubuntu/annotations" \
debian.intel-opt/config/annotations
# Change kernel version in changelog
sed -i "0 r ${KERNEL_DIR}/ubuntu/changelog" debian/changelog debian.intel-opt/changelog

debuild -uc -us -b
popd
Expand Down
9 changes: 9 additions & 0 deletions tools/build/kernel/ubuntu/annotations
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@

CONFIG_TSM_REPORTS policy<{'amd64': 'm'}>
CONFIG_TSM_REPORTS note<'Required for ConfigFS TSM support'>

CONFIG_IMA_CGPATH_TEMPLATE policy<{'amd64': 'n'}>
CONFIG_IMA_CGPATH_TEMPLATE note<'CGPATH for CCNP container measurement'>

CONFIG_IMA_DEP_CGN_TEMPLATE policy<{'amd64': 'n'}>
CONFIG_IMA_DEP_CGN_TEMPLATE note<'CGN for CCNP container measurement'>
8 changes: 8 additions & 0 deletions tools/build/kernel/ubuntu/changelog
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
linux-intel-opt (6.5.0-1003.3.ccnp.1) mantic; urgency=medium

* [CCNP] Add CCNP kernel patches

- [Config] intel-opt: Enable IMA CGPath options
- [Config] intel-opt: Enable ConfigFS TSM options

-- Xiaocheng Dong <[email protected]> Thu, 26 Mar 2024 15:26:10 +0800

0 comments on commit 8fcb3ad

Please sign in to comment.