[PATCH next 6/7] random32: prandom_seed_state() use all 64 bits of the seed
From: David Laight
Date: Mon Nov 02 2026 - 16:47:36 EST
Use the high 32bits to initialise s3 and s4 rather than reducing
the value to 32 bits.
Simplify the avoidance of values near zero by just setting a bit.
Keep the '<< 10' so that bits 0 and 32-35 get used.
Signed-off-by: David Laight <david.laight.linux@xxxxxxxxx>
---
lib/random32.c | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/random32.c b/lib/random32.c
index 83776345adda..1d6468045267 100644
--- a/lib/random32.c
+++ b/lib/random32.c
@@ -133,11 +133,12 @@ EXPORT_SYMBOL(prandom_seed_full_state);
void prandom_seed_state(struct rnd_state *state, u64 seed)
{
- u32 i = ((seed >> 32) ^ (seed << 10) ^ seed) & 0xffffffffUL;
+ seed ^= seed << 10;
- state->s1 = __seed(i, 2U);
- state->s2 = __seed(i, 8U);
- state->s3 = __seed(i, 16U);
- state->s4 = __seed(i, 128U);
+ /* The values must not be near zero. */
+ state->s1 = seed | 0x100;
+ state->s2 = seed | 0x200;
+ state->s3 = (seed >> 32) | 0x100;
+ state->s4 = (seed >> 32) | 0x200;
}
EXPORT_SYMBOL(prandom_seed_state);
--
2.39.5