From nobody Mon Sep 16 19:22:07 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+101113+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+101113+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1678727879; cv=none; d=zohomail.com; s=zohoarc; b=HGMOVxMOaeDkBJgObFWzQbhBEkTSpVSmg+y/CN0UzG0GbjyhH9H3OuR1+OZu/ndeIxEzyrlBs98V+sRizAgoISmtrOwLpyuN9uXmj7FDzOXwwi7BxgssR4hV8tYgNt5p8zeOvA56MN3vIzoVZIRYnwYxEVOtoA+Jy+ZucDzVQIU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678727879; 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=F92tUrYEB4ktFeodProyVEV+WipirqXaIo9D2+BdElo=; b=Yup8p2bv+pQTc9uS5XnbfG+1YY5UIiqR+cJwG/iFhUZvkItaRItvHUgYL3Z/1ceERa9TWh1hGjvJYg6lweyVJiW1l4lHL15wFKlJSBrOHYQlUF5pXTP7Li8LYAx74upiKPcktFtQcSzwunH0KOVj6HuPR6ol1RmsnKaQYft2hYg= 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+101113+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 1678727879909275.5211780932858; Mon, 13 Mar 2023 10:17:59 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id iJ6EYY1788612x2H3Q2NuP5n; Mon, 13 Mar 2023 10:17:59 -0700 X-Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by mx.groups.io with SMTP id smtpd.web10.25793.1678727878561396798 for ; Mon, 13 Mar 2023 10:17:58 -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 0E33F61368; Mon, 13 Mar 2023 17:17:58 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 43BEDC4339C; Mon, 13 Mar 2023 17:17:55 +0000 (UTC) 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: [edk2-devel] [PATCH v5 09/38] ArmPkg/CpuDxe: Expose unified region-to-EFI attribute conversion Date: Mon, 13 Mar 2023 18:16:45 +0100 Message-Id: <20230313171714.3866151-10-ardb@kernel.org> In-Reply-To: <20230313171714.3866151-1-ardb@kernel.org> References: <20230313171714.3866151-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: D58a41zGhnwhb28dUtag2kaVx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678727879; bh=jRLSNXQ9SaNn++aIYxoqyCIG0v5nZFhg9P+Y56FuuB8=; h=Cc:Date:From:Reply-To:Subject:To; b=soSJheE6+KGFdOS8RIlqe+W8zIy08Se6hPwVKYBlykXmKXl0arpafJf7Wo/WFFDlPmk Bq+tq1UwhGg3snYwyZVG4nIzrPrUsNFQEREv9rn3zlwLn0TJSyuX0KMMNU64cVoRmIpOe yfbvWVawHWBxk0DFsGNpuiliFK7o5FhwXHQ= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678727881983100005 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Leif Lindholm --- 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; } =20 +/** + Convert a arch specific set of page attributes into a mask + of EFI_MEMORY_xx constants. + + @param PageAttributes The set of page attributes. + + @retval The mask of EFI_MEMORY_xx constants. + +**/ +UINT64 +RegionAttributeToGcdAttribute ( + IN UINTN PageAttributes + ) +{ + return PageAttributeToGcdAttribute (PageAttributes); +} + STATIC UINT64 GetFirstPageAttribute ( 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 #include "CpuDxe.h" =20 +/** + Convert a set of ARM short descriptor section attributes into a mask + of EFI_MEMORY_xx constants. + + @param SectionAttributes The set of page attributes. + @param GcdAttributes Pointer to the return value. + +**/ +STATIC EFI_STATUS SectionToGcdAttributes ( IN UINT32 SectionAttributes, @@ -74,6 +83,35 @@ SectionToGcdAttributes ( return EFI_SUCCESS; } =20 +/** + Convert a arch specific set of page attributes into a mask + of EFI_MEMORY_xx constants. + + @param PageAttributes The set of page attributes. + + @retval The mask of EFI_MEMORY_xx constants. + +**/ +UINT64 +RegionAttributeToGcdAttribute ( + IN UINTN PageAttributes + ) +{ + UINT64 Result; + + SectionToGcdAttributes (PageAttributes, &Result); + return Result; +} + +/** + Convert a set of ARM short descriptor page attributes into a mask + of EFI_MEMORY_xx constants. + + @param PageAttributes The set of page attributes. + @param GcdAttributes Pointer to the return value. + +**/ +STATIC EFI_STATUS PageToGcdAttributes ( IN UINT32 PageAttributes, 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 ); =20 +/** + Convert a arch specific set of page attributes into a mask + of EFI_MEMORY_xx constants. + + @param PageAttributes The set of page attributes. + + @retval The mask of EFI_MEMORY_xx constants. + +**/ +UINT64 +RegionAttributeToGcdAttribute ( + IN UINTN PageAttributes + ); + #endif // CPU_DXE_H_ --=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 (#101113): https://edk2.groups.io/g/devel/message/101113 Mute This Topic: https://groups.io/mt/97585996/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-