audk/MdeModulePkg/Include/Guid
Michael Kubacki aab3b9b9a1 MdeModulePkg/Variable: Add RT GetVariable() cache support
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2220

This change reduces SMIs for GetVariable () by maintaining a
UEFI variable cache in Runtime DXE in addition to the pre-
existing cache in SMRAM. When the Runtime Service GetVariable()
is invoked, a Runtime DXE cache is used instead of triggering an
SMI to VariableSmm. This can improve overall system performance
by servicing variable read requests without rendezvousing all
cores into SMM.

The runtime cache  can be disabled with by setting the FeaturePCD
gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache
to FALSE. If the PCD is set to FALSE, the runtime cache will not be
used and an SMI will be triggered for Runtime Service
GetVariable () and GetNextVariableName () invocations.

The following are important points regarding the behavior of the
variable drivers when the variable runtime cache is enabled.

1. All of the non-volatile storage contents are loaded into the
   cache upon driver load. This one time load operation from storage
   is preferred as opposed to building the cache on demand. An on-
   demand cache would require a fallback SMI to load data into the
   cache as variables are requested.

2. SetVariable () requests will continue to always trigger an SMI.
   This occurs regardless of whether the variable is volatile or
   non-volatile.

3. Both volatile and non-volatile variables are cached in a runtime
   buffer. As is the case in the current EDK II variable driver, they
   continue to be cached in separate buffers.

4. The cache in Runtime DXE and SMM are intended to be exact copies
   of one another. All SMM variable accesses only return data from the
   SMM cache. The runtime caches are only updated after the variable I/O
   operation is successful in SMM. The runtime caches are only updated
   from SMM.

5. Synchronization mechanisms are in place to ensure the runtime cache
   content integrity with the SMM cache. These may result in updates to
   runtime cache that are the same in content but different in offset and
   size from updates to the SMM cache.

When using SMM variables with runtime cache enabled, two caches will now
be present.
1. "Runtime Cache" - Maintained in VariableSmmRuntimeDxe. Used to service
   Runtime Services GetVariable () and GetNextVariableName () callers.
2. "SMM Cache" - Maintained in VariableSmm to service SMM GetVariable ()
   and GetNextVariableName () callers.
   a. This cache is retained so SMM modules do not operate on data outside
      SMRAM.

Because a race condition can occur if an SMI occurs during the execution
of runtime code reading from the runtime cache, a runtime cache read lock
is introduced that explicitly moves pending updates from SMM to the runtime
cache if an SMM update occurs while the runtime cache is locked. Note that
it is not expected a Runtime services call will interrupt SMM processing
since all CPU cores rendezvous in SMM.

It is possible to view UEFI variable read and write statistics by setting
the gEfiMdeModulePkgTokenSpaceGuid.PcdVariableCollectStatistics FeaturePcd
to TRUE and using the VariableInfo UEFI application in MdeModulePkg to dump
variable statistics to the console. By doing so, a user can view the number
of GetVariable () hits from the Runtime DXE variable driver (Runtime Cache
hits) and the SMM variable driver (SMM Cache hits). SMM Cache hits for
GetVariable () will occur when SMM modules invoke GetVariable ().

Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
2019-11-05 21:55:54 -08:00
..
AcpiS3Context.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
BootScriptExecutorVariable.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
CapsuleVendor.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
ConnectConInEvent.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
ConsoleInDevice.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
ConsoleOutDevice.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
Crc32GuidedSectionExtraction.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
DebugMask.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
DriverSampleHii.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
EndOfS3Resume.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
EventExitBootServiceFailed.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
ExtendedFirmwarePerformance.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
FaultTolerantWrite.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
FirmwarePerformance.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
HiiBootMaintenanceFormset.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
HiiResourceSampleHii.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
IdleLoopEvent.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
LoadModuleAtFixedAddress.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
LzmaDecompress.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
MdeModuleHii.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
MdeModulePkgTokenSpace.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
MemoryProfile.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
MemoryStatusCodeRecord.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
MemoryTypeInformation.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
MtcVendor.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
NonDiscoverableDevice.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
PcdDataBaseHobGuid.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
PcdDataBaseSignatureGuid.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
Performance.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
PerformanceMeasurement.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
PiSmmCommunicationRegionTable.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
PiSmmMemoryAttributesTable.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
PlatDriOverrideHii.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
PlatformHasAcpi.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
RamDiskHii.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
RecoveryDevice.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
S3SmmInitDone.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
S3StorageDeviceInitList.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
SerialPortLibVendor.h MdeModulePkg: Introduce EDKII_SERIAL_PORT_LIB_VENDOR_GUID 2019-06-14 21:26:28 +02:00
SmiHandlerProfile.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
SmmLockBox.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
SmmVariableCommon.h MdeModulePkg/Variable: Add RT GetVariable() cache support 2019-11-05 21:55:54 -08:00
StandardErrorDevice.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
StatusCodeCallbackGuid.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
StatusCodeDataTypeDebug.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
StatusCodeDataTypeVariable.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
SystemNvDataGuid.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
TtyTerm.h MdeModulePkg: Extend the support keyboard type of Terminal console 2019-09-24 21:56:46 +08:00
UsbKeyBoardLayout.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
VarErrorFlag.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
VariableFormat.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
VariableIndexTable.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00
ZeroGuid.h MdeModulePkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:08 -07:00