Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d43d3bd
ci: Create script for installing custom kernel
JackThomson2 Mar 19, 2025
130080c
test: Add test for kernel build
JackThomson2 Mar 24, 2025
1ea914a
ci: Add secret hiding kernel to defaults buildkite
JackThomson2 Mar 25, 2025
421da22
tests: Mark kernels newer than 6.12 as next
JackThomson2 Mar 26, 2025
d59cbb7
tests: Skip more huge page tests on ARM
JackThomson2 Mar 27, 2025
3129768
ci: Move away from using dir stacks
JackThomson2 Mar 27, 2025
cfbe7f2
test: Skip final huge page tests
JackThomson2 Mar 28, 2025
7e34e20
tests(bk): Run the kernel build in our nightly PR
JackThomson2 Mar 31, 2025
7c5afcf
add direct map removal patches to secret hiding CI
roypat Apr 3, 2025
606d6dc
fix(ci): actually test kernel builds if patches are added
roypat Apr 3, 2025
7caefb3
ci: Update script to install for AL23
JackThomson2 Apr 1, 2025
b410770
ci: Update the script to support x86 on AL23
JackThomson2 Apr 4, 2025
dcf08bb
fix: test_hiding_kernel.py
bchalios Apr 7, 2025
2cd78ba
chore: allow clippy::needless_update
roypat Apr 7, 2025
d44b5cf
refactor(test): Move MachineConfig::update tests to machine_config.rs
roypat Apr 3, 2025
448ea07
add helper for Read/Write[Volatile] through bounce buffer
roypat Apr 25, 2025
82b2f47
allow persistent bounce buffers in MaybeBounce
roypat Apr 14, 2025
120c0ce
implement userspace bounce buffering support
roypat Apr 11, 2025
6da974c
ci: dont fail downloading artifacts if no firecracker binaries exist
roypat Mar 24, 2025
24610fc
add Vm::create_guest_memfd
roypat Mar 31, 2025
c8fd23e
refactor: generify "these features are incompatible" error variants
roypat Mar 31, 2025
59cca16
add "secret_free" parameter to /machine-config endpoint
roypat Mar 20, 2025
841ac04
use bounce buffers for loading kernel if secret freedom is enabled
roypat Apr 25, 2025
c9a9cfb
use userspace bounce buffers if secret freedom is enabled
roypat Apr 11, 2025
3c68e63
switch to using kvm_userspace_region2
roypat Apr 1, 2025
0f49046
tmp: call mmap outselves
roypat Apr 2, 2025
5fba4ea
add concept of "secret free" VMs
roypat Apr 25, 2025
c1b0a9c
Use guest_memfd to back memory if secret freedom is enabled
roypat Apr 2, 2025
1349cf5
allow creation of snapshots of secret hidden VMs
roypat Apr 8, 2025
7a8f8d9
tmp: set memory attributes to private on x86
roypat Apr 8, 2025
4a618fd
x86: force no-kvmclock on cmdline if secret_free=True
roypat Apr 16, 2025
8c6ccd0
fix: Stop the scan for vmlinux failing
JackThomson2 Apr 9, 2025
5df1386
chore(hiding_ci): skip non-patch files when applying
kalyazin Apr 22, 2025
b968ca5
doc(hiding_ci): add readme and GPL-2.0 text for Linux patches
kalyazin Apr 22, 2025
e451779
chore(hiding_ci): add userfault Linux patches
kalyazin Apr 22, 2025
51593f3
chore(hiding_ci): rename patches dir to linux_patches
kalyazin Apr 23, 2025
deb856c
chore(hiding_ci): fix up guest_memfd UFFD patches
kalyazin Apr 24, 2025
b8c1f7b
test: run throughput perf tests with secret freedom enabled
roypat Mar 24, 2025
92a2b78
test: add functional tests for booting secret free VMs
roypat Apr 11, 2025
dc53e8d
test: disable memory monitor in boottime tests
roypat Apr 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .buildkite/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
DEFAULT_PLATFORMS = [
("al2", "linux_5.10"),
("al2023", "linux_6.1"),
("ubuntu24", "secret_hiding"),
]


Expand Down
11 changes: 11 additions & 0 deletions .buildkite/pipeline_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@
for step in kani_grp["steps"]:
step["label"] = "🔍 Kani"

