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 1FFAB78003C for ; Sat, 9 Mar 2024 19:06:06 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=JIYNn6v9B7s9Wk3eirZHK5A4vozqMznwgH2/TnxJYJY=; 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=20240206; t=1710011165; v=1; b=sRdGzDzARLB4EyTYvqSNJtno+jibMHcgOW5/ZjYta31S8UUAdlMk5oVEhDZ3uKHSLpHcPP2Y Y+JcBTUqF8QF2wYMOSRh2dJKzc0ClnVvUwqV4FkYA70Eb/pn+MgKZYyHEay6sj2LaGNjs2Y47cV TDNECK32axkY08nmhT4qvgDZdXT+NA3ni3hVV2Y9lGl4NLgcuglSUhWiRz/MfdERZKANZ+Yft8l fvPVq4oAmrMIMia5F+DP7XWlmnGt4xhQvGGNtz2FsBMsKiJbjdd3jxvXCvWKOAEZNBueoW1k3Bc racgWbtaRcWpcQ6u7eRuRY6KJhW3vtrYA7QArQ896dROA== X-Received: by 127.0.0.2 with SMTP id 52v6YY7687511xHSmUxI44YI; Sat, 09 Mar 2024 11:06:05 -0800 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.19015.1710011163609210675 for ; Sat, 09 Mar 2024 11:06:03 -0800 X-Received: from OSD-Desktop.redmond.corp.microsoft.com (unknown [131.107.160.171]) by linux.microsoft.com (Postfix) with ESMTPSA id 0B5FC20B74C2; Sat, 9 Mar 2024 11:06:03 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 0B5FC20B74C2 From: "Oliver Smith-Denny" To: devel@edk2.groups.io Cc: Leif Lindholm , Ard Biesheuvel , Sami Mujawar , Liming Gao Subject: [edk2-devel][PATCH v3 2/3] MdeModulePkg: DxeCore: Correct Runtime Granularity Memory Type Date: Sat, 09 Mar 2024 11:06:03 -0800 Message-Id: <20240309190559.28677-3-osde@linux.microsoft.com> In-Reply-To: <20240309190559.28677-1-osde@linux.microsoft.com> References: <20240309190559.28677-1-osde@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,osde@linux.microsoft.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: CtvH9SkKr9IWRVQoQIRszhbwx7686176AA= Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20240206 header.b=sRdGzDzA; 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 Per the UEFI spec 2.10, section 2.3.6 (for the AARCH64 arch,=0D other architectures in section two confirm the same) the=0D memory types that need runtime page allocation granularity=0D are EfiReservedMemoryType, EfiACPIMemoryNVS, EfiRuntimeServicesCode,=0D and EfiRuntimeServicesData. However, legacy code was setting=0D runtime page allocation granularity for EfiACPIReclaimMemory=0D and not EfiReservedMemoryType. This patch fixes that error.=0D =0D Cc: Leif Lindholm =0D Cc: Ard Biesheuvel =0D Cc: Sami Mujawar =0D Cc: Liming Gao =0D =0D Signed-off-by: Oliver Smith-Denny =0D Suggested-by: Ard Biesheuvel =0D ---=0D MdeModulePkg/Core/Dxe/Mem/Page.c | 4 ++--=0D MdeModulePkg/Core/Dxe/Mem/Pool.c | 4 ++--=0D MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c | 4 ++--=0D MdeModulePkg/Core/Pei/Memory/MemoryServices.c | 2 +-=0D 4 files changed, 7 insertions(+), 7 deletions(-)=0D =0D diff --git a/MdeModulePkg/Core/Dxe/Mem/Page.c b/MdeModulePkg/Core/Dxe/Mem/P= age.c=0D index dd558696ba59..cd201d36a389 100644=0D --- a/MdeModulePkg/Core/Dxe/Mem/Page.c=0D +++ b/MdeModulePkg/Core/Dxe/Mem/Page.c=0D @@ -1403,7 +1403,7 @@ CoreInternalAllocatePages (=0D =0D Alignment =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY;=0D =0D - if ((MemoryType =3D=3D EfiACPIReclaimMemory) ||=0D + if ((MemoryType =3D=3D EfiReservedMemoryType) ||=0D (MemoryType =3D=3D EfiACPIMemoryNVS) ||=0D (MemoryType =3D=3D EfiRuntimeServicesCode) ||=0D (MemoryType =3D=3D EfiRuntimeServicesData))=0D @@ -1666,7 +1666,7 @@ CoreInternalFreePages (=0D =0D Alignment =3D DEFAULT_PAGE_ALLOCATION_GRANULARITY;=0D =0D - if ((Entry->Type =3D=3D EfiACPIReclaimMemory) ||=0D + if ((Entry->Type =3D=3D EfiReservedMemoryType) ||=0D (Entry->Type =3D=3D EfiACPIMemoryNVS) ||=0D (Entry->Type =3D=3D EfiRuntimeServicesCode) ||=0D (Entry->Type =3D=3D EfiRuntimeServicesData))=0D diff --git a/MdeModulePkg/Core/Dxe/Mem/Pool.c b/MdeModulePkg/Core/Dxe/Mem/P= ool.c=0D index 716dd045f9fd..ccfce8c5f959 100644=0D --- a/MdeModulePkg/Core/Dxe/Mem/Pool.c=0D +++ b/MdeModulePkg/Core/Dxe/Mem/Pool.c=0D @@ -370,7 +370,7 @@ CoreAllocatePoolI (=0D =0D ASSERT_LOCKED (&mPoolMemoryLock);=0D =0D - if ((PoolType =3D=3D EfiACPIReclaimMemory) ||=0D + if ((PoolType =3D=3D EfiReservedMemoryType) ||=0D (PoolType =3D=3D EfiACPIMemoryNVS) ||=0D (PoolType =3D=3D EfiRuntimeServicesCode) ||=0D (PoolType =3D=3D EfiRuntimeServicesData))=0D @@ -753,7 +753,7 @@ CoreFreePoolI (=0D Pool->Used -=3D Size;=0D DEBUG ((DEBUG_POOL, "FreePool: %p (len %lx) %,ld\n", Head->Data, (UINT64= )(Head->Size - POOL_OVERHEAD), (UINT64)Pool->Used));=0D =0D - if ((Head->Type =3D=3D EfiACPIReclaimMemory) ||=0D + if ((Head->Type =3D=3D EfiReservedMemoryType) ||=0D (Head->Type =3D=3D EfiACPIMemoryNVS) ||=0D (Head->Type =3D=3D EfiRuntimeServicesCode) ||=0D (Head->Type =3D=3D EfiRuntimeServicesData))=0D diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c b/MdeModulePkg/C= ore/Dxe/Misc/MemoryProtection.c=0D index 977239d08afc..eb243a0137b1 100644=0D --- a/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c=0D +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryProtection.c=0D @@ -300,18 +300,18 @@ IsMemoryProtectionSectionAligned (=0D switch (MemoryType) {=0D case EfiRuntimeServicesCode:=0D case EfiACPIMemoryNVS:=0D + case EfiReservedMemoryType:=0D PageAlignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY;=0D break;=0D case EfiRuntimeServicesData:=0D - case EfiACPIReclaimMemory:=0D ASSERT (FALSE);=0D PageAlignment =3D RUNTIME_PAGE_ALLOCATION_GRANULARITY;=0D break;=0D case EfiBootServicesCode:=0D case EfiLoaderCode:=0D - case EfiReservedMemoryType:=0D PageAlignment =3D EFI_PAGE_SIZE;=0D break;=0D + case EfiACPIReclaimMemory:=0D default:=0D ASSERT (FALSE);=0D PageAlignment =3D EFI_PAGE_SIZE;=0D diff --git a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c b/MdeModulePkg/C= ore/Pei/Memory/MemoryServices.c=0D index a30925da39ee..52f37c960e46 100644=0D --- a/MdeModulePkg/Core/Pei/Memory/MemoryServices.c=0D +++ b/MdeModulePkg/Core/Pei/Memory/MemoryServices.c=0D @@ -584,7 +584,7 @@ PeiAllocatePages (=0D }=0D =0D if ((RUNTIME_PAGE_ALLOCATION_GRANULARITY > DEFAULT_PAGE_ALLOCATION_GRANU= LARITY) &&=0D - ((MemoryType =3D=3D EfiACPIReclaimMemory) ||=0D + ((MemoryType =3D=3D EfiReservedMemoryType) ||=0D (MemoryType =3D=3D EfiACPIMemoryNVS) ||=0D (MemoryType =3D=3D EfiRuntimeServicesCode) ||=0D (MemoryType =3D=3D EfiRuntimeServicesData)))=0D -- =0D 2.40.1=0D =0D -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#116560): https://edk2.groups.io/g/devel/message/116560 Mute This Topic: https://groups.io/mt/104832606/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-