-
Notifications
You must be signed in to change notification settings - Fork 88
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 arm cca #211
base: main
Are you sure you want to change the base?
Conversation
702d17f
to
86f75cd
Compare
b47ef94
to
9e6e5bb
Compare
9e6e5bb
to
68dff0c
Compare
d5952be
to
d4362d6
Compare
cae99a3
to
4a0e61b
Compare
5089b4f
to
e7e2a90
Compare
dae13da
to
6cebf95
Compare
6cebf95
to
94688b2
Compare
94688b2
to
2077cfc
Compare
18e9a7d
to
edb2f4a
Compare
edb2f4a
to
5ba47b6
Compare
@MatiasVara is this ready for review, or should I wait? |
@jakecorrenti I'm addressing the KVM guest_memfd changes (which @MatiasVara also added in this PR) to my latest SEV-SNP patches. This will probably require a rebase after that. Once that happens, it will likely be ready for a review. |
I think the PR is ready to review. The current issue is that it does not work for the latest series for KVM (v6). I am investigating the issue. |
ba8a4b1
to
0cf214d
Compare
I just updated the PR with the fix for v6 series. The fix is only to set the |
0cf214d
to
866514c
Compare
@jakecorrenti @tylerfanelli @slp Feel free to give a quick look. I am pretty sure there many things to fix. |
866514c
to
3d4903a
Compare
7b1f763
to
8b97dc4
Compare
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.
I didn't actually run it, just looked at the code. Overall looks good. Few comments, though.
Thanks for the work!
kvm-bindings = { version = ">=0.8", features = ["fam-wrappers"] , git = "https://github.com/virtee/kvm-bindings", branch = "add_bindings_for_realms" } | ||
kvm-ioctls = { version = ">=0.17", git = "https://github.com/virtee/kvm-ioctls", branch = "cca" } |
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.
Can you make a PR once these branches are ready? I'd like to have the deps be on the main branch
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.
Do you mean to use the main branch rather than the cca?
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.
Exactly. I'm going to have to make some changes for my TDX work, so I think we'll need to merge your CCA work and my TDX work into the main branch and then use that here.
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.
@tylerfanelli Do you think we can merge the cca branches into main for kvm-ioctl/bindings repos? Or, shall we have one branch per flavor? Bear in mind that those repo are temporal until changes are upstreamed.
kvm-bindings = { version = ">=0.8", features = ["fam-wrappers"] , git = "https://github.com/virtee/kvm-bindings", branch = "add_bindings_for_realms" } | ||
kvm-ioctls = { version = ">=0.17", git = "https://github.com/virtee/kvm-ioctls", branch = "cca" } |
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.
Same comment here
crossbeam-channel = "0.5" | ||
env_logger = "0.9.0" | ||
libc = ">=0.2.39" | ||
log = "0.4.0" | ||
once_cell = "1.4.1" | ||
|
||
kvm-bindings = { version = ">=0.8", features = ["fam-wrappers"] , git = "https://github.com/virtee/kvm-bindings", branch = "add_bindings_for_realms" } |
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.
same comment here
//vmm.kernel_cmdline.insert_str("tsi_hijack")?; | ||
#[cfg(feature = "net")] |
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.
Should this be CCA only? There's another one a few lines below 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.
I can't remember why I commented this line.
src/vmm/src/linux/vstate.rs
Outdated
id: u8, | ||
vm_fd: &VmFd, | ||
exit_evt: EventFd, | ||
sender_io: Sender<MemProperties>, |
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.
should be CCA only
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.
The memory fault exception isn't TEE-specific (although it could be used that way), so I don't think I agree that this should be CCA only.
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.
You're right. I did this part of the review before you and I had talked about the order of patches.
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.
I think we can enable the extra this extra thread only when the tee
feature is enabled.
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.
I agree. I made the original comment before it became clear that all of the TEE functionality would end up adopting it
src/vmm/src/builder.rs
Outdated
@@ -1103,17 +1231,19 @@ fn create_vcpus_aarch64( | |||
guest_mem: &GuestMemoryMmap, | |||
entry_addr: GuestAddress, | |||
exit_evt: &EventFd, | |||
sender_io: Sender<MemProperties>, |
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.
should be CCA only
After reviewing the Jake comments I came to the conclusion that this PR should be split otherwise is hard to review:
@jakecorrenti @tylerfanelli @slp WDYT? |
I don't know if this is idiomatic by any means, and it depends on whether you can have target arch-specific features, but could we have something like
Other than my question above, that all sounds good to me. |
I don't think
I'm addressing that in my SEV-SNP PR currently.
Makes sense to me.
Do you mean |
I do not know either. I though that
|
That's OK. I could just leave
The first two items in my list are for all
Yes for the moment. |
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 <[email protected]>
These descriptors are required for handling the KVM_FAULT_MEMORY vmexit. Although this vmexit is only present when the tee feature is enabled, changing for a reference does not seem the right thing to do by using feratures. Use reference and protect it to be able to share these descriptors. These changes prepare the code for handling KVM_EXIT_FAULT_MEMORY Signed-off-by: Matias Ezequiel Vara Larsen <[email protected]>
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 <[email protected]>
This commit will be removed when changes are in upstream. Signed-off-by: Matias Ezequiel Vara Larsen <[email protected]>
The `tee` feature has been used by having in mind only the x86-64 case. Currently, `tee` means sense only if `x86-64` is also enabled. In the future, the `tee` will enable code that is shared by arm and x86-64. Signed-off-by: Matias Ezequiel Vara Larsen <[email protected]>
Enable to build confidential guests using ARM CCA (Confidential Computing Architecture). This work relies on v7 series for Linux and v5 series for KVM. This has been tested only on the corresponding FVP model simulator. For testing, you require specific kvm-ioctls and kvm-bindings crates. Signed-off-by: Matias Ezequiel Vara Larsen <[email protected]>
This commit will be remove when cca use virtio-blk. For the moment, enable virtio-fs in cca. Signed-off-by: Matias Ezequiel Vara Larsen <[email protected]>
8b97dc4
to
c17ae42
Compare
I just split the PR into a few commits. It is the same code though. The first three commits are independent of cca and should be shared by all tees. Also |
This PR aims at adding support to build realm guests. First commit adds support for
create_guest_memfd()
andset_user_memory_region2()
. To do this, thememory_init()
is modified by adding a boolean parameter. This is required when building a confidential guest for arm cca and probably also required by other cases.The second commit imports the
virtee/cca
crate and adds the steps to build a cca guest. The following items should be completed before merge the PR:This has been testing using the v7 series for Linux as a guest and v6 series for KVM on FVP model.
Feedback is welcome.