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.129.124]) by mx.groups.io with SMTP id smtpd.web09.10933.1664891256994032203 for ; Tue, 04 Oct 2022 06:47:38 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XMosPenk; spf=pass (domain: redhat.com, ip: 170.10.129.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664891255; 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=XMosPenkruJ40vlyTpJADhUbiTTH/THw2DCjVHV4wPa+DUR07FCQ0IPCoqYBDcs5LAqGcy HOErdpdXvQjo8jtx7on3stsdY+wlbCzZPV9N4o6xV2JTGJcGlsaZqyLUGdmnUWGNO8TQBI ALFS82nKKbEa2Lx09OzJdZCuXSWmKa0= 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-19-ngQZbtmsPHunCoxnZ7SjYg-1; Tue, 04 Oct 2022 09:47:31 -0400 X-MC-Unique: ngQZbtmsPHunCoxnZ7SjYg-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 26219101E153; Tue, 4 Oct 2022 13:47:31 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.193.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E8DE0477F5D; Tue, 4 Oct 2022 13:47:30 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 15A88180084D; Tue, 4 Oct 2022 15:47:28 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Pawel Polawski , Jiewen Yao , Oliver Steffen , Ard Biesheuvel Subject: [PATCH v2 2/4] OvmfPkg/PlatformInitLib: detect physical address space Date: Tue, 4 Oct 2022 15:47:26 +0200 Message-Id: <20221004134728.55499-3-kraxel@redhat.com> In-Reply-To: <20221004134728.55499-1-kraxel@redhat.com> References: <20221004134728.55499-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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