H_RANDOM hypercall support
This feature implements the so-called H_RANDOM hypercall in QEMU. This hypercall is used on the sPAPR platform (i.e. the ppc64 pseries machines) to provide good random data to the guest. The feature has been realized as a separate QEMU device called "spapr-rng", so that it can be easily instantiated and configured by using the well-known "-device" CLI parameter.
- Thomas Huth
[x] Changes to QEMU
[ ] Changes to guest agent
[ ] Changes to firmware (seabios, vgabios, pxe roms, etc.
[ ] Affects all archs
[x] Affects specific arch: ppc
[x] Affects all guests
[ ] Affects specific guests: Linux, Windows, etc.
The PAPR interface defines a hypercall to pass high-quality hardware generated random numbers to guests. Recent KVM code in the Linux kernel can already provide this hypercall to the guest if the right hardware random number generator is available on the host. But in case the user wants to use another source like EGD, or QEMU is running with an older kernel or in TCG mode, it is also desirable to provide this hypercall in QEMU, too, so that sPAPR guests that do not support virtio-rng yet can get good random numbers, too.
This feature has now been added as a new pseudo-device in QEMU. It can either directly provides this hypercall to the guest or it 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 the Virtio-RNG page for other examples of specifying RngBackends.
Added settings exposed to higher layers or users
A new QEMU device called "spapr-rng" has been added, that can be instantiated with the "-device" command line option. Run "qemu-system-ppc64 -device spapr-rng,?" for a short description of the parameters.
List of commits
See chapter 14.15.1 in the LoPAPR specification.