From mboxrd@z Thu Jan 1 00:00:00 1970 Subject: Recent changes to EsrtFmp causing ASSERTs To: devel@edk2.groups.io From: jason.spottswood@hpe.com X-Originating-Location: Texas, US (15.203.233.76) X-Originating-Platform: Windows Chrome 77 User-Agent: GROUPS.IO Web Poster MIME-Version: 1.0 Date: Mon, 30 Sep 2019 13:48:16 -0700 Message-ID: <19681.1569876496768913642@groups.io> Content-Type: multipart/alternative; boundary="XPMKTo5DhyK12ZtlwNXs" --XPMKTo5DhyK12ZtlwNXs Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable In EsrtFmp.c, function CreateEsrtEntry, line 196, the code asserts if the F= MP image hardware instance matches that of an existing instance.=C2=A0 This= is fine if the hardware instance is supported.=C2=A0 The field is optional= though.=C2=A0 In the UEFI spec, "a zero hardware instance means the FMP pr= ovider is not able to determine a unique hardware instance number or a hard= ware instance number is not needed."=C2=A0 The code below needs to also che= ck if the hardware instance is supported (by comparing it to zero) before c= hecking it against existing entries. // // Check to see of FmpImageInfoBuf GUID/HardwareInstance is unique // for (Index =3D 0; Index < *NumberOfDescriptors; Index++) { if ( CompareGuid (&HardwareInstances[Index].ImageTypeGuid, &FmpImageInf= oBuf->ImageTypeId)) { if (HardwareInstances[Index].HardwareInstance =3D=3D FmpHardwareInsta= nce) { DEBUG ((DEBUG_ERROR, "EsrtFmpDxe: Duplicate firmware image descript= or with GUID %g HardwareInstance:0x%x\n", &FmpImageInfoBuf->ImageTypeId, Fm= pHardwareInstance)); ASSERT ( ! CompareGuid (&HardwareInstances[Index].ImageTypeGuid, &FmpImage= InfoBuf->ImageTypeId) || HardwareInstances[Index].HardwareInstance !=3D FmpHardwareInstanc= e ); return EFI_UNSUPPORTED; } } } --XPMKTo5DhyK12ZtlwNXs Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable In EsrtFmp.c, function CreateEsrtEntry, line 196, the code asserts if the F= MP image hardware instance matches that of an existing instance.  This= is fine if the hardware instance is supported.  The field is optional= though.  In the UEFI spec, "a zero hardware instance means the FMP pr= ovider is not able to determine a unique hardware instance number or a hard= ware instance number is not needed."  The code below needs to also che= ck if the hardware instance is supported (by comparing it to zero) before c= hecking it against existing entries.

  //
  // Check to see of FmpImageInfoBuf GUID/HardwareInstance is unique
  //
  for (Index =3D 0; Index < *NumberOfDescriptors; Index++) {
    if (CompareGuid (&Hard=
wareInstances[Index].ImageTypeGuid, &FmpImageInfoBuf->ImageTypeId)) =
{
      if (HardwareInstances[Index].HardwareInstance =3D=3D FmpHardwareInst=
ance) {
        DEBUG ((DEBUG_ERROR, "=
EsrtFmpDxe: Duplicate firmware image descriptor with GUID %g HardwareInstan=
ce:0x%x\n", &FmpImageInfoBuf->ImageTypeId, FmpHardwareInstance));
        ASSERT (
          !CompareGuid (&H=
ardwareInstances[Index].ImageTypeGuid, &FmpImageInfoBuf->ImageTypeId=
) ||
          HardwareInstances[Index].HardwareInstance !=3D FmpHardwareInstan=
ce
          );
        return EFI_UNSUPPORTED;
      }
    }
  }
--XPMKTo5DhyK12ZtlwNXs--