From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web10.1274.1689086246420024141 for ; Tue, 11 Jul 2023 07:37:26 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: nishant.sharma@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 5882EC15; Tue, 11 Jul 2023 07:38:08 -0700 (PDT) Received: from usa.arm.com (iss-desktop02.cambridge.arm.com [10.1.196.79]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 3AF423F740; Tue, 11 Jul 2023 07:37:25 -0700 (PDT) From: "Nishant Sharma" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Thomas Abraham , Sayanta Pattanayak , Achin Gupta Subject: [edk2-platforms][PATCH V1 11/20] StandaloneMmPkg: Skip zero sized sections while tweaking page permissions Date: Tue, 11 Jul 2023 15:36:49 +0100 Message-Id: <20230711143658.781597-12-nishant.sharma@arm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230711143658.781597-1-nishant.sharma@arm.com> References: <20230711143658.781597-1-nishant.sharma@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Achin Gupta This patch skips zero sized sections in the StMM SP image e.g. .reloc sin= ce there is no point in attempting to change their permissions. Signed-off-by: Achin Gupta Signed-off-by: Nishant Sharma --- StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissions.c = | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPe= rmissions.c b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetP= ermissions.c index 5c6bd0e1d7d2..891e79b32b6f 100644 --- a/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissio= ns.c +++ b/StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/Arm/SetPermissio= ns.c @@ -2,7 +2,7 @@ Locate, get and update PE/COFF permissions during Standalone MM Foundation Entry point on ARM platforms. =20 -Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.
+Copyright (c) 2017 - 2023, Arm Ltd. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -118,6 +118,22 @@ UpdateMmFoundationPeCoffPermissions ( ImageContext->ImageAddress, SectionHeader.PointerToRawData )); + DEBUG (( + DEBUG_INFO, + "%a: Section %d of image at 0x%lx has %d bytes size\n", + __func__, Index, + ImageContext->ImageAddress, + SectionHeader.Misc.VirtualSize + )); + + // Skip sections with a size of 0 + if (SectionHeader.Misc.VirtualSize =3D=3D 0) { + DEBUG (( + DEBUG_INFO, + "%a: Skipping section %a \n", __func__, SectionHeader.Name + )); + continue; + } =20 // // If the section is marked as XN then remove the X attribute. Furth= ermore, --=20 2.34.1