diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2020-09-25 12:50:19 +0200 |
---|---|---|
committer | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2020-09-27 16:10:45 +0200 |
commit | b59c13d42f42811912fd08f32f11e68a8e708c00 (patch) | |
tree | d4473efb33014d1f4b05367f3bc4e8277e697ac7 /lib/efi_loader/efi_rng.c | |
parent | 796933510f84c1a29b1ef104d0962db6c0b7589c (diff) |
efi_loader: installation of EFI_RNG_PROTOCOL
Having an EFI_RNG_PROTOCOL without a backing RNG device leads to failure
to boot Linux 5.8.
Only install the EFI_RNG_PROTOCOL if we have a RNG device.
Reported-by: Scott K Logan <logans@cottsay.net>
Cc: Neil Armstrong <narmstrong@baylibre.com>
Cc: Ard Biesheuvel <ardb@kernel.org>
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'lib/efi_loader/efi_rng.c')
-rw-r--r-- | lib/efi_loader/efi_rng.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/lib/efi_loader/efi_rng.c b/lib/efi_loader/efi_rng.c index caef4085b0..a8a87007b6 100644 --- a/lib/efi_loader/efi_rng.c +++ b/lib/efi_loader/efi_rng.c @@ -3,6 +3,8 @@ * Copyright (c) 2019, Linaro Limited */ +#define LOG_CATEGORY LOGC_EFI + #include <common.h> #include <dm.h> #include <efi_loader.h> @@ -144,7 +146,33 @@ back: return EFI_EXIT(status); } -const struct efi_rng_protocol efi_rng_protocol = { +static const struct efi_rng_protocol efi_rng_protocol = { .get_info = rng_getinfo, .get_rng = getrng, }; + +/** + * efi_rng_register() - register EFI_RNG_PROTOCOL + * + * If a RNG device is available, the Random Number Generator Protocol is + * registered. + * + * Return: An error status is only returned if adding the protocol fails. + */ +efi_status_t efi_rng_register(void) +{ + efi_status_t ret; + struct udevice *dev; + + ret = platform_get_rng_device(&dev); + if (ret != EFI_SUCCESS) { + log_warning("Missing RNG device for EFI_RNG_PROTOCOL"); + return EFI_SUCCESS; + } + ret = efi_add_protocol(efi_root, &efi_guid_rng_protocol, + (void *)&efi_rng_protocol); + if (ret != EFI_SUCCESS) + log_err("Cannot install EFI_RNG_PROTOCOL"); + + return ret; +} |