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 1E5C47803D2 for ; Mon, 22 Jan 2024 20:24:45 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=ghpd0h/s2Jlbq0vPiawzLz+dX1guXfA1yKY49qjOMMI=; c=relaxed/simple; d=groups.io; h=DKIM-Filter:Message-ID:Date:MIME-Version:User-Agent:Subject:To:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1705955084; v=1; b=kN9wWiUwuVhrV4gs2yWbuIeC1I/xxoso2wMrpdLigq9iAQ15bsuK93NbemVWGnfwLqCqmto1 bVNh2SyFOWl0NTNeLhtmKxxwtnce8ODJyPE2XfOcxYHno/mAQIJhU66lQZBDcb4ZjElouNkXlcO UeYW2OB+na9iQsYDLNK9ZZi8= X-Received: by 127.0.0.2 with SMTP id gAz0YY7687511xffhgetqyyC; Mon, 22 Jan 2024 12:24:44 -0800 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.3344.1705955084167599828 for ; Mon, 22 Jan 2024 12:24:44 -0800 X-Received: from [10.137.194.171] (unknown [131.107.160.171]) by linux.microsoft.com (Postfix) with ESMTPSA id 86C5220E2C0A; Mon, 22 Jan 2024 12:24:43 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 86C5220E2C0A Message-ID: <14a7ee41-47a8-4a52-ab45-25008a414e69@linux.microsoft.com> Date: Mon, 22 Jan 2024 12:24:43 -0800 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [edk2-devel] EFI_SYSTEM_TABLE allocated by AllocateRuntimeCopyPool isn't aligned to 4KB To: devel@edk2.groups.io, rebecca@bsdio.com References: <49f7e14e-532e-444c-8978-e290d4338386@bsdio.com> From: "Oliver Smith-Denny" In-Reply-To: <49f7e14e-532e-444c-8978-e290d4338386@bsdio.com> 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: ZBVCvlwSzbrnrstGaQH4dtlvx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed 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=kN9wWiUw; 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 On 1/22/2024 11:52 AM, Rebecca Cran wrote: > I've been working on updating the T32 script EfiLoadDxe.cmm in=20 > EmbeddedPkg/Scripts/LauterbachT32 and one of the issues I've run into is= =20 > that the EFI_SYSTEM_TABLE - pointed to by `gST` and `gDxeCoreST` - isn't= =20 > aligned to 4KB like the script expects. >=20 > Instead, I'm seeing AllocateRuntimeCopyPool return 0xFB7D0018 in=20 > MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c: >=20 > // > // Allocate the EFI System Table and EFI Runtime Service Table from=20 > EfiRuntimeServicesData > // Use the templates to initialize the contents of the EFI System Table= =20 > and EFI Runtime Services Table > // > gDxeCoreST =3D AllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE),=20 > &mEfiSystemTableTemplate); > ASSERT (gDxeCoreST !=3D NULL); >=20 > I'm wondering which is wrong: should AllocateRuntimeCopyPool be=20 > returning a 4KB-aligned pointer, or is the script's assumption wrong? >=20 >=20 Allocating pool memory will never be 4KB aligned because of the POOL_HEAD. See:=20 https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Mem/Poo= l.c#L463-L537. The allocated page is 4KB aligned, of course, but we store the POOL_HEAD at the beginning of that page and return Head->Data to the caller. In addition, this is only in the case where you allocate a new page for the pool. In the case where the pool has the pages it needs, you don't have any alignment guarantee, I believe, it is just offset further into one of the already allocated pages. Oliver -=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 (#114147): https://edk2.groups.io/g/devel/message/114147 Mute This Topic: https://groups.io/mt/103894456/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-