From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sughosh Ganu Date: Wed, 25 Dec 2019 19:01:07 +0530 Subject: [PATCH 2/3] efi: qemu: arm64: Add efi_rng_protocol implementation for the platform In-Reply-To: <09a14bd6-3eeb-d2e5-8c41-faf571433867@gmx.de> References: <1577202865-1215-1-git-send-email-sughosh.ganu@linaro.org> <1577202865-1215-3-git-send-email-sughosh.ganu@linaro.org> <09a14bd6-3eeb-d2e5-8c41-faf571433867@gmx.de> Message-ID: List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On Wed, 25 Dec 2019 at 13:51, Heinrich Schuchardt 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 > > 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 > > > > > --- > > > 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 > > > +#include > > > + > > > +#include > > > + > > > +#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