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

split stage2 and svsm kernel into two crates #532

Open
Freax13 opened this issue Nov 23, 2024 · 1 comment
Open

split stage2 and svsm kernel into two crates #532

Freax13 opened this issue Nov 23, 2024 · 1 comment

Comments

@Freax13
Copy link
Contributor

Freax13 commented Nov 23, 2024

As of today, the stage2 and svsm targets are two binary targets of the same crate and share most of their code through a common lib.rs. This has various downsides:

  1. stage2 is unnecessarily bloated.
  2. We can't have stage2 or svsm-specific APIs in the shared code.
  3. publicly exposing all modules in lib.rs hides a lot of dead-code warnings.

Instead, we should split the code into at least three crates, one for the stage2 target, one for the svsm target, and one for shared code.

There was some discussion on this in one of the meetings.

@Freax13
Copy link
Contributor Author

Freax13 commented Nov 23, 2024

I worked on this for a while, but unfortunately, I won't be able to finish my work 1. You can find my work-in-progress code here.

In the hopes that maybe someone else will be able to pick this up and finish it, here's what I did so far:
I started with one commit that copies all code from the svsm directories into a new stage2 directory. The goal behind this was to make it easy to update when rebasing without missing any new changes. Following this, there are a couple commits that fix build errors introduced by just doing a raw copy in the first commit.
Those first couple of commits don't build, but everything after that starting with Freax13@0dbd970 should build and pass the tests. There have been a few instances where some commits broke tests after a rebase, so I'd recommend keeping this structure until everything's done.
Most of the the remaining commits simply remove dead code, but some of them also rewrite existing code e.g. there's a commit replacing the very complex heap allocator and its SVSM-specific features with a simple bump allocator in stage2.

Footnotes

  1. Previously, my employer was paying me to work on the COCONUT SVSM project, but I started a new position at a new employer last week and my new role doesn't involve SVSM development.

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

1 participant