From nobody Mon Feb 9 12:10:12 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+105656+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+105656+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1685719104; cv=none; d=zohomail.com; s=zohoarc; b=ivV3eK27uUSEp8iDI8vVPFC5vxILzEFznm27sQNR0NwVI01J3Fzhb4kxtjlpm5ysmDVcGajUOx36uP9BXNXXq5eYYvRE6zxehVz4xL7Bw9Lk8uZeVa00QyTrDxElzZdQ3cF+d3HTMBwWrCvjfrJu2cjXd66MRuRbEq+4uYJe1Y0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685719104; 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=MUFCLaSmCb9Om+efHJVviAYExanQ+n+dWOy5DRJ74Z4=; b=oDaekKVTwi9CIU1ALScZIHoxpgk29tJWGAAb4VlQl/RMcsX7MPglynRLgjnioRRSDV5cPzfaKaT4L1zoQB5Ep9mBe3iUuXsyKE5AVhF4Y9M4qJG0xr2HwsNki5pIdWvDG/a+a3077qLpWTRcVzfTIaQL51T8V67ssLN5HqFiwMA= 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+105656+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1685719104842615.4325302796047; Fri, 2 Jun 2023 08:18:24 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id CwPqYY1788612x0DePyl8BRN; Fri, 02 Jun 2023 08:18:24 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web11.16087.1685719103459950585 for ; Fri, 02 Jun 2023 08:18:23 -0700 X-Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 04A0961638; Fri, 2 Jun 2023 15:18:23 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD870C4339C; Fri, 2 Jun 2023 15:18:19 +0000 (UTC) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Ray Ni , Jiewen Yao , Gerd Hoffmann , Taylor Beebe , Oliver Smith-Denny , Dandan Bi , Dun Tan , Liming Gao , "Kinney, Michael D" , Leif Lindholm , Michael Kubacki Subject: [edk2-devel] [PATCH v2 7/7] ArmPkg/CpuDxe: Simplify memory attributes protocol implementation Date: Fri, 2 Jun 2023 17:17:39 +0200 Message-Id: <20230602151739.3600820-8-ardb@kernel.org> In-Reply-To: <20230602151739.3600820-1-ardb@kernel.org> References: <20230602151739.3600820-1-ardb@kernel.org> 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,ardb@kernel.org X-Gm-Message-State: mdNxQLQ9m6IMb9VzKdr0FW0wx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1685719104; bh=Dl47kaD+H19b5cfhb/UhQlZDXK26zepwZxk6pjAeQpg=; h=Cc:Date:From:Reply-To:Subject:To; b=uhIOelXW6OfQYy+upgmDk2eY7qAZL/aS66dRixf4WojefFBLlKpx7LCNLxZnB59BH2G Us9eX2xMJC1mLLYPdXqccH6arCEW4k1w0sIdudoexqq+5l1lFx3rRH5AFwAQBS3R8ZpyW 4s8otR9L1kvACFEXtP7y5j3wg9DUqUyhAbs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1685719105368100005 Content-Type: text/plain; charset="utf-8" Now that ArmSetMemoryAttributes() permits a mask to be provided, we can simplify the implementation the UEFI memory attribute protocol substantially, and just pass on the requested mask to be set or cleared directly. Signed-off-by: Ard Biesheuvel --- ArmPkg/Drivers/CpuDxe/MemoryAttribute.c | 50 +------------------- 1 file changed, 2 insertions(+), 48 deletions(-) diff --git a/ArmPkg/Drivers/CpuDxe/MemoryAttribute.c b/ArmPkg/Drivers/CpuDx= e/MemoryAttribute.c index 61ba8fbbae4ee795..16cc4ef474f9772b 100644 --- a/ArmPkg/Drivers/CpuDxe/MemoryAttribute.c +++ b/ArmPkg/Drivers/CpuDxe/MemoryAttribute.c @@ -183,8 +183,6 @@ SetMemoryAttributes ( IN UINT64 Attributes ) { - EFI_STATUS Status; - DEBUG (( DEBUG_INFO, "%a: BaseAddress =3D=3D 0x%lx, Length =3D=3D 0x%lx, Attributes =3D=3D = 0x%lx\n", @@ -204,28 +202,7 @@ SetMemoryAttributes ( return EFI_UNSUPPORTED; } =20 - if ((Attributes & EFI_MEMORY_RP) !=3D 0) { - Status =3D ArmSetMemoryRegionNoAccess (BaseAddress, Length); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - } - - if ((Attributes & EFI_MEMORY_RO) !=3D 0) { - Status =3D ArmSetMemoryRegionReadOnly (BaseAddress, Length); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - } - - if ((Attributes & EFI_MEMORY_XP) !=3D 0) { - Status =3D ArmSetMemoryRegionNoExec (BaseAddress, Length); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - } - - return EFI_SUCCESS; + return ArmSetMemoryAttributes (BaseAddress, Length, Attributes, Attribut= es); } =20 /** @@ -267,8 +244,6 @@ ClearMemoryAttributes ( IN UINT64 Attributes ) { - EFI_STATUS Status; - DEBUG (( DEBUG_INFO, "%a: BaseAddress =3D=3D 0x%lx, Length =3D=3D 0x%lx, Attributes =3D=3D = 0x%lx\n", @@ -288,28 +263,7 @@ ClearMemoryAttributes ( return EFI_UNSUPPORTED; } =20 - if ((Attributes & EFI_MEMORY_RP) !=3D 0) { - Status =3D ArmClearMemoryRegionNoAccess (BaseAddress, Length); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - } - - if ((Attributes & EFI_MEMORY_RO) !=3D 0) { - Status =3D ArmClearMemoryRegionReadOnly (BaseAddress, Length); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - } - - if ((Attributes & EFI_MEMORY_XP) !=3D 0) { - Status =3D ArmClearMemoryRegionNoExec (BaseAddress, Length); - if (EFI_ERROR (Status)) { - return EFI_UNSUPPORTED; - } - } - - return EFI_SUCCESS; + return ArmSetMemoryAttributes (BaseAddress, Length, 0, Attributes); } =20 EFI_MEMORY_ATTRIBUTE_PROTOCOL mMemoryAttribute =3D { --=20 2.39.2 -=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 (#105656): https://edk2.groups.io/g/devel/message/105656 Mute This Topic: https://groups.io/mt/99288489/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-