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.8945.1638946946935128237 for ; Tue, 07 Dec 2021 23:02:27 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XF1FDiZE; 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=1638946946; 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=Hp2HjXmYUGrXyUkcKSMGzavk+LpTAIjmTD8IlBSx1LI=; b=XF1FDiZEptM2Kt3egs3hrGkbq/nkEoImoDWpm4NZri68ZVWal+kcNmSMbcF7/sKk/j9dK0 A0IGirvyNZfdnVgMK3/Ow5MzTJN8y3NVEqTiaZdz9Pf0P7ny5+4XwC97PRC56LfRa2mXrU RbKKblErxho54WSwBSpM4VDhhgalN84= 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-487-gMmshOAYOM2raPr2bKo59w-1; Wed, 08 Dec 2021 02:02:22 -0500 X-MC-Unique: gMmshOAYOM2raPr2bKo59w-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 6B84781CCBA; Wed, 8 Dec 2021 07:02:21 +0000 (UTC) Received: from sirius.home.kraxel.org (unknown [10.39.192.5]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20C195BE0C; Wed, 8 Dec 2021 07:02:21 +0000 (UTC) Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 2438C18003A5; Wed, 8 Dec 2021 08:01:46 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Ard Biesheuvel , Pawel Polawski , Jordan Justen , Jiewen Yao , Gerd Hoffmann Subject: [PATCH v4 3/3] RFC: OvmfPkg/PlatformPei: stop using cmos for memory detection Date: Wed, 8 Dec 2021 08:01:46 +0100 Message-Id: <20211208070146.1239368-4-kraxel@redhat.com> In-Reply-To: <20211208070146.1239368-1-kraxel@redhat.com> References: <20211208070146.1239368-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" Not needed for qemu 1.7 (released in 2013) and newer. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3593 Signed-off-by: Gerd Hoffmann --- OvmfPkg/PlatformPei/MemDetect.c | 59 +++------------------------------ 1 file changed, 4 insertions(+), 55 deletions(-) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c index e0f2caa9cd3c..21b0b9af26a1 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -37,7 +37,6 @@ Module Name: #include #include "Platform.h" -#include "Cmos.h" UINT8 mPhysMemAddressWidth; @@ -315,51 +314,11 @@ GetSystemMemorySizeBelow4gb ( { EFI_STATUS Status; UINT64 LowerMemorySize = 0; - UINT8 Cmos0x34; - UINT8 Cmos0x35; Status = ScanOrAdd64BitE820Ram (FALSE, &LowerMemorySize, NULL); - if ((Status == EFI_SUCCESS) && (LowerMemorySize > 0)) { - return (UINT32)LowerMemorySize; - } - - // - // CMOS 0x34/0x35 specifies the system memory above 16 MB. - // * CMOS(0x35) is the high byte - // * CMOS(0x34) is the low byte - // * The size is specified in 64kb chunks - // * Since this is memory above 16MB, the 16MB must be added - // into the calculation to get the total memory size. - // - - Cmos0x34 = (UINT8)CmosRead8 (0x34); - Cmos0x35 = (UINT8)CmosRead8 (0x35); - - return (UINT32)(((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB); -} - -STATIC -UINT64 -GetSystemMemorySizeAbove4gb ( - ) -{ - UINT32 Size; - UINTN CmosIndex; - - // - // CMOS 0x5b-0x5d specifies the system memory above 4GB MB. - // * CMOS(0x5d) is the most significant size byte - // * CMOS(0x5c) is the middle size byte - // * CMOS(0x5b) is the least significant size byte - // * The size is specified in 64kb chunks - // - - Size = 0; - for (CmosIndex = 0x5d; CmosIndex >= 0x5b; CmosIndex--) { - Size = (UINT32)(Size << 8) + (UINT32)CmosRead8 (CmosIndex); - } - - return LShiftU64 (Size, 16); + ASSERT_EFI_ERROR (Status); + ASSERT (LowerMemorySize > 0); + return (UINT32)LowerMemorySize; } /** @@ -389,12 +348,9 @@ GetFirstNonAddress ( // If QEMU presents an E820 map, then get the highest exclusive >=4GB RAM // address from it. This can express an address >= 4GB+1TB. // - // Otherwise, get the flat size of the memory above 4GB from the CMOS (which - // can only express a size smaller than 1TB), and add it to 4GB. - // Status = ScanOrAdd64BitE820Ram (FALSE, NULL, &FirstNonAddress); if (EFI_ERROR (Status)) { - FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb (); + FirstNonAddress = BASE_4GB; } // @@ -766,7 +722,6 @@ QemuInitializeRam ( ) { UINT64 LowerMemorySize; - UINT64 UpperMemorySize; MTRR_SETTINGS MtrrSettings; EFI_STATUS Status; @@ -825,12 +780,6 @@ QemuInitializeRam ( // memory size read from the CMOS. // Status = ScanOrAdd64BitE820Ram (TRUE, NULL, NULL); - if (EFI_ERROR (Status)) { - UpperMemorySize = GetSystemMemorySizeAbove4gb (); - if (UpperMemorySize != 0) { - AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); - } - } } // -- 2.33.1