From nobody Sun Feb 8 18:30:01 2026 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+111746+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+111746+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1701109119; cv=none; d=zohomail.com; s=zohoarc; b=biR79NCBsCU6fzO3qjYpzpgXPX4bM4KLy3oJk3/SUSksYmS7BbrQXvJaQRq3Mr6IBPE6pIF+fx95YzIKCPBn2V+1tLuHCzEPvZMNPc+YG8GAh5PO5SfIepn0BSDK0VWZmZ2rPxNjLQP27y+xS9ipmlGyGBMPVZaWfa0fX8mVEHA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1701109119; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Sender:Subject:Subject:To:To:Message-Id; bh=4MgzgTCJ5qD90afqhuEM0HFZKVMIsxG+vGxbMHyDaxU=; b=IWkpk1nrhUFjvObo8G3/oeoxY8Xpdw2n2rmccU71K/eHAwoUhvVMSEUwSQA0zJhi/JScNX9gqnrPUo0K5rDq1VlEmGssgbZnafeh7WkCGtZwBrquV8g6mlrrOST82WrnrJlCDPj+mHHnQOPa/VaRvnlGfrGD/SqlRURgsDirnVo= 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+111746+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 1701109119067597.6071845434976; Mon, 27 Nov 2023 10:18:39 -0800 (PST) Return-Path: DKIM-Signature: a=rsa-sha256; bh=lEVdRg4VEgtcaWBOcZ4BjF3qFljLENx9AnUqPxdRYGU=; c=relaxed/simple; d=groups.io; h=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=1701109118; v=1; b=hEfYBviqnfLrEhx/b7oG2Yi9SwVelQ6zkXmkTluOcZStkXpjPIfm1aIk9vYWQ29BxIRIHe0t 9j+4OlkwuZmAwqhzyZ6W+QVVOI1E6HUVBLrw8uG9RrCax2+I5khQhZL4Rmz1iCS6Q13qHZ5W8Nz jlacBh+rSMSL7Mvd3ouUkrkk= X-Received: by 127.0.0.2 with SMTP id z4iQYY1788612xyJnIGKfGBe; Mon, 27 Nov 2023 10:18:38 -0800 X-Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) by mx.groups.io with SMTP id smtpd.web10.102526.1701109117593564691 for ; Mon, 27 Nov 2023 10:18:37 -0800 X-Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-1cfa168faefso25658195ad.3 for ; Mon, 27 Nov 2023 10:18:37 -0800 (PST) X-Gm-Message-State: l8FTFRkRiPGcPmQKzIM5ypevx1787277AA= X-Google-Smtp-Source: AGHT+IGtmYKkslo+lPMKAPltfHeAwVO0Y9+6+mKE51tts5Fa/54vCnbRzTR8qBU5+mkwB8WH5Mh00Q== X-Received: by 2002:a17:902:e888:b0:1cf:c2b8:4772 with SMTP id w8-20020a170902e88800b001cfc2b84772mr6011252plg.18.1701109116917; Mon, 27 Nov 2023 10:18:36 -0800 (PST) X-Received: from localhost.localdomain ([50.46.253.1]) by smtp.gmail.com with ESMTPSA id c6-20020a170902c1c600b001cfd0ed1604sm2013259plc.87.2023.11.27.10.18.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Nov 2023 10:18:36 -0800 (PST) From: "Taylor Beebe" To: devel@edk2.groups.io Cc: Jian J Wang , Liming Gao , Dandan Bi Subject: [edk2-devel] [PATCH v5 09/16] MdeModulePkg: Fix MAT Descriptor Count Calculation Date: Mon, 27 Nov 2023 10:18:07 -0800 Message-ID: <20231127181818.411-10-taylor.d.beebe@gmail.com> In-Reply-To: <20231127181818.411-1-taylor.d.beebe@gmail.com> References: <20231127181818.411-1-taylor.d.beebe@gmail.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,taylor.d.beebe@gmail.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1701109120290000037 Content-Type: text/plain; charset="utf-8" |4K PAGE|DATA|CODE|DATA|CODE|DATA|4K PAGE| Say the above memory region is currently one memory map descriptor. The above image memory layout example contains two code sections oriented in a way that maximizes the number of descriptors which would be required to describe each section. NOTE: It's unlikely that a data section would ever be between two code sections, but it's still handled by the below formula for correctness. There are two code sections (let's say CodeSegmentMax =3D=3D 2), three data sections, and two unrelated memory regions flanking the image. The number of required descriptors to describe this layout will be 2 * 2 + 3 =3D=3D 7. This patch updates the calculations to account for the worst-case scenario. Cc: Jian J Wang Cc: Liming Gao Cc: Dandan Bi Signed-off-by: Taylor Beebe Reviewed-by: Liming Gao --- MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c |= 2 +- MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLib.c |= 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c b/MdeModule= Pkg/Core/Dxe/Misc/MemoryAttributesTable.c index 51630f504ea1..af6c26244cc0 100644 --- a/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c +++ b/MdeModulePkg/Core/Dxe/Misc/MemoryAttributesTable.c @@ -517,7 +517,7 @@ CoreGetMemoryMapWithSeparatedImageSection ( =20 CoreAcquiremMemoryAttributesTableLock (); =20 - AdditionalRecordCount =3D (2 * mImagePropertiesPrivateData.CodeSegmentCo= untMax + 1) * mImagePropertiesPrivateData.ImageRecordCount; + AdditionalRecordCount =3D (2 * mImagePropertiesPrivateData.CodeSegmentCo= untMax + 3) * mImagePropertiesPrivateData.ImageRecordCount; =20 OldMemoryMapSize =3D *MemoryMapSize; Status =3D CoreGetMemoryMap (MemoryMapSize, MemoryMap, MapKey,= DescriptorSize, DescriptorVersion); diff --git a/MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesR= ecordLib.c b/MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesR= ecordLib.c index 9fb3b922038f..7c0ecd07c1bb 100644 --- a/MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLi= b.c +++ b/MdeModulePkg/Library/ImagePropertiesRecordLib/ImagePropertiesRecordLi= b.c @@ -277,7 +277,7 @@ GetMaxSplitRecordCount ( break; } =20 - SplitRecordCount +=3D (2 * ImageRecord->CodeSegmentCount + 1); + SplitRecordCount +=3D (2 * ImageRecord->CodeSegmentCount + 3); PhysicalStart =3D ImageRecord->ImageBase + ImageRecord->ImageSize; } while ((ImageRecord !=3D NULL) && (PhysicalStart < PhysicalEnd)); =20 --=20 2.42.0.windows.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 (#111746): https://edk2.groups.io/g/devel/message/111746 Mute This Topic: https://groups.io/mt/102834916/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-