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.web09.66509.1629360681493853052 for ; Thu, 19 Aug 2021 01:11:21 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=TdFpvcWg; 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=1629360680; 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=ETn5/7/dWHuxO6xsFYILnYqDm/tR/+tK9wk1iiNBSvI=; b=TdFpvcWgyK0bYynZ7WIjolFd1Av+dWfvdr0H1mEGB7nfA+/qu4fYxbztUFwq55xoFb8bB2 aaI19LmjWxYl8klMcaeSNNEg2t9JemzyCP4vkVxRSJKxOim0lu8DK213pWCfo32bWWgSW0 3wpbOLM0cCbx7tudchTlhm0KAP/OMOQ= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-222-8C2N5NMfNfmySsIJtMEHYA-1; Thu, 19 Aug 2021 04:11:19 -0400 X-MC-Unique: 8C2N5NMfNfmySsIJtMEHYA-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 B0F541008060 for ; Thu, 19 Aug 2021 08:11:18 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.193.216]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 60C6B1A26A; Thu, 19 Aug 2021 08:11:18 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D28A9180079B; Thu, 19 Aug 2021 10:11:10 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Gerd Hoffmann Subject: [PATCH 2/2] OvmfPkg/PlatformPei: prefer etc/e820 for memory detection Date: Thu, 19 Aug 2021 10:11:10 +0200 Message-Id: <20210819081110.1612205-3-kraxel@redhat.com> In-Reply-To: <20210819081110.1612205-1-kraxel@redhat.com> References: <20210819081110.1612205-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" Prefer the e820 map provided via qemu firmware config interface for memory detection. Use rtc cmos only as fallback, which should be rarely needed these days as qemu supports etc/e820 since 2013. Signed-off-by: Gerd Hoffmann --- OvmfPkg/PlatformPei/MemDetect.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c index d7fb3e742be3..71bd28bd1d2b 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -293,9 +293,16 @@ GetSystemMemorySizeBelow4gb ( VOID ) { + EFI_STATUS Status; + UINT64 LowerMemorySize; UINT8 Cmos0x34; UINT8 Cmos0x35; + Status = ScanOrAdd64BitE820Ram (FALSE, &LowerMemorySize, NULL); + if (Status == EFI_SUCCESS || LowerMemorySize > 0) { + return LowerMemorySize; + } + // // CMOS 0x34/0x35 specifies the system memory above 16 MB. // * CMOS(0x35) is the high byte @@ -722,7 +729,6 @@ QemuInitializeRam ( // Determine total memory size available // LowerMemorySize = GetSystemMemorySizeBelow4gb (); - UpperMemorySize = GetSystemMemorySizeAbove4gb (); if (mBootMode == BOOT_ON_S3_RESUME) { // @@ -769,8 +775,11 @@ QemuInitializeRam ( // memory size read from the CMOS. // Status = ScanOrAdd64BitE820Ram (TRUE, NULL, NULL); - if (EFI_ERROR (Status) && UpperMemorySize != 0) { - AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); + if (EFI_ERROR (Status)) { + UpperMemorySize = GetSystemMemorySizeAbove4gb (); + if (UpperMemorySize != 0) { + AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); + } } } -- 2.31.1