[PATCH v2 0/2] CoCo/RDRAND brokenness fixes

From: Jason A. Donenfeld
Date: Wed Feb 14 2024 - 14:58:25 EST


This takes a two-pronged approach to the matter, now that we have
details from Intel and AMD:

- In the generic case, if RDRAND fails, simply WARN(), and don't try
again. It turns out the "try 10 times" thing isn't actually a correct
recommendation from Intel. Since RDRAND failure implies CPU failure, a
WARN() seems in order on all platforms.

- On CoCo machines, where RDRAND failure implies the whole threat model
is compromised and execution shouldn't continue, we ensure that the
RNG gets 256-bits of RDRAND at boot, or otherwise fails.

Cc: Borislav Petkov <bp@xxxxxxxxx>
Cc: Daniel P. Berrangé <berrange@xxxxxxxxxx>
Cc: Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>
Cc: Elena Reshetova <elena.reshetova@xxxxxxxxx>
Cc: H. Peter Anvin <hpa@xxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: Kirill A. Shutemov <kirill.shutemov@xxxxxxxxxxxxxxx>
Cc: Theodore Ts'o <tytso@xxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>

Jason A. Donenfeld (2):
x86/archrandom: WARN if RDRAND fails and don't retry
x86/coco: Require seeding RNG with RDRAND on CoCo systems

arch/x86/coco/core.c | 37 +++++++++++++++++++++++++++++++
arch/x86/include/asm/archrandom.h | 18 ++++++---------
arch/x86/include/asm/coco.h | 2 ++
arch/x86/kernel/setup.c | 2 ++
4 files changed, 48 insertions(+), 11 deletions(-)

--
2.43.0