summaryrefslogtreecommitdiff
path: root/target-ppc/kvm_ppc.h
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2015-09-17 10:49:41 +0200
committerDavid Gibson <david@gibson.dropbear.id.au>2015-09-23 10:51:11 +1000
commit4d9392be6c1aada69ce86c0f6584128976985394 (patch)
tree73492eb4bea00b95ba65cde01dc614d6054caf45 /target-ppc/kvm_ppc.h
parentef001f069e0f175a036929782c5c63053df9569a (diff)
downloadqemu-4d9392be6c1aada69ce86c0f6584128976985394.tar.gz
qemu-4d9392be6c1aada69ce86c0f6584128976985394.tar.bz2
qemu-4d9392be6c1aada69ce86c0f6584128976985394.zip
ppc/spapr: Implement H_RANDOM hypercall in QEMU
The PAPR interface defines a hypercall to pass high-quality hardware generated random numbers to guests. Recent kernels can already provide this hypercall to the guest if the right hardware random number generator is available. But in case the user wants to use another source like EGD, or QEMU is running with an older kernel, we should also have this call in QEMU, so that guests that do not support virtio-rng yet can get good random numbers, too. This patch now adds a new pseudo-device to QEMU that either directly provides this hypercall to the guest or is able to enable the in-kernel hypercall if available. The in-kernel hypercall can be enabled with the use-kvm property, e.g.: qemu-system-ppc64 -device spapr-rng,use-kvm=true For handling the hypercall in QEMU instead, a "RngBackend" is required since the hypercall should provide "good" random data instead of pseudo-random (like from a "simple" library function like rand() or g_random_int()). Since there are multiple RngBackends available, the user must select an appropriate back-end via the "rng" property of the device, e.g.: qemu-system-ppc64 -object rng-random,filename=/dev/hwrng,id=gid0 \ -device spapr-rng,rng=gid0 ... See http://wiki.qemu-project.org/Features-Done/VirtIORNG for other example of specifying RngBackends. Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Diffstat (limited to 'target-ppc/kvm_ppc.h')
-rw-r--r--target-ppc/kvm_ppc.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/target-ppc/kvm_ppc.h b/target-ppc/kvm_ppc.h
index f790d50e51..470f6d62f7 100644
--- a/target-ppc/kvm_ppc.h
+++ b/target-ppc/kvm_ppc.h
@@ -54,6 +54,7 @@ void kvmppc_hash64_free_pteg(uint64_t token);
void kvmppc_hash64_write_pte(CPUPPCState *env, target_ulong pte_index,
target_ulong pte0, target_ulong pte1);
bool kvmppc_has_cap_fixup_hcalls(void);
+int kvmppc_enable_hwrng(void);
#else
@@ -251,6 +252,10 @@ static inline bool kvmppc_has_cap_fixup_hcalls(void)
abort();
}
+static inline int kvmppc_enable_hwrng(void)
+{
+ return -1;
+}
#endif
#ifndef CONFIG_KVM