]> git.proxmox.com Git - mirror_edk2.git/commit
MdeModulePkg/DxeCorePerformanceLib: add lock protection
authorHeyi Guo <heyi.guo@linaro.org>
Mon, 27 Nov 2017 03:31:44 +0000 (11:31 +0800)
committerStar Zeng <star.zeng@intel.com>
Wed, 29 Nov 2017 12:34:10 +0000 (20:34 +0800)
commitf1f7190bf3bf932b52287258a65c366ed5bdce13
tree1f9b7c4c26fddc168d73de5c79dd800fedbcacee
parentcc1ad92aaa5c494c14006751d0f43439880caeba
MdeModulePkg/DxeCorePerformanceLib: add lock protection

DXE performance gauge record access functions might be reentered 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.

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.

So we add EFI lock with TPL_NOTIFY in StartGaugeEx/EndGaugeEx/GetGaugeEx
to avoid memory overflow and gauge data corruption.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c