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

Add sevctl measurement build #68

Merged
merged 14 commits into from
Dec 13, 2022
Merged

Conversation

crobinso
Copy link
Contributor

@crobinso crobinso commented Oct 12, 2022

This adds sevctl measurement build for spitting out a measurement+nonce blob, like we get from qemu and libvirt for a running VM.

Patches tell the story. One note is that this doesn't use sev crate existing Session bits to build the measurement. The sev crate will need some tweaks for us to use it here. And in the end it would only save maybe 7-8 lines of code.

@crobinso crobinso force-pushed the measurement-build branch 5 times, most recently from d2ae085 to 6061d98 Compare October 20, 2022 17:53
@crobinso crobinso changed the title WIP: Add sevctl measurement build Add sevctl measurement build Nov 12, 2022
@crobinso crobinso marked this pull request as ready for review November 12, 2022 21:36
tylerfanelli
tylerfanelli previously approved these changes Nov 16, 2022
Copy link
Member

@tylerfanelli tylerfanelli left a comment

Choose a reason for hiding this comment

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

LGTM.

Assembles the measurement from the follow options

  --api-major INT
  --api-minor INT
  --policy INT
  --build-id INT
  --nonce BASE64
  --tik FILENAME
  --launch-digest BASE64

And spits out a base 64 string

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Same with --nonce

Signed-off-by: Cole Robinson <crobinso@redhat.com>
If specified, we dump binary content to the specified file,
rather than base64 to stdout

Signed-off-by: Cole Robinson <crobinso@redhat.com>
--firmware can be specified independently.
--kernel --initrd --cmdline expect OVMF firmware and must
be specified as a trio
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Allow passing in base64 representation of the full output of the
LAUNCH_MEASURE firmware command, like returned by qemu
`query-sev-launch-measure` and/or `virsh domlaunchsecinfo`

This saves users the pain of peeling the nonce out of that
base64 value

Signed-off-by: Cole Robinson <crobinso@redhat.com>
The LAUNCH_MEASURE firmware call returns measurement+nonce. Arguably
this is two values, but qemu and libvirt treat this blob as opaque
and return it straight to the user.

Because of this, it's kind of ambiguous what `measurement` should refer
to here: the entire blob, or the value with the nonce removed.
`sevtool calc_measurement` returns the latter, but I expect most tools
will want to use qemu and/or libvirt.

Change the measurement output to return the measurement+nonce format.
If this is the wrong choice, we can add an --output-format option later.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Would need some changes on sev crate side to plug existing code
in here

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
Return the Result object gives us better default error output.
Example:

$ sevctl vmsa build ... --firmware idontexist

Before:
  Error: error loading firmware blob entries in OVMF

After:
  Error: error loading firmware blob entries in OVMF

  Caused by:
    0: error reading from firmware path file
    1: No such file or directory (os error 2)

Signed-off-by: Cole Robinson <crobinso@redhat.com>
These will be used in an upcoming patch

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Build header and payload binary files, for use with qemu's
sev-inject-launch-secret / virsh domsetlaunchsecstate

Secrets are injected with one or more --secret UUID:FILENAME
options

Signed-off-by: Cole Robinson <crobinso@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
@crobinso
Copy link
Contributor Author

@tylerfanelli I added secret build commits on top of this PR, since they share some code. Please review + approve when you get some time, thanks!

tylerfanelli
tylerfanelli previously approved these changes Nov 28, 2022
Copy link
Member

@tylerfanelli tylerfanelli left a comment

Choose a reason for hiding this comment

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

Thanks Cole. I've just left 2 comments, however they are not immediate problems. Let me know what you think, and we can merge.

src/main.rs Show resolved Hide resolved
src/measurement.rs Show resolved Hide resolved
@tylerfanelli tylerfanelli merged commit 963a220 into virtee:main Dec 13, 2022
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.

2 participants