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 5AA8294131D for ; Mon, 5 Feb 2024 07:57:55 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=vDRTMeQcZNuDztrLqBjkZpWLHBzk4JrtvQNZjRtq0+g=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc: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=1707119873; v=1; b=SBactvC2+jyM/gRuzl/nwfv8HNQHlndd7gLHOlB7Xrd6oKPhCTfSzL2PVcvnHgzFQD7MUqaw CrBZ1JON2YrOWFu4mfkyaTOJEfATh4wp3ql08dGgJRQ28zgqAwXhNLpY8UdDHUNuHRc79ux4eYA JkUj3U+EZZjD4JfMfmDSvV5o= X-Received: by 127.0.0.2 with SMTP id 6qipYY7687511xdq8c6gZgdK; Sun, 04 Feb 2024 23:57:53 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web10.58638.1707119873249878868 for ; Sun, 04 Feb 2024 23:57:53 -0800 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-205-Dm7BYCMkPQuWyaIFPIpdNg-1; Mon, 05 Feb 2024 02:57:49 -0500 X-MC-Unique: Dm7BYCMkPQuWyaIFPIpdNg-1 X-Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C213E83B828; Mon, 5 Feb 2024 07:57:48 +0000 (UTC) X-Received: from [10.39.192.216] (unknown [10.39.192.216]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D3562492BF0; Mon, 5 Feb 2024 07:57:47 +0000 (UTC) Message-ID: <0299daa3-b139-dc10-ecbc-0863c40bbd39@redhat.com> Date: Mon, 5 Feb 2024 08:57:46 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v2 2/4] OvmfPkg/PlatformPei: consider AP stacks for pei memory cap To: devel@edk2.groups.io, kraxel@redhat.com Cc: Jiewen Yao , Oliver Steffen , Ard Biesheuvel References: <20240202104720.1275308-1-kraxel@redhat.com> <20240202104720.1275308-3-kraxel@redhat.com> From: "Laszlo Ersek" In-Reply-To: <20240202104720.1275308-3-kraxel@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 4c1rUdanfYwFiXMkOr9XHkAAx7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 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=SBactvC2; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.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 2/2/24 11:47, Gerd Hoffmann wrote: > Needed to avoid running out of memory when booting > with a large (~2048) number of vcpus. >=20 > Signed-off-by: Gerd Hoffmann > --- > OvmfPkg/PlatformPei/MemDetect.c | 17 ++++++++++++++--- > 1 file changed, 14 insertions(+), 3 deletions(-) >=20 > diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDet= ect.c > index 1684a3783546..83f1c1d02a26 100644 > --- a/OvmfPkg/PlatformPei/MemDetect.c > +++ b/OvmfPkg/PlatformPei/MemDetect.c > @@ -187,6 +187,8 @@ GetPeiMemoryCap ( > UINT32 Pml4Entries; > UINT32 PdpEntries; > UINTN TotalPages; > + UINT64 ApStacks; > + UINT64 MemoryCap; > =20 > // > // If DXE is 32-bit, then just return the traditional 64 MB cap. > @@ -234,12 +236,21 @@ GetPeiMemoryCap ( > (PdpEntries + 1) * Pml4Entries + 1; > ASSERT (TotalPages <=3D 0x40201); > =20 > + // > + // With 32k stacks and 4096 vcpus this lands at 128 MB (far away > + // from MAX_UINT32). > + // > + ApStacks =3D PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber * PcdGet= 32 (PcdCpuApStackSize); > + > // > // Add 64 MB for miscellaneous allocations. Note that for > - // PhysMemAddressWidth values close to 36, the cap will actually be > - // dominated by this increment. > + // PhysMemAddressWidth values close to 36 and a small number of > + // CPUs, the cap will actually be dominated by this increment. > // > - return (UINT32)(EFI_PAGES_TO_SIZE (TotalPages) + SIZE_64MB); > + MemoryCap =3D EFI_PAGES_TO_SIZE (TotalPages) + ApStacks + SIZE_64MB; > + > + ASSERT (MemoryCap <=3D MAX_UINT32); > + return (UINT32)MemoryCap; > } > =20 > /** Yes, this looks good. At this point, EFI_PAGES_TO_SIZE (TotalPages) is ~1GB at most, and ApStacks is empirically <=3D 128 MB, plus ApStacks is UINT64. Therefore on IA32X64 we have UINT64 =3D (UINT32 + UINT64) + INT32 -> UINT64 =3D (UINT64 + UINT64) + INT32 -> UINT64 =3D UINT64 + INT32 -> UINT64 =3D UINT64 + UINT64 -> UINT64 =3D UINT64 OK! Reviewed-by: Laszlo Ersek -=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 (#115103): https://edk2.groups.io/g/devel/message/115103 Mute This Topic: https://groups.io/mt/104117099/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-