[PATCH 2/3] efi: qemu: arm64: Add efi_rng_protocol implementation for the platform

Sughosh Ganu sughosh.ganu at linaro.org
Wed Dec 25 14:31:07 CET 2019


On Wed, 25 Dec 2019 at 13:51, Heinrich Schuchardt <xypron.glpk at gmx.de>
wrote:

> On 12/25/19 7:21 AM, Sughosh Ganu wrote:
> > hi Heinrich,
> > Thanks for the review.
> >
> > On Tue, 24 Dec 2019 at 22:35, Heinrich Schuchardt <xypron.glpk at gmx.de
> > <mailto:xypron.glpk at gmx.de>> wrote:
> >
> >     On 12/24/19 4:54 PM, Sughosh Ganu wrote:
> >      > Add support for the EFI_RNG_PROTOCOL routines for the qemu arm64
> >      > platform. EFI_RNG_PROTOCOL is an uefi boottime service which is
> >      > invoked by the efi stub in the kernel for getting random seed for
> >      > kaslr.
> >      >
> >      > The routines are platform specific, and use the virtio-rng device
> on
> >      > the platform to get random data.
> >      >
> >      > The feature can be enabled through the following config
> >      > CONFIG_EFI_RNG_PROTOCOL
> >      >
> >      > Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org
> >     <mailto:sughosh.ganu at linaro.org>>
> >      > ---
> >      >   board/emulation/qemu-arm/qemu-arm.c | 50
> +++++++++++++++++++++++++
> >      >   include/efi_rng.h                   | 34 +++++++++++++++++
> >      >   lib/efi_loader/Kconfig              |  8 ++++
> >      >   lib/efi_loader/Makefile             |  1 +
> >      >   lib/efi_loader/efi_rng.c            | 74
> >     +++++++++++++++++++++++++++++++++++++
> >      >   5 files changed, 167 insertions(+)
> >      >   create mode 100644 include/efi_rng.h
> >      >   create mode 100644 lib/efi_loader/efi_rng.c
> >      >
> >      > diff --git a/board/emulation/qemu-arm/qemu-arm.c
> >     b/board/emulation/qemu-arm/qemu-arm.c
> >      > index e1f4709..3176421 100644
> >      > --- a/board/emulation/qemu-arm/qemu-arm.c
> >      > +++ b/board/emulation/qemu-arm/qemu-arm.c
> >      > @@ -91,3 +91,53 @@ void *board_fdt_blob_setup(void)
> >      >       /* QEMU loads a generated DTB for us at the start of RAM. */
> >      >       return (void *)CONFIG_SYS_SDRAM_BASE;
> >      >   }
> >      > +
> >      > +#if defined(CONFIG_EFI_RNG_PROTOCOL)
> >      > +#include <efi_loader.h>
> >      > +#include <efi_rng.h>
> >      > +
> >      > +#include <dm/device-internal.h>
> >      > +
> >      > +#define VIRTIO_RNG_PCI_DEVICE        "virtio-pci.l#0"
> >      > +
> >      > +void platform_rng_getinfo(efi_rng_algorithm *rng_algo)
> >
> >     Thanks for working on the implementation of the EFI_RNG_PROTOCOL.
> >
> >     Please, put an underscore after each word: platform_rng_get_info
> >
> >
> > Ok.
> >
> >
> >      > +{
> >      > +     const efi_guid_t rng_raw_guid = EFI_RNG_ALGORITHM_RAW;
> >      > +
> >      > +     guidcpy(rng_algo, &rng_raw_guid);
> >
> >     This function should be in efi_rng.c if it is needed at all.
> >
> >
> > Is the rng algorithm supported not platform specific. I believe
> > different platforms might use different algorithms for providing the
> > random seed.
>
> Sure you may later want develop code implementing one of the other RNG
> algorithms and than use a Kconfig setting to enable building the code
> and calling it from the EFI_RNG_PROTOCOL driver. But this code will not
> depend on whether you are using a specific board. A good place to put
> the algorithms would be in lib/.
>

Ok. So I guess what you are suggesting is returning the algorithm in
get_info based on what is enabled through Kconfig.

-sughosh


More information about the U-Boot mailing list