summaryrefslogtreecommitdiff
path: root/arch/s390/include/asm/archrandom.h
diff options
context:
space:
mode:
Diffstat (limited to 'arch/s390/include/asm/archrandom.h')
-rw-r--r--arch/s390/include/asm/archrandom.h6
1 files changed, 4 insertions, 2 deletions
diff --git a/arch/s390/include/asm/archrandom.h b/arch/s390/include/asm/archrandom.h
index cf5e000df0a1..1594049893e0 100644
--- a/arch/s390/include/asm/archrandom.h
+++ b/arch/s390/include/asm/archrandom.h
@@ -2,7 +2,7 @@
/*
* Kernel interface for the s390 arch_random_* functions
*
- * Copyright IBM Corp. 2017, 2020
+ * Copyright IBM Corp. 2017, 2022
*
* Author: Harald Freudenberger <freude@de.ibm.com>
*
@@ -12,6 +12,7 @@
#define _ASM_S390_ARCHRANDOM_H
#include <linux/static_key.h>
+#include <linux/preempt.h>
#include <linux/atomic.h>
#include <asm/cpacf.h>
@@ -25,7 +26,8 @@ static inline size_t __must_check arch_get_random_longs(unsigned long *v, size_t
static inline size_t __must_check arch_get_random_seed_longs(unsigned long *v, size_t max_longs)
{
- if (static_branch_likely(&s390_arch_random_available)) {
+ if (static_branch_likely(&s390_arch_random_available) &&
+ in_task()) {
cpacf_trng(NULL, 0, (u8 *)v, max_longs * sizeof(*v));
atomic64_add(max_longs * sizeof(*v), &s390_arch_random_counter);
return max_longs;