mirror of
https://github.com/raspberrypi/linux.git
synced 2026-01-02 07:43:34 +00:00
[ Upstream commit7ef3d06f1b] The existing logic in KVM to support guests calling H_RANDOM only works on Power8, because it looks for an RNG in the device tree, but on Power9 we just use darn. In addition the existing code needs to work in real mode, so we have the special cased powernv_get_random_real_mode() to deal with that. Instead just have KVM call ppc_md.get_random_seed(), and do the real mode check inside of there, that way we use whatever RNG is available, including darn on Power9. Fixes:e928e9cb36("KVM: PPC: Book3S HV: Add fast real-mode H_RANDOM implementation.") Cc: stable@vger.kernel.org # v4.1+ Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com> Tested-by: Sachin Sant <sachinp@linux.ibm.com> [mpe: Rebase on previous commit, update change log appropriately] Signed-off-by: Michael Ellerman <mpe@ellerman.id.au> Link: https://lore.kernel.org/r/20220727143219.2684192-2-mpe@ellerman.id.au Signed-off-by: Sasha Levin <sashal@kernel.org>
45 lines
838 B
C
45 lines
838 B
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _ASM_POWERPC_ARCHRANDOM_H
|
|
#define _ASM_POWERPC_ARCHRANDOM_H
|
|
|
|
#ifdef CONFIG_ARCH_RANDOM
|
|
|
|
#include <asm/machdep.h>
|
|
|
|
static inline bool __must_check arch_get_random_long(unsigned long *v)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool __must_check arch_get_random_int(unsigned int *v)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool __must_check arch_get_random_seed_long(unsigned long *v)
|
|
{
|
|
if (ppc_md.get_random_seed)
|
|
return ppc_md.get_random_seed(v);
|
|
|
|
return false;
|
|
}
|
|
|
|
static inline bool __must_check arch_get_random_seed_int(unsigned int *v)
|
|
{
|
|
unsigned long val;
|
|
bool rc;
|
|
|
|
rc = arch_get_random_seed_long(&val);
|
|
if (rc)
|
|
*v = val;
|
|
|
|
return rc;
|
|
}
|
|
#endif /* CONFIG_ARCH_RANDOM */
|
|
|
|
#ifdef CONFIG_PPC_POWERNV
|
|
int powernv_get_random_long(unsigned long *v);
|
|
#endif
|
|
|
|
#endif /* _ASM_POWERPC_ARCHRANDOM_H */
|