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 DDAB1740446 for ; Wed, 31 Jan 2024 15:38:12 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=3Z2wW1KxYYMSj7QM5XlUfxxfTidkxfUbDz+iCUQwFs8=; 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=1706715491; v=1; b=jx/3VlpWVGBUQS5KygExxg4iGRIcVn1yK0LGUypv5WeblfDgR5zvsljm0/gBcNLK/qSSqozK m3LJt1q0RjtcuKWjL4dynWQNh08KdVahazxbKpD9JnQcw2zi4kJCKgEr89AOkFdOj0XQjBD1M06 43RUK02TanTxDdrsqfeoOz04= X-Received: by 127.0.0.2 with SMTP id v3uFYY7687511xBqfK5S3lQV; Wed, 31 Jan 2024 07:38:11 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.groups.io with SMTP id smtpd.web11.17003.1706715490767390736 for ; Wed, 31 Jan 2024 07:38:10 -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-654-0MjAZQAiO9im-RuPxwNknw-1; Wed, 31 Jan 2024 10:38:06 -0500 X-MC-Unique: 0MjAZQAiO9im-RuPxwNknw-1 X-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 3C1B385A5A6; Wed, 31 Jan 2024 15:38:06 +0000 (UTC) X-Received: from [10.39.192.35] (unknown [10.39.192.35]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 688161121306; Wed, 31 Jan 2024 15:38:05 +0000 (UTC) Message-ID: <240f4298-7db8-3cbd-4e78-5dcb00a1146a@redhat.com> Date: Wed, 31 Jan 2024 16:38:04 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH 3/3] OvmfPkg/PlatformPei: log pei memory cap details To: devel@edk2.groups.io, kraxel@redhat.com Cc: Oliver Steffen , Jiewen Yao , Ard Biesheuvel References: <20240131120000.358090-1-kraxel@redhat.com> <20240131120000.358090-4-kraxel@redhat.com> From: "Laszlo Ersek" In-Reply-To: <20240131120000.358090-4-kraxel@redhat.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 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: hSCr8WOQPltDrvnYOzK5XOIsx7686176AA= 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="jx/3VlpW"; 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 1/31/24 13:00, Gerd Hoffmann wrote: > Signed-off-by: Gerd Hoffmann > --- > OvmfPkg/PlatformPei/MemDetect.c | 24 ++++++++++++++++++++++++ > 1 file changed, 24 insertions(+) >=20 > diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDet= ect.c > index e22743b4bfaa..988fcc512362 100644 > --- a/OvmfPkg/PlatformPei/MemDetect.c > +++ b/OvmfPkg/PlatformPei/MemDetect.c > @@ -246,6 +246,30 @@ GetPeiMemoryCap ( > MemoryCap =3D MAX_UINT32; > } > =20 > + DEBUG (( > + DEBUG_INFO, > + "%a: page tables: %6lld kb (%d/%d/%d/%d)\n", > + __func__, > + (UINT64)(EFI_PAGES_TO_SIZE (TotalPages) / 1024), (1) There is no "ll" size modifier in edk2; is not standard C :) Use a single "l" or "L" (doesn't matter which). (2) "d" is not right for UINT*; we should use "u". In total, please use %lu or %Lu. (3) Using the exact inclusive page count limit, from my comments on the previous patch in the series (0x8040201), the memory usage could be as high as 537,921,540 KB (decimal). Setting the field width to 6 is not consistent with that; we should use 9 (if we want padding). (4) we shouldn't divide in 64-bit "natively", in such code that may be compiled for 32-bit; either use RShiftU64() or DivU64x32(), from BaseLib. (This is really hard to remember, unfortunately.) Ooops, wait, ignore this: you are not dividing in UINT64, but in UINTN. That's fine! The cast only refers to the quotient. > + Level5Pages, > + Level4Pages, > + Level3Pages, > + Level2Pages (5) In my proposal for the previous patch, I changed the type of these variables to UINT64 (for simplicity), so they should all be formatted with %Lu or %lu. (%d is not right in any case; it should be %u even for UINT32.) > + )); > + DEBUG (( > + DEBUG_INFO, > + "%a: ap stacks: %6lld kb (%d cpus)\n", > + __func__, > + (UINT64)(ApStacks / 1024), The division should be OK... ApStacks is UINTN (in fact it is a UINT32 product). Not sure what to specify as field width... 4GB is 4,194,304 KB, so in theory, we should use 7 for the field width. (6) I propose "%7lu". > + PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber (7) UINT32, so should be formatted with %u. (BTW, our ApStacks calculation includes the BSP as well (!), so it is a bit of an over-estimate. The name "ApStacks" is slightly misleading.) > + )); > + DEBUG (( > + DEBUG_INFO, > + "%a: memory cap: %6lld kb\n", > + __func__, > + (UINT64)(MemoryCap / 1024) > + )); > + (8) At this point, MemoryCap is limited to MAX_UINT32, therefore I again propose "%7lu". > // > // Add 64 MB for miscellaneous allocations. Note that for > // PhysMemAddressWidth values close to 36, the cap will actually be Laszlo -=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 (#114907): https://edk2.groups.io/g/devel/message/114907 Mute This Topic: https://groups.io/mt/104073299/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/19134562= 12/xyzzy [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-