From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=g7/dDOqL; spf=pass (domain: kernel.org, ip: 139.178.84.217, mailfrom: ardb@kernel.org) 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) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A10DFC4339B; Thu, 25 May 2023 14:31:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1685025064; bh=C36FstEDwri/X+EappEwJhGBoEHXJCUK4ZUvscL/wSc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=g7/dDOqL40/qSv3Aa9xCbJKBx8RAfSpXAjJ/wxkZ9QAPKgi3rILTadi7Ob97BtS8j x9qknEGOq5LSJwCvRXD+C06mm8sEq5lk8RWgYIEL3gvL0d8uMidHKMf/x56yvIJdCb fE1kloRYs33mxPERKpPyprXlDJaWQK2A/RoBNSkRMwsGOaktWSRtlHupCgKdzSTQMB GSZ1PMfcn/vY1h+un3QM1xf05m+wRgLEFzptmIGJLPf75L+H10HZ3G7V45x2SK/RkZ 8AaCUeYir2eniJVoY9bh1rh+H1ZP7PAUOv7Aig2upoj9PUkst0h/9eO1z0ZILlCSt7 7MrJrhjrvFwLg== 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: [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> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230525143041.1172989-1-ardb@kernel.org> References: <20230525143041.1172989-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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=0D )=0D {=0D - EFI_STATUS Status;=0D -=0D DEBUG ((=0D DEBUG_INFO,=0D "%a: BaseAddress =3D=3D 0x%lx, Length =3D=3D 0x%lx, Attributes =3D=3D = 0x%lx\n",=0D @@ -204,28 +202,7 @@ SetMemoryAttributes ( return EFI_UNSUPPORTED;=0D }=0D =0D - if ((Attributes & EFI_MEMORY_RP) !=3D 0) {=0D - Status =3D ArmSetMemoryRegionNoAccess (BaseAddress, Length);=0D - if (EFI_ERROR (Status)) {=0D - return EFI_UNSUPPORTED;=0D - }=0D - }=0D -=0D - if ((Attributes & EFI_MEMORY_RO) !=3D 0) {=0D - Status =3D ArmSetMemoryRegionReadOnly (BaseAddress, Length);=0D - if (EFI_ERROR (Status)) {=0D - return EFI_UNSUPPORTED;=0D - }=0D - }=0D -=0D - if ((Attributes & EFI_MEMORY_XP) !=3D 0) {=0D - Status =3D ArmSetMemoryRegionNoExec (BaseAddress, Length);=0D - if (EFI_ERROR (Status)) {=0D - return EFI_UNSUPPORTED;=0D - }=0D - }=0D -=0D - return EFI_SUCCESS;=0D + return ArmSetMemoryAttributes (BaseAddress, Length, Attributes, Attribut= es);=0D }=0D =0D /**=0D @@ -267,8 +244,6 @@ ClearMemoryAttributes ( IN UINT64 Attributes=0D )=0D {=0D - EFI_STATUS Status;=0D -=0D DEBUG ((=0D DEBUG_INFO,=0D "%a: BaseAddress =3D=3D 0x%lx, Length =3D=3D 0x%lx, Attributes =3D=3D = 0x%lx\n",=0D @@ -288,28 +263,7 @@ ClearMemoryAttributes ( return EFI_UNSUPPORTED;=0D }=0D =0D - if ((Attributes & EFI_MEMORY_RP) !=3D 0) {=0D - Status =3D ArmClearMemoryRegionNoAccess (BaseAddress, Length);=0D - if (EFI_ERROR (Status)) {=0D - return EFI_UNSUPPORTED;=0D - }=0D - }=0D -=0D - if ((Attributes & EFI_MEMORY_RO) !=3D 0) {=0D - Status =3D ArmClearMemoryRegionReadOnly (BaseAddress, Length);=0D - if (EFI_ERROR (Status)) {=0D - return EFI_UNSUPPORTED;=0D - }=0D - }=0D -=0D - if ((Attributes & EFI_MEMORY_XP) !=3D 0) {=0D - Status =3D ArmClearMemoryRegionNoExec (BaseAddress, Length);=0D - if (EFI_ERROR (Status)) {=0D - return EFI_UNSUPPORTED;=0D - }=0D - }=0D -=0D - return EFI_SUCCESS;=0D + return ArmSetMemoryAttributes (BaseAddress, Length, 0, Attributes);=0D }=0D =0D EFI_MEMORY_ATTRIBUTE_PROTOCOL mMemoryAttribute =3D {=0D --=20 2.39.2