Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
cfc3c33
ci: Create script for installing custom kernel
JackThomson2 Mar 19, 2025
b23626e
test: Add test for kernel build
JackThomson2 Mar 24, 2025
827fb4b
ci: Add secret hiding kernel to defaults buildkite
JackThomson2 Mar 25, 2025
8bf8133
tests: Mark kernels newer than 6.12 as next
JackThomson2 Mar 26, 2025
8664797
ci: Move away from using dir stacks
JackThomson2 Mar 27, 2025
ab60b20
tests(bk): Run the kernel build in our nightly PR
JackThomson2 Mar 31, 2025
e580df8
ci: Add linux patches for secret hiding
roypat Apr 3, 2025
13417e8
fix(ci): actually test kernel builds if patches are added
roypat Apr 3, 2025
32551c0
ci: Update script to install for AL23
JackThomson2 Apr 1, 2025
dd40575
ci: Update the script to support x86 on AL23
JackThomson2 Apr 4, 2025
dc52e58
fix: test_hiding_kernel.py
bchalios Apr 7, 2025
ef7936f
chore: allow clippy::needless_update
roypat Apr 7, 2025
d5d9f95
refactor(test): Move MachineConfig::update tests to machine_config.rs
roypat Apr 3, 2025
ad3e8e9
add helper for Read/Write[Volatile] through bounce buffer
roypat Apr 25, 2025
da638ce
allow persistent bounce buffers in MaybeBounce
roypat Apr 14, 2025
756561f
implement userspace bounce buffering support
roypat Apr 11, 2025
bda5e0b
ci: dont fail downloading artifacts if no firecracker binaries exist
roypat Mar 24, 2025
02991a5
add Vm::create_guest_memfd
roypat Mar 31, 2025
d9b8a8b
refactor: generify "these features are incompatible" error variants
roypat Mar 31, 2025
3d42669
add "secret_free" parameter to /machine-config endpoint
roypat Mar 20, 2025
26249b8
use bounce buffers for loading kernel if secret freedom is enabled
roypat Apr 25, 2025
71c610b
use userspace bounce buffers if secret freedom is enabled
roypat Apr 11, 2025
2ad5fd5
switch to using kvm_userspace_region2
roypat Apr 1, 2025
5753465
tmp: call mmap outselves
roypat Apr 2, 2025
e975ec1
add concept of "secret free" VMs
roypat Apr 25, 2025
9fe82be
Use guest_memfd to back memory if secret freedom is enabled
roypat Apr 2, 2025
6e1558d
allow creation of snapshots of secret hidden VMs
roypat Apr 8, 2025
074d9ab
fix: Stop the scan for vmlinux failing
JackThomson2 Apr 9, 2025
a3d1dd5
chore(hiding_ci): skip non-patch files when applying
kalyazin Apr 22, 2025
5780b36
test: run throughput perf tests with secret freedom enabled
roypat Mar 24, 2025
047e588
test: add functional tests for booting secret free VMs
roypat Apr 11, 2025
70bd4c6
test: disable memory monitor in boottime tests
roypat Apr 8, 2025
754a1da
ci: Use AL23 for secret hiding CI
JackThomson2 Apr 29, 2025
9d7e680
ci: Include config in boot directory
JackThomson2 May 6, 2025
acd6076
hiding_ci: remove support for everything but .patch files
roypat May 6, 2025
3ec1f81
test(uffd_utils): add protocol definitions for secret freedom
kalyazin Jun 11, 2025
d6ad5a0
test(uffd_utils): add UserfaultBitmap
kalyazin Jun 16, 2025
f0c0208
test(uffd_utils): accept guest_memfd and bitmap memfd
kalyazin Jun 12, 2025
011bd7a
test(uffd_utils): add handling for FaultRequest in secret freedom
kalyazin Jun 13, 2025
906a186
feat(vmm): add secret free userfault definitions
kalyazin Jun 16, 2025
10fe7f0
feat(vmm): extend register_memory_regions with userfault bitmap
kalyazin Jun 16, 2025
01c02c5
feat(vmm): configure kvm userfault if secret free is enabled
kalyazin Jun 16, 2025
455cff7
feat(vmm): add offset/gpa conversion functions
kalyazin Jun 18, 2025
d94cfd7
feat(vmm): implement secret-free fault handling protocol
kalyazin Jun 18, 2025
106244d
chore(vmm): prohibit restoring from a file if secret free
kalyazin Jun 18, 2025
e54ae5f
test: enable secret freedom in uffd tests
kalyazin Jun 18, 2025
96391b8
test(uffd/valid_handler): do not use balloon if secret free
kalyazin Jun 19, 2025
e06f5f5
test: update expected error strings
kalyazin Jun 18, 2025
3de46d0
tmp(test/api): disable x86 tests that use reboot
kalyazin Jun 25, 2025
76e5550
tmp: Stop tweaking turbo/pstates in perf tests
roypat Jul 11, 2025
e8eac67
fix: pass -y to yum in build_and_install_kernel.sh
roypat Jul 14, 2025
273be5e
example(uffd): dont panic if read(2) from uffd returns -EAGAIN
roypat Jul 15, 2025
ab33fff
fix(ci): Dont run functional tests if changing patch series
roypat Jul 31, 2025
68f3557
fix(vmm): propagate errors in secret freedom
kalyazin Aug 5, 2025
5ef8e53
fix(vmm): do not unwrap in gpa_to_offset
kalyazin Aug 6, 2025
d091b0f
fix(vmm): write_all in process_vcpu_userfault
kalyazin Aug 6, 2025
10cf583
fix(vmm): handle EINTR in process_uffd_socket
kalyazin Aug 6, 2025
7bd20d2
fix(vmm): simplify vcpus_handles dereferencing in process_uffd_socket
kalyazin Aug 6, 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
7 changes: 5 additions & 2 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"),
("al2023", "secret_hiding"),
]


