On Sun, 29 Mar 2020 at 17:14, Sami Mujawar <sami.muja...@arm.com> wrote: > > 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.muja...@arm.com> > Reviewed-by: Alexei Fedorov <alexei.fedo...@arm.com>
Reviewed-by: Ard Biesheuvel <ard.biesheu...@linaro.org> > --- > > Notes: > v2: > Splitting patch series and re-submitting DynamicTablesPkg [SAMI] > patches from https://edk2.groups.io/g/devel/message/46261 > > DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c > b/DynamicTablesPkg/Library/Acpi/Arm/AcpiPpttLibArm/PpttGenerator.c > index > 9e42eee9b75bb330833b0f56c98947563d9eb821..40699ce113caa8530c89ac20562cf5abda26b88e > 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; > > -- > 'Guid(CE165669-3EF3-493F-B85D-6190EE5B9759)' > > > > -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#56610): https://edk2.groups.io/g/devel/message/56610 Mute This Topic: https://groups.io/mt/72631538/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-