-
Notifications
You must be signed in to change notification settings - Fork 450
rust: add Hardware Random Number Generator subsystem #592
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
rust: add Hardware Random Number Generator subsystem #592
Conversation
2f36f22
to
fa19442
Compare
The new version has just been uploaded. Feel free to review. |
fa19442
to
75319f5
Compare
75319f5
to
94b77fd
Compare
|
CI failes somehow randomly on arm64 run. On my local repo CI completes correctly https://github.com/m-falkowski1/linux/actions/runs/1813535226. The same thing applies to the other patch I posted today. |
Yeah, there are a couple intermittent issues with the CI since the move to containers; I am taking a look. Meanwhile, I will rerun the CI for you. |
The arm64 issue, which was the prevalent one, is solved now. |
That went quickly, I just saw #667, thanks! |
94b77fd
to
6d02ddb
Compare
|
This patch adds abstractions over the hwrng subsystem: - trait `hwrng::Operations` that defines operations of a hwrng driver. - `declare_hwrng_operations!` macro that populates callback pointers located in hwrng structure. - Registration structure for hwrng's drivers. Signed-off-by: Maciej Falkowski <[email protected]>
6d02ddb
to
fe80499
Compare
misc fix for |
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.
Very nice, thanks for putting this together!
This patch adds abstractions over the hwrng subsystem:
hwrng::Operations
that defines operations of a hwrng driver.located in hwrng structure.
This patch is a dependency of a Samsung Exynos trng driver provided initially in #554.
Changes v5 -> v6:
&'static CStr
in favor ofCString
to support names created at runtime,as *const core::ffi::c_void
->as *const _
. rust: add Hardware Random Number Generator subsystem #592 (comment),core::ffi:c_void
->c_types::c_void
, rust: add Hardware Random Number Generator subsystem #592 (comment),[i8]
with[u8]
.Changes v4 -> v5:
hwrng::Operations::Data
onSelf
(replaced with()
) and addedSync
andSend
requirements,Removed
Sized + 'static
requirements forhwrng::Operations
rust: add Hardware Random Number Generator subsystem #592 (comment),ScopeGuard
uses properlyT::Data::from_pointer()
method rust: add Hardware Random Number Generator subsystem #592 (comment),<T::Data as PointerWrapper>::into_pointer(data)
=>data.into_pointer()
rust: add Hardware Random Number Generator subsystem #592 (comment),'static
to&CStr
rust: add Hardware Random Number Generator subsystem #592 (comment),T::Data
incleanup
callback.T::Data
is moved to the callback andSend
is implemented forT::Data
rust: add Hardware Random Number Generator subsystem #592 (comment),impl Registration
rust: add Hardware Random Number Generator subsystem #592 (comment),#[allow(clippy::needless_update)]
rust: add Hardware Random Number Generator subsystem #592 (comment),_p: PhantomData::default()
=>_p: PhantomData,
rust: add Hardware Random Number Generator subsystem #592 (comment),Send
trait forhwrng::Registration
thathas additional
#[allow(clippy::non_send_fields_in_send_ty)]
(see 334eb69).Changes v3 -> v4:
&CStr
reference.Changes v2 -> v3:
register()
method so it now acceptsself: Pin<&mut Self>
. rust: add Hardware Random Number Generator subsystem #592 (comment)&mut *self.hwrng.get()
->self.hwrng.get()
. rust: add Hardware Random Number Generator subsystem #592 (comment)hw_random.rs
->hwrng.rs
. rust: add Hardware Random Number Generator subsystem #592 (comment)HwrngOperations
intohwrng::Operations
. rust: add Hardware Random Number Generator subsystem #592 (comment)name: &'a CStr
->name: &CStr
. rust: add Hardware Random Number Generator subsystem #592 (comment)register()
function makes a copy of thename
argument. rust: add Hardware Random Number Generator subsystem #592 (comment)new()
andregister()
as public methods ofRegistration<T>
. rust: add Hardware Random Number Generator subsystem #592 (comment)ScopeGuard
to prevent leaking registration state on failure. rust: add Hardware Random Number Generator subsystem #592 (comment)bindings::hwrng
is done after the structure is pinned. rust: add Hardware Random Number Generator subsystem #592 (comment)to_result()
method instead of checking error code explicitly. rust: add Hardware Random Number Generator subsystem #592 (comment)registered
toRegistration<T>
to check if driver was registeredin
Drop
implementation.read
method inhwrng::Operations
to unsigned. rust: add Hardware Random Number Generator subsystem #592 (comment)Changes v1 (#554) -> v2:
_
in trait's method declaration Add Samsung Exynos true random number generator driver #554 (comment)PointerWrapper
. #556Signed-off-by: Maciej Falkowski [email protected]