From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mx.groups.io with SMTP id smtpd.web08.1613.1635796724422025541 for ; Mon, 01 Nov 2021 12:58:44 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@corthon-com.20210112.gappssmtp.com header.s=20210112 header.b=d3OTmHv6; spf=none, err=permanent DNS error (domain: corthon.com, ip: 209.85.214.173, mailfrom: bret@corthon.com) Received: by mail-pl1-f173.google.com with SMTP id t11so12364929plq.11 for ; Mon, 01 Nov 2021 12:58:44 -0700 (PDT) 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=4Us1FSL+YTfZKAy5QW10tWELzAF5bEj6o5MNYEOUth8=; b=d3OTmHv6wkAndfxo7ac0GEZaXbAKQXl9fmC11EX+/8h8uA+hELdf6QQIxCp4FSjvVY Qw+KRUsVRz5DgR6blHcX65DRT+D3msXLdKUEKVUL/G4s6JgM5dOxgMj575pY1cdjjeED AFEgsUGNCkXFhY557xgI2WbiGgrfuCD8+rMuLfHly7WHIt+TXbrVeLVPQ/5HY4AOQmsS zUyP3kFdAD3hev14wTmGBCjmPSBU0092QzW2ssAhMwDLa82FbidtzHsweucSrLq74VT9 xksFIrnkKLpdjo0rmOnB8jyU86U9mS/Q2d2sx+6CMyqibHBP9X8G1uV7F7ihzmII/+vB jx0w== 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=4Us1FSL+YTfZKAy5QW10tWELzAF5bEj6o5MNYEOUth8=; b=zfHeTPkqxP2k5xN8SJDxzeLhi/1WO0AnGR32ZCETPN1k2KfKtXjaj0zbAjix7tykgm FOvhmlBp15322W9edhMb2bkXXMxRtNUpWAk2+tng+Dd0ihMVOifRAVWD72HmCHCOMBu9 MWWvQLgOGjXjXNkZkrP7TiOaf1yc3pPPIW2FrK7ZjVgOXbrqkHYlqLaQnAR1UceETo8t OrFX235Hg9oeFeBHtG2vVyv8YNocqEIz16Pd3rbgR+oLYF69tTag4oFSbTXXxcG4YAMV NZvoDfXuKqkNN/5DCkKVMEGY0VEIuJxNb26TIwozY7V6wgiMDg5II4svelAIFPO/5frp YzoA== X-Gm-Message-State: AOAM530oG1a3AwzHApKCivqmfTSZH8h8FEK6dgHFWHnDthEmAtPvEUA6 YDnUizBRVK+TO5lXlG4d6igd97Jr4Z2iMM4e X-Google-Smtp-Source: ABdhPJyj9ssBaaG8BcB7qNx0w41t9zhLSZCm+YvuN46dO0e31vuzzvvSGwrQyoL6Vva2n7TRixt+IA== X-Received: by 2002:a17:90b:1c02:: with SMTP id oc2mr1150892pjb.65.1635796723770; Mon, 01 Nov 2021 12:58:43 -0700 (PDT) Return-Path: Received: from localhost.localdomain (174-21-94-94.tukw.qwest.net. [174.21.94.94]) by smtp.gmail.com with ESMTPSA id t2sm13759796pgf.35.2021.11.01.12.58.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Nov 2021 12:58:43 -0700 (PDT) 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 v1 10/16] StandaloneMmPkg: Switch to the MmuLib abstraction Date: Mon, 1 Nov 2021 12:56:42 -0700 Message-Id: <20211101195648.6420-11-brbarkel@microsoft.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20211101195648.6420-1-brbarkel@microsoft.com> References: <20211101195648.6420-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 | 50 ++++++++++++++++++-- StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/StandaloneMmPeCof= fExtraActionLib.inf | 3 +- StandaloneMmPkg/StandaloneMmPkg.dsc = | 1 + 3 files changed, 47 insertions(+), 7 deletions(-) diff --git a/StandaloneMmPkg/Library/StandaloneMmPeCoffExtraActionLib/AArch= 64/StandaloneMmPeCoffExtraActionLib.c b/StandaloneMmPkg/Library/StandaloneM= mPeCoffExtraActionLib/AArch64/StandaloneMmPeCoffExtraActionLib.c index ca8b1244a313..ca3b9de26a6f 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,46 @@ UpdatePeCoffPermissions ( return RETURN_SUCCESS;=0D }=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 +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 +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 +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 +220,8 @@ PeCoffLoaderRelocateImageExtraAction ( {=0D UpdatePeCoffPermissions (=0D ImageContext,=0D - ArmClearMemoryRegionNoExec,=0D - ArmSetMemoryRegionReadOnly=0D + ArmPeClearMemoryRegionNoExec,=0D + ArmPeSetMemoryRegionReadOnly=0D );=0D }=0D =0D @@ -205,7 +245,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 2c0c9396d633..d3e8d250d972 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