public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [RFC] Add EFI lock when creating new gauge record
@ 2017-11-24  7:04 Heyi Guo
  2017-11-24  9:41 ` Zeng, Star
  0 siblings, 1 reply; 6+ messages in thread
From: Heyi Guo @ 2017-11-24  7:04 UTC (permalink / raw)
  To: edk2-devel@lists.01.org; +Cc: Daryl McDaniel, Jaben Carsey

Hi folks,

We got occasional system exceptions after enabling performance measuring 
feature in edk2. After debugging, we found there is potential memory 
overflow in DXE/DXE_CORE PerformanceLib when PERF_START is reentered, 
and reentrance is possible since we are supporting something like USB 
hot-plug, which is a timer event where gBS->ConnectController might be 
called and then PERF will be called in CoreConnectSingleController. 
However I can't reproduce the issue right now; please let me know if 
PERF reentrance is not theoretically possible in the latest edk2 code.

When StartGaugeEx is being reentered, not only the gauge record might be 
overwritten, more serious situation will be caused if gauge data buffer 
reallocation procedure is interrupted, between line 180 and 187 in 
DxeCorePerformanceLib.c specifically. There, mMaxGaugeRecords will be 
doubled twice (denoted as 4X), but mGaugeData only points to a buffer of 
size 2X, which will probably cause the following 2X memory to be 
overflowed when gauge records are increased.

My proposal is to add EFI lock with TPL notify in StartGaugeEx to avoid 
such situation. The test result seemed good on our platforms and the 
performance measuring data was not impacted much by this patch.

Please let me know your comments.

Thanks,

Gary (Heyi Guo)



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-11-27  6:54 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-24  7:04 [RFC] Add EFI lock when creating new gauge record Heyi Guo
2017-11-24  9:41 ` Zeng, Star
2017-11-25  9:09   ` Heyi Guo
2017-11-27  2:06     ` Zeng, Star
2017-11-27  3:14       ` Heyi Guo
2017-11-27  6:58     ` Gao, Liming

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox