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.web11.8683.1639648255239899263 for ; Thu, 16 Dec 2021 01:50:55 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=CiTrr1Oy; 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=1639648254; 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=8kIyZZb2RytngEERjBzi3btb30lmUueneyJ9duMlk14=; b=CiTrr1OySWo8JxpnkIaweQ+FeS3LkAvxZBL/VUPsLNlyOSWVbpoWa6LXz22Bw5KlTFhr9w LMUu3u+CKRyOeZygHqXo8l8y4hQ2d9QWW4VhrwOJnyYcZMAHpt3cfGk0jh6ETDUsc3RPzU 2VM0tUr/8dzbhD4fjKB50KAkQTWKIP0= 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-590-XjmxlACRNuSuArCVOjCfWA-1; Thu, 16 Dec 2021 04:50:51 -0500 X-MC-Unique: XjmxlACRNuSuArCVOjCfWA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 03D77801B0C; Thu, 16 Dec 2021 09:50:50 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.14]) by smtp.corp.redhat.com (Postfix) with ESMTPS id AF1CD2BCC1; Thu, 16 Dec 2021 09:50:49 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id A218018003BC; Thu, 16 Dec 2021 10:50:37 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Pawel Polawski , Liming Gao , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Jiewen Yao , Abner Chang , Ard Biesheuvel , Ray Ni , Gerd Hoffmann , Hao A Wu , Jian J Wang , Jordan Justen , Leif Lindholm Subject: [PATCH 5/6] OvmfPkg/Microvm/pcie: mPhysMemAddressWidth tweak Date: Thu, 16 Dec 2021 10:50:36 +0100 Message-Id: <20211216095037.1843149-6-kraxel@redhat.com> In-Reply-To: <20211216095037.1843149-1-kraxel@redhat.com> References: <20211216095037.1843149-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 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 81378eaf9b4c..ba8f2d4b3269 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -508,6 +508,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.33.1