From nobody Mon Feb 9 16:34:33 2026 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+100783+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+100783+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1678172101; cv=none; d=zohomail.com; s=zohoarc; b=GSqY3RktbLo3U/peYYUSkV6k9maeABv8lMV7YcuazcrQs9NnWMJ35RGwVr9NXhhNLTplUEMLLGxYQXZZ4B9oppz3/B5VVTFxc+m/M0ecs2h/ie6es54pAaomEBs/Jtq4Fq19dNiJhVttdEBKtj5guD0q4trUkBqF0ZXAcBuYglg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678172101; 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=hoTVTsYmTgbfgdG5ykSRJYh3wsBhRsX/B7ICvMo7IVQ=; b=QDrj8UxEow9oIUFGk7yg+xS2WFX85mSOlTQnjNmi5Loh/ueeHF5aRxvUm50qY0WZ0DIwsEKCutlwxgMnPh5g3A2X9+7F3HCxsG1tq/3xX7l5Ol6faBHrN89iSOVN+Q3JiSIiXuRcpJAdFItD4SbAVIJUMVqQPJAhQ8V9cAtm1yU= 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+100783+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 1678172101812161.66589473092563; Mon, 6 Mar 2023 22:55:01 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id Fqn5YY1788612xdvgp2ah6Zm; Mon, 06 Mar 2023 22:55:01 -0800 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.8922.1678172100877670745 for ; Mon, 06 Mar 2023 22:55:01 -0800 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-460-k7CMJASMPxanSHnVbYV2dQ-1; Tue, 07 Mar 2023 01:54:58 -0500 X-MC-Unique: k7CMJASMPxanSHnVbYV2dQ-1 X-Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C75CC280AA2A; Tue, 7 Mar 2023 06:54:57 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.192.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8ECDD14171C3; Tue, 7 Mar 2023 06:54:57 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id F262E180093B; Tue, 7 Mar 2023 07:54:54 +0100 (CET) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Tom Lendacky , Jiewen Yao , Erdem Aktas , Anthony Perard , Gerd Hoffmann , Jordan Justen , Oliver Steffen , Min Xu , Michael Roth , James Bottomley , Pawel Polawski , Ard Biesheuvel , Julien Grall Subject: [edk2-devel] [PATCH v2 3/3] OvmfPkg/PlatformInitLib: simplify mtrr setup Date: Tue, 7 Mar 2023 07:54:54 +0100 Message-Id: <20230307065454.1434251-4-kraxel@redhat.com> In-Reply-To: <20230307065454.1434251-1-kraxel@redhat.com> References: <20230307065454.1434251-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 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: wCXmO8ZNXO49c76aDZIazw3lx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678172101; bh=xjME1fWQ3Af2kwWL4TWqNGYdCfKpjAob4jTVn0A6+8c=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=mcMgN47apYWwUVXGfku9SngfG5x1E1gbT9JFcakL5+TpnmMk/RUGRbJ8COLh3P9WY4T cNmBEZHT07iKO7o11EwMDMfOyP9oUKkWu8fyyO98SD/VIGqTybgYP6p4CBjB1bx/EEXWQ rxZT5i4/HRknNzVGVwbtEhRRGsbBC1iY/iw= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678172102457100004 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 (#100783): https://edk2.groups.io/g/devel/message/100783 Mute This Topic: https://groups.io/mt/97444647/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-