Skip to content

Commit bcfcbb6

Browse files
author
Martin Schwidefsky
committed
s390: add system information as device randomness
The virtual-machine cpu information data block and the cpu-id of the boot cpu can be used as source of device randomness. Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 852ffd0 commit bcfcbb6

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

‎arch/s390/kernel/setup.c‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include <linux/stddef.h>
2525
#include <linux/unistd.h>
2626
#include <linux/ptrace.h>
27+
#include <linux/random.h>
2728
#include <linux/user.h>
2829
#include <linux/tty.h>
2930
#include <linux/ioport.h>
@@ -61,6 +62,7 @@
6162
#include <asm/diag.h>
6263
#include <asm/os_info.h>
6364
#include <asm/sclp.h>
65+
#include <asm/sysinfo.h>
6466
#include "entry.h"
6567

6668
/*
@@ -766,6 +768,7 @@ static void __init setup_hwcaps(void)
766768
#endif
767769

768770
get_cpu_id(&cpu_id);
771+
add_device_randomness(&cpu_id, sizeof(cpu_id));
769772
switch (cpu_id.machine) {
770773
case 0x9672:
771774
#if !defined(CONFIG_64BIT)
@@ -803,6 +806,19 @@ static void __init setup_hwcaps(void)
803806
}
804807
}
805808

809+
/*
810+
* Add system information as device randomness
811+
*/
812+
static void __init setup_randomness(void)
813+
{
814+
struct sysinfo_3_2_2 *vmms;
815+
816+
vmms = (struct sysinfo_3_2_2 *) alloc_page(GFP_KERNEL);
817+
if (vmms && stsi(vmms, 3, 2, 2) == 0 && vmms->count)
818+
add_device_randomness(&vmms, vmms->count);
819+
free_page((unsigned long) vmms);
820+
}
821+
806822
/*
807823
* Setup function called from init/main.c just after the banner
808824
* was printed.
@@ -901,6 +917,9 @@ void __init setup_arch(char **cmdline_p)
901917

902918
/* Setup zfcpdump support */
903919
setup_zfcpdump();
920+
921+
/* Add system specific data to the random pool */
922+
setup_randomness();
904923
}
905924

906925
#ifdef CONFIG_32BIT

0 commit comments

Comments
 (0)