]> git.proxmox.com Git - mirror_edk2.git/commit
MdePkg/SmmPeriodicSmiLib: Get Periodic SMI Context More Robustly
authorRuiyu Ni <ruiyu.ni@intel.com>
Wed, 9 May 2018 09:36:06 +0000 (17:36 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Mon, 21 May 2018 04:47:10 +0000 (12:47 +0800)
commit1e35fcc9ee8b6b991535d9d6731d0e04169b99c0
tree3d52b37f2ba73eebb07cf04c3173d6bf899ea01a
parent7ebad830d6ab61f0395f6f4bae4156664bbd8086
MdePkg/SmmPeriodicSmiLib: Get Periodic SMI Context More Robustly

The PeriodicSmiDispatchFunction() in SmmPeriodicSmiLib may assert
with "Bad CR signature".

Currently, the SetActivePeriodicSmiLibraryHandler() function
(invoked at the beginning of the PeriodicSmiDispatchFunction()
function) attempts to locate the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT
structure pointer for the current periodic SMI from a given
EFI_SMM_PERIODIC_TIMER_REGISTER_CONTEXT (RegiserContext) structure
pointer (using the CR macro).

The RegisterContext structure pointer passed to the
PeriodicSmiDispatchFunction() is assumed to point to the same
RegisterContext structure address given to the
SmmPeriodicTimerDispatch2 protocol Register() API in
PeriodicSmiEnable().

However, certain SmmPeriodicTimerDispatch2 implementation may copy
the RegisterContext to a local buffer and pass that address as the
context to PeriodicSmiDispatchFunction() in which case usage of the
CR macro to find the parent structure base fails.

The patch uses the LookupPeriodicSmiLibraryHandler() function to
find the PERIODIC_SMI_LIBRARY_HANDLER_CONTEXT structure pointer.
This works even in this scenario since the DispatchHandle returned
from the SmmPeriodicTimerDispatch2 Register() function uniquely
identifies that registration.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdePkg/Library/SmmPeriodicSmiLib/SmmPeriodicSmiLib.c