audk/MdeModulePkg/Universal
Laszlo Ersek 9b4a20321e MdeModulePkg/Variable/RuntimeDxe: introduce PcdMaxVolatileVariableSize
The variable driver doesn't distinguish "non-volatile non-authenticated"
variables from "volatile non-authenticated" variables, when checking
individual variable sizes against the permitted maximum.
PcdMaxVariableSize covers both kinds.

This prevents volatile non-authenticated variables from carrying large
data between UEFI drivers, despite having no flash impact. One example is
EFI_TLS_CA_CERTIFICATE_VARIABLE, which platforms might want to create as
volatile on every boot: the certificate list can be several hundred KB in
size.

Introduce PcdMaxVolatileVariableSize to represent the limit on individual
volatile non-authenticated variables. The default value is zero, which
makes Variable/RuntimeDxe fall back to PcdMaxVariableSize (i.e. the
current behavior). This is similar to the PcdMaxAuthVariableSize fallback.

Whenever the size limit is enforced, consult MaxVolatileVariableSize as
the last option, after checking
- MaxAuthVariableSize for VARIABLE_ATTRIBUTE_AT_AW,
- and MaxVariableSize for EFI_VARIABLE_NON_VOLATILE.

EFI_VARIABLE_HARDWARE_ERROR_RECORD is always handled separately; it always
takes priority over the three cases listed above.

Introduce the GetMaxVariableSize() helper to consider
PcdMaxVolatileVariableSize, in addition to
GetNonVolatileMaxVariableSize(). GetNonVolatileMaxVariableSize() is
currently called at three sites, and two of those need to start using
GetMaxVariableSize() instead:
- VariableServiceInitialize() [VariableSmm.c]: the SMM comms buffer must
  accommodate all kinds of variables,
- VariableCommonInitialize() [Variable.c]: the preallocated scratch space
  must also accommodate all kinds of variables,
- InitNonVolatileVariableStore() [Variable.c] can continue using
  GetNonVolatileMaxVariableSize().

