From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by mx.groups.io with SMTP id smtpd.web10.15549.1675951214822055810 for ; Thu, 09 Feb 2023 06:00:15 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=oMHEB1LF; spf=pass (domain: kernel.org, ip: 145.40.68.75, 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 ams.source.kernel.org (Postfix) with ESMTPS id DD7A0B82147; Thu, 9 Feb 2023 14:00:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A6D9C4339E; Thu, 9 Feb 2023 14:00:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675951211; bh=OIEQ2ApmBp3Drzae4GDWqldbZSrRoH3fMy35jt474vk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oMHEB1LF9Cq3Al0bnwDwNvQXVBSLzhoew9D364XXs/wYJnhrHKv24w3s7DTJcawYq LvUROS40K8wDNFjBV2yUxAdjDzV5AbGKAPXQXL8xW92F/SOTBdRWsO0E7ygey+8pWt StvrSJSkwsz/AHMkXxXrpa7g/PljeQmzrvhP3zWoNJ5hWp6DzOJp3VN8r/+eHly3px cTsQqgiqhAVUFdk7dc1dAn4cdeXvfRgCzV5hl4HQq7IlUTxEIoAn2bWOm/nW2d1mXH B16WNTdFZ4Y4xZwwS90rwypPP0Nr49pH7OaRLYtb493E5rp62MQX2jS/phpFDebNXy fm6VOB10fPDUg== From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Michael Kinney , Liming Gao , Jiewen Yao , Michael Kubacki , Sean Brogan , Rebecca Cran , Leif Lindholm , Sami Mujawar , Taylor Beebe Subject: [PATCH v4 09/11] ArmPkg/CpuDxe: Expose unified region-to-EFI attribute conversion Date: Thu, 9 Feb 2023 14:59:34 +0100 Message-Id: <20230209135936.789983-10-ardb@kernel.org> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230209135936.789983-1-ardb@kernel.org> References: <20230209135936.789983-1-ardb@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable In preparation for introducing an implementation of the EFI memory attributes protocol that is shared between ARM and AArch64, unify the existing code that converts a page table descriptor into a EFI_MEMORY_xxx bitfield, so it can be called from the generic code. Signed-off-by: Ard Biesheuvel --- ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c | 17 +++++++++ ArmPkg/Drivers/CpuDxe/Arm/Mmu.c | 38 ++++++++++++++++++++ ArmPkg/Drivers/CpuDxe/CpuDxe.h | 14 ++++++++ 3 files changed, 69 insertions(+) diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c b/ArmPkg/Drivers/CpuDxe/AA= rch64/Mmu.c index 8bda11f08a30..4a416743fb8a 100644 --- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c +++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c @@ -83,6 +83,23 @@ PageAttributeToGcdAttribute ( return GcdAttributes;=0D }=0D =0D +/**=0D + Convert a arch specific set of page attributes into a mask=0D + of EFI_MEMORY_xx constants.=0D +=0D + @param PageAttributes The set of page attributes.=0D +=0D + @retval The mask of EFI_MEMORY_xx constants.=0D +=0D +**/=0D +UINT64=0D +RegionAttributeToGcdAttribute (=0D + IN UINTN PageAttributes=0D + )=0D +{=0D + return PageAttributeToGcdAttribute (PageAttributes);=0D +}=0D +=0D STATIC=0D UINT64=0D GetFirstPageAttribute (=0D diff --git a/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c b/ArmPkg/Drivers/CpuDxe/Arm/Mm= u.c index 07faab8216ec..8e0dd5d2aaca 100644 --- a/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c +++ b/ArmPkg/Drivers/CpuDxe/Arm/Mmu.c @@ -13,6 +13,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include =0D #include "CpuDxe.h"=0D =0D +/**=0D + Convert a set of ARM short descriptor section attributes into a mask=0D + of EFI_MEMORY_xx constants.=0D +=0D + @param SectionAttributes The set of page attributes.=0D + @param GcdAttributes Pointer to the return value.=0D +=0D +**/=0D +STATIC=0D EFI_STATUS=0D SectionToGcdAttributes (=0D IN UINT32 SectionAttributes,=0D @@ -74,6 +83,35 @@ SectionToGcdAttributes ( return EFI_SUCCESS;=0D }=0D =0D +/**=0D + Convert a arch specific set of page attributes into a mask=0D + of EFI_MEMORY_xx constants.=0D +=0D + @param PageAttributes The set of page attributes.=0D +=0D + @retval The mask of EFI_MEMORY_xx constants.=0D +=0D +**/=0D +UINT64=0D +RegionAttributeToGcdAttribute (=0D + IN UINTN PageAttributes=0D + )=0D +{=0D + UINT64 Result;=0D +=0D + SectionToGcdAttributes (PageAttributes, &Result);=0D + return Result;=0D +}=0D +=0D +/**=0D + Convert a set of ARM short descriptor page attributes into a mask=0D + of EFI_MEMORY_xx constants.=0D +=0D + @param PageAttributes The set of page attributes.=0D + @param GcdAttributes Pointer to the return value.=0D +=0D +**/=0D +STATIC=0D EFI_STATUS=0D PageToGcdAttributes (=0D IN UINT32 PageAttributes,=0D diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.h b/ArmPkg/Drivers/CpuDxe/CpuDxe.h index ff672390ce51..8cb105dcc841 100644 --- a/ArmPkg/Drivers/CpuDxe/CpuDxe.h +++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.h @@ -126,4 +126,18 @@ SetGcdMemorySpaceAttributes ( IN UINT64 Attributes=0D );=0D =0D +/**=0D + Convert a arch specific set of page attributes into a mask=0D + of EFI_MEMORY_xx constants.=0D +=0D + @param PageAttributes The set of page attributes.=0D +=0D + @retval The mask of EFI_MEMORY_xx constants.=0D +=0D +**/=0D +UINT64=0D +RegionAttributeToGcdAttribute (=0D + IN UINTN PageAttributes=0D + );=0D +=0D #endif // CPU_DXE_H_=0D --=20 2.39.1