summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal
Commit message (Collapse)AuthorAgeFilesLines
...
* MdeModulePkg VariablePei: Return GetVariable() attr if EFI_BUFFER_TOO_SMALLMichael Kubacki2020-04-071-9/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2062 This commit makes the behavior for PeiGetVariable() match the following specification-defined behavior. It is now consistent with the DXE/SMM variable driver implementation. The UEFI specification v2.8 Errata A Section 8.2 "GetVariable()" "Attributes" parameter description states: "If not NULL, a pointer to the memory location to return the attributes bitmask for the variable. See 'Related Definitions.' If not NULL, then Attributes is set on output both when EFI_SUCCESS and when EFI_BUFFER_TOO_SMALL is returned." The attributes were previously only returned from the implementation in Variable.c on EFI_SUCCESS. They are now returned on EFI_SUCCESS or EFI_BUFFER_TOO_SMALL according to spec. Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Guomin Jiang <guomin.jiang@intel.com>
* MdeModulePkg Variable: Return GetVariable() attr if EFI_BUFFER_TOO_SMALLMichael Kubacki2020-04-072-7/+13
| | | | | | | | | | | | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2062 The UEFI specification v2.8 Errata A Section 8.2 "GetVariable()" "Attributes" parameter description states: "If not NULL, a pointer to the memory location to return the attributes bitmask for the variable. See 'Related Definitions.' If not NULL, then Attributes is set on output both when EFI_SUCCESS and when EFI_BUFFER_TOO_SMALL is returned." The attributes were previously only returned from the implementation in Variable.c on EFI_SUCCESS. They are now returned on EFI_SUCCESS or EFI_BUFFER_TOO_SMALL according to spec. Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Guomin Jiang <guomin.jiang@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg/SetupBrowserDxe: Fix IsZeroGuid() ASSERT.Nickle Wang2020-03-121-1/+2
| | | | | | | | | From the function description of GetIfrBinaryData(), FormSetGuid can be NULL. However, FormSetGuid is passed to IsZeroGuid(). This causes exception when FormSetGuid is NULL. Signed-off-by: Nickle Wang <nickle.wang@hpe.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com>
* MdeModulePkg/DisplayEngine: Zero memory before free (CVE-2019-14558)Dandan Bi2020-02-141-2/+6
| | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1611 Cc: Liming Gao <liming.gao@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg/String.c: Zero memory before free (CVE-2019-14558)Dandan Bi2020-02-141-1/+8
| | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1611 Cc: Liming Gao <liming.gao@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg/HiiDB: Remove configuration table when it's freed (CVE-2019-14586)Dandan Bi2020-02-141-1/+9
| | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1995 Fix the corner case issue that the original configuration runtime memory is freed, but it is still exposed to the OS runtime. So this patch is to remove the configuration table to avoid being used in OS runtime when the configuration runtime memory is freed. Cc: Liming Gao <liming.gao@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg/Capsule: Remove RT restriction in UpdateCapsule service.Siyuan Fu2020-02-072-4/+5
| | | | | | | | | | | | | | | | | | Current UpdateCapsule service will reject all non-reset capsule images and return EFI_OUT_OF_RESOURCE if the system is at runtime. This will block a platform CapsuleLib from implementing ProcessCapsuleImage() with runtime capsule processing capability. This patch removes this restriction. The change is controled by a feature PCD PcdSupportProcessCapsuleAtRuntime, and the default value is FALSE which means not enable this feature. BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2501 Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
* MdeModulePkg: Perform test only if not ignore memory testHeng Luo2020-02-061-4/+6
| | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2463 Perform Data and Address line test only if not ignore memory test. Signed-off-by: Heng Luo <heng.luo@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
* MdeModulePkg/Variable: Fix VarErrorFlag RT cache offset calculationMichael Kubacki2020-01-171-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2457 This commit fixes an offset calculation that is used to write the VarErrorFlag UEFI variable to the UEFI variable runtime cache. Currently a physical address is used instead of an offset. This commit changes the offset to zero with a length of the entire non-volatile variable store so the entire non-volatile variable store buffer in SMRAM (with the variable update modification) is copied to the runtime variable cache. This follows the same pattern used in other SynchronizeRuntimeVariableCache () calls for consistency. * Observable symptom: An exception in SMM will most likely occur due to the invalid memory reference when the VarErrorFlag variable is written. The variable is most commonly written when the UEFI variable store is full. * The issue only occurs when the variable runtime cache is enabled by the following PCD being set to TRUE: gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache Fixes: aab3b9b9a1e5e1f3fa966fb1667fc3e6c47e7706 Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Michael Turner <michael.turner@microsoft.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg/Setup: Update opcode number variable type to UINTNBrian R Haug2020-01-151-9/+9
| | | | | | | | | | | | | | Update data type of variables which save the opcode numbers to UINTN, in case some configuration module has lots of configuration items. Cc: Liming Gao <liming.gao@intel.com> Cc: Eric Dong <eric.dong@intel.com> Signed-off-by: Brian R Haug <brian.r.haug@intel.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Eric Dong <eric.dong@intel.com>
* MdeModulePkg/Smbios: Add TCG PFP rev 105 support.Jiewen Yao2020-01-062-5/+39
| | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2439 Report EV_EFI_HANDOFF_TABLES2 if the platform chooses PFP >= 105. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Star Zeng <star.zeng@intel.com> Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/Smbios: Done measure Smbios multiple times.Jiewen Yao2020-01-061-2/+2
| | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2439 In current implementation, the SMBIOS table is measured multiple time in every readytoboot event. This causes Smbios Table record appears multiple time in the TCG event log and confuses people. This issue makes it hard to implement 800-155 reference measurement. This patch closes the event to make sure Smbios is measured only once. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Star Zeng <star.zeng@intel.com> Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
* MdeModulePkg/VariableSmmRuntimeDxe.inf: list local header "Variable.h"Laszlo Ersek2019-12-021-0/+1
| | | | | | | | | | | | | | | | | | | | Commit aab3b9b9a1e5 ("MdeModulePkg/Variable: Add RT GetVariable() cache support", 2019-11-05) added "VariableParsing.h" to "VariableSmmRuntimeDxe.inf". "VariableParsing.h" includes "Variable.h", so the "build" utility is right to warn us that "Variable.h" should be listed in [Sources] too. Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Leif Lindholm <leif.lindholm@linaro.org> Cc: Liming Gao <liming.gao@intel.com> Cc: Michael Kubacki <michael.a.kubacki@intel.com> Fixes: aab3b9b9a1e5e1f3fa966fb1667fc3e6c47e7706 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
* MdeModulePkg/Variable: Initialize local variable "RtPtrTrack"edk2-stable201911Kubacki, Michael A2019-11-251-0/+2
| | | | | | | | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2364 Fixes a new build warning in VS2012 introduced in f8ff4cca7c. This patch initializes the local variable "RtPtrTrack" in FindVariableInRuntimeCache (). This ensures the pointers in the structure are initialized in the case no variable stores exist in the list of variable stores. Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg/Variable: Initialize local variable "Variable"Kubacki, Michael A2019-11-251-0/+2
| | | | | | | | | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2364 Fixes a new build warning in VS2012 introduced in f8ff4cca7c. This patch initializes the local variable "Variable" in VariableServiceGetNextVariableInternal (). This ensures the pointers in the structure are initialized in the case no variable stores exist in the list of variable stores. Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg RegularExpressionDxe: Update tool chain name to CLANGPDBLiming Gao2019-11-151-1/+1
| | | | | | | | BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2341 Signed-off-by: Liming Gao <liming.gao@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg/Variable: Fix volatile variable RT cache update logicMichael Kubacki2019-11-151-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | REF:https://bugzilla.tianocore.org/show_bug.cgi?id=2333 During a SetVariable () invocation, UpdateVariable () is called. UpdateVariable () contains logic to determine whether a volatile or non-volatile UEFI variable was set so the corresponding runtime cache can be updated to reflect the change. The current logic simply evaluates Variable->Volatile to determine which runtime cache should be updated. The problem is Variable->Volatile does not always reflect whether a volatile variable is being set. Variable->Volatile is set to TRUE only in the case a pre-existing variable is found in the volatile variable store. Therefore, the value is FALSE when a new volatile variable is written. This change updates the logic to take this into account. If a new variable is written successfully, the Attributes will accurately reflect whether the variable is non-volatile. If a pre-existing variable is modified, the Volatile field will reflect the type of variable (Attributes are not reliable; e.g. 0x0 indicates deletion). * Observable symptom: A volatile variable that was set successfully might return EFI_NOT_FOUND when the variable should be found. * The issue is a regression introduced to the variable services only when the variable runtime cache is enabled by the following PCD being set to TRUE: gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache * The issue was implemented in commit aab3b9b9a1 but the PCD was not set to TRUE by default enabling the issue until commit e07b7d024a. Fixes: aab3b9b9a1e5e1f3fa966fb1667fc3e6c47e7706 Cc: Liming Gao <liming.gao@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Michael Kubacki <michael.a.kubacki@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg/Variable: Add RT GetNextVariableName() cache supportMichael Kubacki2019-11-051-9/+128
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2220 This change implements the Runtime Service GetNextVariableName() using the runtime cache in VariableSmmRuntimeDxe. Runtime Service calls to GetNextVariableName() will no longer trigger a SW SMI when gEfiMdeModulePkgTokenSpaceGuid.PcdEnableVariableRuntimeCache is set to TRUE (default value). Overall system performance and stability will be improved by eliminating an SMI for these calls as they typically result in a relatively large number of invocations to retrieve all variable names in all variable stores present. 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> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/Variable: Add RT GetVariable() cache supportMichael Kubacki2019-11-0510-40/+971
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* MdeModulePkg/Variable: Add a file for NV variable functionsMichael Kubacki2019-11-056-316/+408
| | | | | | | | | | | | | | | | | | | | This change adds a dedicated file for variable operations specific to non-volatile variables. This decreases the overall length of the relatively large Variable.c file. 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> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/Variable: Parameterize auth status in VariableParsingMichael Kubacki2019-11-055-167/+339
| | | | | | | | | | | | | | | | | | | | | | | | | | The file VariableParsing.c provides generic functionality related to parsing variable related structures and information. In order to calculate offsets for certain operations, the functions must know if authenticated variables are enabled as this increases the size of variable headers. This change removes linking against a global variable in an external file in favor of passing the authenticated variable status as a parameter to the variable parsing functions. 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> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/Variable: Parameterize VARIABLE_INFO_ENTRY bufferMichael Kubacki2019-11-053-35/+40
| | | | | | | | | | | | | | | | | | | | | UpdateVariableInfo () currently accepts parameters regarding updates to be made to a global variable of type VARIABLE_INFO_ENTRY. This change passes the structure by pointer to UpdateVariableInfo () so structures other than the fixed global variable can be updated. 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> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/Variable: Parameterize GetNextVariableInternal () storesMichael Kubacki2019-11-054-40/+73
| | | | | | | | | | | | | | | | | | | | | | | The majority of logic related to GetNextVariableName () is currently implemented in VariableServiceGetNextVariableInternal (). The list of variable stores to search for the given variable name and variable GUID is defined in the function body. This change adds a new parameter so that the caller must pass in the list of variable stores to be used in the variable search. 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> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/Variable: Consolidate common parsing functionsMichael Kubacki2019-11-059-845/+1047
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This change moves the following functions into a dedicated file so they may be used in other variable files as needed. These are commonly needed for basic variable data structure parsing operations. The functions are grouped together in VariableParsing.c to support cohesiveness for these operations in the file. Furthermore, it reduces the overall size of the common Variable.c file. * DataSizeOfVariable () * FindVariableEx () * GetEndPointer () * GetNextVariablePtr () * GetStartPointer () * GetVariableDataOffset () * GetVariableDataPtr () * GetVariableHeaderSize () * GetVariableNamePtr () * GetVariableStoreStatus () * GetVendorGuidPtr () * IsValidVariableHeader () * NameSizeOfVariable () * SetDataSizeOfVariable () * SetNameSizeOfVariable () * UpdateVariableInfo () * VariableCompareTimeStampInternal () * VariableServiceGetNextVariableInternal () 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> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/EbcDebugger: Add check for Entry and RetEntryShenglei Zhang2019-11-062-2/+2
| | | | | | | | | Entry and RetEntry might be NULL before used. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/SetupBrowserDxe: ASSERT GetBufferForValue(&Value)Shenglei Zhang2019-11-061-0/+3
| | | | | | | | | | | | | Before called by GetBufferForValue(), Value has already been called function IsTypeInBuffer to make sure the value must be buffer type. So GetBufferForValue can not return NULL. This commit adds ASSERT to assume (GetBufferForValue (&Value) is not NULL. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com>
* MdeModulePkg/EsrtDxe: Add check for EsrtRepositoryShenglei Zhang2019-11-061-0/+10
| | | | | | | | | | EsrtRepository might be NULL. So return EFI_OUT_OF_RESOURCES when it is NULL. Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/HiiDatabaseDxe: ASSERT StringPtrShenglei Zhang2019-11-061-0/+1
| | | | | | | | | | | The caller of CompareAndMergeDefaultString has checked that AltCfgResp must contain AltConfigHdr. So we add ASSERT to assume StringPtr is not NULL. Cc: Dandan Bi <dandan.bi@intel.com> Cc: Eric Dong <eric.dong@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com>
* MdeModulePkg/HiiDatabaseDxe: ASSERT "Private->Attribute >> 4"Shenglei Zhang2019-11-041-0/+1
| | | | | | | | | | | | | Foreground and background color are saved in a single byte. Bits 0..3 are the foreground color and bits 4..6 are the background color. If the Private->Attribute defined correctly, (Private->Attribute >> 4) must be less than 8. This commit uses ASSERT to assume "Attribute >> 4" is less than 8. Cc: Dandan Bi <dandan.bi@intel.com> Cc: Eric Dong <eric.dong@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com>
* MdeModulePkg/Variable/Pei: Update the condition in if statementShenglei Zhang2019-11-041-1/+1
| | | | | | | | | | | IndexTable->Length is used as index in array IndexTable->Index[]. So IndexTable->Length needs to be checked, which should be less than the array size. Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/Oniguruma: Remove redundant IF statementShenglei Zhang2019-11-044-44/+26
| | | | | | | | | | | The if statement is not necessary, so keep it to edk2 style. And this change has been merged to onigruma. REF:https://github.com/kkos/oniguruma/pull/158 Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/BdsDxe: Fix PlatformRecovery issueSunny Wang2019-10-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | For now, PlatformRecovery doesn't work if OsIndications variable doesn't exist, which is wrong. According to the UEFI specification section 3.4.1 and 3.4.2, if processing of BootOrder does not result in success, the OsRecovery and PlatformRecovery options should still be processed regardless of the existence of the OsIndications variable. Therefore, update the code to check PcdPlatformRecoverySupport instead of the value of OsIndications variable (PlatformRecovery) to fix this issue. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Walon Li <walon.li@hpe.com> Signed-off-by: Sunny Wang <sunnywang@hpe.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Acked-by: Jian J Wang <jian.j.wang@intel.com>
* MdeModulePkg RegularExpressionDxe: Disable warning for CLANG9 tool chainLiming Gao2019-10-241-0/+3
| | | | | | | BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=1603 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/BdsDxe: Fix calling PlatformBootManagerWaitCallback on 0Laszlo Ersek2019-10-151-1/+11
| | | | | | | | | | | | | | | | Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=2266 Commit 2de1f611be06ded3a59726a4052a9039be7d459b introduced a regression whereas platforms that did set PcdPlatformBootTimeOut to 0 are now getting an unexpected call to PlatformBootManagerWaitCallback(). This patch also ensures that, if PcdPlatformBootTimeOut is 0xFFFF we don't call PlatformBootManagerWaitCallback() with a zero argument as doing so would produce an unwarranted jump to full progress completion which is likely to throw off users. Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Liming Gao <liming.gao@intel.com>
* MdeModulePkg/S3SaveState: cast Position for S3BootScriptLib explicitlyLaszlo Ersek2019-10-092-4/+4
| | | | | | | | | | | | | | | | | | | | | The BootScriptInsert() and BootScriptLabel() functions take the in/out parameter "Position" as (EFI_S3_BOOT_SCRIPT_POSITION*), and pass it to S3BootScriptMoveLastOpcode() and S3BootScriptLabel(), respectively. The callees take the in/out parameter "Position" as (VOID**). Add explicit casts for clarity. There is no change in functionality. Cc: Dandan Bi <dandan.bi@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg: stop abusing EFI_HANDLE for keystroke notify registrationLaszlo Ersek2019-10-092-3/+3
| | | | | | | | | | | | | | | | | | | | EFI_REGISTER_KEYSTROKE_NOTIFY and EFI_UNREGISTER_KEYSTROKE_NOTIFY require the notification handle to have type (VOID*). The notification handle has nothing to do with the EFI_HANDLE type. This change is a semantic fix; functionally, it's a no-op. Cc: Dandan Bi <dandan.bi@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg: stop abusing EFI_EVENT for protocol notify registrationLaszlo Ersek2019-10-094-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | EfiCreateProtocolNotifyEvent() takes a (VOID**) for "Registration", similarly to gBS->RegisterProtocolNotify(). We should pass the address of an actual pointer-to-VOID, and not the address of an EFI_EVENT. EFI_EVENT just happens to be specified as (VOID*), and has nothing to do with the registration. The same applies to gMmst->MmRegisterProtocolNotify(). "mFtwRegistration", "mFvRegistration", and "mFvbRegistration" are used for nothing else. This change is a no-op in practice; it's a semantic improvement. Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
* MdeModulePkg/BdsDxe: Also call PlatformBootManagerWaitCallback on 0Pete Batard2019-10-081-0/+1
| | | | | | | | | | | | The existing loop is set to call PlatformBootManagerWaitCallback every second except the last one. We believe this is a mistake as it prevents the called code from performing timeout expiration tasks such as, for instance, ensuring that the last segment of a progress bar is displayed before continuing (which is a current issue for the RPi3 platform). Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
* MdeModulePkg: strip trailing whitespaceLeif Lindholm2019-10-045-8/+8
| | | | | | | | | | | | Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/TerminalDxe: Enhance the arrow keys supportGao, Zhichao2019-09-271-2/+6
| | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2219 First previous patch remove the VT100Plus's arrow keys' support. Add it back. The arrow keys would send ESC [A through to ESC [D. Add this support for the new introduced terminal type. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
* MdeModulePkg/PlatformDriOverride: Unload image on EFI_SECURITY_VIOLATIONDandan Bi2019-09-251-1/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | For the LoadImage() boot service, with EFI_SECURITY_VIOLATION retval, the Image was loaded and an ImageHandle was created with a valid EFI_LOADED_IMAGE_PROTOCOL, but the image can not be started right now. This follows UEFI Spec. But if the caller of LoadImage() doesn't have the option to defer the execution of an image, we can not treat EFI_SECURITY_VIOLATION like any other LoadImage() error, we should unload image for the EFI_SECURITY_VIOLATION to avoid resource leak. This patch is to do error handling for EFI_SECURITY_VIOLATION explicitly for the caller in PlatformDriOverrideDxe which don't have the policy to defer the execution of the image. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Liming Gao <liming.gao@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Philippe Mathieu-Daude <philmd@redhat.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1992 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
* MdeModulePkg/TerminalDxe: Extend the terminal console support typesZhichao Gao2019-09-245-26/+320
| | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2186 Extend the support types of terminal console driver. New added types are Linux, XtermR6, VT400 and SCO. Refer to https://www.ssh.com/ssh/putty/putty-manuals/0.68/Chapter4.html#config-funkeys Add the missing VT100+ function keys map. Add F1-F12 function keys map for Linux, XtermR6, VT400 and SCO. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Liming Gao <liming.gao@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com>
* MdeModulePkg SerialDxe.inf: Fix wrong FILE_GUID formatLiming Gao2019-09-171-1/+1
| | | | | | | | | Fix regression issue caused by 0d85e67714e31e0dbe4241ab2ebb7c423aba174d Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/SerialDxe: Update the file Guid in SerialDxe.infShenglei Zhang2019-09-171-1/+1
| | | | | | | | | | | | FILE GUID in MdeModulePkg\Universal\SerialDxe\SerialDxe.inf is same to the one gEdkiiSerialPortLibVendorGuid. Its FILE GUID should be updated to another value. https://bugzilla.tianocore.org/show_bug.cgi?id=2144 Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg: Add missing header files in INF filesShenglei Zhang2019-08-133-2/+11
| | | | | | | | | | The header files are used but missing in INF,which causes generating warning message when building them. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/RegularExpressionDxe: Add two missing null pointer checksLiming Gao2019-08-131-0/+2
| | | | | | | | | | | After update Oniguruma from v6.9.0 to v6.9.3, two null pointer check should be added. This change bases on the patch https://edk2.groups.io/g/devel/message/45183. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg RegularExpressionDxe: Update Oniguruma from v6.9.0 to v6.9.3Liming Gao2019-08-1325-11282/+14041
| | | | | | | | | | | | | | | | | | | BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=2066 Update Oniguruma to the latest version v6.9.3. Oniguruma https://github.com/kkos/oniguruma This release is the security fix release. It includes the changes: Fixed CVE-2019-13224 Fixed CVE-2019-13225 Fixed many problems (found by libfuzzer programs) Verify VS2015, GCC5 build. Verify RegularExpressionProtocol GetInfo() and Match() function. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Cc: Cinnamon Shia <cinnamon.shia@hpe.com> Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg/EsrtFmpDxe: Enhance ESRT to support multiple controllersJin, Eric2019-08-071-137/+257
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1525 The patch is to merge multiple FMP instances into single ESRT entry when they have the same GUID. The policy to LastAttemptStatus/LastAttemptVersion of ESRT entry is: If all the LastAttemptStatus are LAST_ATTEMPT_STATUS_SUCCESS, then LastAttemptVersion should be the smallest of LastAttemptVersion. If any of the LastAttemptStatus is not LAST_ATTEMPT_STATUS_SUCCESS, then the LastAttemptVersion/LastAttemptStatus should be the values of the first FMP instance whose LastAttemptStatus is not LAST_ATTEMPT_STATUS_SUCCESS. To detect possible duplicated GUID/HardwareInstance, a table of GUID/HardwareInstance pairs from all the EFI_FIRMWARE_IMAGE_DESCRIPTORs from all FMP instances is built. If a duplicate is found, then generate a DEBUG_ERROR message, generate an ASSERT(), and ignore the duplicate EFI_FIRMWARE_IMAGE_DESCRIPTOR. Add an internal worker function called FmpGetFirmwareImageDescriptor() that retrieves the list of EFI_FIRMWARE_IMAGE_DESCRIPTORs from a single FMP instance and returns the descriptors in an allocated buffer. This function is used to get the descriptors used to build the table of unique GUID/HardwareInstance pairs. It is then used again to generate the ESRT Table from all the EFI_FIRMWARE_IMAGE_DESCRIPTORs from all the FMP instances. 2 passes are performed so the total number of descriptors is known. This allows the correct sized buffers to always be allocated. Cc: Sean Brogan <sean.brogan@microsoft.com> Cc: Bret Barkelew <Bret.Barkelew@microsoft.com> Cc: Jian J Wang <jian.j.wang@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Eric Jin <eric.jin@intel.com> Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
* MdeModulePkg: Fix typos and add periodsShenglei Zhang2019-08-021-2/+2
| | | | | | | | | | | | 1.Update @parm to @param in function comments in Presentation.c. 2.Add missing period (.) in some function comments. Cc: Jian J Wang <jian.j.wang@intel.com> Cc: Hao A Wu <hao.a.wu@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com>
* MdeModulePkg/Setup: Check ConfigAccess protocol in case it's destroyedGregX Yeh2019-07-101-0/+34
| | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=1920 Check ConfigAccess protocol is available before process user input. Signed-off-by: GregX Yeh <gregx.yeh@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Ted Kuo <ted.kuo@intel.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com>