Skip to content

Conversation

@mfontanini
Copy link
Contributor

This allows all symbols that are needed for SNP measurrement hash generation (e.g. everything needed to invoke snp_calc_launch_digest) to be used in non linux OSes. The main thing preventing this seemed to be launch::snp::PageType since all of launch::snp was gated behind target_os = "linux". I moved this type up to launch, which is maybe not ideal. I'm open to alternatives such as creating 2 modules within launch::snp so one contains this PageType (and maybe something else?), or anything else that makes sense.

@DGonzalezVillal
Copy link
Member

Hello @mfontanini thank you for the PR. I don't love the idea of moving the PageType to launch. I could give better suggestions if I understood your use case a little better.

What I'm imagining is that you are trying to generate hashes in a non-linux environment but, you can't because the measurement library is not compiling because of the linux flag. Is that correct?

@mfontanini
Copy link
Contributor Author

Yes, that's correct. I want to validate an attestation, including generating measurement hashes, in mac/windows (and linux ofc) but the way target_os is used here prevents me from doing so.

@DGonzalezVillal
Copy link
Member

I see. I'm thinking you've hit in a bigger issue, where maybe we are using this gating functions in the wrong way.
I think maybe only the IOCTL API's should be gated behind the linux flag, since you won't be able to reach those in a non-linux machine. But everything that is parsing, validating or calculating should be usable on any platform.

For this particular PR, you can remove the Linux gate on the measurement library and that should unblock your use case. That way you don't need to move PageType. I'll add to the to-do list to make sure other functionality isn't being blocked this way.

@DGonzalezVillal
Copy link
Member

thoughts @tylerfanelli @larrydewey

@mfontanini
Copy link
Contributor Author

That doesn't work unfortunately, I tried it. I don't remember what was the build error (and I no longer have access to a mac) but there's lots in measurement that is gated behind target_os = "linux" unfortunately.

Copy link
Member

@DGonzalezVillal DGonzalezVillal left a comment

Choose a reason for hiding this comment

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

Wait I understand what this is doing better now. This is a good solution. Thoughts @tylerfanelli

//! This ensures (at compile time) that the right steps are called in the
//! right order.
use crate::launch::PageType;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

FYI if this solution works this should probably be a pub use so this doesn't break backwards compatibility.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think that would be the case because PageType is now defined in mod right? we are not exporting it from launch::snp, but from launch directly, if my reasoning is correct.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a breaking change as it is. Any code that was doing use sev::launch::snp::PageType will fail to compile unless this re-export is added ^. They can always fix it to use sev::launch::PageType but still, an avoidable breaking change.

Copy link
Member

Choose a reason for hiding this comment

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

I see, i would prefer avoiding breaking changes

Copy link
Member

Choose a reason for hiding this comment

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

Please make that change

@DGonzalezVillal
Copy link
Member

But now that I think about it. Would it make more sense to move PageType to measurement and have launch import it. Because PageType will get compiled regardless now

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.

4 participants