From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) by mx.groups.io with SMTP id smtpd.web12.878.1635884457195838503 for ; Tue, 02 Nov 2021 13:20:57 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@corthon-com.20210112.gappssmtp.com header.s=20210112 header.b=jXnHSAaw; spf=none, err=permanent DNS error (domain: corthon.com, ip: 209.85.214.179, mailfrom: bret@corthon.com) Received: by mail-pl1-f179.google.com with SMTP id p18so561555plf.13 for ; Tue, 02 Nov 2021 13:20:57 -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=jXnHSAawCoCdO/XlhquEhbcn3bwtWm2+7V2HFqxthtqNI7wMybovSbJXY8RdZUjG8I OhHgdc1f2MbUT7dpALCIStSXesJakwuhvK0dGW15mASphmt6FcNGFaupkQ2Ba53dlsbu k44wGwdtKQmrF3f//1+WaV7xV2YcuspIG/ZChRKRt1H2EkmsVlulYO1a0f7bDNbh+1ng rjJ3WQ0UmXa8SUQa1kEhO5JBr+vxSwMKwVA/tJ35tsroEos35Sqlasy5CmawxwhojVy4 xHkGE6+pTH+ZOhPu+q7ABz5FggqvzXV/k5BbMZ1TjGQattzq+PKR4MQz9LdpvQNNbDix vUOg== 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=lJgf+w7eaW4cEVEyX2VAZrLv0nel4j9y1Gbz2oOF/U/6JuTTlVw/SxrzL3TP3VHXbW pkdp9o2DGW/9bsdwvWto/5iE55Dcu2BP+WgX3R+Ydg2OQ+LKcXklLCufnMz2VwuUYH9k kolJE/G8ae3AWIaJGWA5IgMY4wd+Y+c1Bqlyf6ItroZOwaj4bnD0RD0LVy8xcuDnfLP3 unbXeJc35fkOXeiOQy8tSHwhMIcxwXzwtEQxAggCdJYWGJAiEVGWOmHFVcNFXStbewfq GRCyQWMpcCPHpzNM6Pd6YMNROzT6Qkt9XSKitnESMSuVW+7jdCWH2fWpQL6az4vp6EvF vPbA== X-Gm-Message-State: AOAM532KPEJuPWVYUjQ89es7dn4pg/mA+69sqfV7OZOCyBPYN56T7cnY NQcY6+fZsyKBlTXfEzhnlMmYkdJo/hsRrjnk X-Google-Smtp-Source: ABdhPJybqEclx+z52tlqPqT41hBJEVLuSmEgQt9O+PAYiRoeSEYVNnD6kRTfQtAADWKO4KioXVdWCA== X-Received: by 2002:a17:902:9a91:b0:138:efd5:7302 with SMTP id w17-20020a1709029a9100b00138efd57302mr33770396plp.35.1635884456514; Tue, 02 Nov 2021 13:20:56 -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 t24sm17652pfg.118.2021.11.02.13.20.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Nov 2021 13:20:56 -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 v2 10/16] StandaloneMmPkg: Switch to the MmuLib abstraction Date: Tue, 2 Nov 2021 13:17:42 -0700 Message-Id: <20211102201748.1963-11-brbarkel@microsoft.com> X-Mailer: git-send-email 2.31.1.windows.1 In-Reply-To: <20211102201748.1963-1-brbarkel@microsoft.com> References: <20211102201748.1963-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