From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by mx.groups.io with SMTP id smtpd.web10.4668.1600741740883904813 for ; Mon, 21 Sep 2020 19:29:01 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.151, mailfrom: aaron.li@intel.com) IronPort-SDR: u3yaLC5JPPa+zwX8SzippkbyBId4hkTrYl4vtDQfHzC6X3XNZKck+UPNFh6lNzSIvn18Jx8uHI sBCLuW7KFBeg== X-IronPort-AV: E=McAfee;i="6000,8403,9751"; a="140520189" X-IronPort-AV: E=Sophos;i="5.77,288,1596524400"; d="scan'208";a="140520189" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Sep 2020 19:29:00 -0700 IronPort-SDR: Q0+8Q3SXhH789lgxWoIUp7oZPQ6B3ChNyAeGN9/JxDUYQoOCJfADW9ImRN63BguLoy7rxnnDO0 zMgS2BVkrC/g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,288,1596524400"; d="scan'208";a="346771750" Received: from sh1gapp1015.ccr.corp.intel.com ([10.239.189.85]) by FMSMGA003.fm.intel.com with ESMTP; 21 Sep 2020 19:28:59 -0700 From: "Aaron Li" To: devel@edk2.groups.io Cc: Bob Feng , Liming Gao Subject: [PATCH v2 1/1] Tools/FitGen: Fix microcode alignment support Date: Tue, 22 Sep 2020 10:28:53 +0800 Message-Id: <20200922022853.13251-1-aaron.li@intel.com> X-Mailer: git-send-email 2.23.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3D2971 v2: Add check for basic 16-byte alignment. This patch is to fix a issue that "-A" option would only support 2^n Byte alignment of microcode. Signed-off-by: Aaron Li Cc: Bob Feng Cc: Liming Gao --- Silicon/Intel/Tools/FitGen/FitGen.c | 8 ++++++-- Silicon/Intel/Tools/FitGen/FitGen.h | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitG= en/FitGen.c index c4006e69c822..851d42cb4aca 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.c +++ b/Silicon/Intel/Tools/FitGen/FitGen.c @@ -363,7 +363,7 @@ Returns: printf ("\tMicrocodeSlotSize - Occupied region size of each Microco= de binary.\n");=0D printf ("\tMicrocodeFfsGuid - Guid of FFS which is used to save Mi= crocode binary");=0D printf ("\t-NA - No 0x800 aligned Microcode requireme= nt. No -NA means Microcode is aligned with option MicrocodeAlignment value.= \n");=0D - printf ("\tMicrocodeAlignment - HEX value of Microcode alignment. Ig= nored if \"-NA\" is specified. Default value is 0x800.\n");=0D + printf ("\tMicrocodeAlignment - HEX value of Microcode alignment. Ig= nored if \"-NA\" is specified. Default value is 0x800. The Microcode update= data must start at a 16-byte aligned linear address.\n");=0D printf ("\tRecordType - FIT entry record type. User should e= nsure it is ordered.\n");=0D printf ("\tRecordDataAddress - FIT entry record data address.\n");= =0D printf ("\tRecordDataSize - FIT entry record data size.\n");=0D @@ -1176,7 +1176,11 @@ Returns: // MCU might be put at 2KB alignment, if so, we need to ad= just the size as 2KB alignment.=0D //=0D if (gFitTableContext.MicrocodeIsAligned) {=0D - MicrocodeSize =3D (*(UINT32 *)(MicrocodeBuffer + 32) + (= gFitTableContext.MicrocodeAlignValue - 1)) & ~(gFitTableContext.MicrocodeAl= ignValue - 1);=0D + if (gFitTableContext.MicrocodeAlignValue & 0xF) {=0D + printf ("-A Parameter incorrect, Microcode data must s= tart at a 16-byte aligned linear address!\n");=0D + return 0;=0D + }=0D + MicrocodeSize =3D ROUNDUP (*(UINT32 *)(MicrocodeBuffer += 32), gFitTableContext.MicrocodeAlignValue);=0D } else {=0D MicrocodeSize =3D (*(UINT32 *)(MicrocodeBuffer + 32));=0D }=0D diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitG= en/FitGen.h index abad2d8799c8..435fc26209da 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 62=0D +#define UTILITY_MINOR_VERSION 63=0D #define UTILITY_DATE __DATE__=0D =0D //=0D @@ -45,4 +45,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((A= lignment) - 1))=0D ;=0D =0D +#define ROUNDUP(Size, Alignment) (((Size) + (Alignment) - 1) / (Alignment)= * (Alignment))=0D +=0D #endif=0D --=20 2.23.0.windows.1