From 80388733bc4db4e0da3a0e623ee5468392e20d36 Mon Sep 17 00:00:00 2001 From: Philipp Schuster Date: Wed, 14 Jan 2026 14:44:05 +0100 Subject: [PATCH 1/2] Revert "OvmfPkg/VirtioRngDxe: make VirtioRngGetRNG reentrant safe" This reverts commit 6612c7766dcd9b9ce6ca6ff37b993ab2da5a8546. --- OvmfPkg/VirtioRngDxe/VirtioRng.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.c b/OvmfPkg/VirtioRngDxe/VirtioRng.c index 1b3ff4e13170..8959e51faf71 100644 --- a/OvmfPkg/VirtioRngDxe/VirtioRng.c +++ b/OvmfPkg/VirtioRngDxe/VirtioRng.c @@ -136,7 +136,6 @@ VirtioRngGetRNG ( EFI_STATUS Status; EFI_PHYSICAL_ADDRESS DeviceAddress; VOID *Mapping; - EFI_TPL CurrentTpl; if ((This == NULL) || (RNGValueLength == 0) || (RNGValue == NULL)) { return EFI_INVALID_PARAMETER; @@ -178,8 +177,6 @@ VirtioRngGetRNG ( goto FreeBuffer; } - CurrentTpl = gBS->RaiseTPL (TPL_HIGH_LEVEL); - // // The Virtio RNG device may return less data than we asked it to, and can // only return MAX_UINT32 bytes per invocation. So loop as long as needed to @@ -208,8 +205,6 @@ VirtioRngGetRNG ( ASSERT (Len <= BufferSize); } - gBS->RestoreTPL (CurrentTpl); - // // Unmap the device buffer before accessing it. // From fe00718af102406a64215e47cf8805d03532e991 Mon Sep 17 00:00:00 2001 From: Thomas Prescher Date: Tue, 13 Jan 2026 09:14:12 +0100 Subject: [PATCH 2/2] OvmfPkg/VirtioRngDxe: protect VirtioRngGetRNG against timer callbacks On-behalf-of: SAP thomas.prescher@sap.com Signed-off-by: Thomas Prescher --- OvmfPkg/VirtioRngDxe/VirtioRng.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/OvmfPkg/VirtioRngDxe/VirtioRng.c b/OvmfPkg/VirtioRngDxe/VirtioRng.c index 8959e51faf71..39d07eef0e1c 100644 --- a/OvmfPkg/VirtioRngDxe/VirtioRng.c +++ b/OvmfPkg/VirtioRngDxe/VirtioRng.c @@ -136,6 +136,7 @@ VirtioRngGetRNG ( EFI_STATUS Status; EFI_PHYSICAL_ADDRESS DeviceAddress; VOID *Mapping; + EFI_TPL CurrentTpl; if ((This == NULL) || (RNGValueLength == 0) || (RNGValue == NULL)) { return EFI_INVALID_PARAMETER; @@ -177,6 +178,8 @@ VirtioRngGetRNG ( goto FreeBuffer; } + CurrentTpl = gBS->RaiseTPL (TPL_NOTIFY); + // // The Virtio RNG device may return less data than we asked it to, and can // only return MAX_UINT32 bytes per invocation. So loop as long as needed to @@ -198,6 +201,7 @@ VirtioRngGetRNG ( EFI_SUCCESS) { Status = EFI_DEVICE_ERROR; + gBS->RestoreTPL (CurrentTpl); goto UnmapBuffer; } @@ -205,6 +209,8 @@ VirtioRngGetRNG ( ASSERT (Len <= BufferSize); } + gBS->RestoreTPL (CurrentTpl); + // // Unmap the device buffer before accessing it. //