Skip to content

Commit

Permalink
s390: add system information as device randomness
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Martin Schwidefsky committed Aug 12, 2014
1 parent 852ffd0 commit bcfcbb6
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions arch/s390/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/stddef.h>
#include <linux/unistd.h>
#include <linux/ptrace.h>
#include <linux/random.h>
#include <linux/user.h>
#include <linux/tty.h>
#include <linux/ioport.h>
Expand Down Expand Up @@ -61,6 +62,7 @@
#include <asm/diag.h>
#include <asm/os_info.h>
#include <asm/sclp.h>
#include <asm/sysinfo.h>
#include "entry.h"

/*
Expand Down Expand Up @@ -766,6 +768,7 @@ static void __init setup_hwcaps(void)
#endif

get_cpu_id(&cpu_id);
add_device_randomness(&cpu_id, sizeof(cpu_id));
switch (cpu_id.machine) {
case 0x9672:
#if !defined(CONFIG_64BIT)
Expand Down Expand Up @@ -803,6 +806,19 @@ static void __init setup_hwcaps(void)
}
}

/*
* Add system information as device randomness
*/
static void __init setup_randomness(void)
{
struct sysinfo_3_2_2 *vmms;

vmms = (struct sysinfo_3_2_2 *) alloc_page(GFP_KERNEL);
if (vmms && stsi(vmms, 3, 2, 2) == 0 && vmms->count)
add_device_randomness(&vmms, vmms->count);
free_page((unsigned long) vmms);
}

/*
* Setup function called from init/main.c just after the banner
* was printed.
Expand Down Expand Up @@ -901,6 +917,9 @@ void __init setup_arch(char **cmdline_p)

/* Setup zfcpdump support */
setup_zfcpdump();

/* Add system specific data to the random pool */
setup_randomness();
}

#ifdef CONFIG_32BIT
Expand Down

0 comments on commit bcfcbb6

Please sign in to comment.