if not changed_files or (
any(parent.name == "hiding_ci" for x in changed_files for parent in x.parents)
):
pipeline.build_group_per_arch(
"🕵️ Build Secret Hiding Kernel",
pipeline.devtool_test(
pytest_opts="-m secret_hiding integration_tests/build/test_hiding_kernel.py",
),
depends_on_build=False,
)

if run_all_tests(changed_files):
pipeline.build_group(
"📦 Build",
Expand Down
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ exit = "warn"
tests_outside_test_module = "warn"
assertions_on_result_states = "warn"
error_impl_error = "warn"
needless-update = "allow"

[profile.dev]
panic = "abort"
Expand Down
214 changes: 214 additions & 0 deletions resources/hiding_ci/build_and_install_kernel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,214 @@
#!/bin/bash
# Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0

# fail if we encounter an error, uninitialized variable or a pipe breaks
set -eu -o pipefail

check_root() {
# We need sudo privileges to install the kernel
if [ "$(id -u)" -ne 0 ]; then
echo "To install, this script must be run as root or with sudo privileges"
exit 1
fi
}

check_userspace() {
# Currently this script only works on Ubuntu and AL2023
if grep -qi 'ubuntu' /etc/os-release; then
USERSPACE="UBUNTU"
return 0
fi

if grep -qi 'al2023' /etc/os-release; then
USERSPACE="AL2023"
return 0
fi

echo "This script currently only works on Ubuntu and Amazon Linux 2023."
exit 1
}

tidy_up() {
# Some cleanup after we are done
echo "Cleaning up.."
cd $START_DIR
rm -rf $TMP_BUILD_DIR
}

confirm() {
if [[ "$*" == *"--no-install"* ]]; then
echo "Not installing new kernel."

if [[ "$*" == *"--tidy"* ]]; then
tidy_up
fi

exit 0
fi

if [[ "$*" == *"--install"* ]]; then
return 0
fi

while true; do
read -p "Do you want to install the new kernel? (y/n) " yn
case $yn in
[Yy]*) return 0 ;;
[Nn]*)
echo "Exiting..."
exit 1
;;
*) echo "Please answer yes or no." ;;
esac
done
}

apply_patch_file() {
git apply $1
}

apply_series_mbox() {
git am $1 --empty=drop
}

apply_series_link() {
patch_url=$(cat $1)
echo "Fetching mbox from:" $patch_url
curl --output lore.mbox.gz "$patch_url/t.mbox.gz"
gunzip lore.mbox
apply_series_mbox lore.mbox
rm lore.mbox
}

apply_patch_or_series() {
case "$1" in
*.patch) apply_patch_file $1 ;;
*.mbox) apply_series_mbox $1 ;;
*.lore) apply_series_link $1 ;;
*) echo "Skipping non-patch file" $1 ;;
esac
}

check_override_presence() {
while IFS= read -r line; do
if ! grep -Fq "$line" .config; then
echo "Missing config: $line"
exit 1
fi
done <"$KERNEL_CONFIG_OVERRIDES"

echo "All overrides correctly applied.."
}

ubuntu_update_boot() {
echo "Update initramfs"
update-initramfs -c -k $KERNEL_VERSION
echo "Updating GRUB..."
update-grub
}

al2023_update_boot() {
echo "Installing ENA driver for AL2023"
$START_DIR/install_ena.sh $KERNEL_VERSION $START_DIR/dkms.conf

# Just ensure we are back in the build dir
cd $TMP_BUILD_DIR

echo "Creating the new ram disk"
dracut --kver $KERNEL_VERSION -f -v

# This varies from x86 and ARM so capture what was generated
# We add the || true here due to the fact that we have pipefail enabled
# this causes a non 0 exit when ls cant find vmlinux or vmlinux
VM_LINUX_LOCATION=$(ls /boot/vmlinu{x,z}-$KERNEL_VERSION 2>/dev/null | head -n1 || true)

echo "Updating GRUB..."
grubby --grub2 --add-kernel $VM_LINUX_LOCATION \
--title="Secret Hiding" \
--initrd=/boot/initramfs-$KERNEL_VERSION.img --copy-default
grubby --set-default $VM_LINUX_LOCATION
}

update_boot_config() {
case "$USERSPACE" in
UBUNTU) ubuntu_update_boot ;;
AL2023) al2023_update_boot ;;
*)
echo "Unknown userspace"
exit 1
;;
esac
}

KERNEL_URL=$(cat kernel_url)
KERNEL_COMMIT_HASH=$(cat kernel_commit_hash)
KERNEL_PATCHES_DIR=$(pwd)/linux_patches
KERNEL_CONFIG_OVERRIDES=$(pwd)/kernel_config_overrides

