Skip to content

Commit 5de64d4

Browse files
committed
Merge tag 's390-5.19-7' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux
Pull s390 fix from Alexander GordeevL - Prevent relatively slow PRNO TRNG random number operation from being called from interrupt context. That could for example cause some network loads to timeout. * tag 's390-5.19-7' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux: s390/archrandom: prevent CPACF trng invocations in interrupt context
2 parents cdb281e + 918e75f commit 5de64d4

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

arch/s390/include/asm/archrandom.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/*
33
* Kernel interface for the s390 arch_random_* functions
44
*
5-
* Copyright IBM Corp. 2017, 2020
5+
* Copyright IBM Corp. 2017, 2022
66
*
77
* Author: Harald Freudenberger <freude@de.ibm.com>
88
*
@@ -14,6 +14,7 @@
1414
#ifdef CONFIG_ARCH_RANDOM
1515

1616
#include <linux/static_key.h>
17+
#include <linux/preempt.h>
1718
#include <linux/atomic.h>
1819
#include <asm/cpacf.h>
1920

@@ -32,7 +33,8 @@ static inline bool __must_check arch_get_random_int(unsigned int *v)
3233

3334
static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
3435
{
35-
if (static_branch_likely(&s390_arch_random_available)) {
36+
if (static_branch_likely(&s390_arch_random_available) &&
37+
in_task()) {
3638
cpacf_trng(NULL, 0, (u8 *)v, sizeof(*v));
3739
atomic64_add(sizeof(*v), &s390_arch_random_counter);
3840
return true;
@@ -42,7 +44,8 @@ static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
4244

4345
static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
4446
{
45-
if (static_branch_likely(&s390_arch_random_available)) {
47+
if (static_branch_likely(&s390_arch_random_available) &&
48+
in_task()) {
4649
cpacf_trng(NULL, 0, (u8 *)v, sizeof(*v));
4750
atomic64_add(sizeof(*v), &s390_arch_random_counter);
4851
return true;

0 commit comments

Comments
 (0)