-
Notifications
You must be signed in to change notification settings - Fork 708
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 support for x86_64-unknown-uefi #787
Conversation
6 similar comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please share the instructions for how I can run the ring tests in a simulated UEFI environment.
no_std | ||
)] | ||
// std is only used in tests or when gated with #[cfg(use_heap)] | ||
#![cfg_attr(not(any(test, feature = "use_heap")), no_std)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment here isn't necessary since it's just duplicating the code, so let's remove it.
@@ -100,14 +100,14 @@ impl sealed::Sealed for SystemRandom {} | |||
target_os = "macos", | |||
target_os = "ios", | |||
target_os = "fuchsia", | |||
windows | |||
target_os = "windows" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How should fill_impl
be implemented for UEFI targets? Please provide an implementation.
not(target_os = "macos"), | ||
not(target_os = "ios"), | ||
not(target_os = "fuchsia"), | ||
not(target_os = "windows"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am planning to switch this to a whitelist approach because I want to avoid using /dev/urandom
whenever practical. So I think that while this may work right now, it will soon (in a matter of days) stop working.
@@ -215,7 +215,7 @@ mod urandom { | |||
|
|||
#[cfg(target_os = "redox")] | |||
static RANDOM_PATH: &str = "rand:"; | |||
#[cfg(unix)] | |||
#[cfg(not(target_os = "redox"))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What was wrong with cfg(unix)
here? It seems better to me.
Generally, I am happy to help people port ring to new environments, but to minimize the maintenance burden I ask that ports be reasonably complete and easy for me to test. In the documentation for According to https://github.com/rust-osdev/uefi-rs/blob/master/.travis.yml, it seems like it is relatively straightforward to add UEFI as a target to Travis CI. Please do so. |
Also, thanks for the PR! |
@briansmith I was thinking to have this PR only simplify the Also, UEFI (like SGX) has to use hardware RNG, so actually completing the port will have to wait on some of the material from #775 |
It looks like #738 adds |
I would like to have everything together in one PR, with a separate commit for each separate thing being changed. I will probably merge them all at once. Please add the contribution statement at https://github.com/briansmith/ring#contributing at the end of each commit's commit message. Is Google the copyright holder for these changes? |
Sounds good, I'll have this commit, rdrand support, and UEFI support
Will do, and yes Google is still the copyright holder. I can go though a process to transfer copyright to you (if you prefer), but the projects we contribute to are normally I can change the |
Regarding |
Assigning the copyright would be best. Otherwise, in other files, we have |
I'm currently planning for ring 0.17 to switch away from |
This will be fine. I think bare-metal x86 targets shouldn't need spinlocks. All we have to do is check CPUID, and that operation is idempotent. So we should just be able to use atomic load/store, where we might run cpuid twice, but that seems fine. For reference, |
Closing this as the issues here are best solved generically for all bare-metal x86 targets. |
Right now, ring contains a lot of long
cfg
clauses to determine which RNG implementation to use or if the crate should beno_std
. This change simplifies them, mainly by using the fact thatstd
in only ever used in tests or ifuse_heap
is enabled. It also avoids using the confusingwindows
andunix
attributes, and now makes all target decisions based ontarget_os
.This also fixes a bug arising from the fact that
#[cfg(windows)] != #[cfg(target_os = "windows")]
. Some custom targets base themselves off of the windows family of LLVM, but these targets do not have any of the Windows OS services.The remaining issues blocking use of
x86_64-unknown-uefi
are:libc
types: (Move universal libc types to the root rust-lang/libc#1244)fill_impl
to check for and then use RDRAND.