Commit 5de64d44 authored by Linus Torvalds's avatar Linus Torvalds
Browse files
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
parents cdb281e6 918e75f7
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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>
 *
@@ -14,6 +14,7 @@
#ifdef CONFIG_ARCH_RANDOM

#include <linux/static_key.h>
#include <linux/preempt.h>
#include <linux/atomic.h>
#include <asm/cpacf.h>

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

static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
{
	if (static_branch_likely(&s390_arch_random_available)) {
	if (static_branch_likely(&s390_arch_random_available) &&
	    in_task()) {
		cpacf_trng(NULL, 0, (u8 *)v, sizeof(*v));
		atomic64_add(sizeof(*v), &s390_arch_random_counter);
		return true;
@@ -42,7 +44,8 @@ static inline bool __must_check arch_get_random_seed_long(unsigned long *v)

static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
{
	if (static_branch_likely(&s390_arch_random_available)) {
	if (static_branch_likely(&s390_arch_random_available) &&
	    in_task()) {
		cpacf_trng(NULL, 0, (u8 *)v, sizeof(*v));
		atomic64_add(sizeof(*v), &s390_arch_random_counter);
		return true;