Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a4da0d50 authored by Michael Ellerman's avatar Michael Ellerman Committed by Benjamin Herrenschmidt
Browse files

powerpc: Implement arch_get_random_long/int() for powernv



Add the plumbing to implement arch_get_random_long/int(). It didn't seem
worth adding an extra ppc_md hook for int, so we reuse the one for long.

Add an implementation for powernv based on the hwrng found in power7+
systems. We whiten the output of the hwrng, and the result passes all
the dieharder tests.

Signed-off-by: default avatarMichael Ellerman <michael@ellerman.id.au>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent f95dabef
Loading
Loading
Loading
Loading
+3 −0
Original line number Original line Diff line number Diff line
@@ -1012,6 +1012,9 @@ config PHYSICAL_START
	default "0x00000000"
	default "0x00000000"
endif
endif


config	ARCH_RANDOM
	def_bool n

source "net/Kconfig"
source "net/Kconfig"


source "drivers/Kconfig"
source "drivers/Kconfig"
+32 −0
Original line number Original line Diff line number Diff line
#ifndef _ASM_POWERPC_ARCHRANDOM_H
#define _ASM_POWERPC_ARCHRANDOM_H

#ifdef CONFIG_ARCH_RANDOM

#include <asm/machdep.h>

static inline int arch_get_random_long(unsigned long *v)
{
	if (ppc_md.get_random_long)
		return ppc_md.get_random_long(v);

	return 0;
}

static inline int arch_get_random_int(unsigned int *v)
{
	unsigned long val;
	int rc;

	rc = arch_get_random_long(&val);
	if (rc)
		*v = val;

	return rc;
}

int powernv_get_random_long(unsigned long *v);

#endif /* CONFIG_ARCH_RANDOM */

#endif /* _ASM_POWERPC_ARCHRANDOM_H */
+4 −0
Original line number Original line Diff line number Diff line
@@ -263,6 +263,10 @@ struct machdep_calls {
	ssize_t (*cpu_probe)(const char *, size_t);
	ssize_t (*cpu_probe)(const char *, size_t);
	ssize_t (*cpu_release)(const char *, size_t);
	ssize_t (*cpu_release)(const char *, size_t);
#endif
#endif

#ifdef CONFIG_ARCH_RANDOM
	int (*get_random_long)(unsigned long *v);
#endif
};
};


extern void e500_idle(void);
extern void e500_idle(void);
+1 −0
Original line number Original line Diff line number Diff line
@@ -9,6 +9,7 @@ config PPC_POWERNV
	select EPAPR_BOOT
	select EPAPR_BOOT
	select PPC_INDIRECT_PIO
	select PPC_INDIRECT_PIO
	select PPC_UDBG_16550
	select PPC_UDBG_16550
	select ARCH_RANDOM
	default y
	default y


config POWERNV_MSI
config POWERNV_MSI
+1 −1
Original line number Original line Diff line number Diff line
obj-y			+= setup.o opal-takeover.o opal-wrappers.o opal.o
obj-y			+= setup.o opal-takeover.o opal-wrappers.o opal.o
obj-y			+= opal-rtc.o opal-nvram.o opal-lpc.o
obj-y			+= opal-rtc.o opal-nvram.o opal-lpc.o rng.o


obj-$(CONFIG_SMP)	+= smp.o
obj-$(CONFIG_SMP)	+= smp.o
obj-$(CONFIG_PCI)	+= pci.o pci-p5ioc2.o pci-ioda.o
obj-$(CONFIG_PCI)	+= pci.o pci-p5ioc2.o pci-ioda.o
Loading