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.194671.1673957797904287433 for ; Tue, 17 Jan 2023 04:16:38 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=aEkEdc8e; 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=1673957796; 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=0efB2bJcOGaCEaeYs9sNZifHUYm0evksX4CclZzz/RM=; b=aEkEdc8e0pZoPlKhl4hjsvIaKSzuOuTBHVoCqU0PlPOFLNAPz2kbMzL9QA/o/VA51JfNYI Q4HJi8aMcvPw2+eu5T96/I5fTiMgnWSCWUHuUkHhSc5rmjewOEsnAAKh8dRIVmrQv2I6Vx QMvGT+0TLSguNraCJqMJiO8CubRwtD8= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-422-ruGLapq8PRa0-s_SD2EMzg-1; Tue, 17 Jan 2023 07:16:35 -0500 X-MC-Unique: ruGLapq8PRa0-s_SD2EMzg-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E32911C07554; Tue, 17 Jan 2023 12:16:34 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.124]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A621BC15BA0; Tue, 17 Jan 2023 12:16:34 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 07F991801ABF; Tue, 17 Jan 2023 13:16:30 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jiewen Yao , Oliver Steffen , =?UTF-8?q?L=C3=A1szl=C3=B3=20=C3=89rsek?= , Ard Biesheuvel , Pawel Polawski , Jordan Justen , Gerd Hoffmann Subject: [PATCH v4 5/5] OvmfPkg/PlatformInitLib: reorder PlatformQemuUc32BaseInitialization Date: Tue, 17 Jan 2023 13:16:29 +0100 Message-Id: <20230117121629.2149112-6-kraxel@redhat.com> In-Reply-To: <20230117121629.2149112-1-kraxel@redhat.com> References: <20230117121629.2149112-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; x-default=true First handle the cases which do not need know the value of PlatformInfoHob->LowMemory (microvm and cloudhv). Then call PlatformGetSystemMemorySizeBelow4gb() to get LowMemory. Finally handle the cases (q35 and pc) which need to look at LowMemory, Signed-off-by: Gerd Hoffmann --- OvmfPkg/Library/PlatformInitLib/MemDetect.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c index 1ce692e77ecb..d6984ee96eb4 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -55,8 +55,15 @@ PlatformQemuUc32BaseInitialization ( return; } + if (PlatformInfoHob->HostBridgeDevId == CLOUDHV_DEVICE_ID) { + PlatformInfoHob->Uc32Size = CLOUDHV_MMIO_HOLE_SIZE; + PlatformInfoHob->Uc32Base = CLOUDHV_MMIO_HOLE_ADDRESS; + return; + } + + PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); + if (PlatformInfoHob->HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) { - PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); ASSERT (PcdGet64 (PcdPciExpressBaseAddress) <= MAX_UINT32); ASSERT (PcdGet64 (PcdPciExpressBaseAddress) >= PlatformInfoHob->LowMemory); @@ -78,19 +85,12 @@ PlatformQemuUc32BaseInitialization ( return; } - if (PlatformInfoHob->HostBridgeDevId == CLOUDHV_DEVICE_ID) { - PlatformInfoHob->Uc32Size = CLOUDHV_MMIO_HOLE_SIZE; - PlatformInfoHob->Uc32Base = CLOUDHV_MMIO_HOLE_ADDRESS; - return; - } - ASSERT (PlatformInfoHob->HostBridgeDevId == INTEL_82441_DEVICE_ID); // // On i440fx, start with the [LowerMemorySize, 4GB) range. Make sure one // variable MTRR suffices by truncating the size to a whole power of two, // while keeping the end affixed to 4GB. This will round the base up. // - PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); PlatformInfoHob->Uc32Size = GetPowerOfTwo32 ((UINT32)(SIZE_4GB - PlatformInfoHob->LowMemory)); PlatformInfoHob->Uc32Base = (UINT32)(SIZE_4GB - PlatformInfoHob->Uc32Size); // -- 2.39.0