Expand Down Expand Up @@ -120,10 +121,12 @@ def run_all_tests(changed_files):
"""

# run the whole test suite if either of:
# - any file changed that is not documentation nor GitHub action config file
# - any file changed that is not documentation nor GitHub action config file, nor secret hiding patch series
# - no files changed
return not changed_files or any(
x.suffix != ".md" and not (x.parts[0] == ".github" and x.suffix == ".yml")
x.suffix != ".md"
and not (x.parts[0] == ".github" and x.suffix == ".yml")
and x.parts[1] != "hiding_ci"
for x in changed_files
)

Expand Down
11 changes: 11 additions & 0 deletions .buildkite/pipeline_pr.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,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 @@ -30,6 +30,7 @@ tests_outside_test_module = "warn"
assertions_on_result_states = "warn"
error_impl_error = "warn"
or_fun_call = "warn"
needless-update = "allow"

[profile.dev]
panic = "abort"
Expand Down
240 changes: 240 additions & 0 deletions resources/hiding_ci/build_and_install_kernel.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,240 @@
#!/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
}

install_build_deps() {
case $USERSPACE in
"UBUNTU")
apt-get update && apt-get install -y make bsdmainutils flex yacc bison bc xz-utils libelf-dev elfutils libssl-dev
;;
"AL2023")
yum -y groupinstall "Development Tools"
yum -y install make openssl-devel dkms
;;
esac
}

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() {
echo "Applying patch:" $(basename $1)

git apply $1
}

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

apply_all_patches() {
if [ ! -d "$1" ]; then
echo "Not a directory: $1"
return
fi

echo "Applying all patches in $1"

for f in $1/*; do
if [ -d $f ]; then
apply_all_patches $f
else
apply_patch_or_series $f
fi
done
}

check_new_config() {
if [[ -e "/boot/config-$KERNEL_VERSION" ]]; then
return 0;
fi

echo "Storing new config in /boot/config-$KERNEL_VERSION"
cp .config /boot/config-$KERNEL_VERSION
}

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
}

check_userspace
install_build_deps

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
apply_all_patches $KERNEL_PATCHES_DIR

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

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

check_override_presence

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

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

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

update_boot_config

check_new_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 @@
beafd7ecf2255e8b62a42dc04f54843033db3d24
17 changes: 17 additions & 0 deletions resources/hiding_ci/kernel_config_overrides
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
CONFIG_EXPERT=y
CONFIG_CRYPTO_HW=y
CONFIG_CRYPTO_DEV_CCP=y
CONFIG_CRYPTO_DEV_CCP_DD=y
CONFIG_CRYPTO_DEV_SP_PSP=y
CONFIG_KVM=y
CONFIG_KVM_SW_PROTECTED_VM=y
CONFIG_KVM_AMD=y
CONFIG_KVM_INTEL=y
CONFIG_KVM_AMD_SEV=y
CONFIG_KVM_PRIVATE_MEM=y
CONFIG_KVM_GENERIC_MMU_NOTIFIER=y
CONFIG_KVM_GENERIC_HARDWARE_ENABLING=y
CONFIG_KVM_GENERIC_MEMORY_ATTRIBUTES=y
CONFIG_KVM_GENERIC_PRIVATE_MEM=y
CONFIG_DEBUG_INFO=y
CONFIG_KVM_XEN=n
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