From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@corthon-com.20210112.gappssmtp.com header.s=20210112 header.b=xhaJLdf4; spf=none, err=permanent DNS error (domain: corthon.com, ip: 209.85.216.47, mailfrom: bret@corthon.com) Received: by mail-pj1-f47.google.com with SMTP id v23so2884678pjr.5 for ; Wed, 10 Nov 2021 16:25:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=corthon-com.20210112.gappssmtp.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=U72Hyi2L2+qCBeELiYtSTCK+8k9Q6C3jZyP1ZRvkzJ4=; b=xhaJLdf4KJQmlM54cuKYglH0aJNl8q7X3zgKnX/grUvc/oStPLdtx4s9XTBDmB1QGQ 4GF7eTNxy3AGoKAEhRId/YvoWrWA5DWjSxDglsRfzZJNBv8jImShuicL5z0G1113Y37E OTdXWGrnL3kAiJptp0vK4w2Yf6ebP76aZv0EEs9yZmZ6eQfJ5zwkoSvoKjnuvKcQeK5w zFh84VKNtVS1AlxSsH1B8BqnHIS1b33MgvSG6C1P4YYEzXz4AdYNbZSwb4S+1OgfLQZ9 t9IdwS6p7LRVVo8K0Gjo8TkMB/Xf+cfFPflbwLEkCsuOZU0d7IWIPdxoHuI5Nk5uQzbH atgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=U72Hyi2L2+qCBeELiYtSTCK+8k9Q6C3jZyP1ZRvkzJ4=; b=lRZ/i55xAQ+pYWfeIXL9wsWF1WrpN1rLT3IpQzYXp4TtguNPw1FWu3ECsfXSr3JMjH dRPb6+Nt23x2p5pf+iKIbuiFH/w582WLU50yM7n0D9UyMNqGFhpZQ46nyaX8z4vvIzFF fZE7Na6pXGaoMjtTdg1mihFTsGAPSn8mcrSSq+GRH0zBjXbVF/6z6HRb2/fNEDV2uKjv ZGpgCY8RJYanO67VVb9PZcs4epzah/cVCGeNtCMYQNoRTNMIRT2G9yNsCGYgn9bq7MWf D2j6qnz72OJ0/7TUwJ3pkzVa3+Bw3G5RdV9Rn3yTRbr4t+W/qrfREd/G4huvQAY5TrxC EBPw== X-Gm-Message-State: AOAM531+ySXz2ZHM+A2uT48zJLdpDdE9y3w2XGio5pD8HnzQWKOTdNM5 uejW8jMFSIA3i7kn7DKDEUqtrfSQDbnu80eN 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) Return-Path: 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: [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> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20211111002416.1770-1-brbarkel@microsoft.com> References: <20211111002416.1770-1-brbarkel@microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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 =0D #include =0D =0D -#include =0D +#include =0D #include =0D #include =0D #include =0D @@ -163,6 +163,78 @@ UpdatePeCoffPermissions ( return RETURN_SUCCESS;=0D }=0D =0D +/**=0D + Internal function to parameterize the call int MmuSetAttributes.=0D +=0D + @param [in] BaseAddress=0D + @param [in] Length=0D +=0D + @retval EFI_STATUS Returned by MmuSetAttributes=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +ArmPeSetMemoryRegionNoExec (=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length=0D + )=0D +{=0D + return MmuSetAttributes (BaseAddress, Length, EFI_MEMORY_XP);=0D +}=0D +=0D +/**=0D + Internal function to parameterize the call int MmuSetAttributes.=0D +=0D + @param [in] BaseAddress=0D + @param [in] Length=0D +=0D + @retval EFI_STATUS Returned by MmuSetAttributes=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +ArmPeClearMemoryRegionNoExec (=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length=0D + )=0D +{=0D + return MmuClearAttributes (BaseAddress, Length, EFI_MEMORY_XP);=0D +}=0D +=0D +/**=0D + Internal function to parameterize the call int MmuSetAttributes.=0D +=0D + @param [in] BaseAddress=0D + @param [in] Length=0D +=0D + @retval EFI_STATUS Returned by MmuSetAttributes=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +ArmPeSetMemoryRegionReadOnly (=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length=0D + )=0D +{=0D + return MmuSetAttributes (BaseAddress, Length, EFI_MEMORY_RO);=0D +}=0D +=0D +/**=0D + Internal function to parameterize the call int MmuSetAttributes.=0D +=0D + @param [in] BaseAddress=0D + @param [in] Length=0D +=0D + @retval EFI_STATUS Returned by MmuSetAttributes=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +ArmPeClearMemoryRegionReadOnly (=0D + IN EFI_PHYSICAL_ADDRESS BaseAddress,=0D + IN UINT64 Length=0D + )=0D +{=0D + return MmuClearAttributes (BaseAddress, Length, EFI_MEMORY_RO);=0D +}=0D +=0D /**=0D Performs additional actions after a PE/COFF image has been loaded and re= located.=0D =0D @@ -180,8 +252,8 @@ PeCoffLoaderRelocateImageExtraAction ( {=0D UpdatePeCoffPermissions (=0D ImageContext,=0D - ArmClearMemoryRegionNoExec,=0D - ArmSetMemoryRegionReadOnly=0D + ArmPeClearMemoryRegionNoExec,=0D + ArmPeSetMemoryRegionReadOnly=0D );=0D }=0D =0D @@ -205,7 +277,7 @@ PeCoffLoaderUnloadImageExtraAction ( {=0D UpdatePeCoffPermissions (=0D ImageContext,=0D - ArmSetMemoryRegionNoExec,=0D - ArmClearMemoryRegionReadOnly=0D + ArmPeSetMemoryRegionNoExec,=0D + ArmPeClearMemoryRegionReadOnly=0D );=0D }=0D 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=0D =0D [Packages]=0D - ArmPkg/ArmPkg.dec=0D MdePkg/MdePkg.dec=0D StandaloneMmPkg/StandaloneMmPkg.dec=0D =0D [LibraryClasses]=0D - StandaloneMmMmuLib=0D + MmuLib=0D PcdLib=0D 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=0D StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint= /StandaloneMmDriverEntryPoint.inf=0D VariableMmDependency|StandaloneMmPkg/Library/VariableMmDependency/Variab= leMmDependency.inf=0D + MmuLib|MdePkg/Library/BaseMmuLibNull/BaseMmuLibNull.inf=0D =0D [LibraryClasses.AARCH64, LibraryClasses.ARM]=0D ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf=0D --=20 2.31.1.windows.1