This repository contains utility scripts to automate the setup and operation of virtualized environments using AMD's Secure Encrypted Virtualization - Secure Nested Paging (SEV-SNP). The utility provides a complete flow for creating an SEV-SNP-enabled environment, from provisioning the host machine to calculating measurements for a modified guest image, kernel, and OVMF.
This utility script (snp.sh
) is adapted from sev-utils.
The utility performs the following tasks:
- Provisions an AMD EPYC CPU-powered server by building the required patched versions of qemu, OVMF, and the Linux kernel.
- Allows for the launching of an SNP-enabled guest directly with QEMU.
- Facilitates attestation of the SNP guest using the virtee/snpguest CLI tool.
Tested OS Distributions:
- Ubuntu 20.04
- Ubuntu 22.04
Supported Image Formats:
- qcow2
- Enable SNP features on your AMD EPYC CPU from the system BIOS. Follow the detailed instructions for enabling these options.
Clone this repository and navigate to its directory:
git clone https://github.com/your-repo-link
cd your-repo-directory
Make the script executable:
chmod +x snp.sh
To set up the host with the default UPM-enabled version of the kernel:
./snp.sh setup-host
For users who require support for Confidential Containers (CoCo), which currently does not support UPM, use the --non-upm
option:
./snp.sh setup-host --non-upm
If you only need to build the guest OVMF, kernel, and image, use the following command:
./snp.sh build-guest
Note that only buiding OVM, guest kernel and image does not require KVM supported.
This command is also used in Github Actions for automatic measurement calculation.
To launch a guest with the default UPM-enabled version of the kernel:
./snp.sh launch-guest
Again, for CoCo users, specify the --non-upm
option if you've set up the host using the same:
./snp.sh launch-guest --non-upm
Note: If you intend to use the --non-upm
option for launching a guest, ensure you've also used it during the host setup phase.
./snp.sh attest-guest
./snp.sh stop-guests
To use your own guest image, set these environment variables:
export IMAGE="guest.img"
export GUEST_USER="user"
export GUEST_SSH_KEY_PATH="guest-key"
And then:
./snp.sh launch-guest
ssh -p 10022 -i snp-guest-key amd@localhost
Generate the golden measurement with:
chmod +x cal-measurement.sh
./cal-measurement.sh
- The script installs developer packages. Check
install_dependencies
for admin concerns. - Grub settings will be modified.