From nobody Mon May 6 00:28:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56525+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56525+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1585392209; cv=none; d=zohomail.com; s=zohoarc; b=Z+rXhCECiT8D2+Nsp5Aupc6xIWQNIDSocRR/Kl11RGppnUWwJnIGP7lomFzq+t1XZxuehr4YcQuDRKAW9YLdrhG22hE4gRix5nfSev0VXZqEXpHQsTITmTnMT5jMCs5paULMh/oYPRryMP4clAcmUBVpUNUHPeXrnm/Xvprm8Ig= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585392209; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=UIv2JqWtsUup+3wGCSo5U0UzxwC6DWeCrk7jYqYi37c=; b=HRYGQz3UXyYGDyejcNRWO6YOShgdeBnxSak/QS0oxalw8uAv1hY/O9fkoh4ZR7hteH3vilqp9y4wwEBnWCO1AMPj1sjYzaGQj6QQ0gpl+F/QMrfjy4hpA8xNhEAPSgDWlLwBFOwGTKK4kWBGHgaDb1sBlKRmFrfFPlmLrFZMdTs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56525+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585392209736841.8965126044188; Sat, 28 Mar 2020 03:43:29 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id qc9YYY1788612xgRtQVKgqBo; Sat, 28 Mar 2020 03:43:29 -0700 X-Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web12.3014.1585392208679388492 for ; Sat, 28 Mar 2020 03:43:29 -0700 X-Received: by mail-wr1-f68.google.com with SMTP id a25so14840943wrd.0 for ; Sat, 28 Mar 2020 03:43:28 -0700 (PDT) X-Gm-Message-State: UgjaSF3HNf05BWP6YDHmaCAPx1787277AA= X-Google-Smtp-Source: ADFU+vuYxCZSjC1vT9zD04kCiz8tkRapZ0EAcO3/PO6hKUfuO7bRalt/ZTJGjUu35jv6cG1NCiIxmA== X-Received: by 2002:adf:f1ce:: with SMTP id z14mr4378776wro.68.1585392207063; Sat, 28 Mar 2020 03:43:27 -0700 (PDT) X-Received: from e123331-lin.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr. [109.210.65.247]) by smtp.gmail.com with ESMTPSA id a13sm4756386wrt.64.2020.03.28.03.43.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2020 03:43:26 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH 1/5] ArmPkg/CpuDxe: use private copy of GetRootTranslationTableInfo() Date: Sat, 28 Mar 2020 11:43:17 +0100 Message-Id: <20200328104321.8668-2-ard.biesheuvel@linaro.org> In-Reply-To: <20200328104321.8668-1-ard.biesheuvel@linaro.org> References: <20200328104321.8668-1-ard.biesheuvel@linaro.org> Precedence: Bulk List-Unsubscribe: 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,ard.biesheuvel@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585392209; bh=GjMpqUBoQBnm0xpUEHFrGtfQ7ZE+hpQVyylXGkF4b6A=; h=Cc:Date:From:Reply-To:Subject:To; b=g2TaupfNL90iWQtFUzkyHVd8anhzsBZEF46P496BTz1YFXqtwLH0p1SaNAjXkE1juQx 1L//qf9+zfyzn5kUV5eOJ2lFWNl4bbhJ2iz+85qrGomMjeIsnztIOeqxHNa/S9n8HIX0I KJ9ijjsDR6/K/lv4H+j/I8H/6NP7Q0wam2g= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Before getting rid of GetRootTranslationTableInfo() and the related LookupAddresstoRootTable() in AARCH64's version of ArmMmuLib, add a version of the former to CpuDxe, which will be its only remaining user. While at it, simplify it a bit, since in the CpuDxe cases, both OUT arguments are always provided. Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c | 15 +++++++++++++++ ArmPkg/Drivers/CpuDxe/CpuDxe.h | 7 ------- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c b/ArmPkg/Drivers/CpuDxe/AA= rch64/Mmu.c index 3b6c5e733709..24eb1c4221e3 100644 --- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c +++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c @@ -15,6 +15,21 @@ SPDX-License-Identifier: BSD-2-Clause-Patent =20 #define TT_ATTR_INDX_INVALID ((UINT32)~0) =20 +#define MIN_T0SZ 16 +#define BITS_PER_LEVEL 9 + +STATIC +VOID +GetRootTranslationTableInfo ( + IN UINTN T0SZ, + OUT UINTN *RootTableLevel, + OUT UINTN *RootTableEntryCount + ) +{ + *RootTableLevel =3D (T0SZ - MIN_T0SZ) / BITS_PER_LEVEL; + *RootTableEntryCount =3D TT_ENTRY_COUNT >> (T0SZ - MIN_T0SZ) % BITS_PER= _LEVEL; +} + STATIC UINT64 GetFirstPageAttribute ( diff --git a/ArmPkg/Drivers/CpuDxe/CpuDxe.h b/ArmPkg/Drivers/CpuDxe/CpuDxe.h index b627c3c50ff8..3fe5c24d5e5b 100644 --- a/ArmPkg/Drivers/CpuDxe/CpuDxe.h +++ b/ArmPkg/Drivers/CpuDxe/CpuDxe.h @@ -134,13 +134,6 @@ GetMemoryRegion ( OUT UINTN *RegionAttributes ); =20 -VOID -GetRootTranslationTableInfo ( - IN UINTN T0SZ, - OUT UINTN *TableLevel, - OUT UINTN *TableEntryCount - ); - EFI_STATUS SetGcdMemorySpaceAttributes ( IN EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap, --=20 2.17.1 -=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 (#56525): https://edk2.groups.io/g/devel/message/56525 Mute This Topic: https://groups.io/mt/72606847/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- From nobody Mon May 6 00:28:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56526+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56526+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1585392210; cv=none; d=zohomail.com; s=zohoarc; b=g9U/S3R/FkeiJqOgxkP+PZJAfBOi6j/XRGMhGy1ccwyMTLTSSCeHmBS4RiIDWMNDGWEZI3Ub7jQRKVZ7QuqZmhhYKOypCdsPy8IZRj3w8CF51wCcZCDk5npIT1q0hxBJKzslILQL+msaRlEW2VtzKUrDILmmbS2PFgt20PnwMqI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585392210; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=1UoH6hzYLNacRvbYihSNADOE18TOU1OCclIN6BPNktY=; b=PGVbbi4okSZHHI2YiboDsPZQQwQkn2VyfkM7FIe1ZrpgFjDSyas3rzzbxCAh6FHFeBkZkWw6K3mdB//6Fw0eJlyn6Y5jaAbBSHxiZXC1XnsqMGlPbE/22/SBRalciZaPV1ug6YEi0PlaeIDffLCXycaUKIfas1U/9t2OvyZJXE8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56526+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 158539221084985.77086755862399; Sat, 28 Mar 2020 03:43:30 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id NntKYY1788612xywxL8ioVJE; Sat, 28 Mar 2020 03:43:30 -0700 X-Received: from mail-wr1-f65.google.com (mail-wr1-f65.google.com [209.85.221.65]) by mx.groups.io with SMTP id smtpd.web12.3015.1585392209868711741 for ; Sat, 28 Mar 2020 03:43:30 -0700 X-Received: by mail-wr1-f65.google.com with SMTP id u10so14785130wro.7 for ; Sat, 28 Mar 2020 03:43:29 -0700 (PDT) X-Gm-Message-State: LN2I6jUw9TRqCxIUUFvBdHcpx1787277AA= X-Google-Smtp-Source: ADFU+vtBA+MjyuKpDIBVR7yBNrAkaB7JJq/yqtmM6wkXF7tg0QYMywPGaygTWWMq5VFa/1NySz9wRw== X-Received: by 2002:adf:fece:: with SMTP id q14mr4353819wrs.300.1585392208150; Sat, 28 Mar 2020 03:43:28 -0700 (PDT) X-Received: from e123331-lin.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr. [109.210.65.247]) by smtp.gmail.com with ESMTPSA id a13sm4756386wrt.64.2020.03.28.03.43.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2020 03:43:27 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH 2/5] ArmPkg/CpuDxe: move PageAttributeToGcdAttribute() out of ArmMmuLib Date: Sat, 28 Mar 2020 11:43:18 +0100 Message-Id: <20200328104321.8668-3-ard.biesheuvel@linaro.org> In-Reply-To: <20200328104321.8668-1-ard.biesheuvel@linaro.org> References: <20200328104321.8668-1-ard.biesheuvel@linaro.org> Precedence: Bulk List-Unsubscribe: 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,ard.biesheuvel@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585392210; bh=xVK+qR7gPcOLVaG2UTlb6L6ZIVQzT+8ZRBU/7EjMMg8=; h=Cc:Date:From:Reply-To:Subject:To; b=IO2OYmFoLG6ZNVwsVkzL8Dt86vS/fsF1eBAKdI3qmGPUnDfm4QuiToKPT5rgMvWJie8 woCQ76y8fwXk/lQjFiQgIW5id5zfYOBllm3UCombEf95poDW/3QS3fYXVFIaB5zzrX2Ao T8Gr0vI1EiB9Jr23RdHPJzUD/6UH2erdCDM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The routine PageAttributeToGcdAttribute() is exported by ArmMmuLib but only ever used in the implementation of CpuDxe. So let's move the function there and make it STATIC. Signed-off-by: Ard Biesheuvel --- ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c | 46 ++++++++++++++++++++ ArmPkg/Include/Chipset/AArch64.h | 5 --- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 45 ------------------- 3 files changed, 46 insertions(+), 50 deletions(-) diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c b/ArmPkg/Drivers/CpuDxe/AA= rch64/Mmu.c index 24eb1c4221e3..29fa08f9e07c 100644 --- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c +++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c @@ -30,6 +30,52 @@ GetRootTranslationTableInfo ( *RootTableEntryCount =3D TT_ENTRY_COUNT >> (T0SZ - MIN_T0SZ) % BITS_PER= _LEVEL; } =20 +STATIC +UINT64 +PageAttributeToGcdAttribute ( + IN UINT64 PageAttributes + ) +{ + UINT64 GcdAttributes; + + switch (PageAttributes & TT_ATTR_INDX_MASK) { + case TT_ATTR_INDX_DEVICE_MEMORY: + GcdAttributes =3D EFI_MEMORY_UC; + break; + case TT_ATTR_INDX_MEMORY_NON_CACHEABLE: + GcdAttributes =3D EFI_MEMORY_WC; + break; + case TT_ATTR_INDX_MEMORY_WRITE_THROUGH: + GcdAttributes =3D EFI_MEMORY_WT; + break; + case TT_ATTR_INDX_MEMORY_WRITE_BACK: + GcdAttributes =3D EFI_MEMORY_WB; + break; + default: + DEBUG ((DEBUG_ERROR, + "PageAttributeToGcdAttribute: PageAttributes:0x%lX not supported.\n", + PageAttributes)); + ASSERT (0); + // The Global Coherency Domain (GCD) value is defined as a bit set. + // Returning 0 means no attribute has been set. + GcdAttributes =3D 0; + } + + // Determine protection attributes + if (((PageAttributes & TT_AP_MASK) =3D=3D TT_AP_NO_RO) || + ((PageAttributes & TT_AP_MASK) =3D=3D TT_AP_RO_RO)) { + // Read only cases map to write-protect + GcdAttributes |=3D EFI_MEMORY_RO; + } + + // Process eXecute Never attribute + if ((PageAttributes & (TT_PXN_MASK | TT_UXN_MASK)) !=3D 0) { + GcdAttributes |=3D EFI_MEMORY_XP; + } + + return GcdAttributes; +} + STATIC UINT64 GetFirstPageAttribute ( diff --git a/ArmPkg/Include/Chipset/AArch64.h b/ArmPkg/Include/Chipset/AArc= h64.h index e3d877207b38..0ade5cce91c3 100644 --- a/ArmPkg/Include/Chipset/AArch64.h +++ b/ArmPkg/Include/Chipset/AArch64.h @@ -219,11 +219,6 @@ ArmReadCurrentEL ( VOID ); =20 -UINT64 -PageAttributeToGcdAttribute ( - IN UINT64 PageAttributes - ); - UINTN ArmWriteCptr ( IN UINT64 Cptr diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Libr= ary/ArmMmuLib/AArch64/ArmMmuLibCore.c index 3b10ef58f0a2..d16e847218b7 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -57,51 +57,6 @@ ArmMemoryAttributeToPageAttribute ( } } =20 -UINT64 -PageAttributeToGcdAttribute ( - IN UINT64 PageAttributes - ) -{ - UINT64 GcdAttributes; - - switch (PageAttributes & TT_ATTR_INDX_MASK) { - case TT_ATTR_INDX_DEVICE_MEMORY: - GcdAttributes =3D EFI_MEMORY_UC; - break; - case TT_ATTR_INDX_MEMORY_NON_CACHEABLE: - GcdAttributes =3D EFI_MEMORY_WC; - break; - case TT_ATTR_INDX_MEMORY_WRITE_THROUGH: - GcdAttributes =3D EFI_MEMORY_WT; - break; - case TT_ATTR_INDX_MEMORY_WRITE_BACK: - GcdAttributes =3D EFI_MEMORY_WB; - break; - default: - DEBUG ((DEBUG_ERROR, - "PageAttributeToGcdAttribute: PageAttributes:0x%lX not supported.\n", - PageAttributes)); - ASSERT (0); - // The Global Coherency Domain (GCD) value is defined as a bit set. - // Returning 0 means no attribute has been set. - GcdAttributes =3D 0; - } - - // Determine protection attributes - if (((PageAttributes & TT_AP_MASK) =3D=3D TT_AP_NO_RO) || - ((PageAttributes & TT_AP_MASK) =3D=3D TT_AP_RO_RO)) { - // Read only cases map to write-protect - GcdAttributes |=3D EFI_MEMORY_RO; - } - - // Process eXecute Never attribute - if ((PageAttributes & (TT_PXN_MASK | TT_UXN_MASK)) !=3D 0) { - GcdAttributes |=3D EFI_MEMORY_XP; - } - - return GcdAttributes; -} - #define MIN_T0SZ 16 #define BITS_PER_LEVEL 9 =20 --=20 2.17.1 -=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 (#56526): https://edk2.groups.io/g/devel/message/56526 Mute This Topic: https://groups.io/mt/72606848/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- From nobody Mon May 6 00:28:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56527+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56527+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1585392211; cv=none; d=zohomail.com; s=zohoarc; b=fGu0ZnMguGCkJLgTnvRHkQU158GTxPIjZ+B3c1SNVzE1uposYLLXKPpEBgNzUfSiAgoqZ9KQeJPbRTCbvXNaJyVFxagKD68LP5W3hJ4F0K7TFbLQ8L56fMdzaaNqYCUXrFG3lFyrZQDeAV95MhSHA1FOZpj0PU23MOcVlys1Tkg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585392211; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=HmnKDSvbF4UhCB9ZXpyUKOlPSUfhn11TIId0u2KR6xg=; b=HGLStZha24E/wD+u/kYG7GQepVfaX04YUtZIp7w/sg8O90t1JxIZnTBkPU4e9h503joRzOQDsovvFWxboiD91jhOst9/IfZxiZwHn7r+ZEPJ98yl8R1lCl54vJ4hHPpD7mn5b9sVuSmUA1V5LcblOdEIm6uK77FX7smmhhuDIow= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56527+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585392211830753.9338007587763; Sat, 28 Mar 2020 03:43:31 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6BU9YY1788612xXFV1D73umA; Sat, 28 Mar 2020 03:43:31 -0700 X-Received: from mail-wr1-f67.google.com (mail-wr1-f67.google.com [209.85.221.67]) by mx.groups.io with SMTP id smtpd.web12.3016.1585392210887162972 for ; Sat, 28 Mar 2020 03:43:31 -0700 X-Received: by mail-wr1-f67.google.com with SMTP id 65so14832128wrl.1 for ; Sat, 28 Mar 2020 03:43:30 -0700 (PDT) X-Gm-Message-State: 1DUypBuE9twbNQHRAPVxbJ4ux1787277AA= X-Google-Smtp-Source: ADFU+vtiVjerocW3ikSuAbwwd3cNrNU16hXqnQi3KIRRGqc6wqmy6yp8X4UdwmlCAcrsZ5wBefs1KQ== X-Received: by 2002:adf:a35a:: with SMTP id d26mr4464401wrb.185.1585392209225; Sat, 28 Mar 2020 03:43:29 -0700 (PDT) X-Received: from e123331-lin.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr. [109.210.65.247]) by smtp.gmail.com with ESMTPSA id a13sm4756386wrt.64.2020.03.28.03.43.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2020 03:43:28 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH 3/5] ArmPkg/ArmMmuLib: drop pointless LookupAddresstoRootTable() routine Date: Sat, 28 Mar 2020 11:43:19 +0100 Message-Id: <20200328104321.8668-4-ard.biesheuvel@linaro.org> In-Reply-To: <20200328104321.8668-1-ard.biesheuvel@linaro.org> References: <20200328104321.8668-1-ard.biesheuvel@linaro.org> Precedence: Bulk List-Unsubscribe: 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,ard.biesheuvel@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585392211; bh=YlQZA4362ERWLABrvdkdN9TTGmWhmnWEMYK90i62BFg=; h=Cc:Date:From:Reply-To:Subject:To; b=DToZSZLLUMsk+xTP+Mjv2GjkrROgVZBOsb0RvTh8mlH7wb3h82mQPXhmJXmTXvcudX8 HRThSYR/GElZzd4N/CMolqiaco19R4HgBJXk1Ah6ENFu62u7+mQBzZ/6UDJgV5Rm9Bejf vS25w2CvIlFXd+WrKmvbjVDcltHJPGAcg+E= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" LookupAddresstoRootTable() uses a loop to go over its MaxAddress argument, essentially to do a log2() and determine how many bits are needed to represent it. Since the argument is the result of a shift-left expression, there is some room for improvement here, and we can simply use the bit count directly to calculate the value of T0SZ. At the same time, we can omit calling GetRootTranslationTableInfo() to determine the number of root table entries, and add a new helper that applies the trivial calculation directly. Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 49 ++++++-------------- 1 file changed, 15 insertions(+), 34 deletions(-) diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Libr= ary/ArmMmuLib/AArch64/ArmMmuLibCore.c index d16e847218b7..b6f3ef54aa26 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -59,6 +59,16 @@ ArmMemoryAttributeToPageAttribute ( =20 #define MIN_T0SZ 16 #define BITS_PER_LEVEL 9 +#define MAX_VA_BITS 48 + +STATIC +UINTN +GetRootTableEntryCount ( + IN UINTN T0SZ + ) +{ + return TT_ENTRY_COUNT >> (T0SZ - MIN_T0SZ) % BITS_PER_LEVEL; +} =20 VOID GetRootTranslationTableInfo ( @@ -284,36 +294,6 @@ UpdateRegionMappingRecursive ( return EFI_SUCCESS; } =20 -STATIC -VOID -LookupAddresstoRootTable ( - IN UINT64 MaxAddress, - OUT UINTN *T0SZ, - OUT UINTN *TableEntryCount - ) -{ - UINTN TopBit; - - // Check the parameters are not NULL - ASSERT ((T0SZ !=3D NULL) && (TableEntryCount !=3D NULL)); - - // Look for the highest bit set in MaxAddress - for (TopBit =3D 63; TopBit !=3D 0; TopBit--) { - if ((1ULL << TopBit) & MaxAddress) { - // MaxAddress top bit is found - TopBit =3D TopBit + 1; - break; - } - } - ASSERT (TopBit !=3D 0); - - // Calculate T0SZ from the top bit of the MaxAddress - *T0SZ =3D 64 - TopBit; - - // Get the Table info from T0SZ - GetRootTranslationTableInfo (*T0SZ, NULL, TableEntryCount); -} - STATIC EFI_STATUS UpdateRegionMapping ( @@ -508,6 +488,7 @@ ArmConfigureMmu ( ) { VOID* TranslationTable; + UINTN MaxAddressBits; UINT64 MaxAddress; UINTN T0SZ; UINTN RootTableEntryCount; @@ -526,11 +507,11 @@ ArmConfigureMmu ( // into account the architectural limitations that result from UEFI's // use of 4 KB pages. // - MaxAddress =3D MIN (LShiftU64 (1ULL, ArmGetPhysicalAddressBits ()) - 1, - MAX_ALLOC_ADDRESS); + MaxAddressBits =3D MIN (ArmGetPhysicalAddressBits (), MAX_VA_BITS); + MaxAddress =3D LShiftU64 (1ULL, MaxAddressBits) - 1; =20 - // Lookup the Table Level to get the information - LookupAddresstoRootTable (MaxAddress, &T0SZ, &RootTableEntryCount); + T0SZ =3D 64 - MaxAddressBits; + RootTableEntryCount =3D GetRootTableEntryCount (T0SZ); =20 // // Set TCR that allows us to retrieve T0SZ in the subsequent functions --=20 2.17.1 -=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 (#56527): https://edk2.groups.io/g/devel/message/56527 Mute This Topic: https://groups.io/mt/72606849/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- From nobody Mon May 6 00:28:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56528+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56528+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1585392212; cv=none; d=zohomail.com; s=zohoarc; b=QhpmmqJntfjKAI+mSU/rarau7IlkvrM3tjo8JzfgkTmOioJAc14/iAcgrTsUxxOIHsJ3h0jAlgxrejXWrp6ANFoSeoB7snrpel9/icSe2h1WkvW1QNFRDPAfAjU9IzGR5zWD7h2gs6o2mCIeacojYJSwPYvldZy4dpm52EAGSRA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585392212; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=Z3zTcq4yiBVAY14EzBJgZoVVwHq5+n1qINna9rRhDog=; b=LqcbLka8XRGe7jfQCFgXnEo/Jv5fuRJfPVRFSrmutTSOUaFBU0hzQLgCv8feM66mlHY84ni65BFL3NkYxSg8WmYIsJJ8Doy8lNagHyXndIsE0ll3VaWwWkLWyd2m/6Ohe5xKNP+eepI+QUF416ESJqhcoC/Yxo1gsz4nYU6rt50= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56528+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585392212779602.3738767184323; Sat, 28 Mar 2020 03:43:32 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id pKUNYY1788612xbCgqDH3jYv; Sat, 28 Mar 2020 03:43:32 -0700 X-Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web11.3002.1585392211837102758 for ; Sat, 28 Mar 2020 03:43:32 -0700 X-Received: by mail-wr1-f68.google.com with SMTP id s1so14791115wrv.5 for ; Sat, 28 Mar 2020 03:43:31 -0700 (PDT) X-Gm-Message-State: OtGKl1DLIfbC3W5Iz1Gj7XW5x1787277AA= X-Google-Smtp-Source: ADFU+vsJ/RJPNhAJ/KM9ootCJz/hyJ3LELpQrj3bqlhGmSBMmyNqaIlbS3WUXcU+Oz2UrpZuuGBHxA== X-Received: by 2002:adf:e98a:: with SMTP id h10mr4411547wrm.370.1585392210245; Sat, 28 Mar 2020 03:43:30 -0700 (PDT) X-Received: from e123331-lin.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr. [109.210.65.247]) by smtp.gmail.com with ESMTPSA id a13sm4756386wrt.64.2020.03.28.03.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2020 03:43:29 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH 4/5] ArmPkg/ArmMmuLib: get rid of GetRootTranslationTableInfo() Date: Sat, 28 Mar 2020 11:43:20 +0100 Message-Id: <20200328104321.8668-5-ard.biesheuvel@linaro.org> In-Reply-To: <20200328104321.8668-1-ard.biesheuvel@linaro.org> References: <20200328104321.8668-1-ard.biesheuvel@linaro.org> Precedence: Bulk List-Unsubscribe: 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,ard.biesheuvel@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585392212; bh=8mPZW/ciLqqKcfCnTX9fwMJFvgSQsdz9EW/nJLGNEs4=; h=Cc:Date:From:Reply-To:Subject:To; b=ohXgzQmqZMuUu6arYZIxGvNhkApC1XCHYIITdBcan31G9hFRHvVX6KTE3FEUICJag7E /raLTXVq4GQNIB41dKEzT/jZeQWkLy5+/oUW3DprVVpfIhmORdVsCZ4vBkW0r4j3kEmNN 43gDB4I6JlnRIYisujNz2aJ3EFA23tyVhZo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Only a single call to GetRootTranslationTableInfo() remains, which only provides the root table level. So let's create a new static helper function that returns just this value, and use it instead. Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 22 ++++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Libr= ary/ArmMmuLib/AArch64/ArmMmuLibCore.c index b6f3ef54aa26..a82596d290f1 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -70,21 +70,13 @@ GetRootTableEntryCount ( return TT_ENTRY_COUNT >> (T0SZ - MIN_T0SZ) % BITS_PER_LEVEL; } =20 -VOID -GetRootTranslationTableInfo ( - IN UINTN T0SZ, - OUT UINTN *TableLevel, - OUT UINTN *TableEntryCount +STATIC +UINTN +GetRootTableLevel ( + IN UINTN T0SZ ) { - // Get the level of the root table - if (TableLevel) { - *TableLevel =3D (T0SZ - MIN_T0SZ) / BITS_PER_LEVEL; - } - - if (TableEntryCount) { - *TableEntryCount =3D 1UL << (BITS_PER_LEVEL - (T0SZ - MIN_T0SZ) % BITS= _PER_LEVEL); - } + return (T0SZ - MIN_T0SZ) / BITS_PER_LEVEL; } =20 STATIC @@ -303,7 +295,6 @@ UpdateRegionMapping ( IN UINT64 AttributeClearMask ) { - UINTN RootTableLevel; UINTN T0SZ; =20 if (((RegionStart | RegionLength) & EFI_PAGE_MASK)) { @@ -311,11 +302,10 @@ UpdateRegionMapping ( } =20 T0SZ =3D ArmGetTCR () & TCR_T0SZ_MASK; - GetRootTranslationTableInfo (T0SZ, &RootTableLevel, NULL); =20 return UpdateRegionMappingRecursive (RegionStart, RegionStart + RegionLe= ngth, AttributeSetMask, AttributeClearMask, ArmGetTTBR0BaseAddress (), - RootTableLevel); + GetRootTableLevel (T0SZ)); } =20 STATIC --=20 2.17.1 -=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 (#56528): https://edk2.groups.io/g/devel/message/56528 Mute This Topic: https://groups.io/mt/72606850/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- From nobody Mon May 6 00:28:21 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+56529+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56529+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1585392213; cv=none; d=zohomail.com; s=zohoarc; b=ngDkI0d28VIPzoS2T605yw8l1kK6FisMb76rNiSm65WkRPaMhNdPWdr4oIyYRi8mcvKV/z1lLfj2EB1zD7lYepXgVzV3lDS32eXLV3bh/y7aD8w94LQcw3SGHStabcZeCixrmjXE3KSkGRQgS3XI6szR0zZInf8P7JezGDza+C0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1585392213; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To; bh=mlLlqqVoVpbAZpLKO931jqmfV2ovIQcKqCzs6BRIjOA=; b=lKoq+liZAVJc3hBdfxJ4KbE10mHTGHmmJSWHgnWDDctVudAWpqSk1ZoXgL8XaQUiPlEjDj7CHeuBK/SeqzR088y2TCTrg4Mv4DEzARdZtn4/asnQ4MhgV5V9tDat1DzOwcjy30QKLSM+nHcm5JcI2dFIz6L2ZHbT4kwgDG2fD2s= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+56529+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1585392213792356.69823062079547; Sat, 28 Mar 2020 03:43:33 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id FNn2YY1788612xG6O438lty4; Sat, 28 Mar 2020 03:43:33 -0700 X-Received: from mail-wr1-f68.google.com (mail-wr1-f68.google.com [209.85.221.68]) by mx.groups.io with SMTP id smtpd.web11.3003.1585392212814779830 for ; Sat, 28 Mar 2020 03:43:33 -0700 X-Received: by mail-wr1-f68.google.com with SMTP id p10so14794030wrt.6 for ; Sat, 28 Mar 2020 03:43:32 -0700 (PDT) X-Gm-Message-State: o7iM1sxfkyi5Lxl1ql6d46xfx1787277AA= X-Google-Smtp-Source: ADFU+vuNf4U7dMzCtr1uPH4N7DV+GxNhsYwWgpJrv+5PsNo87BzH/GjhipetdeM9hhjG04vppaopnw== X-Received: by 2002:adf:ab5a:: with SMTP id r26mr4447433wrc.313.1585392211271; Sat, 28 Mar 2020 03:43:31 -0700 (PDT) X-Received: from e123331-lin.home (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr. [109.210.65.247]) by smtp.gmail.com with ESMTPSA id a13sm4756386wrt.64.2020.03.28.03.43.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 28 Mar 2020 03:43:30 -0700 (PDT) From: "Ard Biesheuvel" To: devel@edk2.groups.io Cc: leif@nuviainc.com, Ard Biesheuvel Subject: [edk2-devel] [PATCH 5/5] ArmPkg/ArmMmuLib: drop unused TT_ATTR_INDX_INVALID CPP symbol Date: Sat, 28 Mar 2020 11:43:21 +0100 Message-Id: <20200328104321.8668-6-ard.biesheuvel@linaro.org> In-Reply-To: <20200328104321.8668-1-ard.biesheuvel@linaro.org> References: <20200328104321.8668-1-ard.biesheuvel@linaro.org> Precedence: Bulk List-Unsubscribe: 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,ard.biesheuvel@linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1585392213; bh=Ts1Kkk501oeknXEmz/D8g0uukTsWtuLopn69s6vzSJs=; h=Cc:Date:From:Reply-To:Subject:To; b=ZMsf1Ip1DyVzhoQF7Aa1Eq/2JgoCKlZYhyZTBOqCyHygCtuFqPJb1tYyg2jTQlNxwTh NXw4g7vbSdtbpGWQrhORwn9zgJN+tD0D57Q7MHsEuh9wvjadq+LOSrEAr7WWuYEXd6BkT gSD5WRGo5ixZnv+y483mFbGMhi1R+ybHwGc= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" TT_ATTR_INDX_INVALID is #define'd but never used so drop it. Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c b/ArmPkg/Libr= ary/ArmMmuLib/AArch64/ArmMmuLibCore.c index a82596d290f1..222ff817956f 100644 --- a/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c +++ b/ArmPkg/Library/ArmMmuLib/AArch64/ArmMmuLibCore.c @@ -19,9 +19,6 @@ #include #include =20 -// We use this index definition to define an invalid block entry -#define TT_ATTR_INDX_INVALID ((UINT32)~0) - STATIC UINT64 ArmMemoryAttributeToPageAttribute ( --=20 2.17.1 -=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 (#56529): https://edk2.groups.io/g/devel/message/56529 Mute This Topic: https://groups.io/mt/72606851/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-