[PATCH RT 1/9] Revert "random: Use local locks for crng context access"

From: Daniel Wagner
Date: Mon Oct 24 2022 - 06:55:41 EST


v4.19.255-rt114-rc1 stable review patch.
If anyone has any objections, please let me know.

-----------


This reverts commit af5469c6f4f85f60f3ecc9bd541adfb6bdbeaff2.
---
drivers/char/random.c | 11 ++++-------
1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/char/random.c b/drivers/char/random.c
index c06705a32246..2be38780a7f7 100644
--- a/drivers/char/random.c
+++ b/drivers/char/random.c
@@ -53,7 +53,6 @@
#include <linux/uaccess.h>
#include <linux/siphash.h>
#include <linux/uio.h>
-#include <linux/locallock.h>
#include <crypto/chacha20.h>
#include <crypto/blake2s.h>
#include <asm/processor.h>
@@ -235,7 +234,6 @@ struct crng {
static DEFINE_PER_CPU(struct crng, crngs) = {
.generation = ULONG_MAX
};
-DEFINE_LOCAL_IRQ_LOCK(crngs_lock);

/* Used by crng_reseed() and crng_make_state() to extract a new seed from the input pool. */
static void extract_entropy(void *buf, size_t len);
@@ -364,7 +362,7 @@ static void crng_make_state(u32 chacha_state[CHACHA20_BLOCK_SIZE / sizeof(u32)],
if (unlikely(crng_has_old_seed()))
crng_reseed();

- local_lock_irqsave(crngs_lock, flags);
+ local_irq_save(flags);
crng = raw_cpu_ptr(&crngs);

/*
@@ -389,7 +387,7 @@ static void crng_make_state(u32 chacha_state[CHACHA20_BLOCK_SIZE / sizeof(u32)],
* should wind up here immediately.
*/
crng_fast_key_erasure(crng->key, chacha_state, random_data, random_data_len);
- local_unlock_irqrestore(crngs_lock, flags);
+ local_irq_restore(flags);
}

static void _get_random_bytes(void *buf, size_t len)
@@ -514,7 +512,6 @@ struct batch_ ##type { \
static DEFINE_PER_CPU(struct batch_ ##type, batched_entropy_ ##type) = { \
.position = UINT_MAX \
}; \
-static DEFINE_LOCAL_IRQ_LOCK(batched_entropy_lock_ ##type); \
\
type get_random_ ##type(void) \
{ \
@@ -530,7 +527,7 @@ type get_random_ ##type(void) \
return ret; \
} \
\
- local_lock_irqsave(batched_entropy_lock_ ##type, flags); \
+ local_irq_save(flags); \
batch = raw_cpu_ptr(&batched_entropy_##type); \
\
next_gen = READ_ONCE(base_crng.generation); \
@@ -544,7 +541,7 @@ type get_random_ ##type(void) \
ret = batch->entropy[batch->position]; \
batch->entropy[batch->position] = 0; \
++batch->position; \
- local_unlock_irqrestore(batched_entropy_lock_ ##type, flags); \
+ local_irq_restore(flags); \
return ret; \
} \
EXPORT_SYMBOL(get_random_ ##type);
--
2.38.0