From nobody Sat May 4 00:50:59 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+79561+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+79561+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629360681; cv=none; d=zohomail.com; s=zohoarc; b=D4RaOpKWwgXxNhK0JMFOZbVHVr/2jF4eh4Udcecg87Z8czz65AIN2chW1H4RReHFQWc7i34rAhv5JQMRmBk9VRlQn28X0Zwk84v4m5aOJzx2PZXa/xBHXS3c3ApfQyfmvJznI7Ny3z8QEvKcHGHX4UcZVPyuDHgUfnNL047Spg4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629360681; 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=uXD4Ng2BVAFs0k8+cjO6WH0uzgHzaCaFPjGCN/yjntk=; b=ZGqoh2ypMPTZEeq/QQYBXJDnCCasf20+vyFksXE+de6h7EN+NZqzI+krK7Ji0raT/h1c2H5LtfSSc/Nrvify+GRRG/2QgrtPbtTio6uY8YmjjLn7XHy5WjBAnGQ+rWm9nrNdU37Gt2fgrWoBuVOokX0S8WYVJ8amvVCdvT46Xhw= 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+79561+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 16293606816341020.1599778459017; Thu, 19 Aug 2021 01:11:21 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 1ButYY1788612xxFLLUj2mJa; Thu, 19 Aug 2021 01:11:21 -0700 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.groups.io with SMTP id smtpd.web08.66485.1629360680296839741 for ; Thu, 19 Aug 2021 01:11:20 -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-201-9fQjPd5aP5mykZpjBnbBPQ-1; Thu, 19 Aug 2021 04:11:17 -0400 X-MC-Unique: 9fQjPd5aP5mykZpjBnbBPQ-1 X-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 8A5229196A1 for ; Thu, 19 Aug 2021 08:11:16 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.216]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7B1E3E159; Thu, 19 Aug 2021 08:11:12 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id D09A2180062B; Thu, 19 Aug 2021 10:11:10 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Gerd Hoffmann Subject: [edk2-devel] [PATCH 1/2] OvmfPkg/PlatformPei: ScanOrAdd64BitE820Ram improvements Date: Thu, 19 Aug 2021 10:11:09 +0200 Message-Id: <20210819081110.1612205-2-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 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: 9EyUPPc7rWlGkFAP5UA6YVY8x1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1629360681; bh=uPbo/2FX2afPuwaGKTQcamwNM8037HUSNGNDUvYmiUM=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=RG1drl1DDZWEBJQlsb9EbkFv5REcqspu+kYxikL5cwbSnV+FaPmUknzQFY4mzfke2PF al30J7tJt7bX1UwYvfOqIXwJdI0DhUw57T/fwek8T7KQIswJMq7XDK73VB6WZvlpx2hiu 0B3QPvBIAs+o4hmAes06NzQYTt68WkB4onA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1629360682588100005 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. 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 2deec128f464..d7fb3e742be3 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 (#79561): https://edk2.groups.io/g/devel/message/79561 Mute This Topic: https://groups.io/mt/84992115/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 Sat May 4 00:50:59 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+79562+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+79562+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1629360682; cv=none; d=zohomail.com; s=zohoarc; b=n0QKkJTBLBr04nMPh9QTylxyXXuWStRjGBocbc9UOy793VGuD+1RRv2EqO7sFZ739pMZRuChRInLVvIkeMysrrWpsQC5+kK/4NT/7w12Zu5FOdxgFnqwrREvlL1fTSb8nbkJM1EScH/geEsUUqRZ7OO/vuXpQk6ZTO+V3VVMKSY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629360682; 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=TubGQNrpHgXrg2/HapmWX+ZSb1npEnZU5xhhEzNvuEs=; b=arIf0LyM8blxw4cK4KKgPIBW/GKXjISikOuyFsUy/xkjj3LXiIgXjn8nmbKc2qkuLgZ1r/ZNvQM1rCjKTD6U4nc6UfppAnca8SrTivkF5rpCCk/+ZSodNzuAbs+ERcdVdBLPb0Dp0GlV44+CP0i8FlzsJTlFPZg047WMqVJP1Sc= 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+79562+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 1629360682471848.9420211513392; Thu, 19 Aug 2021 01:11:22 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 2cFZYY1788612x9jHPA3iJmq; Thu, 19 Aug 2021 01:11:22 -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.web09.66509.1629360681493853052 for ; Thu, 19 Aug 2021 01:11:21 -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-222-8C2N5NMfNfmySsIJtMEHYA-1; Thu, 19 Aug 2021 04:11:19 -0400 X-MC-Unique: 8C2N5NMfNfmySsIJtMEHYA-1 X-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) X-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) X-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: [edk2-devel] [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 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: NtQgsYYV69FkI1QbVFBIsNzCx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1629360682; bh=nosUHMB45P8TrvC1TZSxyxECUEvtkEac1ic4cdVY4oU=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=WzwWntMWz+76KLQXRwv8T9U8pyP00x62hhKQK2ElHtv+6KKJc+O7VnTNmRnEy1H0PXD mY8rva7/LzJwAlHPx9m508w4Tj8LE2dmxK4yJMu+/+SGP3tpFJlN67KuUd0b6Z72nTX9Z p90XA85IFgE0FJzfkD1C+3W6LfXTkhzu+f4= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1629360684628100010 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. 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 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; =20 + Status =3D ScanOrAdd64BitE820Ram (FALSE, &LowerMemorySize, NULL); + if (Status =3D=3D 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 =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 (#79562): https://edk2.groups.io/g/devel/message/79562 Mute This Topic: https://groups.io/mt/84992117/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-