Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
e56d19b
ci: Create script for installing custom kernel
JackThomson2 Mar 19, 2025
636471f
test: Add test for kernel build
JackThomson2 Mar 24, 2025
5afdba8
ci: Add secret hiding kernel to defaults buildkite
JackThomson2 Mar 25, 2025
0337b78
tests: Mark kernels newer than 6.12 as next
JackThomson2 Mar 26, 2025
74782c2
ci: Move away from using dir stacks
JackThomson2 Mar 27, 2025
a10eaf5
tests(bk): Run the kernel build in our nightly PR
JackThomson2 Mar 31, 2025
c05bd6a
ci: Add linux patches for secret hiding
roypat Apr 3, 2025
e0bb1cc
fix(ci): actually test kernel builds if patches are added
roypat Apr 3, 2025
66fb3aa
ci: Update script to install for AL23
JackThomson2 Apr 1, 2025
573767d
ci: Update the script to support x86 on AL23
JackThomson2 Apr 4, 2025
741fd23
fix: test_hiding_kernel.py
bchalios Apr 7, 2025
efce9ae
chore: allow clippy::needless_update
roypat Apr 7, 2025
66e9823
refactor(test): Move MachineConfig::update tests to machine_config.rs
roypat Apr 3, 2025
dfe7aa0
add helper for Read/Write[Volatile] through bounce buffer
roypat Apr 25, 2025
bf91698
allow persistent bounce buffers in MaybeBounce
roypat Apr 14, 2025
5cc0097
implement userspace bounce buffering support
roypat Apr 11, 2025
36d4556
ci: dont fail downloading artifacts if no firecracker binaries exist
roypat Mar 24, 2025
6ce3a9e
add Vm::create_guest_memfd
roypat Mar 31, 2025
2753c77
refactor: generify "these features are incompatible" error variants
roypat Mar 31, 2025
15aa301
add "secret_free" parameter to /machine-config endpoint
roypat Mar 20, 2025
8e51fce
use bounce buffers for loading kernel if secret freedom is enabled
roypat Apr 25, 2025
43cbe6e
use userspace bounce buffers if secret freedom is enabled
roypat Apr 11, 2025
34450f3
switch to using kvm_userspace_region2
roypat Apr 1, 2025
657706c
tmp: call mmap outselves
roypat Apr 2, 2025
afdf4f3
add concept of "secret free" VMs
roypat Apr 25, 2025
7d1f440
Use guest_memfd to back memory if secret freedom is enabled
roypat Apr 2, 2025
8732c96
allow creation of snapshots of secret hidden VMs
roypat Apr 8, 2025
a74b981
fix: Stop the scan for vmlinux failing
JackThomson2 Apr 9, 2025
fa0dd8b
chore(hiding_ci): skip non-patch files when applying
kalyazin Apr 22, 2025
5369456
test: run throughput perf tests with secret freedom enabled
roypat Mar 24, 2025
e54c7e1
test: add functional tests for booting secret free VMs
roypat Apr 11, 2025
986273a
test: disable memory monitor in boottime tests
roypat Apr 8, 2025
a697ea3
ci: Use AL23 for secret hiding CI
JackThomson2 Apr 29, 2025
cf199d0
ci: Include config in boot directory
JackThomson2 May 6, 2025
8eb66e6
hiding_ci: remove support for everything but .patch files
roypat May 6, 2025
af56701
test(uffd_utils): add protocol definitions for secret freedom
kalyazin Jun 11, 2025
f7cdcf7
test(uffd_utils): add UserfaultBitmap
kalyazin Jun 16, 2025
eff477a
test(uffd_utils): accept guest_memfd and bitmap memfd
kalyazin Jun 12, 2025
99c2d63
test(uffd_utils): add handling for FaultRequest in secret freedom
kalyazin Jun 13, 2025
b54fd29
feat(vmm): add secret free userfault definitions
kalyazin Jun 16, 2025
c8aab80
feat(vmm): extend register_memory_regions with userfault bitmap
kalyazin Jun 16, 2025
9f98146
feat(vmm): configure kvm userfault if secret free is enabled
kalyazin Jun 16, 2025
fe0d665
feat(vmm): add offset/gpa conversion functions
kalyazin Jun 18, 2025
5fa89be
feat(vmm): implement secret-free fault handling protocol
kalyazin Jun 18, 2025
4840728
chore(vmm): prohibit restoring from a file if secret free
kalyazin Jun 18, 2025
7e0be5b
test: enable secret freedom in uffd tests
kalyazin Jun 18, 2025
508c595
test(uffd/valid_handler): do not use balloon if secret free
kalyazin Jun 19, 2025
4484cac
test: update expected error strings
kalyazin Jun 18, 2025
6304ccc
tmp(test/api): disable x86 tests that use reboot
kalyazin Jun 25, 2025
0b2ce45
tmp: Stop tweaking turbo/pstates in perf tests
roypat Jul 11, 2025
fffc8ab
fix: pass -y to yum in build_and_install_kernel.sh
roypat Jul 14, 2025
69d5774
example(uffd): dont panic if read(2) from uffd returns -EAGAIN
roypat Jul 15, 2025
6f62d06
fix(ci): Dont run functional tests if changing patch series
roypat Jul 31, 2025
79b8523
fix(vmm): propagate errors in secret freedom
kalyazin Aug 5, 2025
3fc69d8
fix(vmm): do not unwrap in gpa_to_offset
kalyazin Aug 6, 2025
bcb8b1d
fix(vmm): write_all in process_vcpu_userfault
kalyazin Aug 6, 2025
89a63d1
fix(vmm): handle EINTR in process_uffd_socket
kalyazin Aug 6, 2025
a5216ca
fix(vmm): simplify vcpus_handles dereferencing in process_uffd_socket
kalyazin Aug 6, 2025
6be072f
chore: upgrade userfaultfd-rs dependency
roypat Aug 18, 2025
9cc20e8
fix(ci): do not crash if file in repo root is modified
roypat Aug 18, 2025
11811c7
buildkite: increase timeout for population latency tests
kalyazin Sep 2, 2025
ce0f006
test: disable memory monitor in test_cpu_all.py
roypat Sep 9, 2025
e9ecf8f
fix(test): disable memory monitor in uvm_restored
roypat Sep 9, 2025
0d2a0bc
refactor(test): de-duplicate MemoryMonitor.stop() implementation
roypat Sep 9, 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 @@ -32,6 +32,7 @@
DEFAULT_PLATFORMS = [
("al2", "linux_5.10"),
("al2023", "linux_6.1"),
("al2023", "secret_hiding"),
]


Expand Down Expand Up @@ -123,10 +124,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 (len(x.parts) < 2 or x.parts[1] != "hiding_ci")
for x in changed_files
)

Expand Down
1 change: 1 addition & 0 deletions .buildkite/pipeline_perf.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"label": "📸 Memory Population Latency",
"tests": "integration_tests/performance/test_snapshot.py::test_population_latency",
"devtool_opts": "-c 1-12 -m 0",
"timeout_in_minutes": 90,
},
"vsock-throughput": {
"label": "🧦 Vsock Throughput",
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 @@
a6ad54137af92535cfe32e19e5f3bc1bb7dbd383
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