From mboxrd@z Thu Jan 1 00:00:00 1970 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.web12.10694.1664460446900602140 for ; Thu, 29 Sep 2022 07:07:27 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=gK3vW4LV; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664460446; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2M2LYcrUNL/bTjo7ocJhHHJgEus1WizuWZePf3YWwYo=; b=gK3vW4LV5dbzmNVERO0rK1jLxszGLEHmGVKz05bJ+ofE2ASZ/IQ+P/MdhWwLjG7Q8havKP CBOjt4IYuAS/f/x+qbaEz0WMx9rVFDeDcGPvzKcQsrsW2EPaiCfVi1Ta6mpzQ4PRWi8hgG X6eO25aMMuhawIHqZYGdcVBvDEgt3rE= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-240-SbUTwEuKMZeJFhCD4MLRqg-1; Thu, 29 Sep 2022 10:07:24 -0400 X-MC-Unique: SbUTwEuKMZeJFhCD4MLRqg-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 81885185A7AF; Thu, 29 Sep 2022 14:07:24 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.194.9]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3F9FB40C6EC2; Thu, 29 Sep 2022 14:07:24 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id E538C18009B8; Thu, 29 Sep 2022 16:07:20 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Gerd Hoffmann , Oliver Steffen , Ard Biesheuvel , Jiewen Yao , Pawel Polawski , Jordan Justen Subject: [PATCH 2/4] OvmfPkg/PlatformInitLib: detect physical address space Date: Thu, 29 Sep 2022 16:07:18 +0200 Message-Id: <20220929140720.1501464-3-kraxel@redhat.com> In-Reply-To: <20220929140720.1501464-1-kraxel@redhat.com> References: <20220929140720.1501464-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true Try detect physical address space, when successful use it. Otherwise go continue using the current guesswork code path. Signed-off-by: Gerd Hoffmann --- OvmfPkg/Library/PlatformInitLib/MemDetect.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c index 143a01ceb01e..16ecbfadc30c 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -761,6 +761,19 @@ PlatformAddressWidthInitialization ( FirstNonAddress = PlatformGetFirstNonAddress (PlatformInfoHob); } + PlatformAddressWidthFromCpuid (PlatformInfoHob, TRUE); + if (PlatformInfoHob->PhysMemAddressWidth != 0) { + // physical address width is known + PlatformInfoHob->FirstNonAddress = FirstNonAddress; + return; + } + + // + // physical address width is NOT known + // -> do some guess work, mostly based on installed memory + // -> try be conservstibe to stay below the guaranteed minimum of + // 36 phys bits (aka 64 GB). + // PhysMemAddressWidth = (UINT8)HighBitSet64 (FirstNonAddress); // -- 2.37.3