From nobody Mon Sep 16 19:41:53 2024 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+105302+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+105302+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1685025066; cv=none; d=zohomail.com; s=zohoarc; b=H6CQif60rw1UIvqglci06aHV/rh//ZDCM+oH1a4wc5KHWq89MLOU2wjHPG4/5N8bvf6+ApIpUnE5z5LKMlvGy/M5J/owto9BjFObuwhnL1PWw4efEjuYCT7RpJMC/nPCpsC/TR20OFMosfQOLV0pphK8ZZc2WGm7O6Yt/oNqZKU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1685025066; 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=e1lKI05EPaA+rGSAirlP69AUjYN3iNEOsiI6nJvgQdA=; b=CcCCrruAWKH9A9e1DOJlCwHFrk0GGBcbYwcfyYwXRF7w0ik5MOkUyDP1+BxwhWee9Tpq8op9VegJmJRFCqcDeg4ig4c0E6y0wO1SzVlIrFgXz8tcnWrFlOB07EeORD+qEDi5g78sF0Yn2m7DMcj6HFQMYRdncnxd4hPZR4lsfLI= 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+105302+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 16850250668161010.9479531378819; Thu, 25 May 2023 07:31:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id LESBYY1788612xkRZVC5Iwus; Thu, 25 May 2023 07:31:06 -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.13270.1685025065227322485 for ; Thu, 25 May 2023 07:31:05 -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 BAA8C64629; Thu, 25 May 2023 14:31:04 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A10DFC4339B; Thu, 25 May 2023 14:31:01 +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 , Liming Gao , "Kinney, Michael D" , Leif Lindholm , Sunil V L , Andrei Warkentin Subject: [edk2-devel] [RFC PATCH 02/10] ArmPkg/CpuDxe: Simplify memory attributes protocol implementation Date: Thu, 25 May 2023 16:30:33 +0200 Message-Id: <20230525143041.1172989-3-ardb@kernel.org> In-Reply-To: <20230525143041.1172989-1-ardb@kernel.org> References: <20230525143041.1172989-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: anZf9uPckvoIKJLM3oMnIIv9x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1685025066; bh=JphNO4ajj24XaD2gWb1N3GBLw+/j6XPGBgpAhaqUpOQ=; h=Cc:Date:From:Reply-To:Subject:To; b=Y60VCM89zZsm9strx+AY18klclMy+8je+J3+FapGdl+PuNLfr9UQRCnUtyFcFkFhnQX Hhg0B2GB9wqH4PS4f4Q8ONbV1XU+1UlUSPjrM4nSIIgaup6+d+SrXT4HQf6x4D8Uofr3S ObV/isgBg3X57d4ZEVs5DW43LYbTD+u41Vw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1685025068587100005 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 (#105302): https://edk2.groups.io/g/devel/message/105302 Mute This Topic: https://groups.io/mt/99131176/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-