Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for running Confidential Workloads with AMD SEV #36

Merged
merged 13 commits into from
Sep 10, 2021

Conversation

slp
Copy link
Contributor

@slp slp commented Sep 10, 2021

No description provided.

In the regular version of libkrun, the integrated VMM starts booting
directly in 64 bits and into the kernel entry point, after setting up
some initial data structures (page tables, e820, mptables...).

With SEV, those data structures are problem, as they become part of
the launch measurement.

So, if targeting SEV, use qboot as firmware, loading it into the
reset, and don't set those initial data structures (they'll be set by
qboot after the VM is started).

This commit also introduces the "amd-sev" feature to allow users to
choose this flavor or the library.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Linux on SEV requires MTRR and PAT, so enable and configure
the MSR for MTRRdefType.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Introduce initial plain SEV support. This sets the stage for adding
remote attestation, SEV-ES and SEV-SNP in the future.

This functionality is gated behind the "amd-sev" feature defined in
the workspace's Cargo. In practice, this means now libkrun comes in
two different flavors, regular libkrun (for container isolation) and
SEV-enabled libkrun (for Confidential Computing).

Signed-off-by: Sergio Lopez <slp@redhat.com>
Import virtio-block support from Firecraker, and use it to replace
virtio-fs in the SEV flavor. Extend the API with the
"krun_set_root_disk()" function to allow users to configure the disk
image that contains the root filesystem.

While there, disable also virtio-balloon when targeting libkrun-SEV.

Signed-off-by: Sergio Lopez <slp@redhat.com>
With virtio-fs gone, we need a trusted place to put the "init" binary
that sets up the environment in the guest for running the workload
entry point and, in case of using LUKS, to unlock the root file
system.

The obvious replacement is using an initramfs. This change extends
libkrun to load the initrd bundled in the SEV variant of libkrunfw.

Signed-off-by: Sergio Lopez <slp@redhat.com>
If the KRUN_PASS environment variable is present, use cryptsetup to
open a LUKS volume in "/dev/vda" and, if successful, mount it and
switch to it as root file system.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Implement support for Remote Attestation using a simple custom
protocol over HTTP, serializing and deserializing SEV-related data
structures as JSON objects.

This also adds the "krun_set_attestation_url()" function to the
API (only for libkrun-SEV), to enable users set up the base URL for
the attestation server. If missing, libkrun-SEV will still encrypt the
guest's memory, but it's initial contents won't be attested.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Detect AMD CPU model (from the SEV supported range) and use it to
download the ASK/ARK certificate.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Add the examples "sev-attest" and "sev-noattest" to test the SEV
functionality.

The first one ("sev-attest") enables SEV and does remote attestation,
receiving the LUKS passphrase and the rest of the command line (which
includes the workload entry point) from the remote attestation server
in pre-encrypted form, so it can be safely injected into the guest
memory by the VMM.

The other ("sev-noattest") also enables SEV (and thus, memory
encryption), but doesn't attempt to do a remote attestation, and as a
consequence, both the LUKS passphrase and the command line are passed
in plain text through the VMM.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Add the SEV flag to Makefile and examples/Makefile, to allow users to
easily opt-in to build the SEV flavor of both libkrun and the examples
by passing "SEV=1" to "make".

Signed-off-by: Sergio Lopez <slp@redhat.com>
Increase the RAM of the SEV examples (sev-attest and sev-noattest) from
512 MiB to 2 GiB, so cryptsetup is able to open LUKS2 volumes.

Signed-off-by: Sergio Lopez <slp@redhat.com>
kvm_bindings::CpuId API has changed slightly, update related code.

Signed-off-by: Sergio Lopez <slp@redhat.com>
Signed-off-by: Sergio Lopez <slp@redhat.com>
@slp slp merged commit a7e38a9 into containers:main Sep 10, 2021
@slp slp deleted the sev-clean branch September 10, 2021 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant