aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRomain Dolbeau <[email protected]>2020-02-06 18:26:13 +0100
committerGitHub <[email protected]>2020-02-06 09:26:13 -0800
commit77122f9d68a3a6e3fbd266652467acbd7b5d3225 (patch)
treee3085141184d8f09db56a02e8207094455193cb4
parentaf09c050e95bebbaeca52156218f3f91e8c9951a (diff)
Replace static per-cpu with dynamic per-cpu data
This solves the issue of loading the spl module on RISC-V. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Romain Dolbeau <[email protected]> Closes #9942
-rw-r--r--module/os/linux/spl/spl-generic.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/module/os/linux/spl/spl-generic.c b/module/os/linux/spl/spl-generic.c
index 091a52a78..c55ebf7c5 100644
--- a/module/os/linux/spl/spl-generic.c
+++ b/module/os/linux/spl/spl-generic.c
@@ -92,7 +92,7 @@ EXPORT_SYMBOL(p0);
* and use them when in_interrupt() from linux/preempt_mask.h evaluates to
* true.
*/
-static DEFINE_PER_CPU(uint64_t[2], spl_pseudo_entropy);
+void __percpu *spl_pseudo_entropy;
/*
* spl_rand_next()/spl_rand_jump() are copied from the following CC-0 licensed
@@ -141,7 +141,7 @@ random_get_pseudo_bytes(uint8_t *ptr, size_t len)
ASSERT(ptr);
- xp = get_cpu_var(spl_pseudo_entropy);
+ xp = get_cpu_ptr(spl_pseudo_entropy);
s[0] = xp[0];
s[1] = xp[1];
@@ -163,7 +163,7 @@ random_get_pseudo_bytes(uint8_t *ptr, size_t len)
xp[0] = s[0];
xp[1] = s[1];
- put_cpu_var(spl_pseudo_entropy);
+ put_cpu_ptr(spl_pseudo_entropy);
return (0);
}
@@ -701,6 +701,9 @@ spl_random_init(void)
uint64_t s[2];
int i = 0;
+ spl_pseudo_entropy = __alloc_percpu(2 * sizeof (uint64_t),
+ sizeof (uint64_t));
+
get_random_bytes(s, sizeof (s));
if (s[0] == 0 && s[1] == 0) {
@@ -717,7 +720,7 @@ spl_random_init(void)
}
for_each_possible_cpu(i) {
- uint64_t *wordp = per_cpu(spl_pseudo_entropy, i);
+ uint64_t *wordp = per_cpu_ptr(spl_pseudo_entropy, i);
spl_rand_jump(s);
@@ -727,6 +730,12 @@ spl_random_init(void)
}
static void
+spl_random_fini(void)
+{
+ free_percpu(spl_pseudo_entropy);
+}
+
+static void
spl_kvmem_fini(void)
{
spl_vmem_fini();
@@ -790,6 +799,7 @@ spl_fini(void)
spl_taskq_fini();
spl_tsd_fini();
spl_kvmem_fini();
+ spl_random_fini();
}
module_init(spl_init);