ShellPkg: acpiview: Improve PPTT table field validation

Add Cache Structure (Type 1) 'Number of sets' and 'Associativity'
field validation in the acpiview Processor Properties Topology
Table (PPTT) parser.

Replace literal values with precompiler macros for existing
Cache Structure validation functions.

Signed-off-by: Krzysztof Koch <krzysztof.koch@arm.com>
Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
Reviewed-by: Zhichao Gao <zhichao.gao@intel.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
This commit is contained in:
Krzysztof Koch
2019-06-28 18:24:35 +08:00
committed by Ray Ni
parent e53303ca05
commit 5a27f7a237
2 changed files with 130 additions and 10 deletions

View File

@@ -5,12 +5,15 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
@par Reference(s):
- ACPI 6.2 Specification - Errata A, September 2017
- ACPI 6.3 Specification - January 2019
- ARM Architecture Reference Manual ARMv8 (D.a)
**/
#include <Library/PrintLib.h>
#include <Library/UefiLib.h>
#include "AcpiParser.h"
#include "AcpiView.h"
#include "PpttParser.h"
// Local variables
STATIC CONST UINT8* ProcessorTopologyStructureType;
@@ -19,11 +22,80 @@ STATIC CONST UINT32* NumberOfPrivateResources;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
An ACPI_PARSER array describing the ACPI PPTT Table.
This function validates the Cache Type Structure (Type 1) 'Number of sets'
field.
@param [in] Ptr Pointer to the start of the field data.
@param [in] Context Pointer to context specific information e.g. this
could be a pointer to the ACPI table header.
**/
STATIC CONST ACPI_PARSER PpttParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo)
};
STATIC
VOID
EFIAPI
ValidateCacheNumberOfSets (
IN UINT8* Ptr,
IN VOID* Context
)
{
UINT32 NumberOfSets;
NumberOfSets = *(UINT32*)Ptr;
if (NumberOfSets == 0) {
IncrementErrorCount ();
Print (L"\nERROR: Cache number of sets must be greater than 0");
return;
}
#if defined(MDE_CPU_ARM) || defined (MDE_CPU_AARCH64)
if (NumberOfSets > PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX) {
IncrementErrorCount ();
Print (
L"\nERROR: When ARMv8.3-CCIDX is implemented the maximum cache number of "
L"sets must be less than or equal to %d",
PPTT_ARM_CCIDX_CACHE_NUMBER_OF_SETS_MAX
);
return;
}
if (NumberOfSets > PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX) {
IncrementWarningCount ();
Print (
L"\nWARNING: Without ARMv8.3-CCIDX, the maximum cache number of sets "
L"must be less than or equal to %d. Ignore this message if "
L"ARMv8.3-CCIDX is implemented",
PPTT_ARM_CACHE_NUMBER_OF_SETS_MAX
);
return;
}
#endif
}
/**
This function validates the Cache Type Structure (Type 1) 'Associativity'
field.
@param [in] Ptr Pointer to the start of the field data.
@param [in] Context Pointer to context specific information e.g. this
could be a pointer to the ACPI table header.
**/
STATIC
VOID
EFIAPI
ValidateCacheAssociativity (
IN UINT8* Ptr,
IN VOID* Context
)
{
UINT8 Associativity;
Associativity = *(UINT8*)Ptr;
if (Associativity == 0) {
IncrementErrorCount ();
Print (L"\nERROR: Cache associativity must be greater than 0");
return;
}
}
/**
This function validates the Cache Type Structure (Type 1) Line size field.
@@ -49,11 +121,14 @@ ValidateCacheLineSize (
UINT16 LineSize;
LineSize = *(UINT16*)Ptr;
if ((LineSize < 16) || (LineSize > 2048)) {
if ((LineSize < PPTT_ARM_CACHE_LINE_SIZE_MIN) ||
(LineSize > PPTT_ARM_CACHE_LINE_SIZE_MAX)) {
IncrementErrorCount ();
Print (
L"\nERROR: The cache line size must be between 16 and 2048 bytes"
L" on ARM Platforms."
L"\nERROR: The cache line size must be between %d and %d bytes"
L" on ARM Platforms.",
PPTT_ARM_CACHE_LINE_SIZE_MIN,
PPTT_ARM_CACHE_LINE_SIZE_MAX
);
return;
}
@@ -96,6 +171,13 @@ ValidateCacheAttributes (
}
}
/**
An ACPI_PARSER array describing the ACPI PPTT Table.
**/
STATIC CONST ACPI_PARSER PpttParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo)
};
/**
An ACPI_PARSER array describing the processor topology structure header.
**/
@@ -133,8 +215,8 @@ STATIC CONST ACPI_PARSER CacheTypeStructureParser[] = {
{L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
{L"Next Level of Cache", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
{L"Size", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
{L"Number of sets", 4, 16, L"%d", NULL, NULL, NULL, NULL},
{L"Associativity", 1, 20, L"%d", NULL, NULL, NULL, NULL},
{L"Number of sets", 4, 16, L"%d", NULL, NULL, ValidateCacheNumberOfSets, NULL},
{L"Associativity", 1, 20, L"%d", NULL, NULL, ValidateCacheAssociativity, NULL},
{L"Attributes", 1, 21, L"0x%x", NULL, NULL, ValidateCacheAttributes, NULL},
{L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, NULL}
};