OvmfPkg/VirtioRngDxe: make VirtioRngGetRNG reentrant safe - #1
Merged
tpressure merged 1 commit intoJan 13, 2026
Merged
Conversation
phip1611
approved these changes
Jan 13, 2026
phip1611
left a comment
Member
There was a problem hiding this comment.
Tremendous debugging, awesome outcome!
hertrste
approved these changes
Jan 13, 2026
On-behalf-of: SAP thomas.prescher@sap.com Signed-off-by: Thomas Prescher <thomas.prescher@cyberus-technology.de>
tpressure
force-pushed
the
stuck_boot_fix
branch
from
January 13, 2026 08:56
7c25c11 to
6612c77
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is a bugfix for the stuck boot issue that we experience from time to time. The reason was that
VirtioRngGetRNGcould be called in a nested way. The issue appears if a timer expires right when we are inVirtioFlush. If we get interrupted there, and the timer callback also callsVirtioRngGetRNG, we enterVirtioFlusha second time and all goes down the drain because the function does modify the virtqueue state.See cloud-hypervisor/cloud-hypervisor#6779 for more details.
The solution is to raise the TPL to
TPL_HIGH_LEVELwhich is basically identical to interrupts being disabled. With this fix, we can no longer be interrupted when we fiddle around with the device and its virtqueues.The callstack looks something like this
VirtioRngGetRNG (call 1)
└─ VirtioFlush
└─ gBS->Stall
└─ AcpiTimerLib::MicroSecondDelay
└─ Timer interrupt
└─ CoreSignalEvent
└─ CoreNotifyEvent
└─ [Notify callback]
└─ GetRandomNumberXX
└─ RngLib
└─ EFI_RNG_PROTOCOL
└─ VirtioRngGetRNG (call 2)