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

Zphrs GetRandom - adds support for the GetRandom syscall (also adds the Instant struct to the kernel) #207

Closed
wants to merge 36 commits into from

Conversation

zphrs
Copy link
Contributor

@zphrs zphrs commented Sep 17, 2024

See twizzler-operating-system/rfcs#12 for more details.

Justification for adding the Instant struct to the kernel: Since the Fortuna specification itself requires only reseeding at most every 100ms to prevent fully replacing the entropy pool with junk events (ex. events with 0s as the only bytes for the seed) within any reasonable timeframe, I required some way of keeping track of how long has passed. Additionally, Instants will be useful in the future for any timing difference based entropy sources such as timing driver events for instance.

Future work:

  • Add some sort of contribute_entropy syscall so that specific approved userspace drivers are able to contribute entropy.
  • Make interrupts call contribute_entropy to contribute to the entropy pools.
  • Instead of running only the very basic randomness tests in random_validation, find a way to stream random bytes out of twizzler and onto my local computer so I can run dieharder tests locally on my machine. Alternatively find a way to compile dieharder, a C library, in twizzler. dieharder debian package source

Note: Before merging this PR, make sure to first merge this one into getrandom-twizzler. Otherwise other contributors will face issues with their submodules.

@@ -45,7 +45,7 @@ impl<T> Once<T> {
Ordering::SeqCst,
) {
Ok(_) => {
// We will initialize this Once.
// We willx initialize this Once.
Copy link
Contributor

Choose a reason for hiding this comment

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

simple fix

Copy link
Contributor

@dbittman dbittman left a comment

Choose a reason for hiding this comment

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

Some cleanup to do, there's those binary files from src/toolchain/install that need to be removed, and then extraneous debugging messages, etc. Otherwise, this looks good. Is the goal to replace the dieharder implementation with a way to extract random info out of qemu and run the tests on linux?

Copy link
Contributor Author

@zphrs zphrs left a comment

Choose a reason for hiding this comment

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

lgtm!

extern "C" fn contribute_entropy_regularly() {
logln!("Starting entropy contribution");
loop {
logln!("Contributing entropy");
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this going to print every second? In general, maybe reduce some of the loglns in this file?

Copy link
Contributor

@dbittman dbittman left a comment

Choose a reason for hiding this comment

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

Just 2 small things :)

@@ -65,8 +69,13 @@ impl QemuCommand {
self.cmd
.arg("--no-reboot") // exit instead of rebooting
.arg("-s") // shorthand for -gdb tcp::1234
.arg("-serial")
.arg("mon:stdio");
// .arg("-serial")
Copy link
Contributor

Choose a reason for hiding this comment

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

We shouldn't hard code in the -smp or the -nographic.

@zphrs zphrs closed this Jan 2, 2025
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