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.web12.9297.1642413719547278019 for ; Mon, 17 Jan 2022 02:01:59 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=LkITM3kw; 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=1642413718; 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=cbBr5laS6ZbK3BRJUeKLzduSKmrS4ijauXc6iRN96cU=; b=LkITM3kwBYLPI15xq0m1HNoH3lojg8q7l+xocxhUNl5BwSB7FPn56Q09LTuqOYlqRdxO5t yqkvMBiWXVzEnhWLqafGJh62OWO0p+tqqc4bqNID2HzTtRn4BaMRs3l09lF5z0GU8IFqSX BWXO8PAEAR96r4DkAuSD5gJtZhM6HC8= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-329-XHMfktOsN3WcpvGv6heE4Q-1; Mon, 17 Jan 2022 05:01:55 -0500 X-MC-Unique: XHMfktOsN3WcpvGv6heE4Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E690E1023F50; Mon, 17 Jan 2022 10:01:53 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.49]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A85277039E; Mon, 17 Jan 2022 10:01:53 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D2FB41800634; Mon, 17 Jan 2022 11:01:46 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Gerd Hoffmann , Ray Ni , Liming Gao , Abner Chang , Jiewen Yao , Jordan Justen , Leif Lindholm , Ard Biesheuvel , Jian J Wang , Pawel Polawski , Hao A Wu Subject: [PATCH v2 5/6] OvmfPkg/Microvm/pcie: mPhysMemAddressWidth tweak Date: Mon, 17 Jan 2022 11:01:45 +0100 Message-Id: <20220117100146.1965662-6-kraxel@redhat.com> In-Reply-To: <20220117100146.1965662-1-kraxel@redhat.com> References: <20220117100146.1965662-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=kraxel@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII" microvm places the 64bit mmio space at the end of the physical address space. So mPhysMemAddressWidth must be correct, otherwise the pci host bridge setup throws an error because it thinks the 64bit mmio window is not addressable. On microvm we can simply use standard cpuid to figure the address width because the host-phys-bits option (-cpu ${name},host-phys-bits=on) is forced to be enabled. Side note: For 'pc' and 'q35' this is not the case for backward compatibility reasons. Signed-off-by: Gerd Hoffmann --- OvmfPkg/PlatformPei/MemDetect.c | 21 +++++++++++++++++++++ OvmfPkg/PlatformPei/Platform.c | 2 +- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c index f87a6f48a1bf..571d02d628f1 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -552,6 +552,27 @@ AddressWidthInitialization ( { UINT64 FirstNonAddress; + if (mHostBridgeDevId == 0xffff /* microvm */) { + UINT32 RegEax; + + /* NOTE: microvm phys-bits are reliable. */ + AsmCpuid (0x80000000, &RegEax, NULL, NULL, NULL); + if (RegEax >= 0x80000008) { + AsmCpuid (0x80000008, &RegEax, NULL, NULL, NULL); + mPhysMemAddressWidth = (UINT8)RegEax; + } else { + mPhysMemAddressWidth = 36; + } + + DEBUG (( + DEBUG_INFO, + "%a: microvm: phys-bits is %d\n", + __FUNCTION__, + mPhysMemAddressWidth + )); + return; + } + // // As guest-physical memory size grows, the permanent PEI RAM requirements // are dominated by the identity-mapping page tables built by the DXE IPL. diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 27ada0c17577..b8cc0c31dd64 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -821,12 +821,12 @@ InitializePlatform ( S3Verification (); BootModeInitialization (); - AddressWidthInitialization (); // // Query Host Bridge DID // mHostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID); + AddressWidthInitialization (); MaxCpuCountInitialization (); -- 2.34.1