From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 0A243AC09E7 for ; Tue, 28 Nov 2023 00:15:28 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=EOy2D3gnwNVqnNgrekskp3E7dRAFeECqy83nPbrEpqw=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1701130527; v=1; b=vgJ2ZF1t1mEWFBFmPe2ijl3Ne+zmcfnwtBwcJQPMTtYON9MavchU5yHIgo/eMNKDzQSKFmva cI4Qteqph9APQJErockY8+Cf36ussAI1vlqwcOAySjPTl0KOVa8NykXb1qOAPMRKhlATRVz4fAy upMBrGhm5+y6zHefMgcfZeoU= X-Received: by 127.0.0.2 with SMTP id NbcOYY7687511xCOIiGrSS95; Mon, 27 Nov 2023 16:15:27 -0800 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.354.1701130527282532212 for ; Mon, 27 Nov 2023 16:15:27 -0800 X-Received: from localhost.localdomain (unknown [47.201.241.198]) by linux.microsoft.com (Postfix) with ESMTPSA id 651A020B74C1; Mon, 27 Nov 2023 16:15:26 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 651A020B74C1 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Ard Biesheuvel , Leif Lindholm , Sami Mujawar Subject: [edk2-devel] [PATCH v1 2/2] ArmPkg/Drivers/CpuDxe: Use lower and upper attributes Date: Mon, 27 Nov 2023 19:15:00 -0500 Message-ID: <20231128001500.1107-3-mikuback@linux.microsoft.com> In-Reply-To: <20231128001500.1107-1-mikuback@linux.microsoft.com> References: <20231128001500.1107-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk 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,mikuback@linux.microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: c6GlaLcxqQTmd7icEyCWChZPx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=vgJ2ZF1t; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=linux.microsoft.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io From: Michael Kubacki GetNextEntryAttribute() is currently applying a 64-bit mask (TT_ATTRIBUTES_MASK) to a 32-bit descriptor value (EntryType). The original descriptor was 64 bits containing the upper and lower attributes which are included in TT_ATTRIBUTES_MASK. The PrevEntryAttribute parameter is also a UINT32, but passed to PageAttributeToGcdAttribute() for a UINT64 parameter where the function checks masks in the upper 32 bits of the integer value: PageAttributeToGcdAttribute (*PrevEntryAttribute) ... STATIC UINT64 PageAttributeToGcdAttribute ( IN UINT64 PageAttributes ) ... if ((PageAttributes & (TT_PXN_MASK | TT_UXN_MASK)) !=3D 0) { GcdAttributes |=3D EFI_MEMORY_XP; } ... #define TT_PXN_MASK BIT53 #define TT_UXN_MASK BIT54 // EL1&0 This change removes UINT32 intermediary values. For EntryType, eliminating an unncessary cast. For EntryAttribute, preserving the upper and lower attributes for evaluation in PageAttributeToGcdAttribute(). Cc: Ard Biesheuvel Cc: Leif Lindholm Cc: Sami Mujawar Signed-off-by: Michael Kubacki --- ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c b/ArmPkg/Drivers/CpuDxe/= AArch64/Mmu.c index 4555fdb5c2c8..ff14c2f814b2 100644 --- a/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c +++ b/ArmPkg/Drivers/CpuDxe/AArch64/Mmu.c @@ -13,7 +13,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent #include #include "CpuDxe.h" =20 -#define INVALID_ENTRY ((UINT32)~0) +#define INVALID_ENTRY ((UINT64)~0) =20 #define MIN_T0SZ 16 #define BITS_PER_LEVEL 9 @@ -169,14 +169,14 @@ GetNextEntryAttribute ( IN UINTN EntryCount, IN UINTN TableLevel, IN UINT64 BaseAddress, - IN OUT UINT32 *PrevEntryAttribute, + IN OUT UINT64 *PrevEntryAttribute, IN OUT UINT64 *StartGcdRegion ) { UINTN Index; UINT64 Entry; - UINT32 EntryAttribute; - UINT32 EntryType; + UINT64 EntryAttribute; + UINT64 EntryType; EFI_STATUS Status; UINTN NumberOfDescriptors; EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap; @@ -195,8 +195,8 @@ GetNextEntryAttribute ( // the subsequent ones should be filled up for (Index =3D 0; Index < EntryCount; Index++) { Entry =3D TableAddress[Index]; - EntryType =3D (UINT32)(Entry & TT_TYPE_MASK); - EntryAttribute =3D (UINT32)(Entry & TT_ATTRIBUTES_MASK); + EntryType =3D Entry & TT_TYPE_MASK; + EntryAttribute =3D Entry & TT_ATTRIBUTES_MASK; =20 // If Entry is a Table Descriptor type entry then go through the sub= -level table if ((EntryType =3D=3D TT_TYPE_BLOCK_ENTRY) || @@ -271,7 +271,7 @@ SyncCacheConfig ( ) { EFI_STATUS Status; - UINT32 PageAttribute; + UINT64 PageAttribute; UINT64 *FirstLevelTableAddress; UINTN TableLevel; UINTN TableCount; --=20 2.42.0.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111768): https://edk2.groups.io/g/devel/message/111768 Mute This Topic: https://groups.io/mt/102842005/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-