From: "PierreGondois" <pierre.gondois@arm.com>
To: devel@edk2.groups.io
Cc: Pierre Gondois <pierre.gondois@arm.com>,
AbdulLateef Attar <AbdulLateef.Attar@amd.com>,
Girish Mahadevan <gmahadevan@nvidia.com>,
Jeff Brasen <jbrasen@nvidia.com>,
Jeshua Smith <jeshuas@nvidia.com>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>,
Sami Mujawar <sami.mujawar@arm.com>,
Sunil V L <sunilvl@ventanamicro.com>,
Yeo Reum Yun <YeoReum.Yun@arm.com>,
Pierre Gondois <Pierre.Gondois@arm.com>
Subject: [edk2-devel] [staging/dynamictables-reorg PATCH 1/2] DynamicTablesPkg: Fix conversion compiler warnings
Date: Wed, 3 Jul 2024 11:53:39 +0200 [thread overview]
Message-ID: <20240703095340.3402057-2-pierre.gondois@arm.com> (raw)
In-Reply-To: <20240703095340.3402057-1-pierre.gondois@arm.com>
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>
---
.../Acpi/Common/AcpiPcctLib/PcctGenerator.c | 15 +++++++++++----
.../SsdtCpuTopologyGenerator.c | 6 ++++--
.../Common/AcpiSsdtPcieLib/SsdtPcieGenerator.c | 15 ++++++++++-----
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 205c44405785..061e12bf1b3d 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 >> 8) == 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 >> 8) == 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 >> 8) == 0);
+ ASSERT ((GenericPccCmObj->AddressLength >> 32) == 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 74595131935c..f82b7449713c 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 >> 16) == 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 >> 16) == 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 5b6d5515622b..3dcca2b33987 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 >> 32) == 0);
+ ASSERT (((AddrMapInfo->PciAddress + AddrMapInfo->AddressSize - 1) >> 32) == 0);
+ ASSERT (((Translation ? AddrMapInfo->CpuAddress - AddrMapInfo->PciAddress : 0) >> 32) == 0);
+ ASSERT ((AddrMapInfo->AddressSize >> 32) == 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,
--
2.25.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119778): https://edk2.groups.io/g/devel/message/119778
Mute This Topic: https://groups.io/mt/107016603/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-07-03 9:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-03 9:53 [edk2-devel] [staging/dynamictables-reorg PATCH 0/2] DynamicTablesPkg: CI related fixes PierreGondois
2024-07-03 9:53 ` PierreGondois [this message]
2024-07-03 10:35 ` [edk2-devel] [staging/dynamictables-reorg PATCH 1/2] DynamicTablesPkg: Fix conversion compiler warnings Sami Mujawar
2024-07-03 10:44 ` PierreGondois
2024-07-03 9:53 ` [edk2-devel] [staging/dynamictables-reorg PATCH 2/2] DynamicTablesPkg: Add EFIAPI to generators hooks PierreGondois
2024-07-03 10:36 ` Sami Mujawar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240703095340.3402057-2-pierre.gondois@arm.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox