summaryrefslogtreecommitdiffstats
path: root/DynamicTablesPkg
diff options
context:
space:
mode:
authorSami Mujawar <sami.mujawar@arm.com>2019-07-09 13:35:02 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2020-03-29 16:53:35 +0000
commit96bb6704e036a2fb66d41d4ab95e976bcaab7a82 (patch)
treeeaf8123884e821edc3bb5aa363981246467cd0ee /DynamicTablesPkg
parent869f234140fd9b11ad9b77fd071164e4be873fb0 (diff)
downloadedk2-96bb6704e036a2fb66d41d4ab95e976bcaab7a82.tar.gz
edk2-96bb6704e036a2fb66d41d4ab95e976bcaab7a82.tar.bz2
edk2-96bb6704e036a2fb66d41d4ab95e976bcaab7a82.zip
DynamicTablesPkg: Fix Proc node length assignment
The length field for the Processor Hierarchy node structure is 8-bit wide while the number of private resource field is 32-bit wide. Therefore, the GetProcHierarchyNodeSize() returns the size as a 32-bit value. The VS2017 compiler reports 'warning C4244: '=': conversion from 'UINT32' to 'UINT8', possible loss of data' while assigning the length field of the Processor Hierarchy node structure. To fix this, a type cast is added. In addition, there is a check to ensure that the Processor Hierarchy node size does not exceed MAX_UINT8. Signed-off-by: Sami Mujawar <sami.mujawar@arm.com> Reviewed-by: Alexei Fedorov <Alexei.Fedorov@arm.com>
Diffstat (limited to 'DynamicTablesPkg')
-rw-r--r--DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c
index 9e42eee9b7..40699ce113 100644
--- a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c
@@ -504,6 +504,7 @@ AddProcHierarchyNodes (
PPTT_NODE_INDEXER * ProcNodeIterator;
UINT32 NodeCount;
+ UINT32 Length;
ASSERT (
(Generator != NULL) &&
@@ -539,8 +540,8 @@ AddProcHierarchyNodes (
// imposed on the Processor Hierarchy node by the specification.
// Note: The length field is 8 bit wide while the number of private
// resource field is 32 bit wide.
- if ((sizeof (EFI_ACPI_6_3_PPTT_STRUCTURE_PROCESSOR) +
- (ProcInfoNode->NoOfPrivateResources * sizeof (UINT32))) > MAX_UINT8) {
+ Length = GetProcHierarchyNodeSize (ProcInfoNode);
+ if (Length > MAX_UINT8) {
Status = EFI_INVALID_PARAMETER;
DEBUG ((
DEBUG_ERROR,
@@ -556,7 +557,7 @@ AddProcHierarchyNodes (
// Populate the node header
ProcStruct->Type = EFI_ACPI_6_3_PPTT_TYPE_PROCESSOR;
- ProcStruct->Length = GetProcHierarchyNodeSize (ProcInfoNode);
+ ProcStruct->Length = (UINT8)Length;
ProcStruct->Reserved[0] = EFI_ACPI_RESERVED_BYTE;
ProcStruct->Reserved[1] = EFI_ACPI_RESERVED_BYTE;