Skip to content

Commit 6134fed

Browse files
committed
Replace rand_chacha with rand_hc
The former seems to use some SSE features, which cause LLVM errors since we're compiling for a target that has SSE disabled.
1 parent 5dbc503 commit 6134fed

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

Cargo.lock

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ x86_64 = { version = "0.14.8" }
1717
xmas-elf = "0.8.0"
1818
raw-cpuid = "10.2.0"
1919
rand = { version = "0.8.4", default-features = false }
20-
rand_chacha = { version = "0.3.1", default-features = false }
20+
rand_hc = "0.3.1"
2121

2222
[dependencies.noto-sans-mono-bitmap]
2323
version = "0.1.2"

common/src/entropy.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
use rand_chacha::{rand_core::SeedableRng, ChaCha20Rng};
1+
use rand::SeedableRng;
2+
use rand_hc::Hc128Rng;
23
use raw_cpuid::CpuId;
34
use x86_64::instructions::{port::Port, random::RdRand};
45

56
/// Gather entropy from various sources to seed a RNG.
6-
pub fn build_rng() -> ChaCha20Rng {
7+
pub fn build_rng() -> Hc128Rng {
78
const ENTROPY_SOURCES: [fn() -> [u8; 32]; 3] = [rd_rand_entropy, tsc_entropy, pit_entropy];
89

910
// Collect entropy from different sources and xor them all together.
@@ -17,7 +18,7 @@ pub fn build_rng() -> ChaCha20Rng {
1718
}
1819

1920
// Construct the RNG.
20-
ChaCha20Rng::from_seed(seed)
21+
Hc128Rng::from_seed(seed)
2122
}
2223

2324
/// Gather entropy by requesting random numbers with `RDRAND` instruction if it's available.

common/src/level_4_entries.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use rand::{
55
distributions::{Distribution, Uniform},
66
seq::IteratorRandom,
77
};
8-
use rand_chacha::ChaCha20Rng;
8+
use rand_hc::Hc128Rng;
99
use usize_conversions::IntoUsize;
1010
use x86_64::{
1111
structures::paging::{Page, PageTableIndex, Size4KiB},
@@ -21,7 +21,7 @@ pub struct UsedLevel4Entries {
2121
entry_state: [bool; 512],
2222
/// A random number generator that should be used to generate random addresses or
2323
/// `None` if aslr is disabled.
24-
rng: Option<ChaCha20Rng>,
24+
rng: Option<Hc128Rng>,
2525
}
2626

2727
impl UsedLevel4Entries {

0 commit comments

Comments
 (0)