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 B749C94149A for ; Wed, 14 Feb 2024 10:45:13 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=pEmcVxEt6Q1j7KC0+5Xt1ovujOZ+8SOkl1QTNsGfHgw=; 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:Content-Type; s=20140610; t=1707907512; v=1; b=kPBHuMKPid9I/EeyKO5aZ8nn7AChI1gFej8R9imQFfe3PyXrQdz6TTq7+H1Mr3ZKTUxDj5SL q8N8fptV368+//wo3xnM2Lwu6VjeqhctQEuKkHXMaty3MPgjTTT2m6pk3ljDvHryWjCLXCSrVSN i1F2JGcp5Ht/o8wERaIML2bM= X-Received: by 127.0.0.2 with SMTP id 9BEiYY7687511xj6R8uCfXKV; Wed, 14 Feb 2024 02:45:12 -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.38649.1707907511777312297 for ; Wed, 14 Feb 2024 02:45:11 -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-331-eBRitkuhPhu6BCms4legzA-1; Wed, 14 Feb 2024 05:45:07 -0500 X-MC-Unique: eBRitkuhPhu6BCms4legzA-1 X-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 2DA03185A780; Wed, 14 Feb 2024 10:45:07 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.192]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C78958077; Wed, 14 Feb 2024 10:45:06 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 6BAAC1800DDB; Wed, 14 Feb 2024 11:45:04 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Oliver Steffen , Ard Biesheuvel , Jiewen Yao , Laszlo Ersek , Gerd Hoffmann Subject: [edk2-devel] [PATCH v3 2/4] OvmfPkg/PlatformPei: consider AP stacks for pei memory cap Date: Wed, 14 Feb 2024 11:45:02 +0100 Message-ID: <20240214104504.2931339-3-kraxel@redhat.com> In-Reply-To: <20240214104504.2931339-1-kraxel@redhat.com> References: <20240214104504.2931339-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 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,kraxel@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: EE7RNlrpwDhHx9hGhCWXTie3x7686176AA= Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=kPBHuMKP; 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 Needed to avoid running out of memory when booting with a large (~2048) number of vcpus. Signed-off-by: Gerd Hoffmann Reviewed-by: Laszlo Ersek --- OvmfPkg/PlatformPei/MemDetect.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c index e0ecca10b6e0..d6c46ffc89dd 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; // // If DXE is 32-bit, then just return the traditional 64 MB cap. @@ -234,12 +236,21 @@ GetPeiMemoryCap ( (PdpEntries + 1) * Pml4Entries + 1; ASSERT (TotalPages <= 0x40201); + // + // With 32k stacks and 4096 vcpus this lands at 128 MB (far away + // from MAX_UINT32). + // + ApStacks = PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber * PcdGet32 (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 = EFI_PAGES_TO_SIZE (TotalPages) + ApStacks + SIZE_64MB; + + ASSERT (MemoryCap <= MAX_UINT32); + return (UINT32)MemoryCap; } /** -- 2.43.0 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115440): https://edk2.groups.io/g/devel/message/115440 Mute This Topic: https://groups.io/mt/104350493/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-