Skip to content

OvmfPkg/VirtioRngDxe: make VirtioRngGetRNG reentrant safe - #1

Merged
tpressure merged 1 commit into
cyberus-technology:gardenlinuxfrom
tpressure:stuck_boot_fix
Jan 13, 2026
Merged

tpressure merged 1 commit into
cyberus-technology:gardenlinuxfrom
tpressure:stuck_boot_fix

Conversation

@tpressure

@tpressure tpressure commented Jan 13, 2026 •

Copy link
Copy Markdown

Description

This is a bugfix for the stuck boot issue that we experience from time to time. The reason was that VirtioRngGetRNG could be called in a nested way. The issue appears if a timer expires right when we are in VirtioFlush. If we get interrupted there, and the timer callback also calls VirtioRngGetRNG, we enter VirtioFlush a 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_LEVEL which 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)

@phip1611 phip1611 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tremendous debugging, awesome outcome!

On-behalf-of: SAP thomas.prescher@sap.com
Signed-off-by: Thomas Prescher <thomas.prescher@cyberus-technology.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants