-
Notifications
You must be signed in to change notification settings - Fork 101
tee/snp: Update SEV-SNP APIs, use KVM guest_memfd #296
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
Conversation
Re-ran the Integration Tests but LGTM otherwise |
4a3fdde
to
6861441
Compare
@jakecorrenti @slp @MatiasVara Can you (re-)review? I'm not sure why the integration test (starting a VM with 1 vCPU and 1GiB of memory) fails. I'm able to boot a (non-confidential) VM with as little as 64MiB of memory. |
It is in my TODO list. I just had no time yet :'( |
I'm trying to understand why the rebase wasn’t done on my branch, which already included the guestmemfd (see 15ac9fc) and KVM_EXIT_MEMORY_FAUL (see 5c3f283) changes since last year—correct me if I’m wrong. To speed things up, I could create a new PR with just those two changes, so you would only need to rebase on top of that. I’d like to avoid any duplication of effort. |
@MatiasVara I could do that if you prefer. The reason is because I needed to handle I also did things a bit differently with not requiring guest_memfd with non-TEE workloads and managing of guest_memfds, associating with a EDIT: I am going to rebase on top of your commits and re-submit. Marking this as a draft until that is done. |
8b56864
to
2baf291
Compare
@MatiasVara PTAL. I've rebased on your branch. |
@mtjhrc Not sure why the integration test is failing, I'm able to run it locally just fine:
Currently investigating. |
d368877
to
9d96dd5
Compare
In the legacy AMD SEV implementation, the sev_secure_virt_attest function performed pre-boot attestation for a VM. This implementation was removed, and SEV-SNP uses post-boot attestation. As such, the SEV-SNP implementation only measures each region for guests, and does not attest anything, making the function name a bit misleading. Signed-off-by: Tyler Fanelli <tfanelli@redhat.com>
kvm_bindings does not yet expose the KVM_X86_SNP_VM value. Hard code the value until it is available in kvm_bindings. Taken from linux/arch/x86/include/uapi/asm/kvm.h Signed-off-by: Tyler Fanelli <tfanelli@redhat.com>
Updated SEV-SNP support in the Linux kernel requires an update of the sev library version along with some modifications to the APIs provided by the library. Signed-off-by: Tyler Fanelli <tfanelli@redhat.com>
When tee feature is enabled, use create_guest_memfd() and set_user_memory_region2(). The created regions are marked as private by using set_memory_attributes() thus imitating QEMU behavior. Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
guest_memfd is required by SEV-SNP guests, and will also be used for other TEE architectures such as TDX and CCA. Probe if guest_memfd will be used on the system (non-TEE workloads do not require guest_memfd), and create/map them if so. Signed-off-by: Tyler Fanelli <tfanelli@redhat.com>
SEV-SNP guests use KVM_EXIT_HYPERCALL to signal to the hypervisor that they would like some memory shared or private. Enable the KVM capability to allow the guests to use KVM_EXIT_HYPERCALL. Signed-off-by: Tyler Fanelli <tfanelli@redhat.com>
5d29996
to
1bc3f71
Compare
@slp @MatiasVara @jakecorrenti Can you re-review? it seems the integration tests failure will need to be handled in a separate PR as its failing on non-TEE tests as well. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commits 6833eb7 and 6be8e02 could be squashed, as well as the last two commits.
Also... Are we positive that nothing in this PR is causing the CI failure? I've posted 2 PRs myself after this one and haven't run into the issue with Integration tests. I only ask because I'd like to avoid failing CI on main if possible
I don't believe they should, as they are from two different authors.
The integration test fails on non-TEE tests. Perhaps its the thread sleep in |
You can add
|
Apologies, I did not have time to see this. I will try next week. |
e425c47
to
ecf414d
Compare
ecf414d
to
cc727a1
Compare
SEV-SNP guests use KVM_EXIT_HYPERCALL exits to signal to the hypervisor it would like some pages set to private or shared. Implements a handler that manages guest memory and can set regions to private or shared. vCPUs can send "memory properties" messages to the handler indicating: - Guest GPA - Size of memory region - Whether the region should be set to private or shared The handler will read these messages and configure the memory regions accordingly. Signed-off-by: Tyler Fanelli <tfanelli@redhat.com>
The KVM_EXIT_MEMORY_FAULT vmexit is triggered when guest wants to switch a region of memory from private to shared and viceversa. To support this when tee is enabled, add an extra thread named sender_io that gets the parameters from the vcpu thread and triggers the set_memory_properties(). The vcpu fd is owned only by this thread. Signed-off-by: Matias Ezequiel Vara Larsen <mvaralar@redhat.com>
Signed-off-by: Tyler Fanelli <tfanelli@redhat.com>
cc727a1
to
81f4653
Compare
Ideally I would like a review from @MatiasVara as well since this impacts him, but if that can't happen that's ok too |
I agree with Jake that those commits could be squashed, including |
I've generally avoided squashing commits that were from two separate authors. Does the
I see. It was a bit of a conundrum because those changes weren't able to be merged yet, so I thought I'd address the changes in my PR. Under typical circumstances I completely agree. Bit of a strange circumstance here, but I will definitely keep your comments in mind in the future. |
This series updates the SEV-SNP APIs (sev library dependency to 6.0.0) and adds KVM guest_memfd support for SEV-SNP guests. This is required for running SEV-SNP encrypted guests on upstream kernels.
Tested on linux
6.14.0-0.rc3
cc @slp @jakecorrenti @MatiasVara