From nobody Fri Mar 29 07:18:41 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+102013+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+102013+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1679988852; cv=none; d=zohomail.com; s=zohoarc; b=OzI3Jx1ruu92R3l3NIuiaPcfl5yAMfu7W1Du9EwF+hjd0jg1CwpqefgMpYFtZzu4W3/lCm7yC0F3GvuqnRTThzzEJJXDRtmS++C83kXUL7fhIph4q+GOfLkfssps40uxvClcy+Y3oaJ6kUwDBCHgi305H+GBJQ8f5QWVGZmmc/8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679988852; 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=EiLXsGFy2CrQ0/tggPDS07kS7529Cvp0OMVcPC+892E=; b=nhwsItMNd36TmNdFD+JMrWrnzbTTmZAUWyghjXWOcI54KDj3VwbGPcOwbrk0UER3qstQ5EA1N1OdVupxLAfxFwxAUuyJ5tgc7veKzOagM3LBHTQ7FNrBnI5k47TajOY39LwfDd0RkzX737PP+7eG0Qntzt4qoaOpxo4/isij/No= 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+102013+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 1679988852328347.35349867354057; Tue, 28 Mar 2023 00:34:12 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id O5VzYY1788612xhgBoVI7NuP; Tue, 28 Mar 2023 00:34:11 -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.web11.60646.1679988851054759445 for ; Tue, 28 Mar 2023 00:34:11 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-543-jAKxwkXQPJW7wHXGQLflXg-1; Tue, 28 Mar 2023 03:34:04 -0400 X-MC-Unique: jAKxwkXQPJW7wHXGQLflXg-1 X-Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3ABDF855422; Tue, 28 Mar 2023 07:34:04 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.68]) by smtp.corp.redhat.com (Postfix) with ESMTPS id DEEEB2166B26; Tue, 28 Mar 2023 07:34:03 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 42C591801B0C; Tue, 28 Mar 2023 09:34:02 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Anthony Perard , Pawel Polawski , Min Xu , Gerd Hoffmann , Jiewen Yao , Erdem Aktas , Oliver Steffen , James Bottomley , Michael Roth , Julien Grall , Jordan Justen , Ard Biesheuvel , Tom Lendacky Subject: [edk2-devel] [PATCH v3 1/3] OvmfPkg/PlatformInitLib: update address space layout comment Date: Tue, 28 Mar 2023 09:34:00 +0200 Message-Id: <20230328073402.594180-2-kraxel@redhat.com> In-Reply-To: <20230328073402.594180-1-kraxel@redhat.com> References: <20230328073402.594180-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 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: kVhAWdKOtQ9dsrt3394lc88jx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679988851; bh=C5ST780MHKFUw7NbWnEXJG/VoDGxN9FU7vfysOXRWO0=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=WjmxmQ3WsxRtiMBFuHMIJgZ0KD++++tt6ynMpb13cVUNiChYayFyJ8Vo36VAcRHWew6 o/QkC+2XAoNtPKAn6RfVVh+d8YZVknPAh1jCzON7OyfY/1s9ycMy6UyYrXcqoHl6fnNOi 2e5hTEX+CdVOgCugy9qkWgl8X8G/+ETNFqo= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679988852595100006 Content-Type: text/plain; charset="utf-8"; x-default="true" Move the commment up so it is placed just before the address space calculations start. Also add q35 memory layout. Signed-off-by: Gerd Hoffmann Reviewed-by: Anthony PERARD --- OvmfPkg/Library/PlatformInitLib/Platform.c | 36 ++++++++++++---------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/OvmfPkg/Library/PlatformInitLib/Platform.c b/OvmfPkg/Library/P= latformInitLib/Platform.c index 9fee6e481038..678e8e329023 100644 --- a/OvmfPkg/Library/PlatformInitLib/Platform.c +++ b/OvmfPkg/Library/PlatformInitLib/Platform.c @@ -152,26 +152,12 @@ PlatformMemMapInitialization ( return; } =20 - PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); - PciExBarBase =3D 0; - if (PlatformInfoHob->HostBridgeDevId =3D=3D INTEL_Q35_MCH_DEVICE_ID) { - // - // The MMCONFIG area is expected to fall between the top of low RAM and - // the base of the 32-bit PCI host aperture. - // - PciExBarBase =3D PcdGet64 (PcdPciExpressBaseAddress); - ASSERT (PlatformInfoHob->LowMemory <=3D PciExBarBase); - ASSERT (PciExBarBase <=3D MAX_UINT32 - SIZE_256MB); - PciBase =3D (UINT32)(PciExBarBase + SIZE_256MB); - } else { - ASSERT (PlatformInfoHob->LowMemory <=3D PlatformInfoHob->Uc32Base); - PciBase =3D PlatformInfoHob->Uc32Base; - } - // // address purpose size // ------------ -------- ------------------------- - // max(top, 2g) PCI MMIO 0xFC000000 - max(top, 2g) + // max(top, 2g) PCI MMIO 0xFC000000 - max(top, 2g) (pc) + // 0xB0000000 MMCONFIG 256 MB (q35) + // 0xC0000000 PCI MMIO 960 MB (q35) // 0xFC000000 gap 44 MB // 0xFEC00000 IO-APIC 4 KB // 0xFEC01000 gap 1020 KB @@ -181,6 +167,22 @@ PlatformMemMapInitialization ( // 0xFED20000 gap 896 KB // 0xFEE00000 LAPIC 1 MB // + PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); + PciExBarBase =3D 0; + if (PlatformInfoHob->HostBridgeDevId =3D=3D INTEL_Q35_MCH_DEVICE_ID) { + // + // The MMCONFIG area is expected to fall between the top of low RAM and + // the base of the 32-bit PCI host aperture. + // + PciExBarBase =3D PcdGet64 (PcdPciExpressBaseAddress); + ASSERT (PlatformInfoHob->LowMemory <=3D PciExBarBase); + ASSERT (PciExBarBase <=3D MAX_UINT32 - SIZE_256MB); + PciBase =3D (UINT32)(PciExBarBase + SIZE_256MB); + } else { + ASSERT (PlatformInfoHob->LowMemory <=3D PlatformInfoHob->Uc32Base); + PciBase =3D PlatformInfoHob->Uc32Base; + } + PciSize =3D 0xFC000000 - PciBase; PlatformAddIoMemoryBaseSizeHob (PciBase, PciSize); =20 --=20 2.39.2 -=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 (#102013): https://edk2.groups.io/g/devel/message/102013 Mute This Topic: https://groups.io/mt/97900592/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 Fri Mar 29 07:18:41 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+102012+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+102012+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1679988851; cv=none; d=zohomail.com; s=zohoarc; b=hNZbuwni9KLiwaldjlRAv9bPS3pSgKAGrQRsYyT9puB0c0zh0jj2Usc2L2fqCktG4OoKlGuVTGMleLK9ciU4SshRKRSNPUaqcaJanDHLzW8IaJtoLw9y9T44Bgthr2XrrCxET2NS9dwKY5g4RaSouPOZMk07szIVwAslxvrKOr0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679988851; 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=03nX4VnWwm+kzCf4s90DfR4pSZEOdLU+UAWlbAZQgWk=; b=WTGRDthk9Zq2sBr+9i0zraEJUY+MNdVBWd2uGYF/uqbWx0aCae13Mj8vZtC7E5argk4M51Fi22u3/Wq7la1NQL+x8hjDT77CHkz/cKyXl0Ko2CmEHor3tYfvMubjdRei6cLcd0+CrwJU2xULGGbrZmQi+A3Y3MJD7OkIabhoGEQ= 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+102012+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 1679988851913595.0731009736844; Tue, 28 Mar 2023 00:34:11 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 0nezYY1788612x6SOoIXVK1G; Tue, 28 Mar 2023 00:34: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.60472.1679988850782841130 for ; Tue, 28 Mar 2023 00:34:10 -0700 X-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-576-xnXjyi2FM26VZeAeW_QzhQ-1; Tue, 28 Mar 2023 03:34:06 -0400 X-MC-Unique: xnXjyi2FM26VZeAeW_QzhQ-1 X-Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 2759D280A321; Tue, 28 Mar 2023 07:34:06 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.68]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 99D12440BC; Tue, 28 Mar 2023 07:34:05 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4719A1801B0E; Tue, 28 Mar 2023 09:34:02 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Anthony Perard , Pawel Polawski , Min Xu , Gerd Hoffmann , Jiewen Yao , Erdem Aktas , Oliver Steffen , James Bottomley , Michael Roth , Julien Grall , Jordan Justen , Ard Biesheuvel , Tom Lendacky Subject: [edk2-devel] [PATCH v3 2/3] OvmfPkg/PlatformInitLib: move mmconfig to 0xe0000000 Date: Tue, 28 Mar 2023 09:34:01 +0200 Message-Id: <20230328073402.594180-3-kraxel@redhat.com> In-Reply-To: <20230328073402.594180-1-kraxel@redhat.com> References: <20230328073402.594180-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 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: weP6z0j5vp4wwh63IOt8fqLhx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679988851; bh=4W2Pc+XT6QHcf8cPCyntOlbMhN7AaSYwwMGpJrgLN9w=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=ZZUhN//BfDuCZNfm362IFw1zLkRXSwn0wap8qgBCN9wRala/P3RIOJu9ELTkrVvnxHX wteaJSFv4BLsT/rH4tAfaJinS6hPcnXQgcELu+2E6C1nWymGfNh4VBDUYafnglu9cru84 1oYaCA9ALh+fFNe6sKoMO3ONdXdRxBxfN/Q= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679988852607100008 Content-Type: text/plain; charset="utf-8"; x-default="true" Also swap the ordering of 32bit PCI MMIO window on q35, i.e. use the room between end of low memory and the start of the mmconfig bar. With a typical configuration on modern qemu with gigabyte-aligned memory the MMIO window start at 0x8000000, sized 1532 MB. In case there is memory present above 0x80000000 the window will start at 0xc0000000 instead, with 512 MB size. This depends on qemu commit 4a4418369d6d ("q35: fix mmconfig and PCI0._CRS"), so it raises the bar for the lowest supported version to qemu 4.1 (released Aug 2019). Signed-off-by: Gerd Hoffmann Reviewed-by: Anthony PERARD --- OvmfPkg/AmdSev/AmdSevX64.dsc | 2 +- OvmfPkg/IntelTdx/IntelTdxX64.dsc | 2 +- OvmfPkg/OvmfPkgIa32.dsc | 2 +- OvmfPkg/OvmfPkgIa32X64.dsc | 2 +- OvmfPkg/OvmfPkgX64.dsc | 2 +- OvmfPkg/Library/PlatformInitLib/Platform.c | 10 +++++----- 6 files changed, 10 insertions(+), 10 deletions(-) diff --git a/OvmfPkg/AmdSev/AmdSevX64.dsc b/OvmfPkg/AmdSev/AmdSevX64.dsc index 654c3af0928b..c005e474dd82 100644 --- a/OvmfPkg/AmdSev/AmdSevX64.dsc +++ b/OvmfPkg/AmdSev/AmdSevX64.dsc @@ -443,7 +443,7 @@ [PcdsFixedAtBuild] # # On Q35 machine types that QEMU intends to support in the long term, QE= MU # never lets the RAM below 4 GB exceed 2816 MB. - gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xB0000000 + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000 =20 !if $(SOURCE_DEBUG_ENABLE) =3D=3D TRUE gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2 diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX6= 4.dsc index e6d85286e002..5c56858d063b 100644 --- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc +++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc @@ -448,7 +448,7 @@ [PcdsFixedAtBuild] # # On Q35 machine types that QEMU intends to support in the long term, QE= MU # never lets the RAM below 4 GB exceed 2816 MB. - gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xB0000000 + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000 =20 # # The NumberOfPages values below are ad-hoc. They are updated sporadical= ly at diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc index 9e4705f29b46..a6db902f54ec 100644 --- a/OvmfPkg/OvmfPkgIa32.dsc +++ b/OvmfPkg/OvmfPkgIa32.dsc @@ -559,7 +559,7 @@ [PcdsFixedAtBuild] # # On Q35 machine types that QEMU intends to support in the long term, QE= MU # never lets the RAM below 4 GB exceed 2816 MB. - gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xB0000000 + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000 =20 !if $(SOURCE_DEBUG_ENABLE) =3D=3D TRUE gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2 diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc index 86940e9af54c..076fc0353de0 100644 --- a/OvmfPkg/OvmfPkgIa32X64.dsc +++ b/OvmfPkg/OvmfPkgIa32X64.dsc @@ -565,7 +565,7 @@ [PcdsFixedAtBuild] # # On Q35 machine types that QEMU intends to support in the long term, QE= MU # never lets the RAM below 4 GB exceed 2816 MB. - gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xB0000000 + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000 =20 !if $(SOURCE_DEBUG_ENABLE) =3D=3D TRUE gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2 diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc index 00f7005fca40..4a276e1ec0d9 100644 --- a/OvmfPkg/OvmfPkgX64.dsc +++ b/OvmfPkg/OvmfPkgX64.dsc @@ -586,7 +586,7 @@ [PcdsFixedAtBuild] # # On Q35 machine types that QEMU intends to support in the long term, QE= MU # never lets the RAM below 4 GB exceed 2816 MB. - gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xB0000000 + gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0xE0000000 =20 !if $(SOURCE_DEBUG_ENABLE) =3D=3D TRUE gEfiSourceLevelDebugPkgTokenSpaceGuid.PcdDebugLoadImageMethod|0x2 diff --git a/OvmfPkg/Library/PlatformInitLib/Platform.c b/OvmfPkg/Library/P= latformInitLib/Platform.c index 678e8e329023..5cf8af825a2f 100644 --- a/OvmfPkg/Library/PlatformInitLib/Platform.c +++ b/OvmfPkg/Library/PlatformInitLib/Platform.c @@ -156,8 +156,8 @@ PlatformMemMapInitialization ( // address purpose size // ------------ -------- ------------------------- // max(top, 2g) PCI MMIO 0xFC000000 - max(top, 2g) (pc) - // 0xB0000000 MMCONFIG 256 MB (q35) - // 0xC0000000 PCI MMIO 960 MB (q35) + // max(top, 2g) PCI MMIO 0xE0000000 - max(top, 2g) (q35) + // 0xE0000000 MMCONFIG 256 MB (q35) // 0xFC000000 gap 44 MB // 0xFEC00000 IO-APIC 4 KB // 0xFEC01000 gap 1020 KB @@ -168,6 +168,7 @@ PlatformMemMapInitialization ( // 0xFEE00000 LAPIC 1 MB // PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); + PciBase =3D PlatformInfoHob->Uc32Base; PciExBarBase =3D 0; if (PlatformInfoHob->HostBridgeDevId =3D=3D INTEL_Q35_MCH_DEVICE_ID) { // @@ -177,13 +178,12 @@ PlatformMemMapInitialization ( PciExBarBase =3D PcdGet64 (PcdPciExpressBaseAddress); ASSERT (PlatformInfoHob->LowMemory <=3D PciExBarBase); ASSERT (PciExBarBase <=3D MAX_UINT32 - SIZE_256MB); - PciBase =3D (UINT32)(PciExBarBase + SIZE_256MB); + PciSize =3D (UINT32)(PciExBarBase - PciBase); } else { ASSERT (PlatformInfoHob->LowMemory <=3D PlatformInfoHob->Uc32Base); - PciBase =3D PlatformInfoHob->Uc32Base; + PciSize =3D 0xFC000000 - PciBase; } =20 - PciSize =3D 0xFC000000 - PciBase; PlatformAddIoMemoryBaseSizeHob (PciBase, PciSize); =20 PlatformInfoHob->PcdPciMmio32Base =3D PciBase; --=20 2.39.2 -=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 (#102012): https://edk2.groups.io/g/devel/message/102012 Mute This Topic: https://groups.io/mt/97900591/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 Fri Mar 29 07:18:41 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+102014+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+102014+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1679988853; cv=none; d=zohomail.com; s=zohoarc; b=PeVD6ibCY0DNXHhrQ50PUbDkjtIfn95TZPtqiKquROqHYF2S2OEpZaLqTBiUJinrwDmc/rKt3hHdB1uSN/R95VVUCSZc5md7s8EnWaylrYS3FVSY/bKyTwaZHoDA69GEeIWWpk+Ysv42ITW9yUF2AZOYmBqY/TjzWY8q6xo3Gsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1679988853; 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=aMOdkrcCUWWbK9nMPz6ogdvmljWl2oIuXJKwYA00U1E=; b=Z+6Dvd9mZQwt89+ldAKGA6JxizGcC7SnT/A1ZN5lJA8hWTaAlxUAdowOzHqfmTxZXqnpYMfGGHpc6k02W3mmH/JIJRUl0fBF8B8y9HQN0I0iv/R1RZ+Bfsv2I5LXJOJ2mtnEASJJqv69SL3ezTKf6ThO8+6Q2YKaEUByWnZoOz0= 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+102014+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 1679988853198747.3606846360623; Tue, 28 Mar 2023 00:34:13 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id M1yJYY1788612xOAFAfztGMm; Tue, 28 Mar 2023 00:34:12 -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.web11.60647.1679988852254613115 for ; Tue, 28 Mar 2023 00:34:12 -0700 X-Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-350-pBi0PEkIMhCtp7gbA4czHw-1; Tue, 28 Mar 2023 03:34:06 -0400 X-MC-Unique: pBi0PEkIMhCtp7gbA4czHw-1 X-Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id E0C33801206; Tue, 28 Mar 2023 07:34:05 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.68]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9BFAD492C13; Tue, 28 Mar 2023 07:34:05 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 4B5871801E84; Tue, 28 Mar 2023 09:34:02 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Anthony Perard , Pawel Polawski , Min Xu , Gerd Hoffmann , Jiewen Yao , Erdem Aktas , Oliver Steffen , James Bottomley , Michael Roth , Julien Grall , Jordan Justen , Ard Biesheuvel , Tom Lendacky Subject: [edk2-devel] [PATCH v3 3/3] OvmfPkg/PlatformInitLib: simplify mtrr setup Date: Tue, 28 Mar 2023 09:34:02 +0200 Message-Id: <20230328073402.594180-4-kraxel@redhat.com> In-Reply-To: <20230328073402.594180-1-kraxel@redhat.com> References: <20230328073402.594180-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 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: rNzbr5VGg86rIqPgXO7GaFVAx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1679988852; bh=HQMGkTsXUKyMHt8byCVB9z9/cVn9qrO4vMgunz94FEw=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=s3sg9XSevmPU3KpZJjIQQSXv7KqDFAfqUPcvVomGOXczs0M3+JqjmDvIBURm8odnd+c 9YRKsophReDopoyqe2ntYX6I/dHDK8zRiIRSFr7O0BCEYAfGP01t34LlchmP17LuS57Fj e5foiEsrrmr6xY53HhQhL4UhdJa6sx7FXQk= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1679988854681100001 Content-Type: text/plain; charset="utf-8"; x-default="true" With the new mmconfig location at 0xe0000000 above the 32-bit PCI MMIO window we don't have to special-case the mmconfig xbar any more. We'll just add a mtrr uncachable entry starting at MMIO window base and ending at 4GB. Update comments to match reality. Signed-off-by: Gerd Hoffmann Reviewed-by: Anthony PERARD --- OvmfPkg/Library/PlatformInitLib/MemDetect.c | 36 +++++++++------------ 1 file changed, 15 insertions(+), 21 deletions(-) diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/= PlatformInitLib/MemDetect.c index 38cece9173e8..f85a63ac5130 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -61,33 +61,20 @@ PlatformQemuUc32BaseInitialization ( return; } =20 + ASSERT ( + PlatformInfoHob->HostBridgeDevId =3D=3D INTEL_Q35_MCH_DEVICE_ID || + PlatformInfoHob->HostBridgeDevId =3D=3D INTEL_82441_DEVICE_ID + ); + PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); =20 if (PlatformInfoHob->HostBridgeDevId =3D=3D INTEL_Q35_MCH_DEVICE_ID) { ASSERT (PcdGet64 (PcdPciExpressBaseAddress) <=3D MAX_UINT32); ASSERT (PcdGet64 (PcdPciExpressBaseAddress) >=3D PlatformInfoHob->LowM= emory); - - if (PlatformInfoHob->LowMemory <=3D BASE_2GB) { - // Newer qemu with gigabyte aligned memory, - // 32-bit pci mmio window is 2G -> 4G then. - PlatformInfoHob->Uc32Base =3D BASE_2GB; - } else { - // - // On q35, the 32-bit area that we'll mark as UC, through variable M= TRRs, - // starts at PcdPciExpressBaseAddress. The platform DSC is responsib= le for - // setting PcdPciExpressBaseAddress such that describing the - // [PcdPciExpressBaseAddress, 4GB) range require a very small number= of - // variable MTRRs (preferably 1 or 2). - // - PlatformInfoHob->Uc32Base =3D (UINT32)PcdGet64 (PcdPciExpressBaseAdd= ress); - } - - return; } =20 - ASSERT (PlatformInfoHob->HostBridgeDevId =3D=3D INTEL_82441_DEVICE_ID); // - // On i440fx, start with the [LowerMemorySize, 4GB) range. Make sure one + // 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. // @@ -1027,6 +1014,13 @@ PlatformQemuInitializeRam ( // practically any alignment, and we may not have enough variable MTRRs = to // cover it exactly. // + // Because of that PlatformQemuUc32BaseInitialization() will round + // up PlatformInfoHob->LowMemory to make sure a single mtrr register + // is enough. The the result will be stored in + // PlatformInfoHob->Uc32Base. On a typical qemu configuration with + // gigabyte-alignment being used LowMemory will be 2 or 3 GB and no + // rounding is needed, so LowMemory and Uc32Base will be identical. + // if (IsMtrrSupported () && (PlatformInfoHob->HostBridgeDevId !=3D CLOUDHV= _DEVICE_ID)) { MtrrGetAllMtrrs (&MtrrSettings); =20 @@ -1056,8 +1050,8 @@ PlatformQemuInitializeRam ( ASSERT_EFI_ERROR (Status); =20 // - // Set the memory range from the start of the 32-bit MMIO area (32-bit= PCI - // MMIO aperture on i440fx, PCIEXBAR on q35) to 4GB as uncacheable. + // Set the memory range from the start of the 32-bit PCI MMIO + // aperture to 4GB as uncacheable. // Status =3D MtrrSetMemoryAttribute ( PlatformInfoHob->Uc32Base, --=20 2.39.2 -=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 (#102014): https://edk2.groups.io/g/devel/message/102014 Mute This Topic: https://groups.io/mt/97900593/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-