From nobody Mon Feb 9 07:23:33 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+83623+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+83623+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1636590358; cv=none; d=zohomail.com; s=zohoarc; b=l+E+BBu2Q0PdKORI+L3UWuMeSHq5RhzfFKTfm4tQXxoTfkYl32uhWEnH7KaN0OfCjKu8jzVlTHB5TgPZPoFaS0SydZquMO7bM/CTdX5YyHdEc9KEfADknRIxaAZzbBUm46fEua4yeJIl102cRpL2yMh2iF8IovZ+tUcXGjCplbw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1636590358; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=4ocanRYjc4qcw0sMKTFOQoc95maLchJznjKnYEluuPI=; b=WlqohUZuOZLR8JNH9hzxMT1vBGC2LiQLRjcqyeZfybojpbkdNXbZ/A169J0K8WU6jaJUgc3lP3K88YItu27GXgJWLK6OA6qoOC3F4pKxYVqfHa4BoFlXrOcIgtIUUzoU498bH2FtJVuy8lGj+KMzAsiFMPIpws0g6GofsHE7S8E= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+83623+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 163659035848364.84389863301499; Wed, 10 Nov 2021 16:25:58 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 62D9YY1788612xykEDbtyiYv; Wed, 10 Nov 2021 16:25:58 -0800 X-Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) by mx.groups.io with SMTP id smtpd.web12.3953.1636590344884871729 for ; Wed, 10 Nov 2021 16:25:44 -0800 X-Received: by mail-pj1-f47.google.com with SMTP id v23so2884678pjr.5 for ; Wed, 10 Nov 2021 16:25:44 -0800 (PST) X-Gm-Message-State: ZdGZyz7WsjRWjsUaASRLjnQGx1787277AA= X-Google-Smtp-Source: ABdhPJxf7auz/O7B+uA9sUAFlLeBb/DynLnL7fGzKmrd2bqGnkyhZiEmBaecl/sbmGOYGL4Lr/u4GA== X-Received: by 2002:a17:902:b907:b0:13f:ccaf:9ed8 with SMTP id bf7-20020a170902b90700b0013fccaf9ed8mr3467516plb.46.1636590343833; Wed, 10 Nov 2021 16:25:43 -0800 (PST) X-Received: from localhost.localdomain (174-21-94-94.tukw.qwest.net. [174.21.94.94]) by smtp.gmail.com with ESMTPSA id e14sm838890pfv.18.2021.11.10.16.25.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Nov 2021 16:25:42 -0800 (PST) From: "Bret Barkelew" X-Google-Original-From: "brbarkel@microsoft.com" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Sami Mujawar , Jiewen Yao , Supreeth Venkatesh , Sean Brogan Subject: [edk2-devel] [PATCH v3 11/14] StandaloneMmPkg: Switch to the MmuLib abstraction Date: Wed, 10 Nov 2021 16:24:13 -0800 Message-Id: <20211111002416.1770-12-brbarkel@microsoft.com> In-Reply-To: <20211111002416.1770-1-brbarkel@microsoft.com> References: <20211111002416.1770-1-brbarkel@microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,bret@corthon.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1636590358; bh=64DWFO1LwO2QSYmlMkhiLhV5TUgLCzbEHUq4N4MhekI=; h=Cc:Date:From:Reply-To:Subject:To; b=eEyoiKpiaA80lsj8w1/p/5CBUS38LOwz27Y07GEWH/W20R3Q7MgXc34xNgcTidnoVND Gs8SaQEJa/CKFdnOSFs1Kwvt6GJSnLm6+FhxfywMfUHk59efjV9Bks2kO152Fcij7BeJW aEbHASqAq1pBC9DmlPWHVLESgczemCq7tj0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1636590359161100011 Content-Type: text/plain; charset="utf-8" From: Bret Barkelew REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3651 Cc: Ard Biesheuvel Cc: Sami Mujawar Cc: Jiewen Yao Cc: Supreeth Venkatesh Cc: Sean Brogan Signed-off-by: Bret Barkelew --- StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/Standalon= eMmPeCoffExtraActionLib.c | 82 ++++++++++++++++++-- StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCof= fExtraActionLib.inf | 3 +- StandaloneMmPkg/StandaloneMmPkg.dsc = | 1 + 3 files changed, 79 insertions(+), 7 deletions(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch= 64/StandaloneMmPeCoffExtraActionLib.c b/StandaloneMmPkg/Library/StandaloneM= mPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c index ca8b1244a313..986f6ade5f47 100644 --- a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/Stan= daloneMmPeCoffExtraActionLib.c +++ b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch64/Stan= daloneMmPeCoffExtraActionLib.c @@ -10,7 +10,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #include =20 -#include +#include #include #include #include @@ -163,6 +163,78 @@ UpdatePeCoffPermissions ( return RETURN_SUCCESS; } =20 +/** + Internal function to parameterize the call int MmuSetAttributes. + + @param [in] BaseAddress + @param [in] Length + + @retval EFI_STATUS Returned by MmuSetAttributes +**/ +STATIC +EFI_STATUS +ArmPeSetMemoryRegionNoExec ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + return MmuSetAttributes (BaseAddress, Length, EFI_MEMORY_XP); +} + +/** + Internal function to parameterize the call int MmuSetAttributes. + + @param [in] BaseAddress + @param [in] Length + + @retval EFI_STATUS Returned by MmuSetAttributes +**/ +STATIC +EFI_STATUS +ArmPeClearMemoryRegionNoExec ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + return MmuClearAttributes (BaseAddress, Length, EFI_MEMORY_XP); +} + +/** + Internal function to parameterize the call int MmuSetAttributes. + + @param [in] BaseAddress + @param [in] Length + + @retval EFI_STATUS Returned by MmuSetAttributes +**/ +STATIC +EFI_STATUS +ArmPeSetMemoryRegionReadOnly ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + return MmuSetAttributes (BaseAddress, Length, EFI_MEMORY_RO); +} + +/** + Internal function to parameterize the call int MmuSetAttributes. + + @param [in] BaseAddress + @param [in] Length + + @retval EFI_STATUS Returned by MmuSetAttributes +**/ +STATIC +EFI_STATUS +ArmPeClearMemoryRegionReadOnly ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64 Length + ) +{ + return MmuClearAttributes (BaseAddress, Length, EFI_MEMORY_RO); +} + /** Performs additional actions after a PE/COFF image has been loaded and re= located. =20 @@ -180,8 +252,8 @@ PeCoffLoaderRelocateImageExtraAction ( { UpdatePeCoffPermissions ( ImageContext, - ArmClearMemoryRegionNoExec, - ArmSetMemoryRegionReadOnly + ArmPeClearMemoryRegionNoExec, + ArmPeSetMemoryRegionReadOnly ); } =20 @@ -205,7 +277,7 @@ PeCoffLoaderUnloadImageExtraAction ( { UpdatePeCoffPermissions ( ImageContext, - ArmSetMemoryRegionNoExec, - ArmClearMemoryRegionReadOnly + ArmPeSetMemoryRegionNoExec, + ArmPeClearMemoryRegionReadOnly ); } diff --git a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/Stand= aloneMmPeCoffExtraActionLib.inf b/StandaloneMmPkg/Library/StandaloneMmPeCof= fExtraActionLib/StandaloneMmPeCoffExtraActionLib.inf index 89083df679a1..25306dd3e707 100644 --- a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMm= PeCoffExtraActionLib.inf +++ b/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMm= PeCoffExtraActionLib.inf @@ -27,10 +27,9 @@ [Sources.common] AArch64/StandaloneMmPeCoffExtraActionLib.c =20 [Packages] - ArmPkg/ArmPkg.dec MdePkg/MdePkg.dec StandaloneMmPkg/StandaloneMmPkg.dec =20 [LibraryClasses] - StandaloneMmMmuLib + MmuLib PcdLib diff --git a/StandaloneMmPkg/StandaloneMmPkg.dsc b/StandaloneMmPkg/Standalo= neMmPkg.dsc index e9488538cb21..da3488e0d3fe 100644 --- a/StandaloneMmPkg/StandaloneMmPkg.dsc +++ b/StandaloneMmPkg/StandaloneMmPkg.dsc @@ -59,6 +59,7 @@ [LibraryClasses] StandaloneMmCoreEntryPoint|StandaloneMmPkg/Library/StandaloneMmCoreEntry= Point/StandaloneMmCoreEntryPoint.inf StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint= /StandaloneMmDriverEntryPoint.inf VariableMmDependency|StandaloneMmPkg/Library/VariableMmDependency/Variab= leMmDependency.inf + MmuLib|MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf =20 [LibraryClasses.AARCH64, LibraryClasses.ARM] ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf --=20 2.31.1.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#83623): https://edk2.groups.io/g/devel/message/83623 Mute This Topic: https://groups.io/mt/86971571/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-