mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2024-12-26 03:09:34 +03:00
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 <behlendorf1@llnl.gov> Signed-off-by: Romain Dolbeau <romain.dolbeau@european-processor-initiative.eu> Closes #9942
This commit is contained in:
parent
af09c050e9
commit
77122f9d68
@ -92,7 +92,7 @@ EXPORT_SYMBOL(p0);
|
|||||||
* and use them when in_interrupt() from linux/preempt_mask.h evaluates to
|
* and use them when in_interrupt() from linux/preempt_mask.h evaluates to
|
||||||
* true.
|
* 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
|
* 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);
|
ASSERT(ptr);
|
||||||
|
|
||||||
xp = get_cpu_var(spl_pseudo_entropy);
|
xp = get_cpu_ptr(spl_pseudo_entropy);
|
||||||
|
|
||||||
s[0] = xp[0];
|
s[0] = xp[0];
|
||||||
s[1] = xp[1];
|
s[1] = xp[1];
|
||||||
@ -163,7 +163,7 @@ random_get_pseudo_bytes(uint8_t *ptr, size_t len)
|
|||||||
xp[0] = s[0];
|
xp[0] = s[0];
|
||||||
xp[1] = s[1];
|
xp[1] = s[1];
|
||||||
|
|
||||||
put_cpu_var(spl_pseudo_entropy);
|
put_cpu_ptr(spl_pseudo_entropy);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -701,6 +701,9 @@ spl_random_init(void)
|
|||||||
uint64_t s[2];
|
uint64_t s[2];
|
||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
|
spl_pseudo_entropy = __alloc_percpu(2 * sizeof (uint64_t),
|
||||||
|
sizeof (uint64_t));
|
||||||
|
|
||||||
get_random_bytes(s, sizeof (s));
|
get_random_bytes(s, sizeof (s));
|
||||||
|
|
||||||
if (s[0] == 0 && s[1] == 0) {
|
if (s[0] == 0 && s[1] == 0) {
|
||||||
@ -717,7 +720,7 @@ spl_random_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
for_each_possible_cpu(i) {
|
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);
|
spl_rand_jump(s);
|
||||||
|
|
||||||
@ -726,6 +729,12 @@ spl_random_init(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
spl_random_fini(void)
|
||||||
|
{
|
||||||
|
free_percpu(spl_pseudo_entropy);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
spl_kvmem_fini(void)
|
spl_kvmem_fini(void)
|
||||||
{
|
{
|
||||||
@ -790,6 +799,7 @@ spl_fini(void)
|
|||||||
spl_taskq_fini();
|
spl_taskq_fini();
|
||||||
spl_tsd_fini();
|
spl_tsd_fini();
|
||||||
spl_kvmem_fini();
|
spl_kvmem_fini();
|
||||||
|
spl_random_fini();
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(spl_init);
|
module_init(spl_init);
|
||||||
|
Loading…
Reference in New Issue
Block a user