Skip to content

Commit

Permalink
Updated space, measurement check error
Browse files Browse the repository at this point in the history
  • Loading branch information
ramagali24 committed Sep 17, 2024
1 parent bb710f8 commit deeb492
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions tools/snp.sh
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ set -eE
set -o pipefail

trap cleanup EXIT

set -x
# Working directory setup
WORKING_DIR="${WORKING_DIR:-$HOME/snp}"
SETUP_WORKING_DIR="${SETUP_WORKING_DIR:-${WORKING_DIR}/setup}"
Expand Down Expand Up @@ -525,7 +525,6 @@ save_binary_paths() {
local guest_kernel=$(echo $(realpath "${SETUP_WORKING_DIR}/AMDSEV/linux/guest/vmlinuz-${guest_kernel_version}"))

# Save binary paths in source file

cat > "${SETUP_WORKING_DIR}/source-bins" <<EOF
QEMU_BIN="${SETUP_WORKING_DIR}/AMDSEV/qemu/build/qemu-system-x86_64"
INITRD_BIN="${GENERATED_INITRD_BIN}"
Expand Down Expand Up @@ -562,7 +561,6 @@ copy_launch_binaries() {
cp "${KERNEL_BIN}" "${LAUNCH_WORKING_DIR}"

# Save binary paths in source file

cat > "${LAUNCH_WORKING_DIR}/source-bins" <<EOF
INITRD_BIN="${LAUNCH_WORKING_DIR}/$(basename "${INITRD_BIN}")"
KERNEL_BIN="${LAUNCH_WORKING_DIR}/$(basename "${KERNEL_BIN}")"
Expand Down Expand Up @@ -688,11 +686,10 @@ build_and_install_amdsev() {
git remote set-url current "${AMDSEV_URL}"
git fetch current "${amdsev_branch}"
git checkout "current/${amdsev_branch}"

# Based on latest AMDSEV documentation
# Delete the ovmf/ directory prior to the build step for ovmf re-initialization
[ ! -d "ovmf" ] || rm -rf "ovmf"


# Build and copy files
./build.sh --package
Expand Down Expand Up @@ -819,7 +816,9 @@ setup_and_launch_guest() {
fi

# ovmf, initrd, kernel and append options
add_qemu_cmdline_opts "-bios ${OVMF_BIN}"
if [ ! "$SVSM" = true ]; then
add_qemu_cmdline_opts "-bios ${OVMF_BIN}"
fi
add_qemu_cmdline_opts "-initrd ${INITRD_BIN}"
add_qemu_cmdline_opts "-kernel ${KERNEL_BIN}"
add_qemu_cmdline_opts "-append \"${GUEST_KERNEL_APPEND}\""
Expand Down Expand Up @@ -1105,12 +1104,15 @@ generate_snp_expected_measurement() {
}
attest_guest() {
local cpu_code_name=$(get_cpu_code_name)

vmpl_flag=""
if [ "$SVSM" = true ]; then
vmpl_flag="--vmpl 3"
fi
# Install the sev-guest module
ssh_guest_command "sudo insmod /lib/modules/*/kernel/drivers/virt/coco/sev-guest/sev-guest.ko >/dev/null 2>&1 || true"

# Request and display the snp attestation report with random data
ssh_guest_command "sudo ./snpguest report attestation-report.bin request-data.txt --random $( [ \"$SVSM\" = true ] && echo '--vmpl 3' )"
ssh_guest_command "sudo ./snpguest report attestation-report.bin request-data.txt --random $vmpl_flag"
ssh_guest_command "./snpguest display report attestation-report.bin"

# Retrieve ark, ask, vcek (saved in ./certs)
Expand Down Expand Up @@ -1153,7 +1155,8 @@ attest_guest() {
}

setup_svsm_guest_attestation() {
ssh_guest_command <<'EOF'
# Define the guest command to be executed
local guest_command=$(cat <<'EOF'
# Update and install necessary packages
echo 'Updating package list...'
sudo apt-get update
Expand Down Expand Up @@ -1197,6 +1200,10 @@ cargo build --release
# Copy the built binary to the home directory
cp target/release/snpguest "$HOME/"
EOF
)

# Pass the guest command to ssh_guest_command
ssh_guest_command "$guest_command"
}

generate_svsm_expected_measurement() {
Expand Down Expand Up @@ -1224,7 +1231,8 @@ generate_svsm_expected_measurement() {
echo "Output: $output"
exit 1
fi

# Convert svsm_measurement to lowercase
svsm_measurement=$(echo "$svsm_measurement" | tr '[:upper:]' '[:lower:]')
echo ${svsm_measurement}
}

Expand Down Expand Up @@ -1339,7 +1347,6 @@ main() {

# TEMPORARY until sev-snp-measure is updated to pass in TCB kernel modifier flags
# Changes in AMDESE/linux set debug_swap on by default and affect the measurement

sudo modprobe -r kvm_amd
sudo modprobe kvm_amd debug_swap=0

Expand Down

0 comments on commit deeb492

Please sign in to comment.