Skip to content

Vm trait for reducing code duplication #469

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

Closed
wants to merge 51 commits into from

Conversation

ludfjig
Copy link
Contributor

@ludfjig ludfjig commented May 8, 2025

This PR introduces a minimal Vm trait. It's implemented by KvmVm, MshvVm and WhpVm. The goal is to reduce code duplication. The existing Hypervisor trait is renamed to HyperlightVm, and is now only implemented by HyperlightSandbox (and Inprocess, but not for long since we're getting rid of inproces mode). In addition, the Vm trait also reduces a bunch of code duplication related to GDB debugging.

About half of the lines of this PR is introducing common register structs used for all Vms. They Are CommonRegisters, CommonStandardRegisters, and CommonFpu, with tests. The rest should be pretty straight forward, and is mostly just plumbing.

This PR will be squashed, so it is not worth it to review commit by commit.

Closes #465
Closes #312
Closes #503

ludfjig added 3 commits May 7, 2025 14:49
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
@dblnz
Copy link
Contributor

dblnz commented May 9, 2025

Nice work, this is a very good idea.

ludfjig added 12 commits May 9, 2025 15:16
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
@ludfjig ludfjig added the kind/refactor For PRs that restructure or remove code without adding new functionality. label May 14, 2025
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
ludfjig added 4 commits May 14, 2025 18:32
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
ludfjig added 4 commits May 16, 2025 09:49
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
use crate::{new_error, Result};

/// Dump registers + memory regions + raw memory to a tempfile
#[cfg(crashdump)]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you're wondering why this was removed, it's because this entire crashdump module is already gated on this

Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
ludfjig added 2 commits May 17, 2025 20:19
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
Signed-off-by: Ludvig Liljenberg <[email protected]>
@ludfjig ludfjig marked this pull request as ready for review May 21, 2025 01:32
@ludfjig ludfjig closed this May 21, 2025
@ludfjig ludfjig mentioned this pull request May 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/refactor For PRs that restructure or remove code without adding new functionality.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Avoid reopening /dev/kvm or /dev/mshv for every new sandbox Rethink driver API Unify register representations across all Hypervisor implementations
2 participants