From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=bob.c.feng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 059FE21A09130 for ; Thu, 3 Jan 2019 21:51:05 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Jan 2019 21:51:04 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,437,1539673200"; d="scan'208";a="112023588" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by fmsmga007.fm.intel.com with ESMTP; 03 Jan 2019 21:51:04 -0800 Received: from fmsmsx115.amr.corp.intel.com (10.18.116.19) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 3 Jan 2019 21:51:04 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by fmsmsx115.amr.corp.intel.com (10.18.116.19) with Microsoft SMTP Server (TLS) id 14.3.408.0; Thu, 3 Jan 2019 21:51:04 -0800 Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.196]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.150]) with mapi id 14.03.0415.000; Fri, 4 Jan 2019 13:51:02 +0800 From: "Feng, Bob C" To: Ard Biesheuvel , "edk2-devel@lists.01.org" CC: Laszlo Ersek , Leif Lindholm , "Kinney, Michael D" , "Gao, Liming" , "Wang, Jian J" , "Wu, Hao A" , Jagadeesh Ujja , Achin Gupta , Thomas Panakamattam Abraham , Sami Mujawar Thread-Topic: [PATCH] BaseTools/GenFds: permit stripped MM_CORE_STANDALONE binaries Thread-Index: AQHUo5IzwhBHLFZzjE+YojE1iDFLeaWem7Ag Date: Fri, 4 Jan 2019 05:51:01 +0000 Message-ID: <08650203BA1BD64D8AD9B6D5D74A85D16004F158@SHSMSX101.ccr.corp.intel.com> References: <20190103182825.32231-1-ard.biesheuvel@linaro.org> <20190103182825.32231-2-ard.biesheuvel@linaro.org> In-Reply-To: <20190103182825.32231-2-ard.biesheuvel@linaro.org> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] BaseTools/GenFds: permit stripped MM_CORE_STANDALONE binaries X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 04 Jan 2019 05:51:06 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Bob Feng =20 -----Original Message----- From: Ard Biesheuvel [mailto:ard.biesheuvel@linaro.org]=20 Sent: Friday, January 4, 2019 2:28 AM To: edk2-devel@lists.01.org Cc: Ard Biesheuvel ; Laszlo Ersek ; Leif Lindholm ; Kinney, Michael D ; Gao, Liming ; Wang, Jian J ; Wu, Hao A ; Jagadeesh Ujja ; Achin Gupta ; Thomas Panakamattam A= braham ; Sami Mujawar ; Feng,= Bob C Subject: [PATCH] BaseTools/GenFds: permit stripped MM_CORE_STANDALONE binar= ies The standalone MM core is executed in place, and resides in a separate exec= ution context which may be space constrained. Since code and data may be mapped with different attributes for security re= asons, the PE/COFF binary could have a section alignment of 4 KB. This means that any relocation data is not only useless, but it will also t= ake up 4 KB of valuable space. So add support for the RELOCS_STRIPPED attribute on FFS files of this type,= so that we can get rid of the .reloc section altogether. Combined with the FIXED attribute (which enables an optimization in GenFfs = that strips redundant padding) and a TE type binary, this gets rid of all t= he needless padding around the standalone MM core binary. Cc: Bob Feng Cc: Liming Gao Cc: Jagadeesh Ujja Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- BaseTools/Source/Python/GenFds/EfiSection.py | 2 +- BaseTools/Source/Python/GenFds/FdfParser.py | 2 +- BaseTools/Source/Python/GenFds/FfsInfStatement.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/BaseTools/Source/Python/GenFds/EfiSection.py b/BaseTools/Sourc= e/Python/GenFds/EfiSection.py index f8573b5c7d1b..0be176ec8ae1 100644 --- a/BaseTools/Source/Python/GenFds/EfiSection.py +++ b/BaseTools/Source/Python/GenFds/EfiSection.py @@ -68,7 +68,7 @@ class EfiSection (EfiSectionClassObject): StringData =3D FfsInf.__ExtendMacro__(self.StringData) ModuleNameStr =3D FfsInf.__ExtendMacro__('$(MODULE_NAME)') NoStrip =3D True - if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, = SUP_MODULE_PEIM) and SectionType in (BINARY_FILE_TYPE_TE, BINARY_FILE_TYPE_= PE32): + if FfsInf.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, = SUP_MODULE_PEIM, SUP_MODULE_MM_CORE_STANDALONE) and SectionType in (BINARY_= FILE_TYPE_TE, BINARY_FILE_TYPE_PE32): if FfsInf.KeepReloc is not None: NoStrip =3D FfsInf.KeepReloc elif FfsInf.KeepRelocFromRule is not None: diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source= /Python/GenFds/FdfParser.py index e000228d2f6c..de0b166030e7 100644 --- a/BaseTools/Source/Python/GenFds/FdfParser.py +++ b/BaseTools/Source/Python/GenFds/FdfParser.py @@ -2589,7 +2589,7 @@ class FdfParser: # @staticmethod def _FileCouldHaveRelocFlag (FileType): - if FileType in {SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PE= IM, 'PEI_DXE_COMBO'}: + if FileType in {SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MODULE_PE= IM, SUP_MODULE_MM_CORE_STANDALONE, 'PEI_DXE_COMBO'}: return True else: return False diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/= Source/Python/GenFds/FfsInfStatement.py index c1073c96e9aa..d4c61c074963 100644 --- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py +++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py @@ -901,7 +901,7 @@ class FfsInfStatement(FfsInfStatementClassObject): # @retval string File name of the generated section file # def __GenComplexFileSection__(self, Rule, FvChildAddr, FvParentAddr, I= sMakefile =3D False): - if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MO= DULE_PEIM): + if self.ModuleType in (SUP_MODULE_SEC, SUP_MODULE_PEI_CORE, SUP_MO= DULE_PEIM, SUP_MODULE_MM_CORE_STANDALONE): if Rule.KeepReloc is not None: self.KeepRelocFromRule =3D Rule.KeepReloc SectFiles =3D [] -- 2.17.1