From nobody Sun Nov 24 00:35:29 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+94700+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+94700+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664891255; cv=none; d=zohomail.com; s=zohoarc; b=El1dds0irqO3EERMM61xCn0pIXjjOL1l2fbj3GPtaEyh5fxkSc+aO5MYkrBKK5a7tDcUigmaDAxl7+aKw6eV6E1isstd/vFvaXCGIAs/uQhPZenRaHi2gpXFNh7gByuc2RNym2VyFsk+xwXKXxBv9XC12bjhldGrQV/f0x4f94g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664891255; 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=7B96VxKlocAiiw4rbAT4EverdfLQPgO0XFJta2fW1mk=; b=CIjrA5IdcHCKJgIF+tdl6xy8qyHeD9OM3leg9ZWIqCMrjKy4DyZIPO/IsbyKreyBkvZOgA8t/ncF4jy4IE6Jm4QSj+mnu8rlsRI0tjEY6+YUgUQT4qycERwOjaKv8goTIkpqGoRFsKHggUot1dI8eKoAbMDPGze/KuhebNYcFUs= 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+94700+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 1664891255233673.7527948300868; Tue, 4 Oct 2022 06:47:35 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id Gtw8YY1788612x0BVJqXFsNF; Tue, 04 Oct 2022 06:47:34 -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.10736.1664891253770303024 for ; Tue, 04 Oct 2022 06:47:34 -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-48-_I02o2eYMXOi5otL374vvA-1; Tue, 04 Oct 2022 09:47:31 -0400 X-MC-Unique: _I02o2eYMXOi5otL374vvA-1 X-Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 4365B382C966; Tue, 4 Oct 2022 13:47:31 +0000 (UTC) X-Received: from sirius.home.kraxel.org (unknown [10.39.193.173]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 104F5C15BA4; Tue, 4 Oct 2022 13:47:31 +0000 (UTC) X-Received: by sirius.home.kraxel.org (Postfix, from userid 1000) id 1A93518017F9; Tue, 4 Oct 2022 15:47:28 +0200 (CEST) From: "Gerd Hoffmann" To: devel@edk2.groups.io Cc: Jordan Justen , Gerd Hoffmann , Pawel Polawski , Jiewen Yao , Oliver Steffen , Ard Biesheuvel Subject: [edk2-devel] [PATCH v2 3/4] OvmfPkg/PlatformInitLib: dynamic mmio window size Date: Tue, 4 Oct 2022 15:47:27 +0200 Message-Id: <20221004134728.55499-4-kraxel@redhat.com> In-Reply-To: <20221004134728.55499-1-kraxel@redhat.com> References: <20221004134728.55499-1-kraxel@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.8 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: pbD0fVZID1y9VLUMHNvjYfgzx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1664891254; bh=1z06z5MRqB75FxHeJ9wGBYx9It3sK1bVfRPHzZUb0Jg=; h=Cc:Content-Type:Date:From:Reply-To:Subject:To; b=YV4UfCrh95inAJ7A8+0gLS1ZiOxy3yX2vn+FXWGZ/Sqa7VLoDcs4UHjiMRK8uRf/B5a d80q8wJ9ePQkiAwe5fwfldTg5P4xh5ZR0ar7+RaIFGD6N8t91aOdHCC282kj/KqxzLT+Y O13njK0fJzQPfQmQxu6fJ3beuxnk865hGHM= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1664891256785100008 Content-Type: text/plain; charset="utf-8"; x-default="true" In case we have a reliable PhysMemAddressWidth use that to dynamically size the 64bit address window. Allocate 1/8 of the physical address space and place the window at the upper end of the address space. Signed-off-by: Gerd Hoffmann --- OvmfPkg/Library/PlatformInitLib/MemDetect.c | 28 +++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/= PlatformInitLib/MemDetect.c index 16ecbfadc30c..ae217d0242ed 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -604,6 +604,33 @@ PlatformAddressWidthFromCpuid ( } } =20 +VOID +EFIAPI +PlatformDynamicMmioWindow ( + IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob + ) +{ + UINT64 AddrSpace, MmioSpace; + + AddrSpace =3D LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth); + MmioSpace =3D LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth - 3); + + if ((PlatformInfoHob->PcdPciMmio64Size < MmioSpace) && + (PlatformInfoHob->PcdPciMmio64Base + MmioSpace < AddrSpace)) + { + DEBUG ((DEBUG_INFO, "%a: using dynamic mmio window\n", __func__)); + DEBUG ((DEBUG_INFO, "%a: Addr Space 0x%Lx (%Ld GB)\n", __func__, Add= rSpace, RShiftU64 (AddrSpace, 30))); + DEBUG ((DEBUG_INFO, "%a: MMIO Space 0x%Lx (%Ld GB)\n", __func__, Mmi= oSpace, RShiftU64 (MmioSpace, 30))); + PlatformInfoHob->PcdPciMmio64Size =3D MmioSpace; + PlatformInfoHob->PcdPciMmio64Base =3D AddrSpace - MmioSpace; + } else { + DEBUG ((DEBUG_INFO, "%a: using classic mmio window\n", __func__)); + } + + DEBUG ((DEBUG_INFO, "%a: Pci64 Base 0x%Lx\n", __func__, PlatformInfoHo= b->PcdPciMmio64Base)); + DEBUG ((DEBUG_INFO, "%a: Pci64 Size 0x%Lx\n", __func__, PlatformInfoHo= b->PcdPciMmio64Size)); +} + /** Iterate over the PCI host bridges resources information optionally provi= ded in fw-cfg and find the highest address contained in the PCI MMIO windows= . If @@ -765,6 +792,7 @@ PlatformAddressWidthInitialization ( if (PlatformInfoHob->PhysMemAddressWidth !=3D 0) { // physical address width is known PlatformInfoHob->FirstNonAddress =3D FirstNonAddress; + PlatformDynamicMmioWindow (PlatformInfoHob); return; } =20 --=20 2.37.3 -=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 (#94700): https://edk2.groups.io/g/devel/message/94700 Mute This Topic: https://groups.io/mt/94113626/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-