summaryrefslogtreecommitdiffstats
path: root/ShellPkg
Commit message (Collapse)AuthorAgeFilesLines
...
* ShellPkg: acpiview: SLIT: Validate System Locality countKrzysztof Koch2020-02-111-5/+42
| | | | | | | | | | | | | | | 1. Check if the 'Number of System Localities' provided can be represented in the SLIT table. The table 'Length' field is a 32-bit value while the 'Number of System Localities' field is 64-bit long. 2. Check if the SLIT matrix fits in the table buffer. If N is the SLIT locality count, then the matrix used to represent the localities is N*N bytes long. The ACPI table length must be big enough to fit the matrix. 3. Remove (now) redundant 64x64 bit multiplication. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
* ShellPkg: acpiview: SLIT: Validate global pointer before useKrzysztof Koch2020-02-111-2/+14
| | | | | | | Check if SlitSystemLocalityCount pointer has been successfully updated before it is used for further table parsing. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
* ShellPkg: acpiview: FADT: Validate global pointer before useKrzysztof Koch2020-02-111-10/+11
| | | | | | | Check if global pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
* ShellPkg: acpiview: RSDP: Validate global pointer before useKrzysztof Koch2020-02-111-0/+12
| | | | | | | Check if XsdtAddress pointer has been successfully updated before it is used for further table parsing. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
* ShellPkg: acpiview: Set ItemPtr to NULL for unprocessed table fieldsKrzysztof Koch2020-02-111-1/+8
| | | | | | | | | | | | | | | | | | | | | | | For fields outside the buffer length provided, reset any pointers, which were supposed to be updated by a ParseAcpi() function call to NULL. This way one can easily validate if a pointer was successfully updated. The ParseAcpi() function parses the given ACPI table buffer by a number of bytes which is a minimum of the buffer length and the length described by ACPI_PARSER array. If the buffer length is shorter than the array describing how to process the ACPI structure, then it is possible that the ItemPtr inside ACPI_PARSER may not get updated or initialized. This can lead to an error if the value pointed to by ItemPtr is later used to control the parsing logic. A typical example would be a 'number of elements' field in an ACPI structure header which defines how many substructures of a given type are present in the structure body. If the 'number of elements' field is not parsed, we will have a dangling pointer which could cause a problem later. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
* ShellPkg: Document UpdateArgcArgv returns EFI_INVALID_PARAMETERPhilippe Mathieu-Daud?2020-02-112-0/+3
| | | | | | | | ShellParametersProtocol::UpdateArgcArgv() can return a EFI_INVALID_PARAMETER value. Document it. Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com>
* ShellPkg: Document ParseCommandLineToArgs returns EFI_INVALID_PARAMETERPhilippe Mathieu-Daud?2020-02-112-0/+2
| | | | | | | | ShellParametersProtocol::ParseCommandLineToArgs() can return a EFI_INVALID_PARAMETER value. Document it. Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com>
* ShellPkg/UefiShellAcpiViewCommandLib: Fix FADT ParserAshish Singhal2020-02-111-1/+1
| | | | | | | | | FADT parser was checking for reduced ACPI flag incorrectly leading to incorrect error message if FIRMWARE_CTRL and X_FIRMWARE_CTRL are both 0. Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Ashish Singhal <ashishsingha@nvidia.com>
* ShellPkg/DynamicCommand: Fix various typosAntoine Coeur2020-02-109-16/+16
| | | | | | | | | | | | Fix various typos in comments and documentation. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Antoine Coeur <coeur@gmx.fr> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com> Message-Id: <20200207010831.9046-69-philmd@redhat.com>
* ShellPkg/Application: Fix various typosAntoine Coeur2020-02-1016-106/+106
| | | | | | | | | | | | Fix various typos in comments and documentation. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Antoine Coeur <coeur@gmx.fr> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com> Message-Id: <20200207010831.9046-68-philmd@redhat.com>
* ShellPkg: acpiview: Update SRAT parser to ACPI 6.3Krzysztof Koch2020-01-153-6/+252
| | | | | | | | | | | | | | | | Add support for revision 3 of System Resource Affinity Table (SRAT). Decode and dump the new Generic Initiator Affinity Structure. Validate the Device Handle Type field inside the Generic Initiator Affinity Structure. Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Tested-by: Sudipto Paul <sudipto.paul@arm.com> Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
* ShellPkg/ShellProtocol: Return error code while fail parsing cmd-lineZhichao Gao2019-12-191-1/+4
| | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2395 Errors happened in the arguments parsing is not a critical error. And it would miss the error status code in the release version of shell. So replace the ASSERT with returning error status code while fail parsing command-line in UpdateArgcArgv. Cc: Ray Ni <ray.ni@intel.com> Cc: Linson Augustine <linson.augustine@intel.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/UefiHandleParsingLib: Fix error allocate poolZhichao Gao2019-12-051-4/+8
| | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1965 For function InsertNewGuidNameMapping, it rellocate the mGuidList with new size "mGuidListCount+1 * sizeof(GUID_INFO_BLOCK)". That isn't its purpose and would cause a overflow operation in "mGuidList[mGuidListCount - 1].xxx = xxx". Its purpose is to increase 1 block size of mGuidList. Change it to "(mGuidListCount + 1) * sizeof (GUID_INFO_BLOCK)". Adjust the coding style of this function. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Andrew Fish <afish@apple.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/edit: typo "%d Lines Wrote"Heinrich Schuchardt2019-12-052-2/+2
| | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2379 When a file is saved in the edit command a status message L"%d Lines Wrote" is displayed. The hexedit command suffers from the same typo. Change the message to L"%d Lines Written". Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
* ShellPkg: acpiview: IORT Spec Rev D updatesSami Mujawar2019-12-051-4/+9
| | | | | | | | | | | | | | | | Updated IORT parser to conform to the IO Remapping Table, Platform Design Document, Revision D, March 2018. The following structure parsers have been updated: 1. SMMUv3 - added proximity domain and device Id mapping index. 2. RootComplex - added memory address size limit. 2. PMCG - added page 1 support. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
* ShellPkg: acpiview: Add support for parsing FACSSami Mujawar2019-12-055-5/+179
| | | | | | | | | | | | | | | | | | Add support for parsing the ACPI FACS table. The FADT parser has also been updated as it links the FACS table using the FIRMWARE_CTRL or X_FIRMWARE_CTRL fields. Since the FACS table does not follow the standard ACPI header, the FADT parser extracts the FACS signature, length and version fields before invoking the FACS parser. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
* ShellPkg/SmbiosView: SMBIOS 3.3.0 Update "Intel persistent memory"Gao, Zhichao2019-11-141-2/+2
| | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2305 Memory Device (Type 17): - SMBIOSCR00179: update the string for Intel persistent memory Cc: Ray Ni <ray.ni@intel.com> Cc: Sai Chaganty <rangasai.v.chaganty@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/SmbiosView: SMBIOS 3.3.0 Add value HBM and Die for type 17Gao, Zhichao2019-11-141-0/+12
| | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2305 Memory Device (Type 17): - SMBIOSCR00178: add new memory device type value (HBM) and new form factor value (Die) Cc: Ray Ni <ray.ni@intel.com> Cc: Sai Chaganty <rangasai.v.chaganty@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/SmbiosView: SMBIOS 3.3.0 add support for CXL FlexbusGao, Zhichao2019-11-141-0/+8
| | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2305 Various: - SMBIOSCR00183: add support for CXL Flexbus Cc: Ray Ni <ray.ni@intel.com> Cc: Sai Chaganty <rangasai.v.chaganty@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/SmbiosView: SMBIOS 3.3.0 add PCI gen4 values for type 9Gao, Zhichao2019-11-142-2/+28
| | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2305 System Slots (Type 9): - SMBIOSCR00184: add PCI Express Gen 4 values Add the SmBios.h to use the MARCOs or enums. Cc: Ray Ni <ray.ni@intel.com> Cc: Sai Chaganty <rangasai.v.chaganty@intel.com> Reviewed-by: Ray Ni <ray.ni@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: Add YAML file for CI buildsMichael D Kinney2019-11-111-0/+55
| | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=2315 Add YAML file to the package directory with the configuration of the checks to perform during a CI build. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Acked-by: Zhichao Gao <zhichao.gao@intel.com> Acked-by: Ray Ni <ray.ni@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
* ShellPkg/CommandLib: Use first found UC for unsupported PlatformLangMarvin H?user2019-11-081-1/+5
| | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2300 On some firmwares PlatformLang is set to the local language (e.g. ru-RU), however there is no Unicode Collation protocol instance that supports it. As for missing PlatformLang, fall back to the first found instance. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Marvin Haeuser <mhaeuser@outlook.de>
* ShellPkg/Shell/FileHandleWrappers.c: Add check for MemFile->BufferShenglei Zhang2019-11-061-0/+7
| | | | | | | | | | Add check for MemFile->Buffer. Return EFI_OUT_OF_RESOURCES if MemFile->Buffer is NULL. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/Ls: Return empty content for all empty foldersMarvin Haeuser2019-11-041-5/+28
| | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2296 Currently, when 'ls' is run on an entirely empty directory (this includes not having '.' and '..'), the output is always 'File not found'. For when not filtering its children, this patch rather displays the usual header and footer. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Marvin Haeuser <mhaeuser@outlook.de> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/Ls: Consider UEFI timezone may not be setMarvin Haeuser2019-11-041-1/+1
| | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2294 EFI_RUNTIME_SERVICES.GetTime() might return an unspecified Timezone, such as when SetTime() has not been called after the RTC was cut off power. Consider this case by not attempting Timezone translations for when it is invalid. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Marvin Haeuser <mhaeuser@outlook.de> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/UefiShellDebug1CommandsLib: Update to support SmBios 3.3.0Abner Chang2019-10-175-5/+100
| | | | | | | | | | | | | | | | Shell command smbiosview updates for SMBIOS 3.3.0 spec. Bugzilla link, https://bugzilla.tianocore.org/show_bug.cgi?id=2202 Signed-off-by: Abner Chang <abner.chang@hpe.com> Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Leif Lindholm <leif.lindholm@linaro.org> Cc: Gilbert Chen <gilbert.chen@hpe.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/UefiShellLib: clarify workaround for unfixable EdkShell bugLaszlo Ersek2019-10-091-2/+20
| | | | | | | | | | | | | | | | | | | The EDK 1 Shell (available at <https://github.com/tianocore/edk-Shell>) has a bug in its EFI_SHELL_ENVIRONMENT2.Execute() implementation that edk2's UefiShellLib has no choice but to work around. Improve the explanation in the code. Also, document the implicit EFI_HANDLE -> (EFI_HANDLE*) conversion, which happens implicitly after dereferencing ParentHandle, with an explicit cast. In practice, this patch is a no-op. Cc: Jaben Carsey <jaben.carsey@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: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/UefiShellDebug1CommandsLib: fix ShellCloseFile() callLaszlo Ersek2019-10-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | In the FileBufferSave() function, we invoke ShellCloseFile() if "Directory Can Not Be Saved". The ShellCloseFile() function takes a (SHELL_FILE_HANDLE*) parameter called "FileHandle", and correctly passes the de-referenced (*FileHandle) to EFI_SHELL_CLOSE_FILE, which takes a SHELL_FILE_HANDLE. However, FileBufferSave() passes SHELL_FILE_HANDLE to ShellCloseFile(), not the expected (SHELL_FILE_HANDLE*). Correct it. This fixes an actual bug that has remained hidden for two reasons: - pointer-to-VOID converts from/to any pointer-to-object type silently, - the bug is on an error path which has likely never fired in practice. Cc: Jaben Carsey <jaben.carsey@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: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: stop taking EFI_HANDLE in place of SHELL_FILE_HANDLELaszlo Ersek2019-10-092-2/+2
| | | | | | | | | | | | | | | | | | The TouchFileByHandle() and IsDirectoryEmpty() functions are passed SHELL_FILE_HANDLE parameters, and they use those parameters correctly. However, their parameter lists say EFI_HANDLE. Spell out the right type in the parameter lists. In practice, this change is a no-op (because, quite regrettably, both EFI_HANDLE and SHELL_FILE_HANDLE are specified to be typedefs of (VOID*)). Cc: Jaben Carsey <jaben.carsey@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: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: stop using EFI_HANDLE in place of EFI_HII_HANDLELaszlo Ersek2019-10-0925-33/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The UefiShell*CommandsLib instances have constructor functions that do something like: gHiiHandle = HiiAddPackages (...); ... ShellCommandRegisterCommandName (..., gHiiHandle, ...); and destructor functions that implement the following pattern: HiiRemovePackages (gHiiHandle); The -- semantic, not functional -- problem is that "gHiiHandle" is declared with type EFI_HANDLE, and not EFI_HII_HANDLE, in all of these library instances, even though HiiAddPackages() correctly returns EFI_HII_HANDLE, and HiiRemovePackages() takes EFI_HII_HANDLE. Once we fix the type of "gHiiHandle", it causes sort of a butterfly effect, because it is passed around widely. Track down and update all of those locations. The DynamicCommand lib instances use a similar pattern, so they are affected too. NOTE: in practice, this patch is a no-op, as both EFI_HII_HANDLE and EFI_HANDLE are typedefs to (VOID*). However, we shouldn't use EFI_HANDLE where semantically EFI_HII_HANDLE is passed around. Cc: Jaben Carsey <jaben.carsey@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: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/UefiShellDriver1CommandsLib: fix parameter list typoLaszlo Ersek2019-10-091-2/+2
| | | | | | | | | | | | | | | | | | | | | | The ShellCommandRunConnect() function passes EFI_HANDLE -- (VOID*) -- objects to ConvertAndConnectControllers(), and ConvertAndConnectControllers() passes those to gBS->OpenProtocol(). Accordingly, ConvertAndConnectControllers() should specify EFI_HANDLE parameter types, not (EFI_HANDLE*) -- (VOID**) -- types. This typo is masked because (VOID*) converts to and from any pointer-to-object type silently. Note that functionally speaking there is no problem, so this patch does not change beavior, only cleans up the code. Cc: Jaben Carsey <jaben.carsey@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: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: Unload image on EFI_SECURITY_VIOLATIONDandan Bi2019-09-253-2/+29
| | | | | | | | | | | | | | | | | | | | | | | | | 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 callers in ShellPkg which don't have the policy to defer the execution of the image. Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.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: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
* ShellPkg/ShellPkg.dsc AARCH64: enable stack protectorArd Biesheuvel2019-09-051-4/+1
| | | | | | | | | | Incorporate the stack protector library into the AARCH64 build of the Shell binaries as a NULL library resolution, to avoid build errors when the compiler injects stack integrity checks. Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org> Acked-by: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
* ShellPkg/Pci.c: Update supported link speed to PCI5.0Gao, Zhichao2019-09-041-2/+14
| | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1955 Refer to PCI express base specification Reversion 5.0, Version 1.0, Table 7-33, Supported Link Speeds Vector bit 3 indicate the speed 16 GT/s and bit 4 indicate the speed 32 GT/s. Add the support to shell command 'pci ...'. Change the MaxLinkSpeed other values' result from 'Unknown' to 'Reserved' to make the result align. Cc: Ray Ni <ray.ni@intel.com> Cc: Oleksiy <oleksiyy@ami.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>
* ShellPkg/CommandLib: avoid NULL derefence and memory leakHeinrich Schuchardt2019-09-031-6/+14
| | | | | | | | | | | | | | | | | | | Since TianoCore EDK2 commit d65f2cea36d1 ("ShellPkg/CommandLib: Locate proper UnicodeCollation instance") in edk2 the UEFI Shell crashes if EFI variable PlatformLang is not defined due to dereferencing gUnicodeCollation gUnicodeCollation (= NULL) in ShellCommandRegisterCommandName(). Furthermore CommandInit() is leaking PlatformLang if gUnicodeCollation != NULL. Close the memory leak and use the first UnicodeCollation instance if PlatfomLang is not defined. Fixes: d65f2cea36d1 ("ShellPkg/CommandLib: Locate proper UnicodeCollation instance") Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/UefiShellDriver1CommandsLib: Make array big enoughZhichao Gao2019-08-191-3/+3
| | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1941 The two CHAR16 array ChildCountStr and DeviceCountStr is defined to hold the decimal string data of UINTN. The max of UINTN is 18446744073709551615 and it contain 20 characters. So make their size to 21 CHAR16s to hold the string data with a null-terminate. UnicodeValueToStringS regard the value input as INT64, and 21 CHARs is enough to hold the lowest value with minus '-'. Although the value shouldn't be such big. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Oleksiy <oleksiyy@ami.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Linson Augustine <Linson.augustine@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/UefiShellAcpiViewCommandLib: Replace shift logical leftShenglei Zhang2019-08-191-1/+1
| | | | | | | | | | | | | Replace the operation to shift logical left with the function LShiftU64, which has the same functionality. The original code causes ShellPkg build failure with build target"-b NOOPT". Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/UefiShellAcpiViewCommandLib: Initialize local variablesShenglei Zhang2019-08-162-0/+18
| | | | | | | | | | | At latest edk2 version, there is build failure when building ShellPkg with VS2012x86, which results from uninitialized local variables. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/UefiShellAcpiViewCommandLib: Remove the variable "Index"Shenglei Zhang2019-08-151-2/+0
| | | | | | | | | | | | | In IortParser.c ,the variable Index is set but not used in function DumpIortNodeNamedComponent. This will cause build failure when building ShellPkg with GCC. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/UefiShellAcpiViewCommandLib: Add missing header files in INFShenglei Zhang2019-08-131-0/+2
| | | | | | | | | | | | MadtParser.h and PpttParser.h are actually used but missing INF file, which will generate warning message when building this package. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Signed-off-by: Shenglei Zhang <shenglei.zhang@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg/UefiShellLevel2CommansLib: Pointer Resonse should be checkedGao, Zhichao2019-08-122-2/+8
| | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2049 ShellPkg\Library\UefiShellLevel2CommandsLib\Cp.c line 104 and ShellPkg\Library\UefiShellLevel2CommandsLib\Mv.c line 640, the pointer variable Response may be a NULL pointer. So we should make sure that it isn't NULL before dereference it. If Response is NULL that indicates a EFI_OUT_OF_RESOURCES error, directly return SHELL_ABORTED. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Signed-off-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
* ShellPkg: acpiview: SRAT: Prevent buffer overrunsKrzysztof Koch2019-08-121-1/+13
| | | | | | | | | | | | | | | | | | | Modify the SRAT parsing logic to prevent reading past the table buffer length provided. Check if the Static Resource Allocation Structure's buffer fits in the SRAT table buffer before its contents are dumped. Prevent buffer overruns when reading the Static Resource Allocation Structure's header. References: - ACPI 6.3, January 2019, Section 5.2.16 Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@inte.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* ShellPkg: acpiview: PPTT: Prevent buffer overrunsKrzysztof Koch2019-08-121-11/+27
| | | | | | | | | | | | | | | | | | | | | | | Modify the PPTT table parsing logic to prevent reading past the ACPI buffer lengths provided. Check if the Number of Private Resources specified in the Processor Hierarchy Node (Type 0) is possible given the Type 0 Structure's buffer length. Make sure that the processor topology structure's buffer fits in the PPTT table buffer before its contents are dumped. Prevent buffer overruns when reading the processor topology structure's header. References: - ACPI 6.3, January 2019, Section 5.2.29 Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@inte.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* ShellPkg: acpiview: MADT: Prevent buffer overrunsKrzysztof Koch2019-08-121-1/+1
| | | | | | | | | | Modify the parsing logic to prevent reading past the MADT table buffer length provided when parsing the Interrupt Controller Structure header. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@inte.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* ShellPkg: acpiview: IORT: Prevent buffer overrunsKrzysztof Koch2019-08-121-86/+105
| | | | | | | | | | | | | | | | | | | | | | | | Modify the IORT table parsing logic to prevent reading past the buffer lengths provided. Change DumpIortNodeIdMappings() function's signature and implementation to simplify buffer overrun prevention. Update all calls to this function accordingly. Modify the parser for each type of IORT node such that the offset from the start of the node's buffer is tracked as the parsing function is executed. Again, this change helps prevent buffer overruns. Test that the IORT node buffer fits in the table buffer before the node's buffer contents are dumped. References: - IO Remapping Table (Issue D), Platform Design Document, March 2018 Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@inte.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* ShellPkg: acpiview: GTDT: Prevent buffer overrunsKrzysztof Koch2019-08-121-73/+78
| | | | | | | | | | | | | | | | | | | | | | | | Modify the GTDT table parsing logic to prevent reading past the ACPI buffer lengths provided and to make it consistent with other table parsers. This includes converting the do-while loop in ParseAcpiGtdt() into a while loop. Remove a check which ensures that the entire Platform GT Block Structure buffer has been parsed. The ACPI specification does not ban from defining buffers which are larger than the size indicated by the count and sizes of substructures which constitute it. Change the data type of the Length parameter to the DumpGTBlock() function to reflect the width of the respective ACPI structure's field. References: - ACPI 6.3, January 2019, Table 5-124 Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@inte.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* ShellPkg: acpiview: DBG2: Prevent buffer overrunsKrzysztof Koch2019-08-121-49/+92
| | | | | | | | | | | | | | | | | | | | | | | | | Modify the DBG2 table parsing logic to prevent reading past the ACPI buffer lengths provided. Modify the signature of the DumpDbgDeviceInfo() function to make it consistent with the ACPI structure processing functions in other acpiview parsers. Now, the length of the Debug Device Information Structure is read before the entire structure is dumped. This refactoring change makes it easier to stop reading beyond the DBG2 table buffer if the Debug Device Information Structure Buffer does not fit in the DBG2 buffer. For processing the first two fields of the Debug Device Information Structure (to get the length) a new ACPI_PARSER array is defined. References: - Microsoft Debug Port Table 2 (DBG2), December 10, 2015 Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@inte.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* ShellPkg/UefiShellBcfgCommandLib: Fix '-opt' optionJonathan Watt2019-08-051-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | For all other bcfg commands the "#" (option number) argument(s) are treated as hexedecimal values regardless of whether or not they are prefixed by "0x". This change fixes '-opt' to handle its "#" (option number) argument consistently with the other commands. Making this change removes a potential footgun whereby a user that has been using a number without a "0x" prefix with other bcfg commands finds that, on using that exact same number with '-opt', it has this time unexpectedly been interpreted as a decimal number and they have modified (corrupted) an unrelated load option. For example, a user may have been specifying "10" to other commands to have them act on the 16th option (because simply "10", without any prefix, is how 'bcfg boot dump' displayed the option number for the 16th option). Unfortunately for them, if they also use '-opt' with "10" it would unexpectedly and inconsistently act on the 10th option. CC: Jaben Carsey <jaben.carsey@intel.com> CC: Ray Ni <ray.ni@intel.com> Signed-off-by: Jonathan Watt <jwatt@jwatt.org> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Bi Dandan <dandan.bi@intel.com>
* ShellPkg: Add shell with all commands integratedMichael D Kinney2019-08-051-1/+21
| | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=1970 Update ShellPkg DSC file to build an extra version of the Shell with all commands integrated. This verifies that the shell can build in this max configuration. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Tested-by: Sami Mujawar <sami.mujawar@arm.com>
* ShellPkg/AcpiView: Fix IA32 link errorMichael D Kinney2019-08-051-1/+1
| | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=1970 Update SLIT_ELEMENT() macro to use MultU64x64() to perform multiplication on 64-bit operands. This is required to avoid use of an intrinsic on IA32 VS20xx builds. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Zhichao Gao <zhichao.gao@intel.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Tested-by: Sami Mujawar <sami.mujawar@arm.com>