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 io and arch modules to std::os::fortanix_sgx #57119

Merged
merged 2 commits into from
Dec 27, 2018

Conversation

jethrogb
Copy link
Contributor

This PR adds two more (unstable) modules to std::os::fortanix_sgx for the x86_64-fortanix-unknown-sgx target.

io

io allows conversion between raw file descriptors and Rust types, similar to std::os::unix::io.

arch

arch exposes the ENCLU[EREPORT] and ENCLU[EGETKEY] instructions. The current functions are very likely not going to be the final form of these functions (see also fortanix/rust-sgx#15), but this should be sufficient to enable experimentation in libraries. I tried using the actual types (from the sgx-isa crate) instead of byte arrays, but that would make std dependent on the bitflags crate which I didn't want to do at this time.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 25, 2018
@Centril
Copy link
Contributor

Centril commented Dec 25, 2018

r? @joshtriplett

@rust-lang rust-lang deleted a comment from rust-highfive Dec 25, 2018

/// Call the `EGETKEY` instruction to obtain a 128-bit secret key.
#[unstable(feature = "sgx_platform", issue = "56975")]
pub fn egetkey(request: &Align512<[u8; 512]>) -> Result<Align16<[u8; 16]>, u32> {
Copy link
Member

Choose a reason for hiding this comment

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

Would it be possible to use more meaningful structs here, rather than Align16<[u8; 16]>? For instance, a struct Key with the appropriate alignment and contents?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As mentioned in the PR description:

I tried using the actual types (from the sgx-isa crate) instead of byte arrays, but that would make std dependent on the bitflags crate which I didn't want to do at this time.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, I see! I didn't realize those were the types you meant.

We do need a better solution for bitfields, in-tree.

In the meantime, would you please add a comment to these types, explicitly saying to consider a more type-safe version before stabilizing? That way it doesn't get lost.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

How about I'll add a note on the tracking issue?

Copy link
Member

Choose a reason for hiding this comment

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

@jethrogb Alright, that works.

@joshtriplett
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Dec 27, 2018

📌 Commit be56561 has been approved by joshtriplett

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 27, 2018
@bors
Copy link
Contributor

bors commented Dec 27, 2018

⌛ Testing commit be56561 with merge d298697...

bors added a commit that referenced this pull request Dec 27, 2018
Add `io` and `arch` modules to `std::os::fortanix_sgx`

This PR adds two more (unstable) modules to `std::os::fortanix_sgx` for the `x86_64-fortanix-unknown-sgx` target.

### io
`io` allows conversion between raw file descriptors and Rust types, similar to `std::os::unix::io`.

### arch
`arch` exposes the `ENCLU[EREPORT]` and `ENCLU[EGETKEY]` instructions. The current functions are very likely not going to be the final form of these functions (see also fortanix/rust-sgx#15), but this should be sufficient to enable experimentation in libraries. I tried using the actual types (from the [`sgx-isa` crate](https://crates.io/crates/sgx-isa)) instead of byte arrays, but that would make `std` dependent on the `bitflags` crate which I didn't want to do at this time.
@bors
Copy link
Contributor

bors commented Dec 27, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: joshtriplett
Pushing d298697 to master...

@bors bors merged commit be56561 into rust-lang:master Dec 27, 2018
@workingjubilee workingjubilee added the O-SGX Target: SGX label Jul 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
O-SGX Target: SGX S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants