vmm, hypervisor: Add support for embedding kernel hashes to a CVM's launch digest - #8084
CookieComputing wants to merge 8 commits into
Conversation
0bce310 to
97cc28b
Compare
This introduces the kernel hashes measured boot table into cloud hypervisor if a cmdline and kernel is passed into an SEV-SNP CVM, incorporating a kernel/cmdline/optional initrd into a memory page that is measured into the launch digest of a SEV-SNP CVM. If both --kernel and --cmdline are not provided, we do not insert this data page Signed-off-by: Kevin Hui <[email protected]>
Introduce the KVM_SNP_PAGE_TYPE_ZERO page type for ZERO pages. AMD SEV SNP can accept ZERO pages as a page in which the page memory is functionally just zeroes Signed-off-by: Kevin Hui <[email protected]>
IGVM has an opinionated way of deterministically loading pages. We should prefer to follow the ordering that IGVM has instead of modifying this page order Signed-off-by: Kevin Hui <[email protected]>
Previous builds were failing because measured_boot concepts rely on fw_cfg, which wasn't provided at the time Signed-off-by: Kevin Hui <[email protected]>
Signed-off-by: Kevin Hui <[email protected]>
Signed-off-by: Kevin Hui <[email protected]>
Signed-off-by: Kevin Hui <[email protected]>
Signed-off-by: Kevin Hui <[email protected]>
a494c53 to
68af816
Compare
| self.kernel | ||
| .read_exact_at(&mut setup_data, 0) | ||
| .map_err(Self::measured_boot_io)?; | ||
| setup_data[..setup_header.len()].copy_from_slice(&setup_header); |
There was a problem hiding this comment.
We already read the whole of setup_data on line 156 which should already contain the bytes covered by setup_header, so do we need to copy setup_header on this line again?
| // Preserve the original IGVM import order for SNP launch updates. | ||
| // The launch digest is order-sensitive, so only coalesce adjacent pages | ||
| // that already share the same page type and size. |
There was a problem hiding this comment.
For my understanding, this is not gated by KVM, so it also applied to MSHV. Was the original MSHV code incorrect? Launch digest being order-sensitive should not be specific to hypervisor IIUC.
There was a problem hiding this comment.
I might be missing some context for the MSHV stuff, but maybe this comment should be above, where we previously sort the GPAs...
I'm guessing that we can coalesce to reduce hypercalls for MSHV, which functionally doesn't affect the launch digest because they're just coalescing the pages, but we definitely don't want to modify page order from IGVM
| #[cfg(all( | ||
| feature = "kvm", | ||
| feature = "sev_snp", | ||
| feature = "fw_cfg", | ||
| target_arch = "x86_64" | ||
| ))] |
There was a problem hiding this comment.
I feel like there are a bit too many of these chunky cfgs scattered around load_igvm that it becomes a bit difficult to follow what's happening.
There was a problem hiding this comment.
Yeah I agree, these cfgs are getting too bloated... I wonder if there's a good way to extract some of these components (e.g. make it such that the fw_cfg cfg is only used to define which method is to used to fetch the kernel/initrd/cmdline components)
|
Drafting as there are some basic CI check failures. |
|
Replaced by #8123 |
Context
I am adding kernel hash support for SEV-SNP in Cloud Hypervisor. The idea behind this is to embed an extra page of data containing a table detailing the
kernel,initrd, andkernel cmdlineso that these are part of the launch digest, ensuring that all of these components are embedded as part of the TCB. Prior to this, a launch digest only represented the contents of the OVMF binary and the other existing VMSA data.This is an existing concept from QEMU and OVMF, see this documentation. I'm simply porting this over to enable support here .
The idea is that this is a GUID table that resembles a struct like:
When this table is added in to the launch digest via
SNP_LAUNCH_UPDATE, we can then enforce via the bootloader that we are launching the correct initrd, kernel, and kernel cmdline (see my changes in project-oak/oak#5073). Tying this together, we get a Launch Digest which represents the bootloader, initrd, kernel, kernel hashes, and VMSA (+ any other fields).Test Plan
Tested this on an SEV-SNP capable AMD Bergamo host.
I generated
buildigvmusing the PRs I've added in 7, 8, and 9. This makes thebuildigvmtooling deterministic and matches the behavior ofsev-snp-measure.Launch parameters:
When using
snpguest, I get the following measurement from the CVM:Using the
sev-snp-measuretool from VirTEE, I get this:So, at least with this original set of changes we have a consistent measurement with existing tooling (IGVM measurement tooling pending conversation with SVSM folks).