powerpc/powernv/kvm: Use darn for H_RANDOM on Power9
authorJason A. Donenfeld <Jason@zx2c4.com>
Wed, 27 Jul 2022 14:32:18 +0000 (00:32 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:24:25 +0000 (14:24 +0200)
commit0ceef1c56875dd0980651b48d30baf6373309069
tree0330580c2cdc064abf77ef98e88e4eec76202ab9
parent0eeb7037a479b5dbd241f1baa04d518af96365dc
powerpc/powernv/kvm: Use darn for H_RANDOM on Power9

[ Upstream commit 7ef3d06f1bc4a5e62273726f3dc2bd258ae1c71f ]

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: e928e9cb3601 ("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>
arch/powerpc/include/asm/archrandom.h
arch/powerpc/kvm/book3s_hv_builtin.c
arch/powerpc/platforms/powernv/rng.c