summaryrefslogtreecommitdiff
path: root/RedfishPkg
diff options
context:
space:
mode:
authorAbner Chang <abner.chang@amd.com>2023-11-23 18:26:12 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-12-05 03:27:03 +0000
commitcfafa45002983f686a0c33781ac02e55cf600548 (patch)
tree0a130d7c50612d28e01cc973f9fbd2581c718169 /RedfishPkg
parent4b5e2b3ac10f895d0bf2f80cbcddcecd85effe20 (diff)
downloadedk2-cfafa45002983f686a0c33781ac02e55cf600548.zip
edk2-cfafa45002983f686a0c33781ac02e55cf600548.tar.gz
edk2-cfafa45002983f686a0c33781ac02e55cf600548.tar.bz2
RedfishPkg/RedfishDiscovery: Refine SMBIOS 42h code
Refine SMBIOS 42h code add mode debug message for the error conditions. Signed-off-by: Abner Chang <abner.chang@amd.com> Cc: Nickle Wang <nicklew@nvidia.com> Cc: Igor Kulchytskyy <igork@ami.com> Cc: Mike Maslenkin <mike.maslenkin@gmail.com> Reviewed-by: Nickle Wang <nicklew@nvidia.com> Acked-by: Mike Maslenkin <mike.maslenkin@gmail.com>
Diffstat (limited to 'RedfishPkg')
-rw-r--r--RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h2
-rw-r--r--RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c20
2 files changed, 20 insertions, 2 deletions
diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
index e27cfa7..de7faa4 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishDiscoverInternal.h
@@ -42,6 +42,8 @@
#define MAC_COMPARE(This, Target) (CompareMem ((VOID *)&(This)->MacAddress, &(Target)->MacAddress, (This)->HwAddressSize) == 0)
#define VALID_TCP6(Target, This) ((Target)->IsIpv6 && ((This)->NetworkProtocolType == ProtocolTypeTcp6))
#define VALID_TCP4(Target, This) (!(Target)->IsIpv6 && ((This)->NetworkProtocolType == ProtocolTypeTcp4))
+#define REDFISH_HI_ITERFACE_SPECIFIC_DATA_LENGTH_OFFSET ((UINT16)(UINTN)(&((SMBIOS_TABLE_TYPE42 *)0)->InterfaceTypeSpecificDataLength))
+#define REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET ((UINT16)(UINTN)(&((REDFISH_OVER_IP_PROTOCOL_DATA *)0)->RedfishServiceHostnameLength))
//
// GUID definitions
diff --git a/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c b/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c
index 0d6edc7..57665f3 100644
--- a/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c
+++ b/RedfishPkg/RedfishDiscoverDxe/RedfishSmbiosHostInterface.c
@@ -56,7 +56,7 @@ RedfishGetHostInterfaceProtocolData (
mType42Record = (SMBIOS_TABLE_TYPE42 *)Record;
if (mType42Record->InterfaceType == MCHostInterfaceTypeNetworkHostInterface) {
ASSERT (Record->Length >= 9);
- Offset = 5;
+ Offset = REDFISH_HI_ITERFACE_SPECIFIC_DATA_LENGTH_OFFSET;
RecordTmp = (UINT8 *)Record + Offset;
//
// Get interface specific data length.
@@ -70,11 +70,13 @@ RedfishGetHostInterfaceProtocolData (
//
if ((*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) || (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_USB_V2)) {
if (*RecordTmp == REDFISH_HOST_INTERFACE_DEVICE_TYPE_PCI_PCIE_V2) {
+ // According to Redfish Host Interface specification, add additional one byte for Device Type field.
if (SpecificDataLen != sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1) {
ASSERT (SpecificDataLen == sizeof (PCI_OR_PCIE_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
return EFI_VOLUME_CORRUPTED;
}
} else {
+ // According to Redfish Host Interface specification, add additional one byte for Device Type field.
if (SpecificDataLen != sizeof (USB_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1) {
ASSERT (SpecificDataLen == sizeof (USB_INTERFACE_DEVICE_DESCRIPTOR_V2) + 1);
return EFI_VOLUME_CORRUPTED;
@@ -105,7 +107,14 @@ RedfishGetHostInterfaceProtocolData (
// This SMBIOS record is invalid, if the length of protocol specific data for
// Redfish Over IP protocol is wrong.
//
- if ((*(RecordTmp + 90) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1) != ProtocolLength) {
+ if ((*(RecordTmp + REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1) != ProtocolLength) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Length of protocol specific data is not match: %d != ProtocolLength(%d).\n",
+ __func__,
+ *(RecordTmp + REDFISH_HI_PROTOCOL_HOSTNAME_LENGTH_OFFSET) + sizeof (REDFISH_OVER_IP_PROTOCOL_DATA) - 1,
+ ProtocolLength
+ ));
return EFI_SECURITY_VIOLATION;
}
@@ -114,6 +123,13 @@ RedfishGetHostInterfaceProtocolData (
// This SMBIOS record is invalid, if the length is smaller than the offset.
//
if (Offset > mType42Record->Hdr.Length) {
+ DEBUG ((
+ DEBUG_ERROR,
+ "%a: Offset (%d) > mType42Record->Hdr.Length (%d).\n",
+ __func__,
+ Offset,
+ mType42Record->Hdr.Length
+ ));
return EFI_SECURITY_VIOLATION;
}