From mboxrd@z Thu Jan 1 00:00:00 1970 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 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=ejZQ/7Mf; spf=pass (domain: redhat.com, ip: 170.10.133.124, mailfrom: kraxel@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664891252; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SzXAY7IbMqcI7Fcb9v+qEpdds8GReQk94H3wOlP09mM=; b=ejZQ/7Mf01587sT9IL3DqQuuExfMJm5ftyTtKiiLl71yWSHHQE8r/1sVr75ZziKhjTg+jW 8jWkzzuaqsPT+sl/4/6yNzjmL+1SltFf/XuK2qImEs9m34jKhPGPwXB1+bjhfHq3TtVFoB NvGdIuaFOp4No/BKG96xV/p/rP5CuTI= 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 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) 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) 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: [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 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset="US-ASCII"; 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 ( } } +VOID +EFIAPI +PlatformDynamicMmioWindow ( + IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob + ) +{ + UINT64 AddrSpace, MmioSpace; + + AddrSpace = LShiftU64 (1, PlatformInfoHob->PhysMemAddressWidth); + MmioSpace = 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__, AddrSpace, RShiftU64 (AddrSpace, 30))); + DEBUG ((DEBUG_INFO, "%a: MMIO Space 0x%Lx (%Ld GB)\n", __func__, MmioSpace, RShiftU64 (MmioSpace, 30))); + PlatformInfoHob->PcdPciMmio64Size = MmioSpace; + PlatformInfoHob->PcdPciMmio64Base = AddrSpace - MmioSpace; + } else { + DEBUG ((DEBUG_INFO, "%a: using classic mmio window\n", __func__)); + } + + DEBUG ((DEBUG_INFO, "%a: Pci64 Base 0x%Lx\n", __func__, PlatformInfoHob->PcdPciMmio64Base)); + DEBUG ((DEBUG_INFO, "%a: Pci64 Size 0x%Lx\n", __func__, PlatformInfoHob->PcdPciMmio64Size)); +} + /** Iterate over the PCI host bridges resources information optionally provided in fw-cfg and find the highest address contained in the PCI MMIO windows. If @@ -765,6 +792,7 @@ PlatformAddressWidthInitialization ( if (PlatformInfoHob->PhysMemAddressWidth != 0) { // physical address width is known PlatformInfoHob->FirstNonAddress = FirstNonAddress; + PlatformDynamicMmioWindow (PlatformInfoHob); return; } -- 2.37.3