On 1/23/24 16:31, Michael Brown wrote: > At TPL_HIGH_LEVEL, CPU interrupts are disabled (as per the UEFI > specification) and so we should never encounter a situation in which > an interrupt occurs at TPL_HIGH_LEVEL. > > Restoring TPL to TPL_HIGH_LEVEL is always a no-op. Return immediately > from NestedInterruptRestoreTPL(TPL_HIGH_LEVEL), so that we do not need > to consider the effect of this possible invariant violation on the > remainder of the logic. > > Signed-off-by: Michael Brown <mc...@ipxe.org> > --- > MdeModulePkg/Library/NestedInterruptTplLib/Tpl.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/MdeModulePkg/Library/NestedInterruptTplLib/Tpl.c > b/MdeModulePkg/Library/NestedInterruptTplLib/Tpl.c > index d56c12a44529..99af553ab189 100644 > --- a/MdeModulePkg/Library/NestedInterruptTplLib/Tpl.c > +++ b/MdeModulePkg/Library/NestedInterruptTplLib/Tpl.c > @@ -99,6 +99,19 @@ NestedInterruptRestoreTPL ( > EFI_TPL SavedInProgressRestoreTPL; > BOOLEAN DeferredRestoreTPL; > > + // > + // At TPL_HIGH_LEVEL, CPU interrupts are disabled (as per the UEFI > + // specification) and so we should never encounter a situation in > + // which InterruptedTPL==TPL_HIGH_LEVEL. > + // > + // Restoring TPL to TPL_HIGH_LEVEL is always a no-op. Return > + // immediately so that we do not need to consider the effect of this > + // possible invariant violation in the logic below. > + // > + if (InterruptedTPL >= TPL_HIGH_LEVEL) { > + return; > + } > + > // > // If the TPL at which this interrupt occurred is equal to that of > // the in-progress RestoreTPL() for an outer instance of the same
Feels like the handling logic might as well be "panic" here (except edk2 does not have a central panic API that's suitable for all platforms). I probably missed the previous discussion that led to this patch. Either way, it seems reasonable. Acked-by: Laszlo Ersek <ler...@redhat.com> -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#114215): https://edk2.groups.io/g/devel/message/114215 Mute This Topic: https://groups.io/mt/103911606/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/9847357/21656/1706620634/xyzzy [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-