From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga18.intel.com (mga18.intel.com [134.134.136.126]) by mx.groups.io with SMTP id smtpd.web10.8439.1655995718478610967 for ; Thu, 23 Jun 2022 07:48:38 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=TdgmsH6q; spf=pass (domain: intel.com, ip: 134.134.136.126, mailfrom: jason1.lin@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655995718; x=1687531718; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=PvrIx8CrSna0uipgjkwoAWmhR7Kxkrh4KndKdvNytZ8=; b=TdgmsH6qAO0YfHJtYj7vJRo7ITm2S5s0kqVazwVIS6zOmercf6mUS/3l mFCj1UNoZvO8wh2ottK/UZJxgl9smPpehr5bReZ7TUWS4nmF2QR3hpF+s t9wpUD14nrqyzTwWrvJ1Gh/1vchiihJJ0G7rmBeXVzeZLUFnEv+ZPPVJx PrYTmO50m9XkafDH8uAyL/3BTs22zRi6ssZnspyEMBB6Hyq50R4kv4OBI xmJhJWhTqikvHT+MK73stTz5WEFnJ0eHW2q0M5P+ZGD3L1XurCi5J4VRI ww5tU5w2eOe26lqI9LFJTE90DKk1xiNML2xGBjGI178HgIpEyaIqqAKyg A==; X-IronPort-AV: E=McAfee;i="6400,9594,10386"; a="263771222" X-IronPort-AV: E=Sophos;i="5.92,216,1650956400"; d="scan'208";a="263771222" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga106.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Jun 2022 07:48:37 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,216,1650956400"; d="scan'208";a="538913714" Received: from linjaso1-desk1.gar.corp.intel.com ([10.5.215.41]) by orsmga003.jf.intel.com with ESMTP; 23 Jun 2022 07:48:35 -0700 From: "Lin, Jason1" To: devel@edk2.groups.io Cc: Jason1 Lin , Bob Feng , Liming Gao , Yuwei Chen , Isaac W Oram , Rangasai V Chaganty , Dakota Chiang Subject: [PATCH v2 2/2] [edk2-platforms] Silicon/Intel/FitGen: Support to override the MBZ byte in Startup ACM entries for other usages Date: Thu, 23 Jun 2022 22:48:33 +0800 Message-Id: <20220623144833.3215-1-jason1.lin@intel.com> X-Mailer: git-send-email 2.26.2.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jason1 Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3959 As per FIT BIOS Specification 1.2 Rules, the size bytes (3 bytes)/ reserved byte (1 byte) / CheckSum byte (1 byte) in type 2 are must-be-zero = (MBZ). These bytes could be override for the other usages. In the future, if these bytes field have other meanings, there would be no = need to change the FitGen. Command: [-S |] [-I ] [-V ] With "-I" input the default Type 2 entry version would be 0x200. Signed-off-by: Jason1 Lin Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Cc: Isaac W Oram Cc: Rangasai V Chaganty Cc: Dakota Chiang --- Silicon/Intel/Tools/FitGen/FitGen.c | 105 ++++++++++++++++---- Silicon/Intel/Tools/FitGen/FitGen.h | 2 +- 2 files changed, 88 insertions(+), 19 deletions(-) diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitG= en/FitGen.c index eac8fa8715..bdda8dfd5a 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.c +++ b/Silicon/Intel/Tools/FitGen/FitGen.c @@ -210,6 +210,7 @@ typedef struct { =0D #define DEFAULT_FIT_TABLE_POINTER_OFFSET 0x40=0D #define DEFAULT_FIT_ENTRY_VERSION 0x0100=0D +#define STARTUP_ACM_FIT_ENTRY_200_VERSION 0x0200=0D =0D #define TOP_FLASH_ADDRESS (gFitTableContext.TopFlashAddressRemapValue)=0D =0D @@ -247,6 +248,12 @@ typedef struct { UINT8 *Buffer; // Used by OptionalModule only=0D UINT32 Size;=0D UINT32 Version; // Used by OptionalModule and PortModule only=0D + UINT32 MaxSize;=0D + UINT8 SizeByte0; // Used by S-ACM only=0D + UINT8 SizeByte1; // Used by S-ACM only=0D + UINT8 SizeByte2; // Used by S-ACM only=0D + UINT8 Rsvd; // Used by S-ACM only=0D + UINT8 ChkSum; // Used by S-ACM only=0D } FIT_TABLE_CONTEXT_ENTRY;=0D =0D typedef struct {=0D @@ -262,7 +269,7 @@ typedef struct { UINT32 GlobalVersion;=0D UINT32 FitHeaderVersion;=0D FIT_TABLE_CONTEXT_ENTRY StartupAcm[MAX_STARTUP_ACM_ENTRY];=0D - UINT32 StartupAcmVersion;=0D + UINT32 StartupAcmVersion[MAX_STARTUP_ACM_ENTRY];=0D FIT_TABLE_CONTEXT_ENTRY DiagnstAcm;=0D UINT32 DiagnstAcmVersion;=0D FIT_TABLE_CONTEXT_ENTRY BiosModule[MAX_BIOS_MODULE_ENTRY];=0D @@ -341,7 +348,7 @@ Returns: "\t[-L ]\n"=0D "\t[-LF ]\n"=0D "\t[-I ]\n"=0D - "\t[-S |] [-V = ]\n"=0D + "\t[-S |] [-I = ] [-V ]\n"=0D "\t[-U |]\n"=0D "\t[-B ] [-B ...] [-V ]\n"=0D "\t[-M ] [-M ...]|[-U ||] [-V ]\n"=0D @@ -357,7 +364,13 @@ Returns: printf ("\tBiosInfoGuid - Guid of BiosInfo Module. If this mod= ule exists, StartupAcm/Bios/Microcode can be optional.\n");=0D printf ("\tStartupAcmAddress - Address of StartupAcm.\n");=0D printf ("\tStartupAcmSize - Size of StartupAcm.\n");=0D - printf ("\tStartupAcmGuid - Guid of StartupAcm Module, if Startu= pAcm is in a BiosModule, it will be excluded form that.\n");=0D + printf ("\tStartupAcmGuid - Guid of StartupAcm Module.\n");=0D + printf ("\tStartupAcmMaxSize - The maximum size value that could pl= ace the StartupAcm in.\n");=0D + printf ("\tStartupAcmSizeByte0 - The value for Size byte 0 (Override = default value).\n");=0D + printf ("\tStartupAcmSizeByte1 - The value for Size byte 1 (Override = default value).\n");=0D + printf ("\tStartupAcmSizeByte2 - The value for Size byte 2 (Override = default value).\n");=0D + printf ("\tStartupAcmRsvd - The value for Reserved byte (Overrid= e default value).\n");=0D + printf ("\tStartupAcmChkSum - The value for CheckSum byte (Overrid= e default value).\n");=0D printf ("\tDiagnstAcmAddress - Address of DiagnstAcm.\n");=0D printf ("\tDiagnstAcmGuid - Guid of DiagnstAcm Module, if Diagns= tAcm is in a BiosModule, it will be excluded from that.\n");=0D printf ("\tBiosModuleAddress - Address of BiosModule. User should e= nsure there is no overlap.\n");=0D @@ -913,6 +926,9 @@ Returns: UINT32 FileSize;=0D UINT32 Type;=0D UINT32 SubType;=0D + UINT8 StartupAcmSizeByte0;=0D + UINT8 StartupAcmSizeByte1;=0D + UINT8 StartupAcmSizeByte2;=0D UINT8 *MicrocodeFileBuffer;=0D UINT8 *MicrocodeFileBufferRaw;=0D UINT32 MicrocodeFileSize;=0D @@ -1155,9 +1171,12 @@ Returns: Error (NULL, 0, 0, "-I Parameter incorrect, too many StartupAc= m!", NULL);=0D return 0;=0D }=0D + //=0D + // NOTE: BIOS INFO structure not support to override the Size/Rs= vd/ChkSum byte value.=0D + //=0D gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].T= ype =3D FIT_TABLE_TYPE_STARTUP_ACM;=0D gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].A= ddress =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Address;=0D - gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].S= ize =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Size;=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].M= axSize =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Size;=0D gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].V= ersion =3D BiosInfoStruct[BiosInfoIndex].Version;=0D gFitTableContext.StartupAcmNumber ++;=0D gFitTableContext.FitEntryNumber ++;=0D @@ -1389,10 +1408,52 @@ Returns: }=0D gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type = =3D FIT_TABLE_TYPE_STARTUP_ACM;=0D gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Address= =3D (UINT32) (UINTN) FileBuffer;=0D - gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size = =3D FileSize;=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].MaxSize= =3D FileSize;=0D =0D //=0D - // 1.1 StartupAcm version=0D + // 1.1 Support 0x200 StartupAcm Information=0D + //=0D + if ((Index + 1 >=3D argc) ||=0D + ((strcmp (argv[Index], "-I") !=3D 0) &&=0D + (strcmp (argv[Index], "-i") !=3D 0)) ) {=0D + //=0D + // Bypass=0D + //=0D + gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber= ] =3D gFitTableContext.GlobalVersion;=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size = =3D 0;=0D + } else {=0D + //=0D + // Should use the multiple StartupACM=0D + //=0D + if (Index + 5 >=3D argc) {=0D + //=0D + // Should get five input value, but not sufficient=0D + //=0D + Error (NULL, 0, 0, "-I Parameter incorrect, Require five inputs va= lue!", NULL);=0D + return 0;=0D + } else {=0D + //=0D + // Should assign this as 0x200=0D + //=0D + gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumb= er] =3D STARTUP_ACM_FIT_ENTRY_200_VERSION;=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Siz= eByte0 =3D (UINT8)xtoi (argv[Index + 1]);=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Siz= eByte1 =3D (UINT8)xtoi (argv[Index + 2]);=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Siz= eByte2 =3D (UINT8)xtoi (argv[Index + 3]);=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Rsv= d =3D (UINT8)xtoi (argv[Index + 4]);=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Chk= Sum =3D (UINT8)xtoi (argv[Index + 5]);=0D +=0D + StartupAcmSizeByte0 =3D (UINT32)gFitTableContext.StartupAcm[gFitT= ableContext.StartupAcmNumber].SizeByte0;=0D + StartupAcmSizeByte1 =3D (UINT32)gFitTableContext.StartupAcm[gFitT= ableContext.StartupAcmNumber].SizeByte1;=0D + StartupAcmSizeByte2 =3D (UINT32)gFitTableContext.StartupAcm[gFitT= ableContext.StartupAcmNumber].SizeByte2;=0D +=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Siz= e =3D (StartupAcmSizeByte2 << 16) + (StartupAcmSizeByte1 << 8) + (Startup= AcmSizeByte0);=0D +=0D + Index +=3D 6;=0D + }=0D + }=0D +=0D + //=0D + // 1.2 StartupAcm version=0D //=0D if ((Index + 1 >=3D argc) ||=0D ((strcmp (argv[Index], "-V") !=3D 0) &&=0D @@ -1400,18 +1461,17 @@ Returns: //=0D // Bypass=0D //=0D - gFitTableContext.StartupAcmVersion =3D gFitTableContext.GlobalVersio= n;=0D } else {=0D //=0D // Get offset from parameter=0D //=0D - gFitTableContext.StartupAcmVersion =3D xtoi (argv[Index + 1]);=0D + gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber= ] =3D xtoi (argv[Index + 1]);=0D Index +=3D 2;=0D }=0D =0D gFitTableContext.StartupAcmNumber ++;=0D gFitTableContext.FitEntryNumber ++;=0D - }=0D + };=0D =0D //=0D // 1.5. DiagnosticsAcm=0D @@ -1895,7 +1955,7 @@ Returns: // Final: Check StartupAcm in BiosModule.=0D //=0D for (Index =3D 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Index= ++) {=0D - CheckOverlap (gFitTableContext.StartupAcm[Index].Address, gFitTableCon= text.StartupAcm[Index].Size);=0D + CheckOverlap (gFitTableContext.StartupAcm[Index].Address, gFitTableCon= text.StartupAcm[Index].MaxSize);=0D }=0D FitEntryNumber =3D gFitTableContext.FitEntryNumber;=0D for (Index =3D 0; Index < (INTN)gFitTableContext.OptionalModuleNumber; I= ndex++) {=0D @@ -2185,7 +2245,7 @@ Returns: printf ("Total FIT Entry number: 0x%x\n", gFitTableContext.FitEntryNumbe= r);=0D printf ("FitHeader version: 0x%04x\n", gFitTableContext.FitHeaderVersion= );=0D for (Index =3D 0; Index < gFitTableContext.StartupAcmNumber; Index++) {= =0D - printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%04x)\n", Index, gFitTabl= eContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].Size= , gFitTableContext.StartupAcmVersion);=0D + printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%08x, 0x%04x)\n", Index, = gFitTableContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Ind= ex].Size, gFitTableContext.StartupAcm[Index].MaxSize, gFitTableContext.Star= tupAcmVersion[Index]);=0D }=0D if (gFitTableContext.DiagnstAcm.Address !=3D 0) {=0D printf ("DiagnosticAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext= .DiagnstAcm.Address, gFitTableContext.DiagnstAcm.Size, gFitTableContext.Dia= gnstAcmVersion);=0D @@ -2817,11 +2877,12 @@ Returns: //=0D for (Index =3D 0; Index < gFitTableContext.StartupAcmNumber; Index++) {= =0D FitEntry[FitIndex].Address =3D gFitTableContext.StartupAcm= [Index].Address;=0D - *(UINT32 *)&FitEntry[FitIndex].Size[0] =3D 0; //gFitTableContext.Start= upAcm.Size / 16;=0D - FitEntry[FitIndex].Version =3D (UINT16)gFitTableContext.St= artupAcmVersion;=0D + *(UINT32 *)&FitEntry[FitIndex].Size[0] =3D gFitTableContext.StartupAcm= [Index].Size;=0D + FitEntry[FitIndex].Version =3D (UINT16)gFitTableContext.St= artupAcmVersion[Index];=0D FitEntry[FitIndex].Type =3D FIT_TABLE_TYPE_STARTUP_ACM;= =0D FitEntry[FitIndex].C_V =3D 0;=0D - FitEntry[FitIndex].Checksum =3D 0;=0D + FitEntry[FitIndex].Rsvd =3D gFitTableContext.StartupAcm= [Index].Rsvd;=0D + FitEntry[FitIndex].Checksum =3D gFitTableContext.StartupAcm= [Index].ChkSum;=0D FitIndex++;=0D }=0D =0D @@ -3170,8 +3231,16 @@ Returns: gFitTableContext.MicrocodeNumber ++;=0D break;=0D case FIT_TABLE_TYPE_STARTUP_ACM:=0D - gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Addre= ss =3D (UINT32)FitEntry[FitIndex].Address;=0D - gFitTableContext.StartupAcmVersion = =3D FitEntry[FitIndex].Version;=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Addre= ss =3D (UINT32)FitEntry[FitIndex].Address;=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type = =3D FitEntry[FitIndex].Type;=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size = =3D *(UINT32 *)&FitEntry[FitIndex].Size[0];=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeB= yte0 =3D *(UINT8 *)&FitEntry[FitIndex].Size[0];=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeB= yte1 =3D *(UINT8 *)&FitEntry[FitIndex].Size[1];=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeB= yte2 =3D *(UINT8 *)&FitEntry[FitIndex].Size[2];=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Rsvd = =3D FitEntry[FitIndex].Rsvd;=0D + gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].ChkSu= m =3D FitEntry[FitIndex].Checksum;=0D + gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber= ] =3D FitEntry[FitIndex].Version;=0D + gFitTableContext.StartupAcmNumber ++;=0D break;=0D case FIT_TABLE_TYPE_BIOS_MODULE:=0D gFitTableContext.BiosModule[gFitTableContext.BiosModuleNumber].Addre= ss =3D (UINT32)FitEntry[FitIndex].Address;=0D @@ -3333,13 +3402,13 @@ Returns: for (Index =3D 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Ind= ex ++) {=0D if (gFitTableContext.StartupAcm[Index].Address !=3D 0) {=0D AcmBuffer =3D FLASH_TO_MEMORY(gFitTableContext.StartupAcm[Index].A= ddress, FdFileBuffer, FdFileSize);=0D - if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.St= artupAcm[Index].Size > FdFileBuffer + FdFileSize)) {=0D + if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.St= artupAcm[Index].MaxSize > FdFileBuffer + FdFileSize)) {=0D printf ("ACM out of range - can not validate it\n");=0D AcmBuffer =3D NULL;=0D }=0D =0D if (AcmBuffer !=3D NULL) {=0D - if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupA= cm[Index].Size)) {=0D + if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupA= cm[Index].MaxSize)) {=0D DumpAcm ((ACM_FORMAT *)AcmBuffer);=0D } else {=0D Status =3D STATUS_ERROR;=0D diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitG= en/FitGen.h index b7de0a6b2d..80a1423ceb 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.h +++ b/Silicon/Intel/Tools/FitGen/FitGen.h @@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // Utility version information=0D //=0D #define UTILITY_MAJOR_VERSION 0=0D -#define UTILITY_MINOR_VERSION 65=0D +#define UTILITY_MINOR_VERSION 66=0D #define UTILITY_DATE __DATE__=0D =0D //=0D --=20 2.26.2.windows.1