summaryrefslogtreecommitdiffstats
path: root/DynamicTablesPkg/Library
diff options
context:
space:
mode:
authorPierre Gondois <pierre.gondois@arm.com>2024-07-03 11:53:39 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-07-29 13:44:55 +0000
commit7537028fa5ab071d9ae686212437b92f1a0ce490 (patch)
treeaa9bd881c52d22cfa9baad46a11d835dfea4554f /DynamicTablesPkg/Library
parent40a0dbdd18fe6303a71113e7e9c49f45042e692b (diff)
downloadedk2-7537028fa5ab071d9ae686212437b92f1a0ce490.tar.gz
edk2-7537028fa5ab071d9ae686212437b92f1a0ce490.tar.bz2
edk2-7537028fa5ab071d9ae686212437b92f1a0ce490.zip
DynamicTablesPkg: Fix conversion compiler warnings
Some CM objects fields are wider than the targeted field in ACPI tables. Some assignments are also subject to data loss and trigger the following warnings: - '<': signed/unsigned mismatch - '=': conversion from 'UINTxx' to 'UINTyy', possible loss of data with xx > yy. Add checks/cast to remove the warnings. Signed-off-by: Pierre Gondois <Pierre.Gondois@arm.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
Diffstat (limited to 'DynamicTablesPkg/Library')
-rw-r--r--DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/PcctGenerator.c15
-rw-r--r--DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyGenerator.c6
-rw-r--r--DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c15
3 files changed, 25 insertions, 11 deletions
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/PcctGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/PcctGenerator.c
index 205c444057..ef5d8823c2 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/PcctGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiPcctLib/PcctGenerator.c
@@ -379,10 +379,12 @@ AddSubspaceStructType1 (
Doorbell = &GenericPccCmObj->DoorbellReg;
ChannelTiming = &GenericPccCmObj->ChannelTiming;
+ ASSERT ((PccCmObj->PlatIrq.Flags & ~MAX_UINT8) == 0);
+
PccAcpi->Type = GenericPccCmObj->Type;
PccAcpi->Length = sizeof (EFI_ACPI_6_4_PCCT_SUBSPACE_1_HW_REDUCED_COMMUNICATIONS);
PccAcpi->PlatformInterrupt = PccCmObj->PlatIrq.Interrupt;
- PccAcpi->PlatformInterruptFlags = PccCmObj->PlatIrq.Flags;
+ PccAcpi->PlatformInterruptFlags = (UINT8)PccCmObj->PlatIrq.Flags;
PccAcpi->Reserved = EFI_ACPI_RESERVED_BYTE;
PccAcpi->BaseAddress = GenericPccCmObj->BaseAddress;
PccAcpi->AddressLength = GenericPccCmObj->AddressLength;
@@ -441,10 +443,12 @@ AddSubspaceStructType2 (
PlatIrqAck = &PccCmObj->PlatIrqAckReg;
ChannelTiming = &GenericPccCmObj->ChannelTiming;
+ ASSERT ((PccCmObj->PlatIrq.Flags & ~MAX_UINT8) == 0);
+
PccAcpi->Type = GenericPccCmObj->Type;
PccAcpi->Length = sizeof (EFI_ACPI_6_4_PCCT_SUBSPACE_2_HW_REDUCED_COMMUNICATIONS);
PccAcpi->PlatformInterrupt = PccCmObj->PlatIrq.Interrupt;
- PccAcpi->PlatformInterruptFlags = PccCmObj->PlatIrq.Flags;
+ PccAcpi->PlatformInterruptFlags = (UINT8)PccCmObj->PlatIrq.Flags;
PccAcpi->BaseAddress = GenericPccCmObj->BaseAddress;
PccAcpi->Reserved = EFI_ACPI_RESERVED_BYTE;
PccAcpi->BaseAddress = GenericPccCmObj->BaseAddress;
@@ -519,13 +523,16 @@ AddSubspaceStructType34 (
ErrorStatus = &PccCmObj->ErrorStatusReg;
ChannelTiming = &GenericPccCmObj->ChannelTiming;
+ ASSERT ((PccCmObj->PlatIrq.Flags & ~MAX_UINT8) == 0);
+ ASSERT ((GenericPccCmObj->AddressLength & ~MAX_UINT32) == 0);
+
PccAcpi->Type = GenericPccCmObj->Type;
PccAcpi->Length = sizeof (EFI_ACPI_6_4_PCCT_SUBSPACE_3_EXTENDED_PCC);
PccAcpi->PlatformInterrupt = PccCmObj->PlatIrq.Interrupt;
- PccAcpi->PlatformInterruptFlags = PccCmObj->PlatIrq.Flags;
+ PccAcpi->PlatformInterruptFlags = (UINT8)PccCmObj->PlatIrq.Flags;
PccAcpi->Reserved = EFI_ACPI_RESERVED_BYTE;
PccAcpi->BaseAddress = GenericPccCmObj->BaseAddress;
- PccAcpi->AddressLength = GenericPccCmObj->AddressLength;
+ PccAcpi->AddressLength = (UINT32)GenericPccCmObj->AddressLength;
CopyMem (
&PccAcpi->DoorbellRegister,
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyGenerator.c
index 7459513193..9097ac3deb 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtCpuTopologyLib/SsdtCpuTopologyGenerator.c
@@ -1026,7 +1026,8 @@ CreateAmlCpuTopologyTree (
if (Generator->ProcNodeList[Index].OverrideNameUidEnabled) {
Name = Generator->ProcNodeList[Index].OverrideName;
} else {
- Name = CpuIndex;
+ ASSERT ((CpuIndex & ~MAX_UINT16) == 0);
+ Name = (UINT16)CpuIndex;
}
Status = CreateAmlCpuFromProcHierarchy (
@@ -1061,7 +1062,8 @@ CreateAmlCpuTopologyTree (
Name = Generator->ProcNodeList[Index].OverrideName;
Uid = Generator->ProcNodeList[Index].OverrideUid;
} else {
- Name = ProcContainerName;
+ ASSERT ((ProcContainerName & ~MAX_UINT16) == 0);
+ Name = (UINT16)ProcContainerName;
Uid = *ProcContainerIndex;
}
diff --git a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c
index 5b6d551562..618056e85a 100644
--- a/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c
+++ b/DynamicTablesPkg/Library/Acpi/Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c
@@ -311,7 +311,7 @@ GeneratePrt (
)
{
EFI_STATUS Status;
- INT32 Index;
+ UINT32 Index;
AML_OBJECT_NODE_HANDLE PrtNode;
CM_ARCH_COMMON_OBJ_REF *RefInfo;
UINT32 RefCount;
@@ -561,6 +561,11 @@ GeneratePciCrs (
break;
case PCI_SS_M32:
+ ASSERT ((AddrMapInfo->PciAddress & ~MAX_UINT32) == 0);
+ ASSERT (((AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1) & ~MAX_UINT32) == 0);
+ ASSERT (((Translation ? AddrMapInfo->CpuAddress - AddrMapInfo->PciAddress : 0) & ~MAX_UINT32) == 0);
+ ASSERT ((AddrMapInfo->AddressSize & ~MAX_UINT32) == 0);
+
Status = AmlCodeGenRdDWordMemory (
FALSE,
IsPosDecode,
@@ -569,10 +574,10 @@ GeneratePciCrs (
AmlMemoryCacheable,
TRUE,
0,
- AddrMapInfo->PciAddress,
- AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1,
- Translation ? AddrMapInfo->CpuAddress - AddrMapInfo->PciAddress : 0,
- AddrMapInfo->AddressSize,
+ (UINT32)(AddrMapInfo->PciAddress),
+ (UINT32)(AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1),
+ (UINT32)(Translation ? AddrMapInfo->CpuAddress - AddrMapInfo->PciAddress : 0),
+ (UINT32)(AddrMapInfo->AddressSize),
0,
NULL,
AmlAddressRangeMemory,