edk2/MdeModulePkg/Universal/Variable/RuntimeDxe
Laszlo Ersek 00663d047f MdeModulePkg/Variable/RuntimeDxe: move SecureBootHook() decl to new header
If the platform supports SMM, a gRT->SetVariable() call at boot time
results in the following call tree to SecureBootHook():

  RuntimeServiceSetVariable()      [VariableSmmRuntimeDxe.c, unprivileged]
    SmmVariableHandler()           [VariableSmm.c,             PRIVILEGED]
      VariableServiceSetVariable() [Variable.c,                PRIVILEGED]
        SecureBootHook()           [VariableSmm.c,             PRIVILEGED]
          //
          // do nothing
          //
    SecureBootHook()               [Measurement.c,           unprivileged]
      //
      // measure variable if it
      // is related to SB policy
      //

And if the platform does not support SMM:

  VariableServiceSetVariable()     [Variable.c,              unprivileged]
    SecureBootHook()               [Measurement.c,           unprivileged]
      //
      // measure variable if it
      // is related to SB policy
      //

In other words, the measurement always happens outside of SMM.

Because there are two implementations of the SecureBootHook() API, one
that is called from SMM and does nothing, and another that is called
outside of SMM and measures variables, the function declaration should be
in a header file. This way the compiler can enforce that the function
declaration and all function definitions match.

"Variable.h" is used for "including common header files, defining internal
structures and functions used by Variable modules". Technically, we could
declare SecureBootHook() in "Variable.h". However, "Measurement.c" and
"VariableSmmRuntimeDxe.c" themselves do not include "Variable.h", and that
is likely intentional -- "Variable.h" exposes so much of the privileged
variable implementation that it is likely excluded from these C source
files on purpose.

Therefore introduce a new header file called "PrivilegePolymorphic.h".
"Variable.h" includes this header (so that all C source files that have
been allowed to see the variable internals learn about the new
SecureBootHook() declaration immediately). In "Measurement.c" and
"VariableSmmRuntimeDxe.c", include *only* the new header.

This change cleans up commit fa0737a839 ("MdeModulePkg Variable: Merge
from Auth Variable driver in SecurityPkg", 2015-07-01).

Cc: Eric Dong <eric.dong@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ladi Prosek <lprosek@redhat.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Tested-by: Ladi Prosek <lprosek@redhat.com>
2017-10-10 11:25:04 +02:00
..
Measurement.c MdeModulePkg/Variable/RuntimeDxe: move SecureBootHook() decl to new header 2017-10-10 11:25:04 +02:00
PrivilegePolymorphic.h MdeModulePkg/Variable/RuntimeDxe: move SecureBootHook() decl to new header 2017-10-10 11:25:04 +02:00
Reclaim.c MdeModulePkg Variable: Merge from Auth Variable driver in SecurityPkg 2015-07-01 03:08:29 +00:00
TcgMorLockDxe.c MdeModulePkg: Add MorLockDxe to variable driver. 2016-01-19 13:21:18 +00:00
TcgMorLockSmm.c MdeModulePkg/Universal: Fix typos in comments 2016-10-27 09:11:19 +08:00
VarCheck.c MdeModulePkg Variable: Consume the separated VarCheckLib 2015-08-25 03:01:56 +00:00
Variable.c MdeModulePkg/Variable/RuntimeDxe: move SecureBootHook() decl to new header 2017-10-10 11:25:04 +02:00
Variable.h MdeModulePkg/Variable/RuntimeDxe: move SecureBootHook() decl to new header 2017-10-10 11:25:04 +02:00
VariableDxe.c MdeModulePkg: Variable: Update PCR[7] measure for new TCG spec 2017-01-22 13:03:06 +08:00
VariableExLib.c MdeModulePkg Variable: Read MonotonicCount by ReadUnaligned64() 2015-07-27 00:49:00 +00:00
VariableRuntimeDxe.inf MdeModulePkg/Variable/RuntimeDxe: move SecureBootHook() decl to new header 2017-10-10 11:25:04 +02:00
VariableRuntimeDxe.uni MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00
VariableRuntimeDxeExtra.uni MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00
VariableSmm.c MdeModulePkg VariableSmm: Check InfoSize correctly 2016-12-12 09:55:37 +08:00
VariableSmm.inf MdeModulePkg/Variable/RuntimeDxe: move SecureBootHook() decl to new header 2017-10-10 11:25:04 +02:00
VariableSmm.uni MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00
VariableSmmExtra.uni MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00
VariableSmmRuntimeDxe.c MdeModulePkg/Variable/RuntimeDxe: move SecureBootHook() decl to new header 2017-10-10 11:25:04 +02:00
VariableSmmRuntimeDxe.inf MdeModulePkg/Variable/RuntimeDxe: move SecureBootHook() decl to new header 2017-10-10 11:25:04 +02:00
VariableSmmRuntimeDxe.uni MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00
VariableSmmRuntimeDxeExtra.uni MdeModulePkg: Convert all .uni files to utf-8 2015-12-15 04:56:23 +00:00