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 9DD407803CD for ; Fri, 2 Feb 2024 10:47:38 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=TL8BolATYROg8ZPMONgHO4nO1Ig6Wj8qkvX7Om1Ndfw=; 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=1706870857; v=1; b=pUJ9L6SDpiyB7slnABCVUWSfSkQRftppz1e8uB+3qg1u6Z/NomY0H2Nu+zSg7+GMaNy6W95l SfmNcP7qLrC8kUaTXyQVfLwl0APTdA/CZ+E2iwycDs+44yFFr8ZrpEWW6XD7nLb4hSXbhE7OS6F 2wFDClPJG+cueTQJPDcN1Ibg= X-Received: by 127.0.0.2 with SMTP id ah0KYY7687511xBDIr2WrS6V; Fri, 02 Feb 2024 02:47:37 -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.20101.1706870856711276025 for ; Fri, 02 Feb 2024 02:47:36 -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-515-X7eqv7D2NwyK1reZzGon0g-1; Fri, 02 Feb 2024 05:47:31 -0500 X-MC-Unique: X7eqv7D2NwyK1reZzGon0g-1 X-Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 A6F93185A780; Fri, 2 Feb 2024 10:47:31 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 79A87492BC6; Fri, 2 Feb 2024 10:47:31 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id DB4671800DE1; Fri, 2 Feb 2024 11:47:20 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jiewen Yao , Laszlo Ersek , Gerd Hoffmann , Oliver Steffen , Ard Biesheuvel Subject: [edk2-devel] [PATCH v2 2/4] OvmfPkg/PlatformPei: consider AP stacks for pei memory cap Date: Fri, 2 Feb 2024 11:47:18 +0100 Message-ID: <20240202104720.1275308-3-kraxel@redhat.com> In-Reply-To: <20240202104720.1275308-1-kraxel@redhat.com> References: <20240202104720.1275308-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 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: cZ77To8xR8jFzGQBB8z8tkbAx7686176AA= 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=pUJ9L6SD; 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 --- 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 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; // // 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 (#115038): https://edk2.groups.io/g/devel/message/115038 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] -=-=-=-=-=-=-=-=-=-=-=-