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

Collaboration / Merge with Ketuvim #62

Open
npmccallum opened this issue Jun 3, 2019 · 14 comments
Open

Collaboration / Merge with Ketuvim #62

npmccallum opened this issue Jun 3, 2019 · 14 comments

Comments

@npmccallum
Copy link
Member

I'm the author of the Ketuvim project. We currently provide an API for KVM with an emphasis on type safety. However, we are still young so we haven't fully accomplished this goal yet. Perhaps we could find a way to merge the projects or at least collaborate?

One major difference between our two approaches is that rust-vmm publicly uses C types generated with bindgen. Ketuvim's strategy has been to use bindgen to generate initial structures and then remove all public access and add safe methods and types with the same memory layout.

Another (similar) strategy we have taken is to carefully define wrapper types that preserve mutability and lifetimes. This allows the hypervisor to work without unsafe blocks.

One major benefit of Ketuvim is that we have full, working AMD SEV support via the sev crate (of which I'm also the author). Perhaps this crate could be merged into rust-vmm too?

Anyway, let me know your thoughts. What is the right way to move forward?

@npmccallum
Copy link
Member Author

I forgot to mention that we are also working with the rust-os project to define memory layout compatible types for hardware features (like register flags, etc.). These should be reusable for things like register tweaking.

@andreeaflorescu
Copy link
Member

Hey @npmccallum I'll take a look at your code, sounds interesting. We definitely don't want to re-invent the wheel where there is no need to. If we could merge the projects/work together that'd be great.
When you say an API for KVM do you mean something similar to what we have in kvm-ioctls?

I would also recommend to drop an email to the rust-vmm email list as it has a larger audience.

@andreeaflorescu
Copy link
Member

rust-vmm email list: [email protected]

@npmccallum
Copy link
Member Author

@andreeaflorescu Yes. However, we have one crate that does the job of multiple of your crates. So there isn't exactly a one-to-one mapping.

@andreeaflorescu
Copy link
Member

@npmccallum what other crates are you referring to?

@npmccallum
Copy link
Member Author

We cover at least kvm-bindings and kvm-ioctls. We also provide additional types that can be reused in a variety of situations.

@npmccallum
Copy link
Member Author

(Some of this is stuff I'm about to push.)

kailun-qin added a commit to kailun-qin/kvm-ioctls that referenced this issue Aug 4, 2020
The `KVM_MEM_ENCRYPT_OP` ioctl is used to access AMD SEV (Secure
Encrypted Virtualization) feature. When enabled, memory contents of a VM
will be transparently encrypted with a key unique to that VM.

This patch added implementation, documentation and related tests for the
following SEV commands:
- KVM_SEV_INIT
- KVM_SEV_LAUNCH_START
- KVM_SEV_LAUNCH_UPDATE_DATA
- KVM_SEV_LAUNCH_MEASURE
- KVM_SEV_LAUNCH_FINISH
- KVM_SEV_LAUNCH_SECRET

Note: this work is based on enarx/ketuvim. See [1]_ for details.

[1] rust-vmm/community#62

Signed-off-by: Kailun Qin <[email protected]>
@kailun-qin
Copy link

kailun-qin commented Aug 4, 2020

Hi @npmccallum and @andreeaflorescu ,
I have made a follow-up work for this based on enarx project. Please kindly help review the drafted PR.
Let me know if any comment or suggestion. Thanks a lot.

@andreeaflorescu
Copy link
Member

@kailun-qin thanks for the PR! I'll take a look in a couple of days. I need to ramp up on what's up with SEV first :))

@alxiord
Copy link
Member

alxiord commented Sep 3, 2020

Hey @kailun-qin, I looked over your PR too, there's one thing that stands out in particular - it introduces a dependency of the sev crate, which, if I got it right, is the one embedded in enarx. If that's the case, it introduces a consumption issue, because:

  • Cargo can't consume sev from the enarx repo because enarx doesn't have a Cargo.toml (I think) => to get the code to build, you'd need to embed sev in kvm-ioctls, which isn't the desired state;
  • even if that worked, kvm-ioctls couldn't be published unless sev was on crates.io.

@npmccallum do you have any plans to publish this crate (and/or others 😃) from enarx?

@npmccallum
Copy link
Member Author

@aghecenco Yes. We are stabilizing sev over the next few weeks and pushing a release since we are close to our first release of enarx-keepldr (which depends on sev).

@npmccallum
Copy link
Member Author

@aghecenco Also, I think our upcoming changes to the sev API would make the linkage to rust-vmm indirect through the AsRawFd trait (we only need the file descriptor of the VM).

@kailun-qin
Copy link

kailun-qin commented Sep 4, 2020

Thank you all for the feedbacks and review comments.
I've already seen that https://github.com/enarx/enarx-keepldr, https://github.com/enarx/sev and https://github.com/enarx/sevctl are published out! Let's wait a while and see how to move this forward.

@connorkuehl
Copy link
Contributor

Also, I think our upcoming changes to the sev API would make the linkage to rust-vmm indirect through the AsRawFd trait (we only need the file descriptor of the VM).

This is now the case for the sev crate. Here's an example of an SEV VM launch using kvm-ioctls, passing in the VmFd as an AsRawFd trait object; there are no hard dependencies on any KVM ioctl implementation. So, someone could just pick their favorite KVM ioctls crate and the sev crate would interoperate with it without any fuss as long as the VM's file descriptor is at hand.

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

No branches or pull requests

5 participants