coconut-svsm / svsm

COCONUT-SVSM
MIT License
122 stars 42 forks source link

soundness improvements around hypervisor-shared memory #451

Closed Freax13 closed 1 month ago

Freax13 commented 2 months ago

This PR improves the soundness of code around hypervisor-shared memory.

~The first patch, 174274d0e8ffb7757b74a42eef1082b05b8ea0a9, is blocked on https://github.com/google/zerocopy/pull/1601. Let me know if you want me to drop that patch if we don't want to wait on a new zerocopy release. I used the following patch to override zerocopy for testing:~

diff --git a/Cargo.toml b/Cargo.toml
index b7bdb46..d87444d 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -49,6 +49,9 @@ zerocopy = { version = "0.7.32", features = ["alloc", "derive"] }
 # other repos
 packit = { git = "https://github.com/coconut-svsm/packit", version = "0.1.1" }

+[patch.crates-io]
+zerocopy = { git = "https://github.com/Freax13/zerocopy.git", rev = "68e1cc8" }
+
 [workspace.lints.rust]
 future_incompatible = { level = "deny", priority = 127 }
 nonstandard_style = { level = "deny", priority = 126 }
joergroedel commented 2 months ago

This PR improves the soundness of code around hypervisor-shared memory.

The first patch, 174274d, is blocked on google/zerocopy#1601. Let me know if you want me to drop that patch if we don't want to wait on a new zerocopy release.

Please move that patch to a separate draft-PR, which you can then "undraft" once all blockers are solved.

In general I like these changes, especially the SharedBox implementation. That will simplify a lot of things.

Once updated this needs testing by @msft-jlange and possibly also a review by @cclaudio .

Freax13 commented 2 months ago

Please move that patch to a separate draft-PR, which you can then "undraft" once all blockers are solved.

Done.

Freax13 commented 2 months ago

Just rebased onto main. I resolved the TODOs by switching to the functions in crate::cpu::mem.