summaryrefslogtreecommitdiffstats
path: root/ShellPkg/Library/UefiShellAcpiViewCommandLib
Commit message (Collapse)AuthorAgeFilesLines
* ShellPkg: Rename Address Size to Access sizeJoey Gouly2021-04-191-2/+2
| | | | | | | | This matches the ACPI spec 6.3, table 5.1: Generic Address Structure. Signed-off-by: Joey Gouly <joey.gouly@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
* ShellPkg/AcpiView: HMAT ParserMarc Moisson-Franckhauser2021-02-035-0/+679
| | | | | | | | | | | | | | | | | Bugzilla: 3045 (https://bugzilla.tianocore.org/show_bug.cgi?id=3045) Add a new parser for the Heterogeneous Memory Attribute Table. The parser also validates some fields for this table. The HMAT table is used to describe the memory attributes such as memory side cache attributes and bandwidth and latency details related to memory proximity domains. The info in the HMAT table can be used by an operating system for optimisation. Signed-off-by: Marc Moisson-Franckhauser <marc.moisson-franckhauser@arm.com> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Tested-by: Vijayenthiran Subramaniam <vijayenthiran.subramaniam@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/Acpiview: AEST ParserMarc Moisson-Franckhauser2021-01-085-1/+781
| | | | | | | | | | | | | | | | | Bugzilla: 3048 (https://bugzilla.tianocore.org/show_bug.cgi?id=3048) Add a new parser for the Arm Error Source Table (AEST) described in the ACPI for the Armv8 RAS Extensions 1.1 Platform Design Document, dated 28 September 2020. (https://developer.arm.com/documentation/den0085/0101/) AEST enables kernel-first handling of errors in a system that supports the Armv8 RAS extensions. It covers Armv8.2+ RAS extensions for PEs and the RAS system architecture for non-PE system components. Signed-off-by: Marc Moisson-Franckhauser <marc.moisson-franckhauser@arm.com> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/AcpiView: PCCT ParserMarc Moisson-Franckhauser2020-12-116-5/+679
| | | | | | | | | | | | | | | | | | | | Bugzilla: 3047 (https://bugzilla.tianocore.org/show_bug.cgi?id=3047) Create a new parser for the PCCT Table. The PCCT Table is used to describe how the OSPM can communicate with entities outside the platform. It describes which memory spaces correspond to which entity as well as a few of the needed information to handle the communications. This new PCCT parser dumps the values and names of the table fields. It also performs some validation on the table's fields. Signed-off-by: Marc Moisson-Franckhauser <marc.moisson-franckhauser@arm.com> Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg/AcpiView: Fix field validator invocationSami Mujawar2020-12-111-8/+7
| | | | | | | | | | | | | | | | | | | | | | | | Bugzilla: 3046 (https://bugzilla.tianocore.org/show_bug.cgi?id=3046) The field validator function provides means to validate fields in the ACPI table structures. To print complex field types a print formatter function is provided. The field validator was being invoked for simple data fields for which the default print format is used. However, the field validator function was not invoked if a print formatter function was provided. This problem is noticed when a Generic Address Structure (GAS) is printed using DumpGas() and a field validator is present to validate the GAS structure. To fix this move the invocation of the field validator after the field is printed such that the validation function is called even when a print formatter function is present. Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: Add AcpiViewCommandLibTomas Pilar2020-06-304-49/+3
| | | | | | | | | | | | | | | The UefiShellAcpiViewCommandLib is converted from NULL library to a named library so that it may be used in modules other than shell. The library interface exposes the main method for to AcpiView functionality as well as a helper method to dump a buffer to a file. The Shell module is still built by pulling UefiShellAcpiViewCommandLib as a NULL library to preserve the modularity of shell builds. 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: Tomas Pilar <tomas.pilar@arm.com>
* ShellPkg/AcpiView: Refactor DumpAcpiTableToFileTomas Pilar2020-06-303-38/+76
| | | | | | | | | | | | | | Method is refactored into two parts. A new method is created that dumps arbitrary buffers into a newly created file. This method is called from core code after the core code determined the appropriate filename to be used. This improves the modular design. 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: Tomas Pilar <tomas.pilar@arm.com>
* ShellPkg/AcpiView: Move parameter parsingTomas Pilar2020-06-304-211/+240
| | | | | | | | | | | Parsing command line parameters is done in the shell command wrapper. This declutters the core code and improves modular design. 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: Tomas Pilar <tomas.pilar@arm.com>
* ShellPkg/AcpiView: Move table count resetTomas Pilar2020-06-301-3/+5
| | | | | | | | | | | The table count module level symbols are now reset when executing the core method, rather than the shell command wrapper. 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: Tomas Pilar <tomas.pilar@arm.com>
* ShellPkg/AcpiView: Refactor configurationTomas Pilar2020-06-3012-315/+479
| | | | | | | | | | | | | | A new file and header (AcpiViewConfig.[ch]) is created that houses the user configuration. This declutters the core code and improves modularity of the design. The module level symbols for verbosity, table selection, and highlighting are refactored into the new file. 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: Tomas Pilar <tomas.pilar@arm.com>
* ShellPkg/AcpiView: Move log reset to main methodTomas Pilar2020-06-301-4/+4
| | | | | | | | | | The error and warning counters are reset in the AcpiView main method. This improves reusability of the main method. 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: Tomas Pilar <tomas.pilar@arm.com>
* ShellPkg: acpiview: Check if SBBR mandatory ACPI tables are installedKrzysztof Koch2020-05-062-0/+38
| | | | | | | | | | | | | | | | | | | | | For Arm-based platforms, count the instances of installed tables for each ACPI table listed as 'mandatory' in any Server Base Boot Requirements (SBBR) specification. Validate that the all the mandatory SBBR tables present. Report an error for each missing table. This new feature is optional and can be enabled with the -r command line parameter. Reference(s): - Arm Server Base Boot Requirements 1.2, September 2019 - Arm Server Base Boot Requirements 1.1, May 2018 - Arm Server Base Boot Requirements 1.0, March 2016 Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Sami Mujawar <Sami.Mujawar@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: acpiview: Add library for SBBR ACPI requirements validationKrzysztof Koch2020-05-063-1/+318
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For Arm-based platforms, define and implement an interface for Server Base Boot Requirements (SBBR) compliance checks. The library is responsible for validating that all mandatory ACPI tables are installed on the platform. Internally, the library maintains a data structure which tracks instance counts for ACPI tables which are labeled as 'mandatory' in any SBBR specification version. The provided interface allows: - resetting all instance counts to 0 - incremementing the instance count for a table with a given signature - validating the instance counts against the requirements in SBBR The ACPI table requirements for each SBBR spec version are represented internally as a list of table signatures. Every missing mandatory table (for the input SBBR version) is reported to the user as a separate error. If all requirements are met, an info message is displayed. Reference(s): - Arm Server Base Boot Requirements 1.2, September 2019 - Arm Server Base Boot Requirements 1.1, May 2018 - Arm Server Base Boot Requirements 1.0, March 2016 Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Sami Mujawar <Sami.Mujawar@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: acpiview: Add -r parameter for table requirements validationKrzysztof Koch2020-05-063-4/+136
| | | | | | | | | | | | | | | | | | | | | | | Define a new command line parameter '-r' to enable checking if all mandatory ACPI tables listed in a specification are present. The -r parameter takes an integer value to specify which specification the validation should be performed against. The parameter is used to set two Acpiview variables. An interface to access these variables is implemented in this patch. The new functionality is aimed at Arm-based platforms, however, there are no restriction on extending it to other architectures. For the 32-bit and 64-bit Arm architectures, the possible values for the -r parameter are: 0: Arm Server Base Boot Requirements 1.0, March 2016 1: Arm Server Base Boot Requirements 1.1, May 2018 2: Arm Server Base Boot Requirements 1.2, September 2019 Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Sami Mujawar <Sami.Mujawar@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: acpiview: Prevent infinite loop if structure length is 0Krzysztof Koch2020-02-206-52/+47
| | | | | | | | | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2534 Extend validation of ACPI structure lengths which are read from the ACPI table being parsed. Additionally check if the structure 'Length' field value is positive. If not, stop parsing the faulting table. Some ACPI tables define internal structures of variable size. The 'Length' field inside the substructure is used to update a pointer used for table traversal. If the byte-length of the structure is equal to 0, acpiview can enter an infinite loop. This condition can occur if, for example, the zero-allocated ACPI table buffer is not fully populated. This is typically a bug on the ACPI table writer side. In short, this method helps acpiview recover gracefully from a zero-valued ACPI structure length. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: acpiview: Validate ACPI table 'Length' fieldKrzysztof Koch2020-02-191-1/+19
| | | | | | | | | | | | Check if the ACPI table length, as reported in the ACPI table header, is big enough to fit at least the header itself. If not, report an error to the user and stop parsing the table in order to prevent buffer overruns. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: acpiview: Remove duplicate ACPI structure size definitionsKrzysztof Koch2020-02-192-25/+5
| | | | | | | | | | | | | | | | | | | | Remove duplicate Generic Address Structure (GAS) and ACPI table header size definitions. Replace any dependencies with the definitions from Acpi63.h. AcpiParser.h redefines the size of Generic Address Structure (GAS) and the ACPI table header. The motivation is to 'minimise any reference to the EDK2 ACPI headers in an attempt to provide cross checking'. While the redefined values are unlikely to change, redefinition causes unnecessary maintenance overhead for acpiview. In addition to this, EDK2 ACPI headers are referenced throughout the entire project, so the assumption should be that the definitions in these header files are correct. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: acpiview: DBG2: Validate global pointers before useKrzysztof Koch2020-02-111-0/+43
| | | | | | | Check if global (in the scope of the DBG2 parser) pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
* ShellPkg: acpiview: GTDT: Validate global pointers before useKrzysztof Koch2020-02-111-0/+37
| | | | | | | Check if global (in the scope of the GTDT parser) pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
* ShellPkg: acpiview: IORT: Validate global pointers before useKrzysztof Koch2020-02-111-0/+52
| | | | | | | Check if global (in the scope of the IORT parser) pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
* ShellPkg: acpiview: PPTT: Validate global pointers before useKrzysztof Koch2020-02-111-0/+25
| | | | | | | | Check if the NumberOfPrivateResources, ProcessorTopologyStructureType and ProcessorTopologyStructureLength pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
* ShellPkg: acpiview: MADT: Validate global pointers before useKrzysztof Koch2020-02-111-0/+13
| | | | | | | | Check if the MadtInterruptControllerType and MadtInterruptControllerLength pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
* ShellPkg: acpiview: SRAT: Validate global pointers before useKrzysztof Koch2020-02-111-0/+13
| | | | | | | Check if SratRAType and SratRALength pointers have been successfully updated before they are used for further table parsing. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
* 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/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: 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: 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/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: 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/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>
* ShellPkg: acpiview: IORT: Refactor PMCG node mapping count validationKrzysztof Koch2019-07-311-9/+23
| | | | | | | | | | | | | | | | Move Performance Monitoring Counter Group (PMCG) node ID mapping count validation from the core IORT acpiview parser logic to a dedicated function. Now, the pointer to the validation function is passed to the IortNodePmcgParser[] ACPI_PARSER array. This check does not affect the flow of IORT parsing and is limited to a single table field in scope, therefore, it is better to keep it away from the code responsible for traversing the table. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: acpiview: MADT: Split structure length validationKrzysztof Koch2019-07-311-8/+22
| | | | | | | | | | | | | | | | | | | Split the Interrupt Controller Structure length validation in the acpiview UEFI shell tool into two logical parts: 1. Ensuring MADT table parser forward progress. 2. Preventing MADT table buffer overruns. Also, make the condition for infinite loop detection applicable to all types of Interrupt Controller Structures (for all interrupt models which can be represented in MADT). Check if the controller length specified is shorter than the byte size of the first two fields ('Type' and 'Length') present in every valid Interrupt Controller Structure. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: acpiview: SRAT: Minor code style enhancementsKrzysztof Koch2019-07-311-1/+2
| | | | | | | | | | Minor changes to the SRAT parser code to conform with the EDKII coding style and to make it consistent with other ACPI table parsers. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: acpiview: RSDP: Make code consistent with other parsersKrzysztof Koch2019-07-311-2/+9
| | | | | | | | | | | | | | | | | List ParseAcpi() function arguments one per line in order to make this function call consistent with ParseAcpi() calls in other ACPI table parsers. Also, notify the user that XsdtAddress value of 0 results in RSDP parsing being terminated and that the XSDT table will not be processed. This effectively means that no more ACPI tables will be parsed because of this RSDP table content error. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: acpiview: XSDT: Remove redundant ParseAcpi() callKrzysztof Koch2019-07-311-14/+4
| | | | | | | | | | | | | | Remove a call to ParseAcpi() responsible for getting the XSDT table length. This call is not needed because the ACPI table buffer length is provided as an input argument to the ParseAcpiXsdt() function. Modify remaining code to use the AcpiTableLength argument of the ParseAcpiXsdt() function instead of a global static variable. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: acpiview: Allow passing buffer length to DumpGasStruct()Krzysztof Koch2019-07-313-14/+22
| | | | | | | | | | | | | | | | | Modify the signature of the DumpGasStruct() function to include the buffer length parameter and to return the number of bytes parsed by the function. This way it becomes possible to prevent buffer overruns when dumping Generic Address Structure's (GAS) fields in the acpiview table parsers. Update all existing DumpGasStruct() calls in acpiview to add the length argument. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
* ShellPkg: acpiview: DBG2: Remove redundant forward declarationsKrzysztof Koch2019-07-191-46/+16
| | | | | | | | | | | | Remove redundant forward function declarations by repositioning blocks of code. This way the code structure is consistent across ACPI table parsers and the code becomes more concise. Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com> Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>