TMP_BUILD_DIR=$(mktemp -d -t kernel-build-XXXX)

START_DIR=$(pwd)

cd $TMP_BUILD_DIR

echo "Cloning kernel repository into" $TMP_BUILD_DIR

# We checkout the repository that way to make it as
# small and fast as possible
git init
git remote add origin $KERNEL_URL
git fetch --depth 1 origin $KERNEL_COMMIT_HASH
git checkout FETCH_HEAD

# Apply our patches on top
for PATCH in $KERNEL_PATCHES_DIR/*.*; do
echo "Applying patch:" $(basename $PATCH)
apply_patch_or_series $PATCH
done

echo "Making kernel config ready for build"
# We use olddefconfig to automatically pull in the
# config from the AMI and update to the newest
# defaults
make olddefconfig

# Disable the ubuntu keys
scripts/config --disable SYSTEM_TRUSTED_KEYS
scripts/config --disable SYSTEM_REVOCATION_KEYS

# We run this again to default options now changed by
# the disabling of the ubuntu keys
make olddefconfig

# Apply our config overrides on top of the config
scripts/kconfig/merge_config.sh -m .config $KERNEL_CONFIG_OVERRIDES

check_override_presence

echo "Building kernel this may take a while"
make -s -j $(nproc)
echo "Building kernel modules"
make modules -s -j $(nproc)
echo "Kernel build complete!"

KERNEL_VERSION=$(KERNELVERSION=$(make -s kernelversion) ./scripts/setlocalversion)

echo "New kernel version:" $KERNEL_VERSION

# Make sure a user really wants to install this kernel
confirm "$@"

check_root
check_userspace

echo "Installing kernel modules..."
make INSTALL_MOD_STRIP=1 modules_install
echo "Installing kernel..."
make INSTALL_MOD_STRIP=1 install

update_boot_config

echo "Kernel built and installed successfully!"

tidy_up
10 changes: 10 additions & 0 deletions resources/hiding_ci/dkms.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
PACKAGE_NAME="ena"
PACKAGE_VERSION="1.0.0"
CLEAN="make -C kernel/linux/ena clean"
MAKE="make -C kernel/linux/ena/ BUILD_KERNEL=${kernelver}"
BUILT_MODULE_NAME[0]="ena"
BUILT_MODULE_LOCATION="kernel/linux/ena"
DEST_MODULE_LOCATION[0]="/updates"
DEST_MODULE_NAME[0]="ena"
REMAKE_INITRD="yes"
AUTOINSTALL="yes"
24 changes: 24 additions & 0 deletions resources/hiding_ci/install_ena.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
# Copyright 2025 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# # SPDX-License-Identifier: Apache-2.0

# fail if we encounter an error, uninitialized variable or a pipe breaks
set -eu -o pipefail

AMZN_DRIVER_VERSION="2.13.3"
KERNEL_VERSION=$1
DKMS_CONF_LOCATION=$2
START_DIR=$(pwd)

cd /tmp/

git clone --depth=1 https://github.com/amzn/amzn-drivers.git
mv amzn-drivers /usr/src/amzn-drivers-${AMZN_DRIVER_VERSION}

cp $DKMS_CONF_LOCATION /usr/src/amzn-drivers-${AMZN_DRIVER_VERSION}

dkms add -m amzn-drivers -v ${AMZN_DRIVER_VERSION}
dkms build -k ${KERNEL_VERSION} -m amzn-drivers -v ${AMZN_DRIVER_VERSION}
dkms install -k ${KERNEL_VERSION} -m amzn-drivers -v ${AMZN_DRIVER_VERSION}

cd $START_DIR
1 change: 1 addition & 0 deletions resources/hiding_ci/kernel_commit_hash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4701f33a10702d5fc577c32434eb62adde0a1ae1
6 changes: 6 additions & 0 deletions resources/hiding_ci/kernel_config_overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CONFIG_EXPERT=y
CONFIG_KVM=y
CONFIG_KVM_SW_PROTECTED_VM=y
CONFIG_KVM_PRIVATE_MEM=y
CONFIG_KVM_AMD_SEV=y
CONFIG_DEBUG_INFO=y
1 change: 1 addition & 0 deletions resources/hiding_ci/kernel_url
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
git://git.kernel.org/pub/scm/virt/kvm/kvm.git
Loading