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

Implement an IGVM builder in rust #235

Merged
merged 6 commits into from
Jan 31, 2024

Conversation

roy-hopkins
Copy link
Collaborator

Coconut SVSM currently packages the and optionally the OVMF firmware inside an IGVM file using a builder tool that is invoked from the Makefile for both QEMU and Hyper-V. The current implementation of the builder tool is written in C. The intention was always to replace this with a rust implementation of a builder.

This PR implements an IGVM builder in rust equivalent to the C implementation, and is intended to provide a drop-in replacement.

The commits in the PR are engineered to demonstrate the fact that both builders generate the same output, which generally follows this sequence:

  1. Implement the new rust builder (4edabe7, 12219e0 and 9d978f7)
  2. Sort the output of directives in both builders to make it easy to compare outputs (766c801, 083880b)
  3. Remove the C implementation of the builder (ca85d7c)

This approach meant that I could generate a sorted output from both the C and rust builders simultaneously during a build, dump the output using the dump_igvm tool implemented in this PR: microsoft/igvm#3 then perform a diff to ensure the outputs are consistent for the following configurations:

  1. QEMU without OVMF
  2. QEMU with OVMF
  3. Hyper-V without firmware
  4. Hyper-V with IGVM based firmware

Once I determined the outputs were identical, the final commit was added to remove the C builder.

…ation

This adds a new IGVM builder and integrates it into the makefile. The
output of the IGVM builder is functionally exactly the same as the
C-based builder and can be used as a direct replacement.

Signed-off-by: Roy Hopkins <roy.hopkins@suse.com>
The implementation suffered from being a direct converstion from the the
C builder. This commit separates the code into different structs/crates
and uses rust more effectively.

Signed-off-by: Roy Hopkins <roy.hopkins@suse.com>
Hyper-V does not use OVMF firmware. Instead it uses a firmware binary
that is described in IGVM format. This commit adds an IGVM parser that
extracts the relevent directives from the firmware binary and adds them
to the built IGVM file.

Signed-off-by: Roy Hopkins <roy.hopkins@suse.com>
The order pages are defined in the IGVM file is generally not important.
However, in order to verify the output of the builder it is useful to
compare the output to the existing (working) C implementation of the
builder. To simplify this, this commit adds a sort option that ensures
all pages are described in ascending GPA order.

In addition, there is a requirement that directives defining parameters
are specified in the right order. After building the list of directives,
this commit unconditionally moves all Page directives to the end of the
list.

Signed-off-by: Roy Hopkins <roy.hopkins@suse.com>
In order to allow an easy comparison between the output of this C IGVM
builder and the rust IGVM builder, add an option to the C builder to
sort all Page directives in order of ascending GPA.

This allows an IGVM dump tool to be used to compare the outputs of the
two different builders.

Signed-off-by: Roy Hopkins <roy.hopkins@suse.com>
The C implementation has been replaced with a rust implementation with
equivalent functionality.

Signed-off-by: Roy Hopkins <roy.hopkins@suse.com>
@msft-jlange
Copy link
Collaborator

Booting with real Hyper-V firmware works identically between the new and old versions of the file builder - no regressions here!

@joergroedel joergroedel merged commit df06885 into coconut-svsm:main Jan 31, 2024
2 checks passed
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

Successfully merging this pull request may close these issues.

3 participants