Don't modify the ReclaimForOS() function as it is specific to non-volatile
variables and should ignore PcdMaxVolatileVariableSize.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.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: Gary Lin <glin@suse.com>
Tested-by: Gary Lin <glin@suse.com>
[lersek@redhat.com: set MaxVolatileVariableSize where Star suggested]
Reviewed-by: Star Zeng <star.zeng@intel.com>
2018-03-30 21:17:07 +02:00
..
Acpi MdeModulePkg/BootGraphicsResourceDxe: Add Boot Logo 2 Protocol 2018-02-28 11:58:27 -08:00
BdsDxe MdeModulePkg/BdsDxe: Remove useless perf Code 2018-02-12 11:36:14 +08:00
BootManagerPolicyDxe
CapsulePei MdeModulePkg CapsulePei: Sort and merge memory resource entries 2017-12-05 10:21:18 +08:00
CapsuleRuntimeDxe MdeModulePkg: Error Level is not used correctly 2017-04-12 08:56:12 +08:00
Console MdeModulePkg/Terminal: ReadKeyStrokeEx always return key state 2018-03-06 12:14:29 +08:00
DebugPortDxe MdeModulePkg: Refine type cast for pointer subtraction 2017-03-06 14:14:09 +08:00
DebugSupportDxe MdeModulePkg: Update DebugSupportDxe to pass XCODE5 build 2018-01-16 23:30:12 +08:00
DevicePathDxe
Disk MdeModulePkg/PartitionDxe: Add partition type guid to installed handle 2018-03-29 13:05:19 +08:00
DisplayEngineDxe MdeModulePkg/DisplayEngineDxe: Remove unnecessary parentheses in 'if' 2017-12-06 08:47:56 +08:00
DriverHealthManagerDxe
DriverSampleDxe MdeModulePkg/DriverSampleDxe: Refine the sample case for UNION type 2018-03-08 08:58:47 +08:00
EbcDxe MdeModulePkg: Refine casting expression result to bigger size 2017-03-06 14:33:20 +08:00
EsrtDxe MdeModulePkg: Update Ppi/Protocol/Guid usage in INF files 2017-10-10 18:10:25 +08:00
EsrtFmpDxe MdeModulePkg: Fix coding style issues in file/function comments 2018-03-19 09:57:22 +08:00
FaultTolerantWriteDxe MdeModulePkg: Refine casting expression result to bigger size 2017-03-06 14:33:20 +08:00
FaultTolerantWritePei
FileExplorerDxe
FvSimpleFileSystemDxe MdeModulePkg: Fix misuses of AllocateCopyPool 2017-11-08 17:13:03 +08:00
HiiDatabaseDxe MdeModulePkg HiiDataBase: Fix the potential NULL pointer access 2017-12-28 13:34:34 +08:00
HiiResourcesSampleDxe
LegacyRegion2Dxe
LoadFileOnFv2 MdeModulePkg LoadFileOnFv2: Correct the parameter name in function comment 2016-10-25 11:53:59 +08:00
LockBox/SmmLockBox MdeModulePkg SmmLockBox: Return updated Length for EFI_BUFFER_TOO_SMALL 2018-02-26 14:03:23 +08:00
MemoryTest MdeModulePkg/NullMemoryTest: Fix bug in CompatibleRangeTest 2018-03-07 12:36:14 +08:00
Metronome
MonotonicCounterRuntimeDxe
Network MdeModulePkg/Mtftp4Dxe: Fix the incorrect return status. 2018-03-13 16:55:18 +08:00
PCD MdeModulePkg PCD: Remove unused PCD attribute PCD_TYPE_SKU_ENABLED 2018-03-13 15:57:05 +08:00
PcatSingleSegmentPciCfg2Pei
PlatformDriOverrideDxe MdeModulePkg: Error Level is not used correctly 2017-04-12 08:56:12 +08:00
PrintDxe MdeModulePkg/PrintDxe: Handle the deprecation of [A|U]ValueToString 2017-03-02 09:59:06 +08:00
PropertiesTableAttributesDxe
RegularExpressionDxe MdeModulePkg: Delete useless case code 2017-08-16 16:55:22 +08:00
ReportStatusCodeRouter
ResetSystemPei MdeModulePkg/ResetSystemPei: Add reset notifications in PEI 2018-02-09 15:30:01 +08:00
ResetSystemRuntimeDxe MdeModulePkg/ResetSystemRuntimeDxe: Add more debug message 2018-02-09 15:29:57 +08:00
SectionExtractionDxe
SectionExtractionPei MdeModulePkg SectionExtractionPei: remove the hard code alignment adjustment 2018-01-19 13:20:20 +08:00
SecurityStubDxe MdeModulePkg: Update Ppi/Protocol/Guid usage in INF files 2017-10-10 18:10:25 +08:00
SerialDxe MdeModulePkg/SerialDxe: Do not fail reset when SetAttributes is not supported 2017-11-30 09:11:53 +08:00
SetupBrowserDxe MdeModulePkg: Fix MSFT C4255 warning 2017-11-14 18:18:43 +08:00
SmbiosDxe MdeModulePkg: Refine casting expression result to bigger size 2017-03-06 14:33:20 +08:00
SmbiosMeasurementDxe MdeModulePkg SmbiosMeasurementDxe: Skip measurement for OEM type 2017-09-18 10:19:40 +08:00
SmmCommunicationBufferDxe
StatusCodeHandler MdeModulePkg/MemoryStatusCode: Expose the DXE memory status code table. 2016-06-29 09:46:51 +08:00
TimestampDxe
Variable MdeModulePkg/Variable/RuntimeDxe: introduce PcdMaxVolatileVariableSize 2018-03-30 21:17:07 +02:00
WatchdogTimerDxe MdeModulePkg/Universal: Fix typos in comments 2016-10-27 09:11:19 +08:00