From nobody Sun Apr 28 17:52:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+80820+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80820+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631804646; cv=none; d=zohomail.com; s=zohoarc; b=gBXSRRinmDeSLoBUg7uRn3L4JuvzfxPDhr0ZNyW1PQYhjJtU55Ff9cXZosVovT4GxK4J8k27wUkywXJyGMmYXp6no92rezjyGEREz6V5lM32VEPwLVQ85z4f5T5HSWn7sz6IXHTwGKv4/YN4uJUTmK+PHgYjqRtBcQnzpPRnAXE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631804646; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=FOzJWl9kTpZR3rzovfkmqAMkt/N6/ZSAVkcZG5vbH6I=; b=M4AqBprmQTi0vBCFx5Jc0xXp21zVZXekjMgFM6zkMVPvClb8e1C+HACBfJOQpQTq4aRs4eIY2/zWoQeDsJs1JD5t/rRVB86U/9bsGSkfxQs7Ys+Uq4X9d993XwGtKe2ll6roKKe5CgLGxsi4mmReFhsbgqyUPHrtsDOAzL1zAlo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80820+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1631804646144510.9920794158504; Thu, 16 Sep 2021 08:04:06 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id rD8vYY1788612xJWbX30M5rI; Thu, 16 Sep 2021 08:04:05 -0700 X-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.535.1631804644618736797 for ; Thu, 16 Sep 2021 08:04:05 -0700 X-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-17-EtP-8aKhP_WQCo10WPvmiA-1; Thu, 16 Sep 2021 11:03:59 -0400 X-MC-Unique: EtP-8aKhP_WQCo10WPvmiA-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4328F10059CD; Thu, 16 Sep 2021 15:03:58 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D250100164A; Thu, 16 Sep 2021 15:03:54 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 319AD18000B2; Thu, 16 Sep 2021 17:03:52 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Philippe Mathieu-Daude , Jiewen Yao , Jordan Justen , Ard Biesheuvel , Gerd Hoffmann Subject: [edk2-devel] [PATCH v3 1/3] OvmfPkg/PlatformPei: ScanOrAdd64BitE820Ram improvements Date: Thu, 16 Sep 2021 17:03:50 +0200 Message-Id: <20210916150352.2662317-2-kraxel@redhat.com> In-Reply-To: <20210916150352.2662317-1-kraxel@redhat.com> References: <20210916150352.2662317-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com X-Gm-Message-State: IWQq2i0pzqPjXs19ONQ6uwK1x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1631804645; bh=BfCrSnmfi1xwm3be95yICSeR1hJnEzQ41gTRH8RAX8g=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=q9mw96pAxNipXOG/8MxEe9kkQHVj71Jsg1fj3mDnYtDdrnYcqj6PasIZhWmQoTAwaCf in74epbCDmHHv7woF40JJR9Rbdn5DwiLeButNtsqZmgHt2Wm32EEIV9tUjec/JTvh/FA7 r4ngOOWAhEG96vRFoso7mAM5KZ1vg1wOLSE= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1631804647961100001 Content-Type: text/plain; charset="utf-8" Add a bool parameter to ScanOrAdd64BitE820Ram to explicitly specify whenever ScanOrAdd64BitE820Ram should add HOBs for high memory (above 4G) or scan only. Also add a lowmem parameter so ScanOrAdd64BitE820Ram can report the memory size below 4G. This allows a more flexible usage of ScanOrAdd64BitE820Ram, a followup patch will use it for all memory detection. No functional change. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3593 Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daude --- OvmfPkg/PlatformPei/MemDetect.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 2c2c4641ec8a..500c1d4d5231 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -200,6 +200,8 @@ QemuUc32BaseInitialization ( STATIC EFI_STATUS ScanOrAdd64BitE820Ram ( + IN BOOLEAN AddHighHob, + OUT UINT64 *LowMemory OPTIONAL, OUT UINT64 *MaxAddress OPTIONAL ) { @@ -217,6 +219,9 @@ ScanOrAdd64BitE820Ram ( return EFI_PROTOCOL_ERROR; } =20 + if (LowMemory !=3D NULL) { + *LowMemory =3D 0; + } if (MaxAddress !=3D NULL) { *MaxAddress =3D BASE_4GB; } @@ -232,9 +237,8 @@ ScanOrAdd64BitE820Ram ( E820Entry.Length, E820Entry.Type )); - if (E820Entry.Type =3D=3D EfiAcpiAddressRangeMemory && - E820Entry.BaseAddr >=3D BASE_4GB) { - if (MaxAddress =3D=3D NULL) { + if (E820Entry.Type =3D=3D EfiAcpiAddressRangeMemory) { + if (AddHighHob && E820Entry.BaseAddr >=3D BASE_4GB) { UINT64 Base; UINT64 End; =20 @@ -254,11 +258,12 @@ ScanOrAdd64BitE820Ram ( End )); } - } else { + } + if (MaxAddress || LowMemory) { UINT64 Candidate; =20 Candidate =3D E820Entry.BaseAddr + E820Entry.Length; - if (Candidate > *MaxAddress) { + if (MaxAddress && Candidate > *MaxAddress) { *MaxAddress =3D Candidate; DEBUG (( DEBUG_VERBOSE, @@ -267,6 +272,15 @@ ScanOrAdd64BitE820Ram ( *MaxAddress )); } + if (LowMemory && Candidate > *LowMemory && Candidate < BASE_4GB) { + *LowMemory =3D Candidate; + DEBUG (( + DEBUG_VERBOSE, + "%a: LowMemory=3D0x%Lx\n", + __FUNCTION__, + *LowMemory + )); + } } } } @@ -353,7 +367,7 @@ GetFirstNonAddress ( // Otherwise, get the flat size of the memory above 4GB from the CMOS (w= hich // can only express a size smaller than 1TB), and add it to 4GB. // - Status =3D ScanOrAdd64BitE820Ram (&FirstNonAddress); + Status =3D ScanOrAdd64BitE820Ram (FALSE, NULL, &FirstNonAddress); if (EFI_ERROR (Status)) { FirstNonAddress =3D BASE_4GB + GetSystemMemorySizeAbove4gb (); } @@ -754,7 +768,7 @@ QemuInitializeRam ( // entries. Otherwise, create a single memory HOB with the flat >=3D4GB // memory size read from the CMOS. // - Status =3D ScanOrAdd64BitE820Ram (NULL); + Status =3D ScanOrAdd64BitE820Ram (TRUE, NULL, NULL); if (EFI_ERROR (Status) && UpperMemorySize !=3D 0) { AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); } --=20 2.31.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#80820): https://edk2.groups.io/g/devel/message/80820 Mute This Topic: https://groups.io/mt/85653729/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun Apr 28 17:52:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+80821+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80821+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631804651; cv=none; d=zohomail.com; s=zohoarc; b=GDuF8h0h5Vr7JGXCCh8dkJD9GamZ52zl4DX2jbCwQptCVuDFMrmK0lfN1Qe4PDOCDoBAqO/0iA3EFGUhgNqXVaoRaR8Etv5/G0sRrlhBWoJYj9X33FIthXqmIvHIiiFLyZ5EoY4qDIOx35inwKg0q3UxLIxq9mzHZV+VcnFfkgI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631804651; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=U2R8XTA5uZtcbbtEoA6Dt7yi+wIRcEdihBOzGhVuOqg=; b=OS/aJOj901iJv73DVCa3yb7gHeV+SKu/bjr9xNLyGfwviZ/8Sue0XI88o0eQIs9B1WIYirR9udMY0AXNaLiW4ZK+7iQ5ElPLYmLXEqJTa1IYYS1S/K6ePI8/oZ/XsYkIfu+dmy8Jz1Aziw6oeUMJI6qqq3s4wQ8lxGGlZ/+Z3so= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80821+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1631804651233326.21686417013314; Thu, 16 Sep 2021 08:04:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id d5xqYY1788612xn1bWA1Wotf; Thu, 16 Sep 2021 08:04:10 -0700 X-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.web10.566.1631804649896974365 for ; Thu, 16 Sep 2021 08:04:10 -0700 X-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-104-OgxB9PefONOitRq9tVvAqQ-1; Thu, 16 Sep 2021 11:04:04 -0400 X-MC-Unique: OgxB9PefONOitRq9tVvAqQ-1 X-Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BCB2C801B3D; Thu, 16 Sep 2021 15:04:03 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 07AB67A8CE; Thu, 16 Sep 2021 15:04:00 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 33DD818007A8; Thu, 16 Sep 2021 17:03:52 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Philippe Mathieu-Daude , Jiewen Yao , Jordan Justen , Ard Biesheuvel , Gerd Hoffmann Subject: [edk2-devel] [PATCH v3 2/3] OvmfPkg/PlatformPei: prefer etc/e820 for memory detection Date: Thu, 16 Sep 2021 17:03:51 +0200 Message-Id: <20210916150352.2662317-3-kraxel@redhat.com> In-Reply-To: <20210916150352.2662317-1-kraxel@redhat.com> References: <20210916150352.2662317-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com X-Gm-Message-State: D7jMPA52s4ntbThuuuAsHRopx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1631804650; bh=WI9vnZ6mgZIutg88amKd3q3Q64Eptn87r48wUinkMFI=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=GMtlCpIshkcSkhn5RYJfW8bgqUUlftUXU6okLtnLCS/aGY+QlWet0DnqQNbGTyUwxO4 Y/WXFYM3FwTEo0mRqsU9C72NFZUThmrHqr1FvXa1wvC97Ns5SDOFijThSJgmw6uNS8YSW eUOkJS1zgN7HY06FNzwda/HKTrH7IkNxFH0= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1631804651971100002 Content-Type: text/plain; charset="utf-8" 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. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3593 Signed-off-by: Gerd Hoffmann Reviewed-by: Philippe Mathieu-Daude --- OvmfPkg/PlatformPei/MemDetect.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetec= t.c index 500c1d4d5231..1d942b12d519 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -293,9 +293,16 @@ GetSystemMemorySizeBelow4gb ( VOID ) { + EFI_STATUS Status; + UINT64 LowerMemorySize =3D 0; UINT8 Cmos0x34; UINT8 Cmos0x35; =20 + Status =3D ScanOrAdd64BitE820Ram (FALSE, &LowerMemorySize, NULL); + if (Status =3D=3D EFI_SUCCESS && LowerMemorySize > 0) { + return (UINT32)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 =3D GetSystemMemorySizeBelow4gb (); - UpperMemorySize =3D GetSystemMemorySizeAbove4gb (); =20 if (mBootMode =3D=3D BOOT_ON_S3_RESUME) { // @@ -769,8 +775,11 @@ QemuInitializeRam ( // memory size read from the CMOS. // Status =3D ScanOrAdd64BitE820Ram (TRUE, NULL, NULL); - if (EFI_ERROR (Status) && UpperMemorySize !=3D 0) { - AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); + if (EFI_ERROR (Status)) { + UpperMemorySize =3D GetSystemMemorySizeAbove4gb (); + if (UpperMemorySize !=3D 0) { + AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); + } } } =20 --=20 2.31.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#80821): https://edk2.groups.io/g/devel/message/80821 Mute This Topic: https://groups.io/mt/85653733/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun Apr 28 17:52:47 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+80822+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80822+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1631804651; cv=none; d=zohomail.com; s=zohoarc; b=LrzrNwFT4q/3eIZIF33boEK1c38JamGV+QF9tXFEDPyrGui2q4M3LYgw6vg21jTBJcZdFc/HzEe2joRfC60ktzXyX9INymc03XJqfZSWweK2IXlCn/NFE3MvmISt9j4kEsrKeFEx3OSZEWNvJ3kxpIOeD7YU0tbUNa3MholCdP4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1631804651; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=flCXqNfg0oW5tgzidSvkJNn89ZcEwavNmTuGNw6JCgg=; b=NJBDXhgL9SqRx6/bRL4exHKMaLvCtvEgIH08DyqXrKLhmzVLvjX1ffVY9qBD66YzUmTszAi2BBgLr9KnVSVpOaa7TPXZ8rugm8w4JKZfXkrGa8/u2zfgedhNJE/D89ml9utLejxPL9t8SMaZymc2zB0YATnLu9xz35T0Khhkofk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+80822+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 16318046516314.3077268897135355; Thu, 16 Sep 2021 08:04:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id kJbOYY1788612xaHlXGKHigt; Thu, 16 Sep 2021 08:04:11 -0700 X-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.web10.567.1631804650377714868 for ; Thu, 16 Sep 2021 08:04:10 -0700 X-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-144-w_gREQI_N6CMoz3SuR5D7w-1; Thu, 16 Sep 2021 11:04:05 -0400 X-MC-Unique: w_gREQI_N6CMoz3SuR5D7w-1 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90ECA80124F; Thu, 16 Sep 2021 15:04:04 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.91]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A6B8B60583; Thu, 16 Sep 2021 15:04:00 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 39E051800937; Thu, 16 Sep 2021 17:03:52 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Philippe Mathieu-Daude , Jiewen Yao , Jordan Justen , Ard Biesheuvel , Gerd Hoffmann Subject: [edk2-devel] [PATCH v3 3/3] RFC: OvmfPkg/PlatformPei: stop using cmos for memory detection Date: Thu, 16 Sep 2021 17:03:52 +0200 Message-Id: <20210916150352.2662317-4-kraxel@redhat.com> In-Reply-To: <20210916150352.2662317-1-kraxel@redhat.com> References: <20210916150352.2662317-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,kraxel@redhat.com X-Gm-Message-State: yerfX5RLdUnBRSVGkO3gVvzvx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1631804651; bh=pUJiSlQKBRuHqF+Eu0DFOqi5ks33E2IgrIz1GrNErI8=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=tFi8TqXLW6CYNAeFkpzwBqmtyDqD45kt/DLxqvuuWR707kZO1hD9Gsy2odz0zWy7VU8 mZEjabwBvu+0eqxlnQsjqEDK5ux2oQvZaFyZpgi2Z9J+vGBUl/G4JQU4fkv9qqpPYRPz5 OUuS2lA/Bdrs9zrj4vWH/moAW4MqY9ImbLM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1631804652320100006 Content-Type: text/plain; charset="utf-8" Not needed for qemu 1.7 (released in 2013) and newer. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3593 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/MemDetec= t.c index 1d942b12d519..778d150e956b 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -37,7 +37,6 @@ Module Name: #include =20 #include "Platform.h" -#include "Cmos.h" =20 UINT8 mPhysMemAddressWidth; =20 @@ -295,52 +294,12 @@ GetSystemMemorySizeBelow4gb ( { EFI_STATUS Status; UINT64 LowerMemorySize =3D 0; - UINT8 Cmos0x34; - UINT8 Cmos0x35; =20 Status =3D ScanOrAdd64BitE820Ram (FALSE, &LowerMemorySize, NULL); - if (Status =3D=3D EFI_SUCCESS && LowerMemorySize > 0) { - return (UINT32)LowerMemorySize; - } + ASSERT_EFI_ERROR (Status); + ASSERT (LowerMemorySize > 0); + return (UINT32)LowerMemorySize; =20 - // - // 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 =3D (UINT8) CmosRead8 (0x34); - Cmos0x35 =3D (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 =3D 0; - for (CmosIndex =3D 0x5d; CmosIndex >=3D 0x5b; CmosIndex--) { - Size =3D (UINT32) (Size << 8) + (UINT32) CmosRead8 (CmosIndex); - } - - return LShiftU64 (Size, 16); } =20 =20 @@ -371,12 +330,9 @@ GetFirstNonAddress ( // If QEMU presents an E820 map, then get the highest exclusive >=3D4GB = RAM // address from it. This can express an address >=3D 4GB+1TB. // - // Otherwise, get the flat size of the memory above 4GB from the CMOS (w= hich - // can only express a size smaller than 1TB), and add it to 4GB. - // Status =3D ScanOrAdd64BitE820Ram (FALSE, NULL, &FirstNonAddress); if (EFI_ERROR (Status)) { - FirstNonAddress =3D BASE_4GB + GetSystemMemorySizeAbove4gb (); + FirstNonAddress =3D BASE_4GB; } =20 // @@ -719,7 +675,6 @@ QemuInitializeRam ( ) { UINT64 LowerMemorySize; - UINT64 UpperMemorySize; MTRR_SETTINGS MtrrSettings; EFI_STATUS Status; =20 @@ -775,12 +730,6 @@ QemuInitializeRam ( // memory size read from the CMOS. // Status =3D ScanOrAdd64BitE820Ram (TRUE, NULL, NULL); - if (EFI_ERROR (Status)) { - UpperMemorySize =3D GetSystemMemorySizeAbove4gb (); - if (UpperMemorySize !=3D 0) { - AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize); - } - } } =20 // --=20 2.31.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#80822): https://edk2.groups.io/g/devel/message/80822 Mute This Topic: https://groups.io/mt/85653735/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-