From 8f65619ac629e0c681d450469680fe8bae5785b1 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Tue, 4 Apr 2023 15:25:21 +0200 Subject: [efi] Remove old RDRAND hack; now officially supported --- src/interface/efi/efi_entropy.c | 47 ----------------------------------------- 1 file changed, 47 deletions(-) (limited to 'src') diff --git a/src/interface/efi/efi_entropy.c b/src/interface/efi/efi_entropy.c index 8e55c77b1..cda1c3640 100644 --- a/src/interface/efi/efi_entropy.c +++ b/src/interface/efi/efi_entropy.c @@ -28,11 +28,6 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL ); #include #include -#if defined(__i386) || defined(__x86_64) -#include -static char have_hwrnd = 0; -#endif - /** @file * * EFI entropy source @@ -132,44 +127,6 @@ static int efi_entropy_tick ( void ) { return low; } -/** - * Get noise sample from rdrand - * - * @ret noise Noise sample - * @ret rc Return status code - */ -static int efi_get_noise_rdrand ( noise_sample_t *noise ) { -#if defined(__i386) || defined(__x86_64) - if ( have_hwrnd == 0 ) { - struct x86_features features; - x86_features( &features ); - if ( features.intel.ecx & ( 1 << 30 ) ) { - have_hwrnd = 1; - } else { - have_hwrnd = 2; - } - DBGC( &tick, "Have RDRAND: %s\n", ( have_hwrnd == 1 ? "YES!" : "NO :-(" ) ); - } - if ( have_hwrnd == 1 ) { - int ret, retries = 10; - char ok; - while ( --retries > 0 ) { - __asm__ volatile ( "rdrand %0; setc %1" : "=r" ( ret ), "=qm" ( ok ) ); - if ( ok ) { - if ( ret == -1 ) { - /* Assume this is a broken AMD CPU, fall back to TSC */ - ret = profile_timestamp(); - } - *noise = ret; - return 0; - } - } - return -EBUSY; - } -#endif - return -ENOTSUP; -} - /** * Get noise sample from timer ticks * @@ -181,10 +138,6 @@ static int efi_get_noise ( noise_sample_t *noise ) { int after; int rc; - rc = efi_get_noise_rdrand ( noise ); - if ( rc == 0 ) - return 0; - /* Wait for a timer tick */ before = efi_entropy_tick(); if ( before < 0 ) { -- cgit v1.2.3-55-g7522