From: "Dan Callaghan" <djc@djc.id.au>
To: devel@edk2.groups.io
Cc: Jon Nettleton <jon@solid-run.com>,
Leif Lindholm <quic_llindhol@quicinc.com>,
Meenakshi Aggarwal <meenakshi.aggarwal@nxp.com>,
Dan Callaghan <djc@djc.id.au>
Subject: [edk2-platform][PATCH] Silicon/NXP: avoid integer overflow when computing Serdes protocol map
Date: Sun, 7 Aug 2022 11:16:37 +1000 [thread overview]
Message-ID: <20220807011637.929232-1-djc@djc.id.au> (raw)
SerDesProtocolMap is a UINT64, but BIT0 is an unadorned int. Shifting
BIT0 left by more than 31 bits is undefined behaviour. This would cause
SerDesProtocolMap to be filled with incorrect values when using Serdes
protocols numbered 32 and above, such as the SGMII protocols.
This fixes a hang at boot time on the Solidrun Honeycomb with SERDES
configuration 4_5_2.
Signed-off-by: Dan Callaghan <djc@djc.id.au>
---
Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c | 2 +-
Silicon/NXP/Library/SerDesHelperLib/SerDesHelperLib.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
index 7f11d7a602..127eb3e175 100644
--- a/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
+++ b/Silicon/NXP/Library/PciHostBridgeLib/PciHostBridgeLib.c
@@ -748,7 +748,7 @@ IsPcieNumEnabled(
// Reading serdes protocol map
GetSerDesProtocolMap (&SerDesProtocolMap);
- return (SerDesProtocolMap & (BIT0 << (PcieNum))) != 0;
+ return (SerDesProtocolMap & ((UINT64) BIT0 << (PcieNum))) != 0;
}
/**
diff --git a/Silicon/NXP/Library/SerDesHelperLib/SerDesHelperLib.c b/Silicon/NXP/Library/SerDesHelperLib/SerDesHelperLib.c
index 1e8158541c..62a32d5caf 100644
--- a/Silicon/NXP/Library/SerDesHelperLib/SerDesHelperLib.c
+++ b/Silicon/NXP/Library/SerDesHelperLib/SerDesHelperLib.c
@@ -157,7 +157,7 @@ GetSerDesMap (
DEBUG ((DEBUG_ERROR, "Unknown SerDes lane protocol %d\n", LaneProtocol));
return EFI_NO_MAPPING;
}
- *SerDesProtocolMap |= (BIT0 << (LaneProtocol));
+ *SerDesProtocolMap |= ((UINT64) BIT0 << (LaneProtocol));
}
return EFI_SUCCESS;
--
2.36.0
reply other threads:[~2022-08-07 1:23 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20220807011637.929232-1-djc@djc.id.au \
--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